smalltalk: Behavior>>compile: + addSelector:/removeSelector: + 9 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -872,6 +872,29 @@
|
||||
(= selector "category:")
|
||||
(= selector "comment:"))
|
||||
cref)
|
||||
;; Behavior>>compile: parses the source string as a method and
|
||||
;; installs it. Returns the selector as a symbol.
|
||||
;; Sister forms: compile:classified: and compile:notifying:
|
||||
;; ignore the extra arg, mirroring Pharo's tolerant behaviour.
|
||||
((or (= selector "compile:")
|
||||
(= selector "compile:classified:")
|
||||
(= selector "compile:notifying:"))
|
||||
(let ((src (nth args 0)))
|
||||
(let ((method-ast (st-parse-method (str src))))
|
||||
(st-class-add-method!
|
||||
name (get method-ast :selector) method-ast)
|
||||
(make-symbol (get method-ast :selector)))))
|
||||
((or (= selector "addSelector:withMethod:")
|
||||
(= selector "addSelector:method:"))
|
||||
(let
|
||||
((sel (str (nth args 0)))
|
||||
(method-ast (nth args 1)))
|
||||
(begin
|
||||
(st-class-add-method! name sel method-ast)
|
||||
(make-symbol sel))))
|
||||
((= selector "removeSelector:")
|
||||
(let ((sel (str (nth args 0))))
|
||||
(st-class-remove-method! name sel)))
|
||||
((= selector "printString") name)
|
||||
((= selector "class") (st-class-ref "Metaclass"))
|
||||
((= selector "==") (and (st-class-ref? (nth args 0))
|
||||
|
||||
Reference in New Issue
Block a user