Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Last active November 17, 2017 14:51
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 SpringMT/922c6b8ffa35f9293cbc75307410f581 to your computer and use it in GitHub Desktop.
Save SpringMT/922c6b8ffa35f9293cbc75307410f581 to your computer and use it in GitHub Desktop.
fooがメソッド呼び出しになる
== disasm: #<ISeq:<main>@./sample2.rb>==================================
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] a
0000 putspecialobject 3 ( 1)
0002 putnil
0003 defineclass :A, <class:A>, 0
0007 pop
0008 getinlinecache 15, <is:0> ( 13)
0011 getconstant :A
0013 setinlinecache <is:0>
0015 send <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>, nil
0019 setlocal a, 0
0022 getlocal a, 0 ( 14)
0025 putobject 1
0027 send <callinfo!mid:foo=, argc:1, ARGS_SIMPLE>, <callcache>, nil
0031 pop
0032 putself ( 15)
0033 getlocal a, 0
0036 send <callinfo!mid:bar, argc:0, ARGS_SIMPLE>, <callcache>, nil
0040 send <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0044 leave
== disasm: #<ISeq:<class:A>@./sample2.rb>===============================
0000 putself ( 2)
0001 putobject :foo
0003 send <callinfo!mid:attr_accessor, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0007 pop
0008 putspecialobject 1 ( 3)
0010 putobject :bar
0012 putiseq bar
0014 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, nil
0018 pop
0019 putspecialobject 1 ( 8)
0021 putobject :baz
0023 putiseq baz
0025 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, nil
0029 leave
== disasm: #<ISeq:bar@./sample2.rb>=====================================
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] test
0000 putself ( 4)
0001 putself
0002 send             <callinfo!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>, nil <==== fooメソッドが呼び出されている
0006 send             <callinfo!mid:baz, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0010 setlocal test, 0
0013 getlocal test, 0 ( 5)
0016 leave
== disasm: #<ISeq:baz@./sample2.rb>=====================================
local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] v<Arg>
0000 getlocal v, 0 ( 9)
0003 leave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment