Class: Node::OP_ASGN1
- Defined in:
- ext/internal/node/nodeinfo.c,
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 bracket assignment of the form:
recv[index] += value or
recv[index] ||= value or
recv[index] &&= value.
The index is obtained from args.body.
The value is obtained from args.head.
In the case of ||=, mid will be 0. The rhs will be equal to the result of evaluating args.head if the lhs is false, otherwise the rhs will be equal to lhs.
In the case of &&=, mid will be 1. The rhs will be equal to the lhs if lhs is false, otherwise the rhs will be equal to the result of evaluating args.head. In all other cases, mid will be the name of the method to call to calculate value, such that the expression is equivalent to:
recv[args.body] = recv[args.body].mid(args.head)
In no case does ruby short-circuit the assignment.
Class Method Summary collapse
-
.members ⇒ Array
Return an array of strings containing the names of the node class’s members.
Instance Method Summary collapse
-
#args ⇒ Object
Return the Node’s args member.
-
#mid ⇒ Object
Return the Node’s mid member.
-
#recv ⇒ Object
Return the Node’s recv member.
Methods inherited from Node
#[], #_dump, _load, #address, #bytecode_compile, compile_string, #eval, #flags, #inspect, #members, #nd_file, #nd_line, #nd_type, #obfusc, #pretty_print, #swap, #to_a, #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
#args ⇒ Object
Return the Node’s args member. The return type is either a Node or an Object.
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 |
# File 'ext/internal/node/nodeinfo.c', line 2022
static VALUE node_args(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_args) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_args,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_args);
}
}
else
{
return (VALUE)n->nd_args;
}
}
|
#mid ⇒ Object
Return the Node’s mid member. The return type is a Symbol.
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 |
# File 'ext/internal/node/nodeinfo.c', line 2416
static VALUE node_mid(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(n->nd_mid == 0)
{
return Qfalse;
}
else if(n->nd_mid == 1)
{
return Qtrue;
}
else
{
return ID2SYM(n->nd_mid);
}
}
|
#recv ⇒ Object
Return the Node’s recv member. The return type is either a Node or an Object.
2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 |
# File 'ext/internal/node/nodeinfo.c', line 2511
static VALUE node_recv(VALUE self)
{
NODE * n;
Data_Get_Struct(self, NODE, n);
if(TYPE(n->nd_recv) == T_NODE)
{
if(0 && nd_type(n) == NODE_OP_ASGN2)
{
return wrap_node_as(
(NODE *)n->nd_recv,
rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
}
else
{
return wrap_node((NODE *)n->nd_recv);
}
}
else
{
return (VALUE)n->nd_recv;
}
}
|