Skip to content

Instantly share code, notes, and snippets.

@subbuss
Created July 7, 2009 03:25
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/141862 to your computer and use it in GitHub Desktop.
Save subbuss/141862 to your computer and use it in GitHub Desktop.
[subbu@earth jruby] java -cp lib/jruby.jar org.jruby.compiler.ir.IR_Builder -e 'class Test; TEST_VAL = 5; private; def foo(n); n > TEST_VAL ? 1 : 0; end; public; def bar(n, name); tmp = foo(n); if (tmp > 0); puts "Hi there #{name}"; else; puts "Sorry there #{name}"; end; end; end'
Script:
file: "-e"
class:
Class:
className: _DUMMY_
instrs:
0 DEF_CLASS_METH(_DUMMY_, __file__)
methods:
[Method:
name: __file__
classes:
[Class:
className: Test
constants: {TEST_VAL=5:fixnum}
instrs:
0 CONST(Class Test, TEST_VAL) = 5:fixnum
1 %v_0 = CALL(private, [self])
2 DEF_INST_METH(Test, foo)
3 %v_1 = CALL(public, [self])
4 DEF_INST_METH(Test, bar)
methods:
[Method:
name: foo
instrs:
0 self = RECV_ARG(0)
1 n = RECV_ARG(1)
2 %v_1 = CALL(>, [n, 5:fixnum])
3 BEQ(%v_1, FALSE, LBL_0)
4 %v_0 = COPY(1:fixnum)
5 JUMP LBL_1
6 LBL_0:
7 %v_0 = COPY(0:fixnum)
8 LBL_1:
9 RETURN(%v_0)
, Method:
name: bar
instrs:
0 self = RECV_ARG(0)
1 n = RECV_ARG(1)
2 name = RECV_ARG(2)
3 %v_0 = CALL(foo, [self, n])
4 tmp = COPY(%v_0)
5 %v_2 = CALL(>, [tmp, 0:fixnum])
6 BEQ(%v_2, FALSE, LBL_0)
7 %v_3 = CALL(puts, [self, COMPOUND_STRING["Hi there ", name]])
8 %v_1 = COPY(%v_3)
9 JUMP LBL_1
10 LBL_0:
11 %v_4 = CALL(puts, [self, COMPOUND_STRING["Sorry there ", name]])
12 %v_1 = COPY(%v_4)
13 LBL_1:
14 RETURN(%v_1)
]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment