Created
October 31, 2008 22:57
-
-
Save mvr/21438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source | |
_global_ = 1 | |
class Blah | |
def foo(a, b) | |
c = a._op_plus(b) | |
_global_.print(c) | |
end | |
end | |
b = Blah._new_ | |
b.foo(1, 2) | |
ParseTree | |
s(:block, | |
s(:lasgn, :_global_, s(:lit, 1)), | |
s(:class, | |
:Blah, | |
nil, | |
s(:scope, | |
s(:defn, | |
:foo, | |
s(:scope, | |
s(:block, | |
s(:args, :a, :b), | |
s(:lasgn, | |
:c, | |
s(:call, s(:lvar, :a), :_op_plus, s(:array, s(:lvar, :b)))), | |
s(:call, s(:vcall, :_global_), :print, s(:array, s(:lvar, :c)))))))), | |
s(:lasgn, :b, s(:call, s(:const, :Blah), :_new_)), | |
s(:call, s(:lvar, :b), :foo, s(:array, s(:lit, 1), s(:lit, 2)))) | |
Ruby2Simple | |
[:block, | |
[:asgn, [:lvar, :_global_], [:num, 1]], | |
[:class, | |
:Blah, | |
:Object, | |
[:defn, | |
:foo, | |
[:args, :a, :b], | |
[:block, | |
[:asgn, | |
[:lvar, :c], | |
[:call, [:lvar, :a], :_op_plus, [:arglist, [:lvar, :b]]]], | |
[:call, [:lvar, :_global_], :print, [:arglist, [:lvar, :c]]]]]], | |
[:asgn, [:lvar, :b], [:call, [:const, :Blah], :_new_, [:arglist]]], | |
[:call, [:lvar, :b], :foo, [:arglist, [:num, 1], [:num, 2]]]] | |
Simple2Sexp | |
[:block, | |
[:asgn, [:var, :_global_], [:num, 1]], | |
[:dummy, | |
[:decl, :Blah], | |
[:func, :Blah, [:args], [:block]], | |
[:asgn, | |
[:property, [:property, [:var, :Blah], :prototype], "foo"], | |
[:anonfunc, | |
[:args, :a, :b], | |
[:block, | |
[:asgn, [:var, :c], [:op, :+, [:var, :a], [:var, :b]]], | |
[:call, [:property, [:var, :_global_], :print], [:args, [:var, :c]]]]]]], | |
[:asgn, | |
[:var, :b], | |
[:new, [:call, [:property, :_global_, [:var, :Blah]], [:args]]]], | |
[:call, [:property, [:var, :b], :foo], [:args, [:num, 1], [:num, 2]]]] | |
LocalVariableAnnotator | |
[:block, | |
[:decl, :_global_], | |
[:decl, :b], | |
[:asgn, [:var, :_global_], [:num, 1]], | |
[:dummy, | |
[:decl, :Blah], | |
[:func, :Blah, [:args], [:block]], | |
[:asgn, | |
[:property, [:property, [:var, :Blah], :prototype], "foo"], | |
[:anonfunc, | |
[:args, :a, :b], | |
[:block, | |
[:decl, :c], | |
[:asgn, [:var, :c], [:op, :+, [:var, :a], [:var, :b]]], | |
[:call, [:property, [:var, :_global_], :print], [:args, [:var, :c]]]]]]], | |
[:asgn, | |
[:var, :b], | |
[:new, [:call, [:property, :_global_, [:var, :Blah]], [:args]]]], | |
[:call, [:property, [:var, :b], :foo], [:args, [:num, 1], [:num, 2]]]] | |
Splatter | |
[:block, | |
[:decl, :_global_], | |
[:decl, :b], | |
[:asgn, [:var, :_global_], [:num, 1]], | |
[:decl, :Blah], | |
[:func, :Blah, [:args], [:block]], | |
[:asgn, | |
[:property, [:property, [:var, :Blah], :prototype], "foo"], | |
[:anonfunc, | |
[:args, :a, :b], | |
[:block, | |
[:decl, :c], | |
[:asgn, [:var, :c], [:op, :+, [:var, :a], [:var, :b]]], | |
[:call, [:property, [:var, :_global_], :print], [:args, [:var, :c]]]]]], | |
[:asgn, | |
[:var, :b], | |
[:new, [:call, [:property, :_global_, [:var, :Blah]], [:args]]]], | |
[:call, [:property, [:var, :b], :foo], [:args, [:num, 1], [:num, 2]]]] | |
Sexp2Script | |
"{var _global_;var b;_global_=(1);var Blah;function Blah(){};Blah.prototype.foo=function(a, b){var c;c=a+b;print(c);};b=(new Blah());b.foo((1), (2));}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment