ext/cached/ruby-1.9.1/internal/node/nodeinfo.c in ruby-internal-0.7.3 vs ext/cached/ruby-1.9.1/internal/node/nodeinfo.c in ruby-internal-0.8.0

- old
+ new

@@ -226,11 +226,11 @@ path = rb_class_path(singleton); } else { path = rb_class_path(klass); - if(STR2CSTR(path)[0] == '#') + if(StringValuePtr(path)[0] == '#') { rb_raise(rb_eArgError, "cannot dump anonymous class"); } } return rb_assoc_new( @@ -320,11 +320,11 @@ path = rb_class_path(singleton); } else { path = rb_class_path(klass); - if(STR2CSTR(path)[0] == '#') + if(StringValuePtr(path)[0] == '#') { rb_raise(rb_eArgError, "cannot dump anonymous class"); } } return rb_assoc_new( @@ -519,11 +519,11 @@ path = rb_class_path(singleton); } else { path = rb_class_path(klass); - if(STR2CSTR(path)[0] == '#') + if(StringValuePtr(path)[0] == '#') { rb_raise(rb_eArgError, "cannot dump anonymous class"); } } return rb_assoc_new( @@ -656,11 +656,11 @@ path = rb_class_path(singleton); } else { path = rb_class_path(klass); - if(STR2CSTR(path)[0] == '#') + if(StringValuePtr(path)[0] == '#') { rb_raise(rb_eArgError, "cannot dump anonymous class"); } } return rb_assoc_new( @@ -870,11 +870,11 @@ path = rb_class_path(singleton); } else { path = rb_class_path(klass); - if(STR2CSTR(path)[0] == '#') + if(StringValuePtr(path)[0] == '#') { rb_raise(rb_eArgError, "cannot dump anonymous class"); } } return rb_assoc_new( @@ -1129,24 +1129,27 @@ { rb_raise(rb_eRuntimeError, "Cannot load cfunc"); } case NEN_CLSS: { + int flags; Check_Type(v, T_ARRAY); if(RARRAY_LEN(v) != 2) { rb_raise(rb_eArgError, "wrong size for array"); } - int flags = NUM2INT(RARRAY_PTR(v)[0]); + flags = NUM2INT(RARRAY_PTR(v)[0]); switch(flags & T_MASK) { case T_CLASS: case T_MODULE: { - VALUE str = RARRAY_PTR(v)[1]; + VALUE str, klass; + + str = RARRAY_PTR(v)[1]; Check_Type(str, T_STRING); - VALUE klass = rb_path2class(STR2CSTR(str)); + klass = rb_path2class(StringValuePtr(str)); if(flags & FL_SINGLETON) { *(VALUE *)(&n->nd_clss) = rb_singleton_class(klass); } @@ -1218,24 +1221,27 @@ } return; } case NEN_CVAL: { + int flags; Check_Type(v, T_ARRAY); if(RARRAY_LEN(v) != 2) { rb_raise(rb_eArgError, "wrong size for array"); } - int flags = NUM2INT(RARRAY_PTR(v)[0]); + flags = NUM2INT(RARRAY_PTR(v)[0]); switch(flags & T_MASK) { case T_CLASS: case T_MODULE: { - VALUE str = RARRAY_PTR(v)[1]; + VALUE str, klass; + + str = RARRAY_PTR(v)[1]; Check_Type(str, T_STRING); - VALUE klass = rb_path2class(STR2CSTR(str)); + klass = rb_path2class(StringValuePtr(str)); if(flags & FL_SINGLETON) { *(VALUE *)(&n->nd_cval) = rb_singleton_class(klass); } @@ -1412,24 +1418,27 @@ } return; } case NEN_LIT: { + int flags; Check_Type(v, T_ARRAY); if(RARRAY_LEN(v) != 2) { rb_raise(rb_eArgError, "wrong size for array"); } - int flags = NUM2INT(RARRAY_PTR(v)[0]); + flags = NUM2INT(RARRAY_PTR(v)[0]); switch(flags & T_MASK) { case T_CLASS: case T_MODULE: { - VALUE str = RARRAY_PTR(v)[1]; + VALUE str, klass; + + str = RARRAY_PTR(v)[1]; Check_Type(str, T_STRING); - VALUE klass = rb_path2class(STR2CSTR(str)); + klass = rb_path2class(StringValuePtr(str)); if(flags & FL_SINGLETON) { *(VALUE *)(&n->nd_lit) = rb_singleton_class(klass); } @@ -1554,24 +1563,27 @@ } return; } case NEN_ORIG: { + int flags; Check_Type(v, T_ARRAY); if(RARRAY_LEN(v) != 2) { rb_raise(rb_eArgError, "wrong size for array"); } - int flags = NUM2INT(RARRAY_PTR(v)[0]); + flags = NUM2INT(RARRAY_PTR(v)[0]); switch(flags & T_MASK) { case T_CLASS: case T_MODULE: { - VALUE str = RARRAY_PTR(v)[1]; + VALUE str, klass; + + str = RARRAY_PTR(v)[1]; Check_Type(str, T_STRING); - VALUE klass = rb_path2class(STR2CSTR(str)); + klass = rb_path2class(StringValuePtr(str)); if(flags & FL_SINGLETON) { *(VALUE *)(&n->nd_orig) = rb_singleton_class(klass); } @@ -1806,24 +1818,27 @@ } return; } case NEN_TVAL: { + int flags; Check_Type(v, T_ARRAY); if(RARRAY_LEN(v) != 2) { rb_raise(rb_eArgError, "wrong size for array"); } - int flags = NUM2INT(RARRAY_PTR(v)[0]); + flags = NUM2INT(RARRAY_PTR(v)[0]); switch(flags & T_MASK) { case T_CLASS: case T_MODULE: { - VALUE str = RARRAY_PTR(v)[1]; + VALUE str, klass; + + str = RARRAY_PTR(v)[1]; Check_Type(str, T_STRING); - VALUE klass = rb_path2class(STR2CSTR(str)); + klass = rb_path2class(StringValuePtr(str)); if(flags & FL_SINGLETON) { *(VALUE *)(&n->nd_tval) = rb_singleton_class(klass); } @@ -2106,37 +2121,10 @@ NODE * n; Data_Get_Struct(self, NODE, n); return LONG2NUM((long)(n->nd_cfnc)); } /* - * Return the Node's _clss_ member. The return type is - * either a Node or an Object. - */ -static VALUE node_clss(VALUE self) -{ - NODE * n; - Data_Get_Struct(self, NODE, n); - - if(TYPE(n->nd_clss) == T_NODE) - { - if(0 && nd_type(n) == NODE_OP_ASGN2) - { - return wrap_node_as( - (NODE *)n->nd_clss, - rb_cNodeSubclass[NODE_OP_ASGN2_ARG]); - } - else - { - return wrap_node((NODE *)n->nd_clss); - } - } - else - { - return (VALUE)n->nd_clss; - } -} -/* * Return the Node's _cnt_ member. The return type is an * Integer. */ static VALUE node_cnt(VALUE self) { @@ -2498,31 +2486,10 @@ NODE * n; Data_Get_Struct(self, NODE, n); return LONG2NUM(n->nd_nth); } /* - * Return the Node's _oid_ member. The return type is a - * Symbol. - */ -static VALUE node_oid(VALUE self) -{ - NODE * n; - Data_Get_Struct(self, NODE, n); - if(n->nd_oid == 0) - { - return Qfalse; - } - else if(n->nd_oid == 1) - { - return Qtrue; - } - else - { - return ID2SYM(n->nd_oid); - } -} -/* * Return the Node's _opt_ member. The return type is * either a Node or an Object. */ static VALUE node_opt(VALUE self) { @@ -2863,14 +2830,14 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_ALIAS] = rb_cALIAS; rb_iv_set(rb_cALIAS, "__member__", members); rb_iv_set(rb_cALIAS, "__type__", INT2NUM(NODE_ALIAS)); rb_define_singleton_method(rb_cALIAS, "members", node_s_members, 0); - rb_define_method(rb_cALIAS, "first", node_1st, 0); - rb_ary_push(members, rb_str_new2("first")); rb_define_method(rb_cALIAS, "second", node_2nd, 0); rb_ary_push(members, rb_str_new2("second")); + rb_define_method(rb_cALIAS, "first", node_1st, 0); + rb_ary_push(members, rb_str_new2("first")); } /* Document-class: Node::ALLOCA * A node used for temporary allocation of memory on platforms that do * not support alloca. @@ -2884,10 +2851,16 @@ rb_cNodeSubclass[NODE_ALLOCA] = rb_cALLOCA; rb_iv_set(rb_cALLOCA, "__member__", members); rb_iv_set(rb_cALLOCA, "__type__", INT2NUM(NODE_ALLOCA)); rb_define_singleton_method(rb_cALLOCA, "members", node_s_members, 0); + /* Document-method: cnt + * the number of bytes allocated + */ + rb_define_method(rb_cALLOCA, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); + /* Document-method: cfnc * a pointer to the allocated memory */ rb_define_method(rb_cALLOCA, "cfnc", node_cfnc, 0); rb_ary_push(members, rb_str_new2("cfnc")); @@ -2895,16 +2868,10 @@ /* Document-method: value * a pointer to the previously allocated temporary node */ rb_define_method(rb_cALLOCA, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: cnt - * the number of bytes allocated - */ - rb_define_method(rb_cALLOCA, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); } #endif /* Document-class: Node::AND * Represents a logical 'and' of the form: @@ -2919,21 +2886,21 @@ rb_cNodeSubclass[NODE_AND] = rb_cAND; rb_iv_set(rb_cAND, "__member__", members); rb_iv_set(rb_cAND, "__type__", INT2NUM(NODE_AND)); rb_define_singleton_method(rb_cAND, "members", node_s_members, 0); - /* Document-method: first - * the expression on the left hand side - */ - rb_define_method(rb_cAND, "first", node_1st, 0); - rb_ary_push(members, rb_str_new2("first")); - /* Document-method: second * the expression on the right hand side */ rb_define_method(rb_cAND, "second", node_2nd, 0); rb_ary_push(members, rb_str_new2("second")); + + /* Document-method: first + * the expression on the left hand side + */ + rb_define_method(rb_cAND, "first", node_1st, 0); + rb_ary_push(members, rb_str_new2("first")); } /* Document-class: Node::ARGS * Represents the arguments to a method. */ @@ -2943,28 +2910,28 @@ rb_cNodeSubclass[NODE_ARGS] = rb_cARGS; rb_iv_set(rb_cARGS, "__member__", members); rb_iv_set(rb_cARGS, "__type__", INT2NUM(NODE_ARGS)); rb_define_singleton_method(rb_cARGS, "members", node_s_members, 0); - /* Document-method: rest - * an assignment node to assign the rest arg, if it is present + /* Document-method: cnt + * the number of required arguments */ - rb_define_method(rb_cARGS, "rest", node_rest, 0); - rb_ary_push(members, rb_str_new2("rest")); + rb_define_method(rb_cARGS, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); /* Document-method: opt * a list of assignment nodes to assign default values to the * optional arguments if no argument is specified */ rb_define_method(rb_cARGS, "opt", node_opt, 0); rb_ary_push(members, rb_str_new2("opt")); - /* Document-method: cnt - * the number of required arguments + /* Document-method: rest + * an assignment node to assign the rest arg, if it is present */ - rb_define_method(rb_cARGS, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); + rb_define_method(rb_cARGS, "rest", node_rest, 0); + rb_ary_push(members, rb_str_new2("rest")); } /* Document-class: Node::ARGSCAT * Represents the concatenation of a list of arguments and a splatted * value, e.g.: @@ -3056,16 +3023,10 @@ rb_cNodeSubclass[NODE_ATTRASGN] = rb_cATTRASGN; rb_iv_set(rb_cATTRASGN, "__member__", members); rb_iv_set(rb_cATTRASGN, "__type__", INT2NUM(NODE_ATTRASGN)); rb_define_singleton_method(rb_cATTRASGN, "members", node_s_members, 0); - /* Document-method: args - * the arguments to the method - */ - rb_define_method(rb_cATTRASGN, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: mid * the id of the attribute, with a trailing '=' sign */ rb_define_method(rb_cATTRASGN, "mid", node_mid, 0); rb_ary_push(members, rb_str_new2("mid")); @@ -3073,10 +3034,16 @@ /* Document-method: recv * the receiver of the method */ rb_define_method(rb_cATTRASGN, "recv", node_recv, 0); rb_ary_push(members, rb_str_new2("recv")); + + /* Document-method: args + * the arguments to the method + */ + rb_define_method(rb_cATTRASGN, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); } /* Document-class: Node::ATTRSET * A placeholder for an attribute writer method, which can added to a * class by using attr_writer: @@ -3111,23 +3078,23 @@ rb_cNodeSubclass[NODE_BACK_REF] = rb_cBACK_REF; rb_iv_set(rb_cBACK_REF, "__member__", members); rb_iv_set(rb_cBACK_REF, "__type__", INT2NUM(NODE_BACK_REF)); rb_define_singleton_method(rb_cBACK_REF, "members", node_s_members, 0); - /* Document-method: nth - * the integer representation of the character of the variable to - * reference, one of '&', '`', '\'', or '+' - */ - rb_define_method(rb_cBACK_REF, "nth", node_nth, 0); - rb_ary_push(members, rb_str_new2("nth")); - /* Document-method: cnt * the index into the local variable table where the match data is * stored */ rb_define_method(rb_cBACK_REF, "cnt", node_cnt, 0); rb_ary_push(members, rb_str_new2("cnt")); + + /* Document-method: nth + * the integer representation of the character of the variable to + * reference, one of '&', '`', '\'', or '+' + */ + rb_define_method(rb_cBACK_REF, "nth", node_nth, 0); + rb_ary_push(members, rb_str_new2("nth")); } /* Document-class: Node::BEGIN * Represents a begin/end block. * @@ -3211,21 +3178,21 @@ rb_cNodeSubclass[NODE_BLOCK_PASS] = rb_cBLOCK_PASS; rb_iv_set(rb_cBLOCK_PASS, "__member__", members); rb_iv_set(rb_cBLOCK_PASS, "__type__", INT2NUM(NODE_BLOCK_PASS)); rb_define_singleton_method(rb_cBLOCK_PASS, "members", node_s_members, 0); - /* Document-method: body - * the object to pass as a block - */ - rb_define_method(rb_cBLOCK_PASS, "body", node_body, 0); - rb_ary_push(members, rb_str_new2("body")); - /* Document-method: iter * an expression which calls a method */ rb_define_method(rb_cBLOCK_PASS, "iter", node_iter, 0); rb_ary_push(members, rb_str_new2("iter")); + + /* Document-method: body + * the object to pass as a block + */ + rb_define_method(rb_cBLOCK_PASS, "body", node_body, 0); + rb_ary_push(members, rb_str_new2("body")); } /* Document-class: Node::BMETHOD * A placeholder for a method defined using define_method, e.g.: * define_method(:foo) { @@ -3278,16 +3245,10 @@ rb_cNodeSubclass[NODE_CALL] = rb_cCALL; rb_iv_set(rb_cCALL, "__member__", members); rb_iv_set(rb_cCALL, "__type__", INT2NUM(NODE_CALL)); rb_define_singleton_method(rb_cCALL, "members", node_s_members, 0); - /* Document-method: args - * the arguments to the method - */ - rb_define_method(rb_cCALL, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: mid * the method id */ rb_define_method(rb_cCALL, "mid", node_mid, 0); rb_ary_push(members, rb_str_new2("mid")); @@ -3295,10 +3256,16 @@ /* Document-method: recv * the receiver of the method */ rb_define_method(rb_cCALL, "recv", node_recv, 0); rb_ary_push(members, rb_str_new2("recv")); + + /* Document-method: args + * the arguments to the method + */ + rb_define_method(rb_cCALL, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); } /* Document-class: Node::CASE * Represents the value portion of a case/end block, e.g.: * case head @@ -3340,21 +3307,21 @@ rb_cNodeSubclass[NODE_CDECL] = rb_cCDECL; rb_iv_set(rb_cCDECL, "__member__", members); rb_iv_set(rb_cCDECL, "__type__", INT2NUM(NODE_CDECL)); rb_define_singleton_method(rb_cCDECL, "members", node_s_members, 0); - /* Document-method: value - * the value to be assigned to the constant - */ - rb_define_method(rb_cCDECL, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the constant to be assigned, all uppercase */ rb_define_method(rb_cCDECL, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); + + /* Document-method: value + * the value to be assigned to the constant + */ + rb_define_method(rb_cCDECL, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::CFUNC * A placeholder for a function implemented in C. */ @@ -3393,16 +3360,10 @@ rb_cNodeSubclass[NODE_CLASS] = rb_cCLASS; rb_iv_set(rb_cCLASS, "__member__", members); rb_iv_set(rb_cCLASS, "__type__", INT2NUM(NODE_CLASS)); rb_define_singleton_method(rb_cCLASS, "members", node_s_members, 0); - /* Document-method: cpath - * the name of the class to define - */ - rb_define_method(rb_cCLASS, "cpath", node_cpath, 0); - rb_ary_push(members, rb_str_new2("cpath")); - /* Document-method: body * the body of the class definition */ rb_define_method(rb_cCLASS, "body", node_body, 0); rb_ary_push(members, rb_str_new2("body")); @@ -3411,10 +3372,16 @@ * an expression returning the base class, or false if there is no * base class specified */ rb_define_method(rb_cCLASS, "super", node_super, 0); rb_ary_push(members, rb_str_new2("super")); + + /* Document-method: cpath + * the name of the class to define + */ + rb_define_method(rb_cCLASS, "cpath", node_cpath, 0); + rb_ary_push(members, rb_str_new2("cpath")); } /* Document-class: Node::COLON2 * Represents a constant lookup in a particular class. This expression * has the form: @@ -3512,22 +3479,22 @@ rb_cNodeSubclass[NODE_CVASGN] = rb_cCVASGN; rb_iv_set(rb_cCVASGN, "__member__", members); rb_iv_set(rb_cCVASGN, "__type__", INT2NUM(NODE_CVASGN)); rb_define_singleton_method(rb_cCVASGN, "members", node_s_members, 0); + /* Document-method: vid + * the name of the class variable to assign + */ + rb_define_method(rb_cCVASGN, "vid", node_vid, 0); + rb_ary_push(members, rb_str_new2("vid")); + /* Document-method: value * an expression whose result is the new value of the class * variable */ rb_define_method(rb_cCVASGN, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: vid - * the name of the class variable to assign - */ - rb_define_method(rb_cCVASGN, "vid", node_vid, 0); - rb_ary_push(members, rb_str_new2("vid")); } /* Document-class: Node::CVDECL * Represents class variable assignment in a class context. * @@ -3539,22 +3506,22 @@ rb_cNodeSubclass[NODE_CVDECL] = rb_cCVDECL; rb_iv_set(rb_cCVDECL, "__member__", members); rb_iv_set(rb_cCVDECL, "__type__", INT2NUM(NODE_CVDECL)); rb_define_singleton_method(rb_cCVDECL, "members", node_s_members, 0); + /* Document-method: vid + * the name of the class variable to assign + */ + rb_define_method(rb_cCVDECL, "vid", node_vid, 0); + rb_ary_push(members, rb_str_new2("vid")); + /* Document-method: value * an expression whose result is the new value of the class * variable */ rb_define_method(rb_cCVDECL, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: vid - * the name of the class variable to assign - */ - rb_define_method(rb_cCVDECL, "vid", node_vid, 0); - rb_ary_push(members, rb_str_new2("vid")); } /* Document-class: Node::DASGN * Represents dynamic local variable assignment. Dynamic assignment * differs from static assignment in that the slots for static local @@ -3573,21 +3540,21 @@ rb_cNodeSubclass[NODE_DASGN] = rb_cDASGN; rb_iv_set(rb_cDASGN, "__member__", members); rb_iv_set(rb_cDASGN, "__type__", INT2NUM(NODE_DASGN)); rb_define_singleton_method(rb_cDASGN, "members", node_s_members, 0); - /* Document-method: value - * the value to assign to the local variable - */ - rb_define_method(rb_cDASGN, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the local variable */ rb_define_method(rb_cDASGN, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); + + /* Document-method: value + * the value to assign to the local variable + */ + rb_define_method(rb_cDASGN, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::DASGN_CURR * Represents dynamic local variable assignment in the current frame. * See DASGN for a description of how dynamic assignment works. @@ -3598,21 +3565,21 @@ rb_cNodeSubclass[NODE_DASGN_CURR] = rb_cDASGN_CURR; rb_iv_set(rb_cDASGN_CURR, "__member__", members); rb_iv_set(rb_cDASGN_CURR, "__type__", INT2NUM(NODE_DASGN_CURR)); rb_define_singleton_method(rb_cDASGN_CURR, "members", node_s_members, 0); - /* Document-method: value - * the value to assign to the local variable - */ - rb_define_method(rb_cDASGN_CURR, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the local variable */ rb_define_method(rb_cDASGN_CURR, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); + + /* Document-method: value + * the value to assign to the local variable + */ + rb_define_method(rb_cDASGN_CURR, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::DEFINED * Represents an expression using the 'defined?' keyword. The result * is either nil or a string describing the expression. @@ -3644,22 +3611,22 @@ rb_cNodeSubclass[NODE_DEFN] = rb_cDEFN; rb_iv_set(rb_cDEFN, "__member__", members); rb_iv_set(rb_cDEFN, "__type__", INT2NUM(NODE_DEFN)); rb_define_singleton_method(rb_cDEFN, "members", node_s_members, 0); - /* Document-method: defn - * the body of the method definition - */ - rb_define_method(rb_cDEFN, "defn", node_defn, 0); - rb_ary_push(members, rb_str_new2("defn")); - /* Document-method: mid * the name of the method* defn the body of the method */ rb_define_method(rb_cDEFN, "mid", node_mid, 0); rb_ary_push(members, rb_str_new2("mid")); + /* Document-method: defn + * the body of the method definition + */ + rb_define_method(rb_cDEFN, "defn", node_defn, 0); + rb_ary_push(members, rb_str_new2("defn")); + /* Document-method: noex * the flags which should be used to define the method */ rb_define_method(rb_cDEFN, "noex", node_noex, 0); rb_ary_push(members, rb_str_new2("noex")); @@ -3676,18 +3643,18 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_DEFS] = rb_cDEFS; rb_iv_set(rb_cDEFS, "__member__", members); rb_iv_set(rb_cDEFS, "__type__", INT2NUM(NODE_DEFS)); rb_define_singleton_method(rb_cDEFS, "members", node_s_members, 0); - rb_define_method(rb_cDEFS, "defn", node_defn, 0); - rb_ary_push(members, rb_str_new2("defn")); /* Document-method: mid * the name of the method* defn the body of the method */ rb_define_method(rb_cDEFS, "mid", node_mid, 0); rb_ary_push(members, rb_str_new2("mid")); + rb_define_method(rb_cDEFS, "defn", node_defn, 0); + rb_ary_push(members, rb_str_new2("defn")); /* Document-method: recv * the object to whose singleton class the new method is to be added */ rb_define_method(rb_cDEFS, "recv", node_recv, 0); @@ -3705,23 +3672,23 @@ rb_cNodeSubclass[NODE_DOT2] = rb_cDOT2; rb_iv_set(rb_cDOT2, "__member__", members); rb_iv_set(rb_cDOT2, "__type__", INT2NUM(NODE_DOT2)); rb_define_singleton_method(rb_cDOT2, "members", node_s_members, 0); - /* Document-method: beg - * the beginning of the range - */ - rb_define_method(rb_cDOT2, "beg", node_beg, 0); - rb_ary_push(members, rb_str_new2("beg")); - /* Document-method: end * the end of the range */ rb_define_method(rb_cDOT2, "end", node_end, 0); rb_ary_push(members, rb_str_new2("end")); rb_define_method(rb_cDOT2, "state", node_state, 0); rb_ary_push(members, rb_str_new2("state")); + + /* Document-method: beg + * the beginning of the range + */ + rb_define_method(rb_cDOT2, "beg", node_beg, 0); + rb_ary_push(members, rb_str_new2("beg")); } /* Document-class: Node::DOT3 * Represents a range created with the form: * beg...end @@ -3733,23 +3700,23 @@ rb_cNodeSubclass[NODE_DOT3] = rb_cDOT3; rb_iv_set(rb_cDOT3, "__member__", members); rb_iv_set(rb_cDOT3, "__type__", INT2NUM(NODE_DOT3)); rb_define_singleton_method(rb_cDOT3, "members", node_s_members, 0); - /* Document-method: beg - * the beginning of the range - */ - rb_define_method(rb_cDOT3, "beg", node_beg, 0); - rb_ary_push(members, rb_str_new2("beg")); - /* Document-method: end * the end of the range */ rb_define_method(rb_cDOT3, "end", node_end, 0); rb_ary_push(members, rb_str_new2("end")); rb_define_method(rb_cDOT3, "state", node_state, 0); rb_ary_push(members, rb_str_new2("state")); + + /* Document-method: beg + * the beginning of the range + */ + rb_define_method(rb_cDOT3, "beg", node_beg, 0); + rb_ary_push(members, rb_str_new2("beg")); } /* Document-class: Node::DREGX * Represents a regular expresion with interpolation. The node is * evaluated by duplicating the regex stored in the 'lit' element, then @@ -4001,42 +3968,10 @@ rb_iv_set(rb_cFALSE, "__member__", members); rb_iv_set(rb_cFALSE, "__type__", INT2NUM(NODE_FALSE)); rb_define_singleton_method(rb_cFALSE, "members", node_s_members, 0); } - /* Document-class: Node::FBODY - * A placeholder for a method alias, which can be added to a class by - * using alias or alias_method: - * alias old new - */ - { - VALUE rb_cFBODY = rb_define_class_under(rb_cNode, "FBODY", rb_cNode); - members = rb_ary_new(); - rb_cNodeSubclass[NODE_FBODY] = rb_cFBODY; - rb_iv_set(rb_cFBODY, "__member__", members); - rb_iv_set(rb_cFBODY, "__type__", INT2NUM(NODE_FBODY)); - rb_define_singleton_method(rb_cFBODY, "members", node_s_members, 0); - - /* Document-method: body - * the method body - */ - rb_define_method(rb_cFBODY, "body", node_body, 0); - rb_ary_push(members, rb_str_new2("body")); - - /* Document-method: cnt - * the method's flags - */ - rb_define_method(rb_cFBODY, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); - - /* Document-method: oid - * the original name of the method - */ - rb_define_method(rb_cFBODY, "oid", node_oid, 0); - rb_ary_push(members, rb_str_new2("oid")); - } - /* Document-class: Node::FCALL * Represents a method call in the form: * mid(args). * * This makes a method call on an object using self as the implicit @@ -4048,21 +3983,21 @@ rb_cNodeSubclass[NODE_FCALL] = rb_cFCALL; rb_iv_set(rb_cFCALL, "__member__", members); rb_iv_set(rb_cFCALL, "__type__", INT2NUM(NODE_FCALL)); rb_define_singleton_method(rb_cFCALL, "members", node_s_members, 0); - /* Document-method: args - * the arguments to the method - */ - rb_define_method(rb_cFCALL, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: mid * the method id */ rb_define_method(rb_cFCALL, "mid", node_mid, 0); rb_ary_push(members, rb_str_new2("mid")); + + /* Document-method: args + * the arguments to the method + */ + rb_define_method(rb_cFCALL, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); } /* Document-class: Node::FLIP2 * Represents part of an awk-like flip-flop expression of the form: * if beg..end then @@ -4075,28 +4010,28 @@ rb_cNodeSubclass[NODE_FLIP2] = rb_cFLIP2; rb_iv_set(rb_cFLIP2, "__member__", members); rb_iv_set(rb_cFLIP2, "__type__", INT2NUM(NODE_FLIP2)); rb_define_singleton_method(rb_cFLIP2, "members", node_s_members, 0); - /* Document-method: beg - * the beginning of the range + /* Document-method: cnt + * the index into the local variable table of the special variable + * to use in the flip-flop expression (usually 2 for $_) */ - rb_define_method(rb_cFLIP2, "beg", node_beg, 0); - rb_ary_push(members, rb_str_new2("beg")); + rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); /* Document-method: end * the end of the range */ rb_define_method(rb_cFLIP2, "end", node_end, 0); rb_ary_push(members, rb_str_new2("end")); - /* Document-method: cnt - * the index into the local variable table of the special variable - * to use in the flip-flop expression (usually 2 for $_) + /* Document-method: beg + * the beginning of the range */ - rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); + rb_define_method(rb_cFLIP2, "beg", node_beg, 0); + rb_ary_push(members, rb_str_new2("beg")); } /* Document-class: Node::FLIP3 * Represents part of a sed-like flip-flop expression of the form: * if beg..end then @@ -4109,28 +4044,28 @@ rb_cNodeSubclass[NODE_FLIP3] = rb_cFLIP3; rb_iv_set(rb_cFLIP3, "__member__", members); rb_iv_set(rb_cFLIP3, "__type__", INT2NUM(NODE_FLIP3)); rb_define_singleton_method(rb_cFLIP3, "members", node_s_members, 0); - /* Document-method: beg - * the beginning of the range + /* Document-method: cnt + * the index into the local variable table of the special variable + * to use in the flip-flop expression (usually 2 for $_) */ - rb_define_method(rb_cFLIP3, "beg", node_beg, 0); - rb_ary_push(members, rb_str_new2("beg")); + rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); /* Document-method: end * the end of the range */ rb_define_method(rb_cFLIP3, "end", node_end, 0); rb_ary_push(members, rb_str_new2("end")); - /* Document-method: cnt - * the index into the local variable table of the special variable - * to use in the flip-flop expression (usually 2 for $_) + /* Document-method: beg + * the beginning of the range */ - rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); + rb_define_method(rb_cFLIP3, "beg", node_beg, 0); + rb_ary_push(members, rb_str_new2("beg")); } /* Document-class: Node::FOR * Represents a loop constructed with the 'for' keyword, e.g.: * for var in iter do @@ -4151,22 +4086,22 @@ rb_cNodeSubclass[NODE_FOR] = rb_cFOR; rb_iv_set(rb_cFOR, "__member__", members); rb_iv_set(rb_cFOR, "__type__", INT2NUM(NODE_FOR)); rb_define_singleton_method(rb_cFOR, "members", node_s_members, 0); - /* Document-method: body - * the body of the loop - */ - rb_define_method(rb_cFOR, "body", node_body, 0); - rb_ary_push(members, rb_str_new2("body")); - /* Document-method: iter * the sequence over which to iterate */ rb_define_method(rb_cFOR, "iter", node_iter, 0); rb_ary_push(members, rb_str_new2("iter")); + /* Document-method: body + * the body of the loop + */ + rb_define_method(rb_cFOR, "body", node_body, 0); + rb_ary_push(members, rb_str_new2("body")); + /* Document-method: var * an assignment node which assigns the next value in the sequence * to a variable, which may or may not be local. May also be a * multiple assignment. */ @@ -4183,23 +4118,23 @@ rb_cNodeSubclass[NODE_GASGN] = rb_cGASGN; rb_iv_set(rb_cGASGN, "__member__", members); rb_iv_set(rb_cGASGN, "__type__", INT2NUM(NODE_GASGN)); rb_define_singleton_method(rb_cGASGN, "members", node_s_members, 0); - /* Document-method: value - * an expression whose result is the new value of the global variable - */ - rb_define_method(rb_cGASGN, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the global variable, with a leading '$' character. */ rb_define_method(rb_cGASGN, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); rb_define_method(rb_cGASGN, "entry", node_entry, 0); rb_ary_push(members, rb_str_new2("entry")); + + /* Document-method: value + * an expression whose result is the new value of the global variable + */ + rb_define_method(rb_cGASGN, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::GVAR * Represents global variable retrieval. */ @@ -4248,21 +4183,21 @@ rb_cNodeSubclass[NODE_IASGN] = rb_cIASGN; rb_iv_set(rb_cIASGN, "__member__", members); rb_iv_set(rb_cIASGN, "__type__", INT2NUM(NODE_IASGN)); rb_define_singleton_method(rb_cIASGN, "members", node_s_members, 0); - /* Document-method: value - * the value to assign to the instance variable - */ - rb_define_method(rb_cIASGN, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the instance variable, with a leading '@' sign */ rb_define_method(rb_cIASGN, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); + + /* Document-method: value + * the value to assign to the instance variable + */ + rb_define_method(rb_cIASGN, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::IF * Represents a conditional of the form: * if cond then @@ -4290,23 +4225,23 @@ rb_cNodeSubclass[NODE_IF] = rb_cIF; rb_iv_set(rb_cIF, "__member__", members); rb_iv_set(rb_cIF, "__type__", INT2NUM(NODE_IF)); rb_define_singleton_method(rb_cIF, "members", node_s_members, 0); - /* Document-method: cond - * the condition to evaluate - */ - rb_define_method(rb_cIF, "cond", node_cond, 0); - rb_ary_push(members, rb_str_new2("cond")); - /* Document-method: body * the expression to evaluate if the expression is true, or false * if the expression is empty */ rb_define_method(rb_cIF, "body", node_body, 0); rb_ary_push(members, rb_str_new2("body")); + /* Document-method: cond + * the condition to evaluate + */ + rb_define_method(rb_cIF, "cond", node_cond, 0); + rb_ary_push(members, rb_str_new2("cond")); + /* Document-method: else * the expression to evaluate if the expression is false, or false * if the expression is empty */ rb_define_method(rb_cIF, "else", node_else, 0); @@ -4322,10 +4257,16 @@ rb_cNodeSubclass[NODE_IFUNC] = rb_cIFUNC; rb_iv_set(rb_cIFUNC, "__member__", members); rb_iv_set(rb_cIFUNC, "__type__", INT2NUM(NODE_IFUNC)); rb_define_singleton_method(rb_cIFUNC, "members", node_s_members, 0); + /* Document-method: state + * always 0 + */ + rb_define_method(rb_cIFUNC, "state", node_state, 0); + rb_ary_push(members, rb_str_new2("state")); + /* Document-method: cfnc * a pointer to the C function to which to yield */ rb_define_method(rb_cIFUNC, "cfnc", node_cfnc, 0); rb_ary_push(members, rb_str_new2("cfnc")); @@ -4334,16 +4275,10 @@ * the user-specified data to be passed as the second argument to * cfnc */ rb_define_method(rb_cIFUNC, "tval", node_tval, 0); rb_ary_push(members, rb_str_new2("tval")); - - /* Document-method: state - * always 0 - */ - rb_define_method(rb_cIFUNC, "state", node_state, 0); - rb_ary_push(members, rb_str_new2("state")); } /* Document-class: Node::ITER * Represents an iteration loop, e.g.: * iter do |*args| @@ -4363,23 +4298,23 @@ rb_cNodeSubclass[NODE_ITER] = rb_cITER; rb_iv_set(rb_cITER, "__member__", members); rb_iv_set(rb_cITER, "__type__", INT2NUM(NODE_ITER)); rb_define_singleton_method(rb_cITER, "members", node_s_members, 0); - /* Document-method: body - * the body of the loop - */ - rb_define_method(rb_cITER, "body", node_body, 0); - rb_ary_push(members, rb_str_new2("body")); - /* Document-method: iter * an expression which calls the desired iteration method, usually * recv.each */ rb_define_method(rb_cITER, "iter", node_iter, 0); rb_ary_push(members, rb_str_new2("iter")); + /* Document-method: body + * the body of the loop + */ + rb_define_method(rb_cITER, "body", node_body, 0); + rb_ary_push(members, rb_str_new2("body")); + /* Document-method: var * an assignment node which assigns the next value in the sequence * to a variable, which may or may not be local. May also be a * multiple assignment. */ @@ -4416,24 +4351,24 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_LASGN] = rb_cLASGN; rb_iv_set(rb_cLASGN, "__member__", members); rb_iv_set(rb_cLASGN, "__type__", INT2NUM(NODE_LASGN)); rb_define_singleton_method(rb_cLASGN, "members", node_s_members, 0); + rb_define_method(rb_cLASGN, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); - /* Document-method: value - * the value to assign to the local variable - */ - rb_define_method(rb_cLASGN, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: vid * the name of the local variable */ rb_define_method(rb_cLASGN, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); - rb_define_method(rb_cLASGN, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); + + /* Document-method: value + * the value to assign to the local variable + */ + rb_define_method(rb_cLASGN, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::LIT * Represents a literal object. The result of the expression is the * object contained in this node. @@ -4461,18 +4396,18 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_LVAR] = rb_cLVAR; rb_iv_set(rb_cLVAR, "__member__", members); rb_iv_set(rb_cLVAR, "__type__", INT2NUM(NODE_LVAR)); rb_define_singleton_method(rb_cLVAR, "members", node_s_members, 0); + rb_define_method(rb_cLVAR, "cnt", node_cnt, 0); + rb_ary_push(members, rb_str_new2("cnt")); /* Document-method: vid * the name of the local variable to retrieve. */ rb_define_method(rb_cLVAR, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); - rb_define_method(rb_cLVAR, "cnt", node_cnt, 0); - rb_ary_push(members, rb_str_new2("cnt")); } /* Document-class: Node::MASGN * Represents multiple assignment. */ @@ -4482,22 +4417,22 @@ rb_cNodeSubclass[NODE_MASGN] = rb_cMASGN; rb_iv_set(rb_cMASGN, "__member__", members); rb_iv_set(rb_cMASGN, "__type__", INT2NUM(NODE_MASGN)); rb_define_singleton_method(rb_cMASGN, "members", node_s_members, 0); - /* Document-method: args - * TODO - */ - rb_define_method(rb_cMASGN, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: head * TODO */ rb_define_method(rb_cMASGN, "head", node_head, 0); rb_ary_push(members, rb_str_new2("head")); + /* Document-method: args + * TODO + */ + rb_define_method(rb_cMASGN, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); + /* Document-method: value * TODO */ rb_define_method(rb_cMASGN, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); @@ -4561,24 +4496,24 @@ rb_cNodeSubclass[NODE_MATCH2] = rb_cMATCH2; rb_iv_set(rb_cMATCH2, "__member__", members); rb_iv_set(rb_cMATCH2, "__type__", INT2NUM(NODE_MATCH2)); rb_define_singleton_method(rb_cMATCH2, "members", node_s_members, 0); + /* Document-method: recv + * the regular expression on the left hand side of the match + * operator + */ + rb_define_method(rb_cMATCH2, "recv", node_recv, 0); + rb_ary_push(members, rb_str_new2("recv")); + /* Document-method: value * the expression on the right hand side of the match operator, or * an expression returning $_ if there is nothing on the right hand * side */ rb_define_method(rb_cMATCH2, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: recv - * the regular expression on the left hand side of the match - * operator - */ - rb_define_method(rb_cMATCH2, "recv", node_recv, 0); - rb_ary_push(members, rb_str_new2("recv")); } /* Document-class: Node::MATCH3 * Represents a regular expression match of the form: * recv =~ /value/ @@ -4592,21 +4527,21 @@ rb_cNodeSubclass[NODE_MATCH3] = rb_cMATCH3; rb_iv_set(rb_cMATCH3, "__member__", members); rb_iv_set(rb_cMATCH3, "__type__", INT2NUM(NODE_MATCH3)); rb_define_singleton_method(rb_cMATCH3, "members", node_s_members, 0); - /* Document-method: value - * the right hand side of the match - */ - rb_define_method(rb_cMATCH3, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); - /* Document-method: recv * the left hand side of the match */ rb_define_method(rb_cMATCH3, "recv", node_recv, 0); rb_ary_push(members, rb_str_new2("recv")); + + /* Document-method: value + * the right hand side of the match + */ + rb_define_method(rb_cMATCH3, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::MEMO * A node used for temporary storage. * @@ -4628,46 +4563,10 @@ rb_iv_set(rb_cMEMO, "__member__", members); rb_iv_set(rb_cMEMO, "__type__", INT2NUM(NODE_MEMO)); rb_define_singleton_method(rb_cMEMO, "members", node_s_members, 0); } - /* Document-class: Node::METHOD - * A placeholder for a method entry in a class's method table. - * - * On ruby 1.9 this node type is also known as RUBY_VM_METHOD_NODE. - * Its use differs from that of NODE_METHOD in that it is used as the - * body of another METHOD node and is used to store the method's - * instruction sequence. - */ - { - VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode); - members = rb_ary_new(); - rb_cNodeSubclass[NODE_METHOD] = rb_cMETHOD; - rb_iv_set(rb_cMETHOD, "__member__", members); - rb_iv_set(rb_cMETHOD, "__type__", INT2NUM(NODE_METHOD)); - rb_define_singleton_method(rb_cMETHOD, "members", node_s_members, 0); - - /* Document-method: body - * the body of the method - */ - rb_define_method(rb_cMETHOD, "body", node_body, 0); - rb_ary_push(members, rb_str_new2("body")); - - /* Document-method: clss - * the class to which the method was added or the instruction - * sequence used to implement this method - */ - rb_define_method(rb_cMETHOD, "clss", node_clss, 0); - rb_ary_push(members, rb_str_new2("clss")); - - /* Document-method: noex - * the method's flags - */ - rb_define_method(rb_cMETHOD, "noex", node_noex, 0); - rb_ary_push(members, rb_str_new2("noex")); - } - /* Document-class: Node::MODULE * Represents a module definition, e.g.: * module cpath * body * end @@ -4683,21 +4582,21 @@ rb_cNodeSubclass[NODE_MODULE] = rb_cMODULE; rb_iv_set(rb_cMODULE, "__member__", members); rb_iv_set(rb_cMODULE, "__type__", INT2NUM(NODE_MODULE)); rb_define_singleton_method(rb_cMODULE, "members", node_s_members, 0); - /* Document-method: cpath - * the name of the module to define - */ - rb_define_method(rb_cMODULE, "cpath", node_cpath, 0); - rb_ary_push(members, rb_str_new2("cpath")); - /* Document-method: body * the body of the module definition */ rb_define_method(rb_cMODULE, "body", node_body, 0); rb_ary_push(members, rb_str_new2("body")); + + /* Document-method: cpath + * the name of the module to define + */ + rb_define_method(rb_cMODULE, "cpath", node_cpath, 0); + rb_ary_push(members, rb_str_new2("cpath")); } /* Document-class: Node::NEXT * Represents the 'next' keyword. * Causes control to be transferred to the end of the loop, causing the @@ -4735,21 +4634,21 @@ rb_cNodeSubclass[NODE_NTH_REF] = rb_cNTH_REF; rb_iv_set(rb_cNTH_REF, "__member__", members); rb_iv_set(rb_cNTH_REF, "__type__", INT2NUM(NODE_NTH_REF)); rb_define_singleton_method(rb_cNTH_REF, "members", node_s_members, 0); - /* Document-method: nth - * the index of the match data item to retrieve - */ - rb_define_method(rb_cNTH_REF, "nth", node_nth, 0); - rb_ary_push(members, rb_str_new2("nth")); - /* Document-method: cnt * the index into the local variable table where the match data is stored */ rb_define_method(rb_cNTH_REF, "cnt", node_cnt, 0); rb_ary_push(members, rb_str_new2("cnt")); + + /* Document-method: nth + * the index of the match data item to retrieve + */ + rb_define_method(rb_cNTH_REF, "nth", node_nth, 0); + rb_ary_push(members, rb_str_new2("nth")); } /* Document-class: Node::OPT_N * Represents the top-level loop when the -n or -p options are used * with the interpreter. @@ -4798,16 +4697,10 @@ rb_cNodeSubclass[NODE_OP_ASGN1] = rb_cOP_ASGN1; rb_iv_set(rb_cOP_ASGN1, "__member__", members); rb_iv_set(rb_cOP_ASGN1, "__type__", INT2NUM(NODE_OP_ASGN1)); rb_define_singleton_method(rb_cOP_ASGN1, "members", node_s_members, 0); - /* Document-method: args - * the arguments to the assigment - */ - rb_define_method(rb_cOP_ASGN1, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: mid * 0, 1, or the name a method to call to calculate the value of the * rhs */ rb_define_method(rb_cOP_ASGN1, "mid", node_mid, 0); @@ -4816,10 +4709,16 @@ /* Document-method: recv * the receiver of the assignment */ rb_define_method(rb_cOP_ASGN1, "recv", node_recv, 0); rb_ary_push(members, rb_str_new2("recv")); + + /* Document-method: args + * the arguments to the assigment + */ + rb_define_method(rb_cOP_ASGN1, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); } /* Document-class: Node::OP_ASGN2 * Represents attribute assignment of the form: * recv.attr op value @@ -4838,28 +4737,28 @@ rb_cNodeSubclass[NODE_OP_ASGN2] = rb_cOP_ASGN2; rb_iv_set(rb_cOP_ASGN2, "__member__", members); rb_iv_set(rb_cOP_ASGN2, "__type__", INT2NUM(NODE_OP_ASGN2)); rb_define_singleton_method(rb_cOP_ASGN2, "members", node_s_members, 0); - /* Document-method: value - * the value to assign to the attribute + /* Document-method: recv + * the receiver of the attribute */ - rb_define_method(rb_cOP_ASGN2, "value", node_value, 0); - rb_ary_push(members, rb_str_new2("value")); + rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0); + rb_ary_push(members, rb_str_new2("recv")); /* Document-method: next * another node of type OP_ASGN2 which contains more information * about the assignment operation than can fit in this node alone */ rb_define_method(rb_cOP_ASGN2, "next", node_next, 0); rb_ary_push(members, rb_str_new2("next")); - /* Document-method: recv - * the receiver of the attribute + /* Document-method: value + * the value to assign to the attribute */ - rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0); - rb_ary_push(members, rb_str_new2("recv")); + rb_define_method(rb_cOP_ASGN2, "value", node_value, 0); + rb_ary_push(members, rb_str_new2("value")); } /* Document-class: Node::OP_ASGN2_ARG * Actually a node of type OP_ASGN2, this is a placeholder for * additional information about the assignment than can fit in a single @@ -4871,10 +4770,18 @@ rb_cNodeSubclass[NODE_OP_ASGN2_ARG] = rb_cOP_ASGN2_ARG; rb_iv_set(rb_cOP_ASGN2_ARG, "__member__", members); rb_iv_set(rb_cOP_ASGN2_ARG, "__type__", INT2NUM(NODE_OP_ASGN2_ARG)); rb_define_singleton_method(rb_cOP_ASGN2_ARG, "members", node_s_members, 0); + /* Document-method: mid + * The operation to apply to the attribute before setting it. May + * be 0 (false) to indicate "logical or" or 1 (nil) to indicate + * "logical and". + */ + rb_define_method(rb_cOP_ASGN2_ARG, "mid", node_mid, 0); + rb_ary_push(members, rb_str_new2("mid")); + /* Document-method: vid * The method to call on the receiver to retrieve the attribute */ rb_define_method(rb_cOP_ASGN2_ARG, "vid", node_vid, 0); rb_ary_push(members, rb_str_new2("vid")); @@ -4882,18 +4789,10 @@ /* Document-method: aid * The method to call on the receiver to set the attribute */ rb_define_method(rb_cOP_ASGN2_ARG, "aid", node_aid, 0); rb_ary_push(members, rb_str_new2("aid")); - - /* Document-method: mid - * The operation to apply to the attribute before setting it. May - * be 0 (false) to indicate "logical or" or 1 (nil) to indicate - * "logical and". - */ - rb_define_method(rb_cOP_ASGN2_ARG, "mid", node_mid, 0); - rb_ary_push(members, rb_str_new2("mid")); } /* Document-class: Node::OP_ASGN_AND * Represents an expression of the form: * recv &&= value @@ -4908,22 +4807,22 @@ rb_cNodeSubclass[NODE_OP_ASGN_AND] = rb_cOP_ASGN_AND; rb_iv_set(rb_cOP_ASGN_AND, "__member__", members); rb_iv_set(rb_cOP_ASGN_AND, "__type__", INT2NUM(NODE_OP_ASGN_AND)); rb_define_singleton_method(rb_cOP_ASGN_AND, "members", node_s_members, 0); + /* Document-method: recv + * an expression representing the left hand side of the assignment + */ + rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0); + rb_ary_push(members, rb_str_new2("recv")); + /* Document-method: value * an expression representing the assignment that should be * performed if the left hand side is true */ rb_define_method(rb_cOP_ASGN_AND, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: recv - * an expression representing the left hand side of the assignment - */ - rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0); - rb_ary_push(members, rb_str_new2("recv")); } /* Document-class: Node::OP_ASGN_OR * Represents an expression of the form: * recv ||= value @@ -4938,10 +4837,16 @@ rb_cNodeSubclass[NODE_OP_ASGN_OR] = rb_cOP_ASGN_OR; rb_iv_set(rb_cOP_ASGN_OR, "__member__", members); rb_iv_set(rb_cOP_ASGN_OR, "__type__", INT2NUM(NODE_OP_ASGN_OR)); rb_define_singleton_method(rb_cOP_ASGN_OR, "members", node_s_members, 0); + /* Document-method: recv + * the receiver of the assignment + */ + rb_define_method(rb_cOP_ASGN_OR, "recv", node_recv, 0); + rb_ary_push(members, rb_str_new2("recv")); + /* Document-method: aid * if this indicator is nonzero, ruby will check to see if the * provided expression is defined, otherwise it will assume that * the provided expression is defined. */ @@ -4951,16 +4856,10 @@ /* Document-method: value * the right hand side of the assignment */ rb_define_method(rb_cOP_ASGN_OR, "value", node_value, 0); rb_ary_push(members, rb_str_new2("value")); - - /* Document-method: recv - * the receiver of the assignment - */ - rb_define_method(rb_cOP_ASGN_OR, "recv", node_recv, 0); - rb_ary_push(members, rb_str_new2("recv")); } /* Document-class: Node::OR * Represents a logical 'or' of the form: * first || second @@ -4974,21 +4873,21 @@ rb_cNodeSubclass[NODE_OR] = rb_cOR; rb_iv_set(rb_cOR, "__member__", members); rb_iv_set(rb_cOR, "__type__", INT2NUM(NODE_OR)); rb_define_singleton_method(rb_cOR, "members", node_s_members, 0); - /* Document-method: first - * the expression on the left hand side - */ - rb_define_method(rb_cOR, "first", node_1st, 0); - rb_ary_push(members, rb_str_new2("first")); - /* Document-method: second * the expression on the right hand side */ rb_define_method(rb_cOR, "second", node_2nd, 0); rb_ary_push(members, rb_str_new2("second")); + + /* Document-method: first + * the expression on the left hand side + */ + rb_define_method(rb_cOR, "first", node_1st, 0); + rb_ary_push(members, rb_str_new2("first")); } /* Document-class: Node::POSTEXE * Represents the END keyword, e.g.: * END { ... } @@ -5042,21 +4941,21 @@ * the next rescue */ rb_define_method(rb_cRESBODY, "head", node_head, 0); rb_ary_push(members, rb_str_new2("head")); - /* Document-method: args - * the expression type to match against - */ - rb_define_method(rb_cRESBODY, "args", node_args, 0); - rb_ary_push(members, rb_str_new2("args")); - /* Document-method: body * the expresion to evaluate if the exception type matches */ rb_define_method(rb_cRESBODY, "body", node_body, 0); rb_ary_push(members, rb_str_new2("body")); + + /* Document-method: args + * the expression type to match against + */ + rb_define_method(rb_cRESBODY, "args", node_args, 0); + rb_ary_push(members, rb_str_new2("args")); } /* Document-class: Node::RESCUE * Represents part of a rescue expression of the form: * head rescue expr @@ -5098,21 +4997,21 @@ * the body of the block to evaluate */ rb_define_method(rb_cRESCUE, "head", node_head, 0); rb_ary_push(members, rb_str_new2("head")); - /* Document-method: else - * the expression to be evaluated if no exception is raised - */ - rb_define_method(rb_cRESCUE, "else", node_else, 0); - rb_ary_push(members, rb_str_new2("else")); - /* Document-method: resq * the expression to be evaluated if an exception is raised */ rb_define_method(rb_cRESCUE, "resq", node_resq, 0); rb_ary_push(members, rb_str_new2("resq")); + + /* Document-method: else + * the expression to be evaluated if no exception is raised + */ + rb_define_method(rb_cRESCUE, "else", node_else, 0); + rb_ary_push(members, rb_str_new2("else")); } /* Document-class: Node::RETRY * Represents the retry keyword. */ @@ -5198,24 +5097,24 @@ rb_cNodeSubclass[NODE_SCOPE] = rb_cSCOPE; rb_iv_set(rb_cSCOPE, "__member__", members); rb_iv_set(rb_cSCOPE, "__type__", INT2NUM(NODE_SCOPE)); rb_define_singleton_method(rb_cSCOPE, "members", node_s_members, 0); - /* Document-method: tbl - * the names of the local variables* next the first expression in - * the scope - */ - rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0); - rb_ary_push(members, rb_str_new2("tbl")); - /* Document-method: rval * holds information about which class(es) to search for constants * in this scope */ rb_define_method(rb_cSCOPE, "rval", node_rval, 0); rb_ary_push(members, rb_str_new2("rval")); + /* Document-method: tbl + * the names of the local variables* next the first expression in + * the scope + */ + rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0); + rb_ary_push(members, rb_str_new2("tbl")); + /* Document-method: next * the body of the lexical scope */ rb_define_method(rb_cSCOPE, "next", node_next, 0); rb_ary_push(members, rb_str_new2("next")); @@ -5358,10 +5257,12 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_UNTIL] = rb_cUNTIL; rb_iv_set(rb_cUNTIL, "__member__", members); rb_iv_set(rb_cUNTIL, "__type__", INT2NUM(NODE_UNTIL)); rb_define_singleton_method(rb_cUNTIL, "members", node_s_members, 0); + rb_define_method(rb_cUNTIL, "state", node_state, 0); + rb_ary_push(members, rb_str_new2("state")); /* Document-method: body * the body of the loop */ rb_define_method(rb_cUNTIL, "body", node_body, 0); @@ -5370,12 +5271,10 @@ /* Document-method: cond * a condition to terminate the loop when it becomes true */ rb_define_method(rb_cUNTIL, "cond", node_cond, 0); rb_ary_push(members, rb_str_new2("cond")); - rb_define_method(rb_cUNTIL, "state", node_state, 0); - rb_ary_push(members, rb_str_new2("state")); } /* Document-class: Node::VALIAS * Represents an alias expression of the form: * alias 1st 2nd @@ -5387,14 +5286,14 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_VALIAS] = rb_cVALIAS; rb_iv_set(rb_cVALIAS, "__member__", members); rb_iv_set(rb_cVALIAS, "__type__", INT2NUM(NODE_VALIAS)); rb_define_singleton_method(rb_cVALIAS, "members", node_s_members, 0); - rb_define_method(rb_cVALIAS, "first", node_1st, 0); - rb_ary_push(members, rb_str_new2("first")); rb_define_method(rb_cVALIAS, "second", node_2nd, 0); rb_ary_push(members, rb_str_new2("second")); + rb_define_method(rb_cVALIAS, "first", node_1st, 0); + rb_ary_push(members, rb_str_new2("first")); } /* Document-class: Node::VCALL * Represents a local variable or a method call without an explicit * receiver, to be determined at run-time. @@ -5482,10 +5381,12 @@ members = rb_ary_new(); rb_cNodeSubclass[NODE_WHILE] = rb_cWHILE; rb_iv_set(rb_cWHILE, "__member__", members); rb_iv_set(rb_cWHILE, "__type__", INT2NUM(NODE_WHILE)); rb_define_singleton_method(rb_cWHILE, "members", node_s_members, 0); + rb_define_method(rb_cWHILE, "state", node_state, 0); + rb_ary_push(members, rb_str_new2("state")); /* Document-method: body * the body of the loop */ rb_define_method(rb_cWHILE, "body", node_body, 0); @@ -5494,11 +5395,9 @@ /* Document-method: cond * a condition to terminate the loop when it becomes false */ rb_define_method(rb_cWHILE, "cond", node_cond, 0); rb_ary_push(members, rb_str_new2("cond")); - rb_define_method(rb_cWHILE, "state", node_state, 0); - rb_ary_push(members, rb_str_new2("state")); } /* Document-class: Node::XSTR * Represents a string object inside backticks, e.g.: * `lit`