Skip to content

Instantly share code, notes, and snippets.

@subbuss
Created July 6, 2009 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subbuss/141239 to your computer and use it in GitHub Desktop.
Save subbuss/141239 to your computer and use it in GitHub Desktop.
[subbu@earth jruby] java -cp lib/jruby.jar org.jruby.compiler.ir.IR_Builder -e "def fib(a); if a < 2; a; else; fib(a - 1) + fib(a - 2); end; end; fib(35)"
Script:
file: (string: "-e")
class:
Class:
className: _DUMMY_
methods:
[Method:
name: __file__
instrs:
0 %v_0 = CALL(fib, [self, 35:fixnum])
methods:
[Method:
name: fib
instrs:
0 self = RECV_ARG(0)
1 a = RECV_ARG(1)
2 %v_1 = CALL(<, [a, 2:fixnum])
3 BEQ(%v_1, FALSE, LBL_0)
4 %v_0 = COPY(a)
5 JUMP LBL_1
6 LBL_0:
7 %v_2 = CALL(-, [a, 1:fixnum])
8 %v_3 = CALL(fib, [self, %v_2])
9 %v_4 = CALL(-, [a, 2:fixnum])
10 %v_5 = CALL(fib, [self, %v_4])
11 %v_6 = CALL(+, [%v_3, %v_5])
12 %v_0 = COPY(%v_6)
13 LBL_1:
]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment