Me, too! :)

Doru


On Fri, Dec 6, 2013 at 9:38 PM, St�phane Ducasse <stephane.ducasse@inria.fr> wrote:
> �get a copy of the IR tree"
> irMethod := (TestMy>>#test) ir copy.
>
> �get all instance variable access IR instructions�
> allIvarAccesses := �irMethod allInstructionsMatching: [ :ir |ir isInstVarAccess].
>
> �insert code for �1 halt� before all of them"
> allIvarAccesses do: [ :each | each �addInstructionsBefore: { �IRInstruction pushLiteral: 1. �IRInstruction send: �#halt. IRInstruction popTop }].
>
> �generate a new compiledMethod"
> cm := irMethod generate: �(TestMy>>#test) trailer.
>
> �install in the class"
> TestMy addSelector: #test withMethod: cm.
>
> 17 <76> pushConstant: 1
> 18 <D0> send: halt
> 19 <87> pop
> 20 <00> pushRcvr: 0
> 21 <76> pushConstant: 1
> 22 <B0> send: +
> 23 <76> pushConstant: 1
> 24 <D0> send: halt
> 25 <87> pop
> 26 <00> pushRcvr: 0
> 27 <B0> send: +
> 28 <7C> returnTop
>
>
> �> TestMy new test
>
> What is now yet wiring is quick return methods �> need to clear the primitive in that case, should not be hard to do.

I love this in 5 lines!!!!





--
www.tudorgirba.com

"Every thing has its own flow"