"Available reifications"
RBProgram>>availableReifications
Many reifications are available for all nodes, namely
RFReification allSubclasses select: [ :each |
each entities includes: RBProgramNode
] thenCollect: #key
" == common reifications ==
#object
#link
#node
#context
#class
#entity"
For AssignmentNode
, the reifications newValue
and value
will be the same if you use control: #after
.
They will be (correctly) different only for control: before
.
Maybe oldValue
could be introduced for #after
in the future.
When the block used as a condition has arguments, the name is matched to the possible reifications and if valid this value is passed as an argument. Very useful e.g. for object specific links:
link := MetaLink new
condition: [ :object | object == <the object I am intersted in> ];
metaObject: <someObject>;
selector: <some selector>
Every valid reified value can be the metaobject of the link. e.g. you can now define a link where the meta is the node where the Link is installed:
link := MetaLink new
metaObject: #node;
selector: #tagHasBeenExecuted.
Or the #receiver:
link := MetaLink new
metaObject: #receiver;
selector: #perform:withArguments:;
arguments: #(selector arguments).
X) optionOneShot (options:
, optionOneShot: true
)
link := MetaLink new
metaObject: self;
options: #(optionOneShot);
optionOneShot: true;
selector: #tagExec.
The full test looks like this:
testLinkOneShot
| sendNode link |
sendNode := (ReflectivityExamples>>#exampleMethod) sendNodes first.
link := MetaLink new
metaObject: self;
options: #(optionOneShot);
selector: #tagExec.
sendNode link: link.
self assert: sendNode hasMetalink.
self assert: tag isNil.
self assert: (ReflectivityExamples new exampleMethod = 5).
self assert: (tag = #yes).
self deny: sendNode hasMetalink.
tag := nil.
self assert: (ReflectivityExamples new exampleMethod = 5).
self assert: tag isNil.
Disabl
The latest image now has some more options for meta links. The complete list is listed in the #defaultOptions method of MetaLink class:
defaultOptions
^ #(
+ optionInlineMetaObject "meta object is inlined by default."
+ optionInlineCondtion "condition is inlined by default.” (ups, typo, will fix)
- optionCompileOnLinkInstallation "generate compiledMethod on link installation"
- optionOneShot "remove link after first activation"
- optionMetalevel "force level: 0 for the link"
- optionDisabledLink "links are active by default"
)
Some of the options make only sense because after this issue will be integrated:
https://pharo.fogbugz.com/f/cases/16695/allow-classes-to-force-meta-link-options-metaLinkOptions
we will have a mechanism that classes can enforce options for all links installed in them. This is done by adding a method on the instance or class side like this:
metaLinkOptions
^{
#exampleMethodWithMetaLinkOptionsViaClass -> #( + optionCompileOnLinkInstallation)
}
This allows e.g. a class to turn off links for one method or enforce using meta-level awareness. (for now the options are overridden when installing a link, I will move this into the code generator to have a real overlay semantics as a next step).