Module: MethodSig

Included in:
Method, Node::METHOD, Node::SCOPE, RubyVM::InstructionSequence, UnboundMethod
Defined in:
lib/decompiler/method/signature.rb,
lib/decompiler/method/signature/argument.rb,
lib/decompiler/method/signature/signature.rb

Defined Under Namespace

Classes: Argument, NodeOptionalArgument, OptionalArgument, Signature, YarvOptionalArgument

Instance Method Summary collapse

Instance Method Details

#argument_namesObject

Return the names of the arguments this method takes, in the order in which they appear in the argument list.



21
22
23
# File 'lib/decompiler/method/signature.rb', line 21

def argument_names
  return self.body.argument_names
end

#argumentsObject

Return a hash mapping each argument name to a description of that argument.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/decompiler/method/signature.rb', line 51

def arguments
  names = self.argument_names()
  block_arg = self.block_arg()

  args = {}
  names.each do |name|
    args[name] = Argument.new(name, false, false)
  end

  # Optional args
  args_node = args_node()
  set_optional_args(args, args_node, names)

  # Rest arg
  if self.rest_arg then
    rest_name = names[rest_arg]
    args[rest_name] = Argument.new(rest_name, true, false)
  end

  # Block arg
  if block_arg then
    block_name = names[block_arg]
    args[block_name] = Argument.new(block_name, false, true)
  end

  return args
end

#block_argObject

If this method has a “block” argument, that is, it has an argument that is preceded by an ampersand (&) in the argument list, then return its index, otherwise return nil.



40
41
42
# File 'lib/decompiler/method/signature.rb', line 40

def block_arg
  return self.body.block_arg
end

#local_varsObject

Return the names of the local variables of this method.



15
16
17
# File 'lib/decompiler/method/signature.rb', line 15

def local_vars
  return self.body.local_vars
end

#rest_argObject

If this method has a “rest” argument, that is, it has an argument that is preceded by an asterisk (*) in the argument list, then return its index, otherwise return nil.



33
34
35
# File 'lib/decompiler/method/signature.rb', line 33

def rest_arg
  return self.body.rest_arg
end