Class: Node::METHOD
- Inherits:
-
Object
- Object
- Node::METHOD
- Includes:
- MethodSig
- Defined in:
- lib/decompiler/method/signature/node.rb
Overview
YARV up to 1.9.1
Instance Method Summary collapse
- #args_node ⇒ Object
- #argument_names ⇒ Object
- #block_arg ⇒ Object
- #local_vars ⇒ Object
- #rest_arg ⇒ Object
- #set_optional_args(args, args_node, names) ⇒ Object
Methods included from MethodSig
Instance Method Details
#args_node ⇒ Object
131 132 133 |
# File 'lib/decompiler/method/signature/node.rb', line 131 def args_node return nil end |
#argument_names ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/decompiler/method/signature/node.rb', line 118 def argument_names local_vars = self.local_vars iseq = self.body opt_args = iseq.arg_opt_table opt_args.pop # last arg is a pointer to the start of the code num_args = \ iseq.argc + \ opt_args.size + \ (rest_arg ? 1 : 0) + \ (block_arg ? 1 : 0) return local_vars[0...num_args] end |
#block_arg ⇒ Object
140 141 142 143 |
# File 'lib/decompiler/method/signature/node.rb', line 140 def block_arg arg_block = self.body.arg_block return arg_block >= 0 ? arg_block : nil end |
#local_vars ⇒ Object
112 113 114 115 116 |
# File 'lib/decompiler/method/signature/node.rb', line 112 def local_vars iseq = self.body local_vars = iseq.local_table return local_vars end |
#rest_arg ⇒ Object
135 136 137 138 |
# File 'lib/decompiler/method/signature/node.rb', line 135 def rest_arg arg_rest = self.body.arg_rest return arg_rest >= 0 ? arg_rest : nil end |
#set_optional_args(args, args_node, names) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/decompiler/method/signature/node.rb', line 145 def set_optional_args(args, args_node, names) opt_table = self.body.arg_opt_table opt_table.pop first_opt_idx = names.size - opt_table.size - (self.rest_arg ? 1 : 0) - (self.block_arg ? 1 : 0) opt_table.each_with_index do |pc, idx| name = names[first_opt_idx + idx] args[name] = YarvOptionalArgument.new(name, self.body, pc, idx, false, false) end end |