Charles Oliver Nutter
3/29/2009 5:28:00 AM
Tony Arcieri wrote:
> On Sat, Mar 28, 2009 at 1:11 PM, Charles Oliver Nutter <
>> fb = FileBuilder.build(__FILE__) do
>> public_class "SimpleLoop" do
>> public_static_method "main", void, string[] do
>> aload 0
>> push_int 0
...
> That's some awesome use of blocks
Thanks! I know the instance_eval'ed pattern for executing blocks is
sometimes considered bad form, but it makes the code look so nice here I
figured I'd go for it. If you want to use it as a normal API, you can do
that just as easily; you just have to "start" and "stop" the method body
yourself:
fb = FileBuilder.build(__FILE__) do
cls = fb.public_class "SimpleLoop"
m = cls.public_static_method "main", void, string[]
m.start
m.aload 0
m.push_int 0
m.aaload
m.label :top
m.dup
m.aprintln
m.goto :top
m.returnvoid
m.stop
- Charlie