Class: Node::METHOD

Inherits:
Object
  • Object
show all
Includes:
MethodSig
Defined in:
lib/decompiler/method/signature/node.rb

Overview

YARV up to 1.9.1

Instance Method Summary collapse

Methods included from MethodSig

#arguments

Instance Method Details

#args_nodeObject



131
132
133
# File 'lib/decompiler/method/signature/node.rb', line 131

def args_node
  return nil
end

#argument_namesObject



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_argObject



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_varsObject



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_argObject



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