Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created January 9, 2011 01:04
Show Gist options
  • Save bakkdoor/771300 to your computer and use it in GitHub Desktop.
Save bakkdoor/771300 to your computer and use it in GitHub Desktop.
Output of running blocks.fy - I cut out a big part that isn't interesting to the problem (due to output size). See below.
# Fancy source code for the output below:
i = 0
loop: { # endless loop, same as: while: { true } do: { ... }
"-------> " ++ i println
2 times: {
"yo" println
}
i = i + 1
}
# generated bytecode for blocks.fy
Compiling blocks.fy
============= :__script__ ==============
Arguments: 0 required, 0 total
Locals: 1: i
Stack size: 3
Lines to IP: 1: 0..3, 8: 4..13
0000: meta_push_0
0001: set_local 0 # i
0003: pop
0004: push_self
0005: create_block #<Rubinius::CompiledMethod __block__ file=blocks.fy>
0007: allow_private
0008: send_stack :"loop:", 1
0011: pop
0012: push_true
0013: ret
----------------------------------------
============== :__block__ ==============
Arguments: 0 required, 0 total
Locals: 0
Stack size: 3
Lines to IP: 3: 0..12, 4: 13..13, 6: 14..15, 7: 16..19, 7: 20..30
0000: push_literal "-------> "
0002: string_dup
0003: push_local_depth 1, 0
0006: send_stack :":++", 1
0009: send_stack :":println", 0
0012: pop
0013: meta_push_2
0014: create_block #<Rubinius::CompiledMethod __block__ file=blocks.fy>
0016: send_stack :"times:", 1
0019: pop
0020: push_local_depth 1, 0
0023: meta_push_1
0024: send_stack :":+", 1
0027: set_local_depth 1, 0
0030: ret
----------------------------------------
============== :__block__ ==============
Arguments: 0 required, 0 total
Locals: 0
Stack size: 2
Lines to IP: 5: 0..6
0000: push_literal "yo"
0002: string_dup
0003: send_stack :":println", 0
0006: ret
----------------------------------------
-------> 0
yo
yo
-------> 1
yo
yo
-------> 2
yo
yo
-------> 3
yo
yo
-------> 4
yo
yo
-------> 5
yo
yo
-------> 6
yo
yo
-------> 7
yo
yo
-------> 8
yo
yo
-------> 9
yo
yo
-------> 10
yo
yo
[...]
-------> 4445
yo
yo
-------> 4446
yo
yo
-------> 4447
yo
yo
-------> 4448
yo
yo
-------> 4449
yo
yo
-------> 4450 // why is this happening? it should keep on calling the inner block as well ... Maybe due to some kind of inlining?
-------> 4451
-------> 4452
-------> 4453
-------> 4454
-------> 4455
-------> 4456
-------> 4457
-------> 4458
-------> 4459
-------> 4460
-------> 4461
-------> 4462
-------> 4463
-------> 4464
-------> 4465
-------> 4466
-------> 4467
-------> 4468
-------> 4469
-------> 4470
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment