Created
March 17, 2023 20:03
-
-
Save kddnewton/d58ab1235ac0795c9ed6c12fc9ba6e4c to your computer and use it in GitHub Desktop.
Using YARV assembler in Syntax Tree
This file contains hidden or 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
putspecialobject 3 | |
putnil | |
defineclass :FooBar, 0 | |
definemethod :foo | |
putobject "FooBar#foo" | |
leave | |
definemethod :bar | |
putobject "class variable" | |
setclassvariable :@@bar | |
getclassvariable :@@bar | |
leave | |
definemethod :baz | |
ARG_BLOCK blk | |
invokeblock | |
leave | |
definemethod :baz2 | |
ARG_BLOCK blk | |
getblockparam blk | |
send call | |
getblockparamproxy blk | |
send call | |
newarray 2 | |
leave | |
putnil | |
leave | |
pop | |
putspecialobject 3 | |
opt_getconstant_path [:FooBar] | |
defineclass :FooBarBaz, 16 | |
definemethod :foo | |
putself | |
invokesuper | |
putobject " - foobarbaz" | |
opt_plus | |
leave | |
putnil | |
leave | |
pop | |
definemethod :foo | |
putobject "inside method" | |
leave | |
putself | |
definesmethod :bar | |
putobject "inside singleton method" | |
leave | |
nop | |
nop | |
nop | |
duparray [1, 2, 3] | |
send each | |
once | |
putspecialobject 1 | |
send core#set_postexe 0 FCALL | |
putself | |
putobject "THE END!" | |
send puts 1 ARGS_SIMPLE|FCALL | |
leave | |
leave | |
pop | |
putnil | |
leave | |
pop | |
putnil | |
dupn 3 | |
adjuststack 3 | |
putself | |
swap | |
swap | |
swap | |
pop | |
putobject 1 | |
putobject 2 | |
newrange 1 | |
putobject 0b1110 | |
putobject 0b0111 | |
opt_and | |
putobject 0b1001 | |
putobject 0b0110 | |
opt_or | |
putobject 6 | |
putobject 2 | |
opt_div | |
putobject 5 | |
putobject 2 | |
opt_minus | |
putobject 3 | |
putobject 1 | |
opt_mult | |
putobject 1 | |
putobject 2 | |
opt_plus | |
putstring "Hello, " | |
intern | |
dup | |
objtostring | |
anytostring | |
putstring "world!" | |
concatstrings 2 | |
newarray 8 | |
dup | |
checktype 0x07 | |
pop | |
duparray [true, false, nil] | |
concatarray | |
putobject /foo/i | |
setinstancevariable :@foo | |
getinstancevariable :@foo | |
opt_ltlt | |
putstring "bar" | |
toregexp 6, 1 | |
opt_ltlt | |
dup | |
putobject 11 | |
opt_aref | |
putstring "~~~ FOO ~~~" | |
swap | |
checkmatch 2 | |
opt_ltlt | |
duphash { "foo" => "" } | |
opt_aref_with "foo" | |
opt_empty_p | |
putobject true | |
opt_eq | |
opt_ltlt | |
putobject 3 | |
putobject 2 | |
opt_ge | |
opt_ltlt | |
opt_getconstant_path [:"", :Object] | |
opt_ltlt | |
putobject true | |
branchif truthy | |
falsy: | |
putstring "this should be skipped" | |
opt_ltlt | |
jump done | |
truthy: | |
putobject "this should be added" | |
opt_ltlt | |
done: | |
putobject 5 | |
putobject 7 | |
putobject 1 | |
putobject 3 | |
opt_newarray_max 4 | |
opt_ltlt | |
putobject 5 | |
putobject 7 | |
putobject 1 | |
putobject 3 | |
opt_newarray_min 4 | |
opt_ltlt | |
putobject 5 | |
putobject 3 | |
opt_gt | |
opt_ltlt | |
putobject 5 | |
putobject 7 | |
opt_lt | |
opt_ltlt | |
putobject 5 | |
putobject 5 | |
opt_le | |
opt_ltlt | |
putobject 5 | |
putobject 2 | |
opt_mod | |
opt_ltlt | |
putobject 7 | |
opt_succ | |
opt_ltlt | |
putnil | |
opt_nil_p | |
opt_not | |
opt_ltlt | |
dup | |
opt_length | |
opt_ltlt | |
dup | |
opt_size | |
opt_ltlt | |
putspecialobject 1 | |
putobject "%05d" | |
putobject 5 | |
opt_send_without_block core#sprintf 2 | |
opt_ltlt | |
opt_str_uminus "uminus" | |
opt_ltlt | |
opt_str_freeze "freeze" | |
opt_ltlt | |
putobject "global" | |
setglobal :$foo | |
getglobal :$foo | |
opt_ltlt | |
putobject /^this is a (.+) string/ | |
putobject "this is a matched string" | |
opt_regexpmatch2 | |
pop | |
getspecial 1, 2 | |
opt_ltlt | |
putobject 1 | |
putobject 2 | |
opt_neq | |
opt_ltlt | |
putobject "constant" | |
putspecialobject 3 | |
setconstant :Foo | |
putnil | |
putobject true | |
getconstant :Foo | |
opt_ltlt | |
putspecialobject 1 | |
newhash 0 | |
duphash { a: 1 } | |
opt_send_without_block core#hash_merge_kwd 2 | |
newarraykwsplat 1 | |
topn 1 | |
topn 1 | |
opt_ltlt | |
adjuststack 2 | |
dup | |
putobject 1 | |
putobject "aset" | |
opt_aset | |
pop | |
duphash { "a" => 1 } | |
dup | |
putobject 2 | |
putobject 3 | |
setn 1 | |
pop | |
opt_aset_with "a" | |
pop | |
opt_ltlt | |
putobject "local" | |
setlocal foo | |
getlocal foo | |
opt_ltlt | |
duparray [1, 2, 3] | |
expandarray 5, 0 | |
newarray 5 | |
opt_reverse | |
splatarray false | |
opt_ltlt | |
putobject "last line" | |
setspecial 0 | |
getglobal :$_ | |
opt_ltlt | |
putobject true | |
opt_case_dispatch { true => when_true, false => when_false }, when_done | |
when_true: | |
putobject "matched true" | |
jump when_done | |
when_false: | |
putobject "matched false" | |
when_done: | |
opt_ltlt | |
putself | |
send foo 0 ARGS_SIMPLE|FCALL | |
opt_ltlt | |
putself | |
send bar 0 ARGS_SIMPLE|FCALL | |
opt_ltlt | |
opt_getconstant_path [:FooBar] | |
send new | |
send foo | |
opt_ltlt | |
opt_getconstant_path [:FooBar] | |
send new | |
send bar | |
opt_ltlt | |
opt_getconstant_path [:FooBar] | |
send new | |
send baz | |
putobject "invokeblock" | |
leave | |
opt_ltlt | |
opt_getconstant_path [:FooBar] | |
send new | |
send baz2 | |
putobject "invokeblock2" | |
leave | |
opt_ltlt | |
opt_getconstant_path [:FooBarBaz] | |
send new | |
send foo | |
opt_ltlt | |
duparray [1, 2, 3] | |
send map! | |
ARG_REQ i | |
getlocal i | |
putobject 2 | |
opt_mult | |
leave | |
opt_ltlt | |
putself | |
defined func, :puts, "method" | |
opt_ltlt | |
send p 1 ARGS_SIMPLE|FCALL | |
leave |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment