On Jul 16, 2013, at 4:10 PM, Udo Schneider <udo.schnei...@homeaddress.de> wrote:

> All,
> 
> is there a supported interface to generate methods (incl. their bytecodes) 
> manually?
> 

In 3.0 we have two nice additions:

1) you can easily create CompiledMethods from RB ASTs

| cm methodNode |

methodNode := RBMethodNode 
        selector: #test 
        body: (RBReturnNode value: (RBLiteralNode value: 1)) asSequenceNode.
        
methodNode doSemanticAnalysis.
cm := methodNode generate.

cm valueWithReceiver: nil arguments: #()


2) For low level stuff there is IRBuilder. IR is a bytecode-level representation
(CFG) that abstracts away from the details yet is very close.



        |  cm |
        
cm := IRBuilder buildMethod: [ : builder | 
                builder pushLiteral: 3;
                pushDup;
                send: #=;
                returnTop].
        
cm valueWithReceiver: nil arguments: #()



Reply via email to