Class: Node::METHOD

Inherits:
Node show all
Includes:
MethodSig
Defined in:
lib/internal/method/signature/node.rb,
ext/cached/ruby-1.8.4/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.4/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.5/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.5/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.6/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.6/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.7/internal/node/nodeinfo.c,
ext/cached/ruby-1.8.7/internal/node/nodeinfo.c

Overview

A placeholder for a method entry in a class’s method table.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MethodSig

#arguments

Methods inherited from Node

#[], #_dump, _load, #address, #as_code, #as_expression, #as_paren_expression, #bytecode_compile, compile_string, define_code, define_expression, #eval, #flags, #inspect, #members, #nd_file, #nd_line, #nd_type, #obfusc, #pretty_print, #swap, #to_a, #tree, type

Class Method Details

.membersArray

Return an array of strings containing the names of the node class’s members.

Returns:

  • (Array)


2897
2898
2899
2900
# File 'ext/cached/ruby-1.8.4/internal/node/nodeinfo.c', line 2897

VALUE node_s_members(VALUE klass)
{
  return rb_iv_get(klass, "__member__");
}

Instance Method Details

#args_nodeObject



131
132
133
# File 'lib/internal/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/internal/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/internal/method/signature/node.rb', line 140

def block_arg
  arg_block = self.body.arg_block
  return arg_block >= 0 ? arg_block : nil
end

#bodyObject

Return the Node’s body member. The return type is either a Node or an Object.



2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
# File 'ext/cached/ruby-1.8.4/internal/node/nodeinfo.c', line 2137

static VALUE node_body(VALUE self)
{
  NODE * n;
  Data_Get_Struct(self, NODE, n);

  if(TYPE(n->nd_body) == T_NODE)
  {
    if(0 && nd_type(n) == NODE_OP_ASGN2)
    {
      return wrap_node_as(
        (NODE *)n->nd_body,
        rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
    }
    else
    {
      return wrap_node((NODE *)n->nd_body);
    }
  }
  else
  {
    return (VALUE)n->nd_body;
  }
}

#local_varsObject



112
113
114
115
116
# File 'lib/internal/method/signature/node.rb', line 112

def local_vars
  iseq = self.body
  local_vars = iseq.local_table
  return local_vars
end

#noexObject

Return the Node’s noex member. The return type is an Integer.



2552
2553
2554
2555
2556
2557
# File 'ext/cached/ruby-1.8.4/internal/node/nodeinfo.c', line 2552

static VALUE node_noex(VALUE self)
{
  NODE * n;
  Data_Get_Struct(self, NODE, n);
  return LONG2NUM(n->nd_noex);
}

#rest_argObject



135
136
137
138
# File 'lib/internal/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/internal/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