|
Hi,
For blocks, we now have the correct model to destinguish “block creation” from “block execution”:
1) put a link on the block node, it will be called when the block definition (creation) is executed.
e.g. when you put a before link on the block in this method, it will be called when you execute the method:
TT>>method
^[1 + 2].
2) put a link on the *body* of the block (the sequence of statements), it will be called when the block *executes*.
For the example, it would not be called when executing “TT new method”, but only when you do “TT new method value”.
Test:
testBeforeBlockSequenceNoValue
| sequence link |
sequence := (ReflectivityExamples >> #exampleBlockNoValue) ast statements first value body.
self assert: sequence isSequence.
link := MetaLink new
metaObject: self;
selector: #tagExec.
sequence link: link.
self assert: sequence hasMetalinkBefore.
self assert: (ReflectivityExamples >> #exampleBlockNoValue) class = ReflectiveMethod.
self assert: tag isNil.
ReflectivityExamples new exampleBlockNoValue.
self assert: tag isNil.
ReflectivityExamples new exampleBlockNoValue value.
self assert: tag = 'yes'.
self assert: (ReflectivityExamples >> #exampleBlockNoValue) class = CompiledMethod.
link uninstall.
ReflectivityExamples recompile: #exampleBlockNoValue
Marcus
|