Class: Node::BLOCK
- Defined in:
- ext/internal/node/nodeinfo.c,
lib/internal/node/to_a.rb,
lib/internal/node/as_expression.rb,
ext/internal/node/nodeinfo.c,
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,
ext/cached/ruby-1.9.1/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.1/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.2/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.2/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.3/internal/node/nodeinfo.c,
ext/cached/ruby-1.9.3/internal/node/nodeinfo.c
Overview
Represents a block of code (a succession of multiple expressions). A single block node can hold two expressions: one expression to be evaluated and second expression, which may be another BLOCK. The first node in the block may be of type ARGS, in which case it represents the arguments to the current method. The second node in the block may be of type BLOCK_ARG, in which case it represents an explicit block argument. The result of the block is the last expression evaluated.
Class Method Summary collapse
-
.members ⇒ Array
Return an array of strings containing the names of the node class’s members.
Instance Method Summary collapse
- #as_expression_impl(node) ⇒ Object
-
#head ⇒ Object
Return the Node’s head member.
-
#next ⇒ Object
Return the Node’s next member.
- #to_a ⇒ Object
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, #tree, type
Class Method Details
.members ⇒ Array
Return an array of strings containing the names of the node class’s members.
2793 2794 2795 2796 |
# File 'ext/internal/node/nodeinfo.c', line 2793
VALUE node_s_members(VALUE klass)
{
return rb_iv_get(klass, "__member__");
}
|
Instance Method Details
#as_expression_impl(node) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/internal/node/as_expression.rb', line 134 def as_expression_impl(node) a = node.to_a if a.size == 1 then return 'nil' end d = a[0] while d.class == Node::DASGN_CURR do d = d.value end a.shift if not d expressions = a.map { |n| n.as_expression } expressions.reject! { |e| e.nil? } if expressions.nitems == 0 then return 'nil' else return expressions.join('; ') end end |
#head ⇒ Object
Return the Node’s head member. The return type is either a Node or an Object.
2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 |
# File 'ext/internal/node/nodeinfo.c', line 2335
static VALUE node_head(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_head) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_head,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_head);
}
}
else
{
return (VALUE)n->nd_head;
}
}
|
#next ⇒ Object
Return the Node’s next member. The return type is either a Node or an Object.
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 |
# File 'ext/internal/node/nodeinfo.c', line 2437
static VALUE node_next(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_next) == T_NODE)
{
if(1 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_next,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_next);
}
}
else
{
return (VALUE)n->nd_next;
}
}
|
#to_a ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/internal/node/to_a.rb', line 22 def to_a a = [] e = self while e do a << e.head e = e.next end a end |