[Reflectivity] tiny step: conditions for links
Hi, Now with Pharo5 started, I will try to at least do a tiny increment regularly again on Reflectivity (and hopefully larger ones, too). Today: tiny fix: Link condition is working. The idea is that a meta link can have a condition which is compiled into the code. This tiny change makes it work again: testLinkWithCondition | sendNode link condition | condition := false. sendNode := (ReflectivityExamples>>#exampleMethod) ast body statements first value. link := MetaLink new condition: [condition]; metaObject: self; selector: #tagExec. sendNode link: link. self assert: sendNode hasMetalink. self assert: (ReflectivityExamples>>#exampleMethod) class = ReflectiveMethod. self assert: (tag isNil). self assert: (ReflectivityExamples new exampleMethod = 5). self assert: (tag isNil). condition := true. self assert: (ReflectivityExamples new exampleMethod = 5). self assert: (tag = #yes). This is fixed in #50017 (test is green). Next step: when *changing* the condition object (e.g. to true or false or a different block), we need to re-generate code. ==> we need #invalidate on the MetaLink and call it on #condition:. This is the next step for (hopefully) tomorrow. Marcus
Next step: when *changing* the condition object (e.g. to true or false or a different block), we need to re-generate code.
==> we need #invalidate on the MetaLink and call it on #condition:. This is the next step for (hopefully) tomorrow.
This issue: https://pharo.fogbugz.com/f/cases/15435 <https://pharo.fogbugz.com/f/cases/15435> has the change. The idea is that all accessors in MetaLink call #invalidate which just does invalidate nodes do: [ :node | node invalidate ] With this simple change, one can now use e.g. a boolean as a link condition: haltLink := MetaLink new condition: false; metaObject: Halt; selector: #now. When installed, it does nothing. But we can afterwards change the condition: haltLink condition: true. and it will make sure to re-compile all affected code before the next execution and thus enable the link. The same is true for #selector: and #metaObject:. Marcus
Marcus Denker-4 wrote
haltLink := MetaLink new condition: false; metaObject: Halt; selector: #now.
Pretty :) ----- Cheers, Sean -- View this message in context: http://forum.world.st/Reflectivity-tiny-step-conditions-for-links-tp4822570p... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
participants (2)
-
Marcus Denker -
Sean P. DeNigris