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"