ruby-internal 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/README +204 -6
  2. data/ext/cached/ruby-1.6.8/internal/binding/block.h +35 -0
  3. data/ext/cached/ruby-1.6.8/internal/method/method.h +19 -0
  4. data/ext/cached/ruby-1.6.8/internal/module/classpath.c +3 -0
  5. data/ext/cached/ruby-1.6.8/internal/module/classpath.h +8 -0
  6. data/ext/cached/ruby-1.6.8/internal/node/block.h +35 -0
  7. data/ext/cached/ruby-1.6.8/internal/node/global_entry.h +15 -0
  8. data/ext/cached/ruby-1.6.8/internal/node/node_type_descrip.c +149 -0
  9. data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.c +5582 -0
  10. data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.h +69 -0
  11. data/ext/cached/ruby-1.6.8/internal/proc/block.h +35 -0
  12. data/ext/cached/ruby-1.6.8/internal/tag/tag.h +15 -0
  13. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.c +39 -0
  14. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.h +21 -0
  15. data/ext/cached/ruby-1.6.8/internal/vm/iseq/insns_info.inc +12 -0
  16. data/ext/cached/ruby-1.6.8/internal/vm/iseq/iseq_load.inc +9 -0
  17. data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +91 -91
  18. data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +1909 -1909
  19. data/ext/cached/ruby-1.8.0/internal/vm/iseq/iseq_load.inc +9 -0
  20. data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +90 -90
  21. data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +1946 -1946
  22. data/ext/cached/ruby-1.8.1/internal/vm/iseq/iseq_load.inc +9 -0
  23. data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +90 -90
  24. data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +1946 -1946
  25. data/ext/cached/ruby-1.8.2/internal/vm/iseq/iseq_load.inc +9 -0
  26. data/ext/cached/ruby-1.8.3/internal/node/node_type_descrip.c +90 -90
  27. data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +1946 -1946
  28. data/ext/cached/ruby-1.8.3/internal/vm/iseq/iseq_load.inc +9 -0
  29. data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +90 -90
  30. data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +1946 -1946
  31. data/ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc +9 -0
  32. data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +90 -90
  33. data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +1909 -1909
  34. data/ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc +9 -0
  35. data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +90 -90
  36. data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +1909 -1909
  37. data/ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc +9 -0
  38. data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +90 -90
  39. data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +1909 -1909
  40. data/ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc +9 -0
  41. data/ext/cached/ruby-1.9.0/internal/node/node_type_descrip.c +85 -85
  42. data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.c +1800 -1800
  43. data/ext/cached/ruby-1.9.0/internal/vm/iseq/iseq_load.inc +13 -0
  44. data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +51 -51
  45. data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +85 -85
  46. data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +1800 -1800
  47. data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.h +1 -2
  48. data/ext/cached/ruby-1.9.1/internal/vm/iseq/iseq_load.inc +356 -0
  49. data/ext/cached/ruby-1.9.1/internal/yarv-headers/eval_intern.h +15 -9
  50. data/ext/cached/ruby-1.9.1/internal/yarv-headers/id.h +45 -66
  51. data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +12 -3
  52. data/ext/cached/ruby-1.9.1/internal/yarv-headers/node.h +2 -2
  53. data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +23 -138
  54. data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -1
  55. data/ext/cached/ruby-1.9.1/internal/yarv-headers/transcode_data.h +9 -2
  56. data/ext/cached/ruby-1.9.1/internal/yarv-headers/transdb.h +62 -0
  57. data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +17 -23
  58. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +20 -29
  59. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_exec.h +4 -7
  60. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +6 -5
  61. data/ext/internal/module/cfp.h +13 -0
  62. data/ext/internal/module/extconf.rb +2 -2
  63. data/ext/internal/module/module.c +3 -8
  64. data/ext/internal/node/nodes.rb +2 -1
  65. data/ext/internal/vm/iseq/iseq.c +2 -3
  66. data/ext/internal/vm/iseq/iseq_load.inc.rpp +61 -0
  67. data/ext/internal/yarv-headers/debug.h +36 -0
  68. data/ext/internal/yarv-headers/dln.h +41 -0
  69. data/ext/internal/yarv-headers/encdb.h +147 -0
  70. data/ext/internal/yarv-headers/eval_intern.h +215 -0
  71. data/ext/internal/yarv-headers/gc.h +75 -0
  72. data/ext/internal/yarv-headers/id.h +163 -0
  73. data/ext/internal/yarv-headers/iseq.h +103 -0
  74. data/ext/internal/yarv-headers/node.h +516 -0
  75. data/ext/internal/yarv-headers/parse.h +188 -0
  76. data/ext/internal/yarv-headers/regenc.h +207 -0
  77. data/ext/internal/yarv-headers/regint.h +842 -0
  78. data/ext/internal/yarv-headers/regparse.h +351 -0
  79. data/ext/internal/yarv-headers/revision.h +1 -0
  80. data/ext/internal/yarv-headers/thread_pthread.h +24 -0
  81. data/ext/internal/yarv-headers/thread_win32.h +33 -0
  82. data/ext/internal/yarv-headers/transcode_data.h +106 -0
  83. data/ext/internal/yarv-headers/transdb.h +147 -0
  84. data/ext/internal/yarv-headers/version.h +54 -0
  85. data/ext/internal/yarv-headers/vm_core.h +646 -0
  86. data/ext/internal/yarv-headers/vm_exec.h +184 -0
  87. data/ext/internal/yarv-headers/vm_insnhelper.h +195 -0
  88. data/ext/internal/yarv-headers/vm_opts.h +51 -0
  89. data/publish_rdoc.rb +4 -0
  90. metadata +52 -2
@@ -2894,88 +2894,86 @@ void define_node_subclass_methods()
2894
2894
  }
2895
2895
 
2896
2896
 
2897
- /* Document-class: Node::DASGN_CURR
2898
- * Represents dynamic local variable assignment in the current frame.
2899
- * See DASGN for a description of how dynamic assignment works.
2897
+ /* Document-class: Node::ALIAS
2898
+ * Represents an alias expression of the form:
2899
+ * alias 1st 2nd
2900
+ * where 2nd is the name of an existing method and 1st is the name of
2901
+ * its new alias.
2900
2902
  */
2901
2903
  {
2902
- VALUE rb_cDASGN_CURR = rb_define_class_under(rb_cNode, "DASGN_CURR", rb_cNode);
2904
+ VALUE rb_cALIAS = rb_define_class_under(rb_cNode, "ALIAS", rb_cNode);
2903
2905
  members = rb_ary_new();
2904
- rb_cNodeSubclass[NODE_DASGN_CURR] = rb_cDASGN_CURR;
2905
- rb_iv_set(rb_cDASGN_CURR, "__member__", members);
2906
- rb_iv_set(rb_cDASGN_CURR, "__type__", INT2NUM(NODE_DASGN_CURR));
2907
- rb_define_singleton_method(rb_cDASGN_CURR, "members", node_s_members, 0);
2908
-
2909
- /* Document-method: value
2910
- * the value to assign to the local variable
2911
- */
2912
- rb_define_method(rb_cDASGN_CURR, "value", node_value, 0);
2913
- rb_ary_push(members, rb_str_new2("value"));
2914
-
2915
- /* Document-method: vid
2916
- * the name of the local variable
2917
- */
2918
- rb_define_method(rb_cDASGN_CURR, "vid", node_vid, 0);
2919
- rb_ary_push(members, rb_str_new2("vid"));
2906
+ rb_cNodeSubclass[NODE_ALIAS] = rb_cALIAS;
2907
+ rb_iv_set(rb_cALIAS, "__member__", members);
2908
+ rb_iv_set(rb_cALIAS, "__type__", INT2NUM(NODE_ALIAS));
2909
+ rb_define_singleton_method(rb_cALIAS, "members", node_s_members, 0);
2910
+ rb_define_method(rb_cALIAS, "first", node_1st, 0);
2911
+ rb_ary_push(members, rb_str_new2("first"));
2912
+ rb_define_method(rb_cALIAS, "second", node_2nd, 0);
2913
+ rb_ary_push(members, rb_str_new2("second"));
2920
2914
  }
2921
2915
 
2922
- /* Document-class: Node::UNTIL
2923
- * Represents a loop constructed with the 'until' keyword, e.g.:
2924
- * until cond do
2925
- * body
2926
- * end
2916
+ /* Document-class: Node::ALLOCA
2917
+ * A node used for temporary allocation of memory on platforms that do
2918
+ * not support alloca.
2919
+ *
2920
+ * It should never be evaluated as an expression.
2927
2921
  */
2922
+ #ifdef HAVE_NODE_ALLOCA
2928
2923
  {
2929
- VALUE rb_cUNTIL = rb_define_class_under(rb_cNode, "UNTIL", rb_cNode);
2924
+ VALUE rb_cALLOCA = rb_define_class_under(rb_cNode, "ALLOCA", rb_cNode);
2930
2925
  members = rb_ary_new();
2931
- rb_cNodeSubclass[NODE_UNTIL] = rb_cUNTIL;
2932
- rb_iv_set(rb_cUNTIL, "__member__", members);
2933
- rb_iv_set(rb_cUNTIL, "__type__", INT2NUM(NODE_UNTIL));
2934
- rb_define_singleton_method(rb_cUNTIL, "members", node_s_members, 0);
2926
+ rb_cNodeSubclass[NODE_ALLOCA] = rb_cALLOCA;
2927
+ rb_iv_set(rb_cALLOCA, "__member__", members);
2928
+ rb_iv_set(rb_cALLOCA, "__type__", INT2NUM(NODE_ALLOCA));
2929
+ rb_define_singleton_method(rb_cALLOCA, "members", node_s_members, 0);
2935
2930
 
2936
- /* Document-method: body
2937
- * the body of the loop
2931
+ /* Document-method: cfnc
2932
+ * a pointer to the allocated memory
2938
2933
  */
2939
- rb_define_method(rb_cUNTIL, "body", node_body, 0);
2940
- rb_ary_push(members, rb_str_new2("body"));
2934
+ rb_define_method(rb_cALLOCA, "cfnc", node_cfnc, 0);
2935
+ rb_ary_push(members, rb_str_new2("cfnc"));
2941
2936
 
2942
- /* Document-method: cond
2943
- * a condition to terminate the loop when it becomes true
2937
+ /* Document-method: value
2938
+ * a pointer to the previously allocated temporary node
2944
2939
  */
2945
- rb_define_method(rb_cUNTIL, "cond", node_cond, 0);
2946
- rb_ary_push(members, rb_str_new2("cond"));
2947
- rb_define_method(rb_cUNTIL, "state", node_state, 0);
2948
- rb_ary_push(members, rb_str_new2("state"));
2940
+ rb_define_method(rb_cALLOCA, "value", node_value, 0);
2941
+ rb_ary_push(members, rb_str_new2("value"));
2942
+
2943
+ /* Document-method: cnt
2944
+ * the number of bytes allocated
2945
+ */
2946
+ rb_define_method(rb_cALLOCA, "cnt", node_cnt, 0);
2947
+ rb_ary_push(members, rb_str_new2("cnt"));
2949
2948
  }
2949
+ #endif
2950
2950
 
2951
- /* Document-class: Node::BACK_REF
2952
- * Represents one of the regex back reference variables:
2953
- * * $& - last match
2954
- * * $` - pre
2955
- * * $' - post
2956
- * * $+ - last
2951
+ /* Document-class: Node::AND
2952
+ * Represents a logical 'and' of the form:
2953
+ * first && second
2954
+ * The expression will short-circuit and yield the result of the left
2955
+ * hand side if it is false or nil, else it will evaluate the right
2956
+ * hand side and use it as the result of the expression.
2957
2957
  */
2958
2958
  {
2959
- VALUE rb_cBACK_REF = rb_define_class_under(rb_cNode, "BACK_REF", rb_cNode);
2959
+ VALUE rb_cAND = rb_define_class_under(rb_cNode, "AND", rb_cNode);
2960
2960
  members = rb_ary_new();
2961
- rb_cNodeSubclass[NODE_BACK_REF] = rb_cBACK_REF;
2962
- rb_iv_set(rb_cBACK_REF, "__member__", members);
2963
- rb_iv_set(rb_cBACK_REF, "__type__", INT2NUM(NODE_BACK_REF));
2964
- rb_define_singleton_method(rb_cBACK_REF, "members", node_s_members, 0);
2961
+ rb_cNodeSubclass[NODE_AND] = rb_cAND;
2962
+ rb_iv_set(rb_cAND, "__member__", members);
2963
+ rb_iv_set(rb_cAND, "__type__", INT2NUM(NODE_AND));
2964
+ rb_define_singleton_method(rb_cAND, "members", node_s_members, 0);
2965
2965
 
2966
- /* Document-method: nth
2967
- * the integer representation of the character of the variable to
2968
- * reference, one of '&', '`', '\'', or '+'
2966
+ /* Document-method: first
2967
+ * the expression on the left hand side
2969
2968
  */
2970
- rb_define_method(rb_cBACK_REF, "nth", node_nth, 0);
2971
- rb_ary_push(members, rb_str_new2("nth"));
2969
+ rb_define_method(rb_cAND, "first", node_1st, 0);
2970
+ rb_ary_push(members, rb_str_new2("first"));
2972
2971
 
2973
- /* Document-method: cnt
2974
- * the index into the local variable table where the match data is
2975
- * stored
2972
+ /* Document-method: second
2973
+ * the expression on the right hand side
2976
2974
  */
2977
- rb_define_method(rb_cBACK_REF, "cnt", node_cnt, 0);
2978
- rb_ary_push(members, rb_str_new2("cnt"));
2975
+ rb_define_method(rb_cAND, "second", node_2nd, 0);
2976
+ rb_ary_push(members, rb_str_new2("second"));
2979
2977
  }
2980
2978
 
2981
2979
  /* Document-class: Node::ARGS
@@ -3009,220 +3007,183 @@ void define_node_subclass_methods()
3009
3007
  rb_ary_push(members, rb_str_new2("cnt"));
3010
3008
  }
3011
3009
 
3012
- /* Document-class: Node::OP_ASGN_AND
3013
- * Represents an expression of the form:
3014
- * recv &&= value
3015
- * Ruby will evaluate the expression on the left hand side of the
3016
- * assignment; if it is true, then it will assign the result of the
3017
- * expression on the right hand side to the receiver on the left hand
3018
- * side.
3010
+ /* Document-class: Node::ARGSCAT
3011
+ * Represents the concatenation of a list of arguments and a splatted
3012
+ * value, e.g.:
3013
+ * a, b, *value
3014
+ * Evaluates head to create an array. Evaluates body and performs a
3015
+ * splat operation on the result to create another array (see SPLAT).
3016
+ * Concatenates the the second array onto the end of the first to
3017
+ * produce the result.
3019
3018
  */
3020
3019
  {
3021
- VALUE rb_cOP_ASGN_AND = rb_define_class_under(rb_cNode, "OP_ASGN_AND", rb_cNode);
3020
+ VALUE rb_cARGSCAT = rb_define_class_under(rb_cNode, "ARGSCAT", rb_cNode);
3022
3021
  members = rb_ary_new();
3023
- rb_cNodeSubclass[NODE_OP_ASGN_AND] = rb_cOP_ASGN_AND;
3024
- rb_iv_set(rb_cOP_ASGN_AND, "__member__", members);
3025
- rb_iv_set(rb_cOP_ASGN_AND, "__type__", INT2NUM(NODE_OP_ASGN_AND));
3026
- rb_define_singleton_method(rb_cOP_ASGN_AND, "members", node_s_members, 0);
3022
+ rb_cNodeSubclass[NODE_ARGSCAT] = rb_cARGSCAT;
3023
+ rb_iv_set(rb_cARGSCAT, "__member__", members);
3024
+ rb_iv_set(rb_cARGSCAT, "__type__", INT2NUM(NODE_ARGSCAT));
3025
+ rb_define_singleton_method(rb_cARGSCAT, "members", node_s_members, 0);
3027
3026
 
3028
- /* Document-method: value
3029
- * an expression representing the assignment that should be
3030
- * performed if the left hand side is true
3027
+ /* Document-method: head
3028
+ * a list of fixed arguments
3031
3029
  */
3032
- rb_define_method(rb_cOP_ASGN_AND, "value", node_value, 0);
3033
- rb_ary_push(members, rb_str_new2("value"));
3030
+ rb_define_method(rb_cARGSCAT, "head", node_head, 0);
3031
+ rb_ary_push(members, rb_str_new2("head"));
3034
3032
 
3035
- /* Document-method: recv
3036
- * an expression representing the left hand side of the assignment
3033
+ /* Document-method: body
3034
+ * the last argument, which will be splatted onto the end of the
3035
+ * fixed arguments
3037
3036
  */
3038
- rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0);
3039
- rb_ary_push(members, rb_str_new2("recv"));
3037
+ rb_define_method(rb_cARGSCAT, "body", node_body, 0);
3038
+ rb_ary_push(members, rb_str_new2("body"));
3040
3039
  }
3041
3040
 
3042
- /* Document-class: Node::RETURN
3043
- * Represents the 'return' keyword. Evaluation of this node results in
3044
- * a return from the current method. If no argument is supplied,
3045
- * returns nil, otherwise returns the result of the supplied
3046
- * expression.
3041
+ /* Document-class: Node::ARGSPUSH
3042
+ * Represents the splat portion of the index in an expression:
3043
+ * obj[arg, arg, *head] = body
3044
+ * Evaluates head to create an array. Evaluates body and pushes the
3045
+ * result onto the end of the array, which will then be used to form
3046
+ * the arguments of the method call.
3047
3047
  */
3048
3048
  {
3049
- VALUE rb_cRETURN = rb_define_class_under(rb_cNode, "RETURN", rb_cNode);
3049
+ VALUE rb_cARGSPUSH = rb_define_class_under(rb_cNode, "ARGSPUSH", rb_cNode);
3050
3050
  members = rb_ary_new();
3051
- rb_cNodeSubclass[NODE_RETURN] = rb_cRETURN;
3052
- rb_iv_set(rb_cRETURN, "__member__", members);
3053
- rb_iv_set(rb_cRETURN, "__type__", INT2NUM(NODE_RETURN));
3054
- rb_define_singleton_method(rb_cRETURN, "members", node_s_members, 0);
3055
-
3056
- /* Document-method: stts
3057
- * an expression representing the value to return
3058
- */
3059
- rb_define_method(rb_cRETURN, "stts", node_stts, 0);
3060
- rb_ary_push(members, rb_str_new2("stts"));
3051
+ rb_cNodeSubclass[NODE_ARGSPUSH] = rb_cARGSPUSH;
3052
+ rb_iv_set(rb_cARGSPUSH, "__member__", members);
3053
+ rb_iv_set(rb_cARGSPUSH, "__type__", INT2NUM(NODE_ARGSPUSH));
3054
+ rb_define_singleton_method(rb_cARGSPUSH, "members", node_s_members, 0);
3055
+ rb_define_method(rb_cARGSPUSH, "head", node_head, 0);
3056
+ rb_ary_push(members, rb_str_new2("head"));
3057
+ rb_define_method(rb_cARGSPUSH, "body", node_body, 0);
3058
+ rb_ary_push(members, rb_str_new2("body"));
3061
3059
  }
3062
3060
 
3063
- /* Document-class: Node::RESCUE
3064
- * Represents part of a rescue expression of the form:
3065
- * head rescue expr
3066
- *
3067
- * or the longer form:
3068
- * begin
3069
- * head
3070
- * rescue exception
3071
- * expr
3072
- * end
3073
- *
3074
- * or the form using the else keyword:
3075
- * begin
3076
- * head
3077
- * rescue exception
3078
- * expr
3079
- * else
3080
- * else_expr
3081
- * end
3082
- *
3083
- * The head expression is first evaluated, and if an exception is
3084
- * raised, evaluates the resq node. If no exception is raised, the
3085
- * else node is evaluated if it is not false (0).
3086
- *
3087
- * The resq node will be a RESBDOY node, which will test the exception
3088
- * to see if it matches one of the expected types. If it does it will
3089
- * handle the exception, otherwise it will allow the expression to pass
3090
- * to the outer scope.
3061
+ /* Document-class: Node::ARRAY
3062
+ * Represents an array of elements. Evaluation of this node creates a
3063
+ * new Array by evalating the given expressions and placing them into
3064
+ * the array.
3091
3065
  */
3092
3066
  {
3093
- VALUE rb_cRESCUE = rb_define_class_under(rb_cNode, "RESCUE", rb_cNode);
3067
+ VALUE rb_cARRAY = rb_define_class_under(rb_cNode, "ARRAY", rb_cNode);
3094
3068
  members = rb_ary_new();
3095
- rb_cNodeSubclass[NODE_RESCUE] = rb_cRESCUE;
3096
- rb_iv_set(rb_cRESCUE, "__member__", members);
3097
- rb_iv_set(rb_cRESCUE, "__type__", INT2NUM(NODE_RESCUE));
3098
- rb_define_singleton_method(rb_cRESCUE, "members", node_s_members, 0);
3069
+ rb_cNodeSubclass[NODE_ARRAY] = rb_cARRAY;
3070
+ rb_iv_set(rb_cARRAY, "__member__", members);
3071
+ rb_iv_set(rb_cARRAY, "__type__", INT2NUM(NODE_ARRAY));
3072
+ rb_define_singleton_method(rb_cARRAY, "members", node_s_members, 0);
3099
3073
 
3100
3074
  /* Document-method: head
3101
- * the body of the block to evaluate
3075
+ * the first element of the array
3102
3076
  */
3103
- rb_define_method(rb_cRESCUE, "head", node_head, 0);
3077
+ rb_define_method(rb_cARRAY, "head", node_head, 0);
3104
3078
  rb_ary_push(members, rb_str_new2("head"));
3079
+ rb_define_method(rb_cARRAY, "alen", node_alen, 0);
3080
+ rb_ary_push(members, rb_str_new2("alen"));
3105
3081
 
3106
- /* Document-method: else
3107
- * the expression to be evaluated if no exception is raised
3108
- */
3109
- rb_define_method(rb_cRESCUE, "else", node_else, 0);
3110
- rb_ary_push(members, rb_str_new2("else"));
3111
-
3112
- /* Document-method: resq
3113
- * the expression to be evaluated if an exception is raised
3082
+ /* Document-method: next
3083
+ * the tail of the array
3114
3084
  */
3115
- rb_define_method(rb_cRESCUE, "resq", node_resq, 0);
3116
- rb_ary_push(members, rb_str_new2("resq"));
3085
+ rb_define_method(rb_cARRAY, "next", node_next, 0);
3086
+ rb_ary_push(members, rb_str_new2("next"));
3117
3087
  }
3118
3088
 
3119
- /* Document-class: Node::LIT
3120
- * Represents a literal object. The result of the expression is the
3121
- * object contained in this node.
3089
+ /* Document-class: Node::ATTRASGN
3090
+ * Represents attribute assignment in the form:
3091
+ * recv.mid = args
3092
+ * or:
3093
+ * recv.mid=(args).
3122
3094
  */
3123
3095
  {
3124
- VALUE rb_cLIT = rb_define_class_under(rb_cNode, "LIT", rb_cNode);
3096
+ VALUE rb_cATTRASGN = rb_define_class_under(rb_cNode, "ATTRASGN", rb_cNode);
3125
3097
  members = rb_ary_new();
3126
- rb_cNodeSubclass[NODE_LIT] = rb_cLIT;
3127
- rb_iv_set(rb_cLIT, "__member__", members);
3128
- rb_iv_set(rb_cLIT, "__type__", INT2NUM(NODE_LIT));
3129
- rb_define_singleton_method(rb_cLIT, "members", node_s_members, 0);
3098
+ rb_cNodeSubclass[NODE_ATTRASGN] = rb_cATTRASGN;
3099
+ rb_iv_set(rb_cATTRASGN, "__member__", members);
3100
+ rb_iv_set(rb_cATTRASGN, "__type__", INT2NUM(NODE_ATTRASGN));
3101
+ rb_define_singleton_method(rb_cATTRASGN, "members", node_s_members, 0);
3130
3102
 
3131
- /* Document-method: lit
3132
- * the object
3103
+ /* Document-method: args
3104
+ * the arguments to the method
3133
3105
  */
3134
- rb_define_method(rb_cLIT, "lit", node_lit, 0);
3135
- rb_ary_push(members, rb_str_new2("lit"));
3106
+ rb_define_method(rb_cATTRASGN, "args", node_args, 0);
3107
+ rb_ary_push(members, rb_str_new2("args"));
3108
+
3109
+ /* Document-method: mid
3110
+ * the id of the attribute, with a trailing '=' sign
3111
+ */
3112
+ rb_define_method(rb_cATTRASGN, "mid", node_mid, 0);
3113
+ rb_ary_push(members, rb_str_new2("mid"));
3114
+
3115
+ /* Document-method: recv
3116
+ * the receiver of the method
3117
+ */
3118
+ rb_define_method(rb_cATTRASGN, "recv", node_recv, 0);
3119
+ rb_ary_push(members, rb_str_new2("recv"));
3136
3120
  }
3137
3121
 
3138
- /* Document-class: Node::SELF
3139
- * Represents the keyword 'self'.
3122
+ /* Document-class: Node::ATTRSET
3123
+ * A placeholder for an attribute writer method, which can added to a
3124
+ * class by using attr_writer:
3125
+ * attr_writer :attribute
3126
+ * Its reader counterpart is IVAR.
3140
3127
  */
3141
3128
  {
3142
- VALUE rb_cSELF = rb_define_class_under(rb_cNode, "SELF", rb_cNode);
3129
+ VALUE rb_cATTRSET = rb_define_class_under(rb_cNode, "ATTRSET", rb_cNode);
3143
3130
  members = rb_ary_new();
3144
- rb_cNodeSubclass[NODE_SELF] = rb_cSELF;
3145
- rb_iv_set(rb_cSELF, "__member__", members);
3146
- rb_iv_set(rb_cSELF, "__type__", INT2NUM(NODE_SELF));
3147
- rb_define_singleton_method(rb_cSELF, "members", node_s_members, 0);
3131
+ rb_cNodeSubclass[NODE_ATTRSET] = rb_cATTRSET;
3132
+ rb_iv_set(rb_cATTRSET, "__member__", members);
3133
+ rb_iv_set(rb_cATTRSET, "__type__", INT2NUM(NODE_ATTRSET));
3134
+ rb_define_singleton_method(rb_cATTRSET, "members", node_s_members, 0);
3135
+
3136
+ /* Document-method: vid
3137
+ * the name of the attribute, with a leading '@' sign
3138
+ */
3139
+ rb_define_method(rb_cATTRSET, "vid", node_vid, 0);
3140
+ rb_ary_push(members, rb_str_new2("vid"));
3148
3141
  }
3149
3142
 
3150
- /* Document-class: Node::IFUNC
3151
- * A temporary node used in iteration.
3143
+ /* Document-class: Node::BACK_REF
3144
+ * Represents one of the regex back reference variables:
3145
+ * * $& - last match
3146
+ * * $` - pre
3147
+ * * $' - post
3148
+ * * $+ - last
3152
3149
  */
3153
3150
  {
3154
- VALUE rb_cIFUNC = rb_define_class_under(rb_cNode, "IFUNC", rb_cNode);
3151
+ VALUE rb_cBACK_REF = rb_define_class_under(rb_cNode, "BACK_REF", rb_cNode);
3155
3152
  members = rb_ary_new();
3156
- rb_cNodeSubclass[NODE_IFUNC] = rb_cIFUNC;
3157
- rb_iv_set(rb_cIFUNC, "__member__", members);
3158
- rb_iv_set(rb_cIFUNC, "__type__", INT2NUM(NODE_IFUNC));
3159
- rb_define_singleton_method(rb_cIFUNC, "members", node_s_members, 0);
3160
-
3161
- /* Document-method: cfnc
3162
- * a pointer to the C function to which to yield
3163
- */
3164
- rb_define_method(rb_cIFUNC, "cfnc", node_cfnc, 0);
3165
- rb_ary_push(members, rb_str_new2("cfnc"));
3153
+ rb_cNodeSubclass[NODE_BACK_REF] = rb_cBACK_REF;
3154
+ rb_iv_set(rb_cBACK_REF, "__member__", members);
3155
+ rb_iv_set(rb_cBACK_REF, "__type__", INT2NUM(NODE_BACK_REF));
3156
+ rb_define_singleton_method(rb_cBACK_REF, "members", node_s_members, 0);
3166
3157
 
3167
- /* Document-method: tval
3168
- * the user-specified data to be passed as the second argument to
3169
- * cfnc
3158
+ /* Document-method: nth
3159
+ * the integer representation of the character of the variable to
3160
+ * reference, one of '&', '`', '\'', or '+'
3170
3161
  */
3171
- rb_define_method(rb_cIFUNC, "tval", node_tval, 0);
3172
- rb_ary_push(members, rb_str_new2("tval"));
3162
+ rb_define_method(rb_cBACK_REF, "nth", node_nth, 0);
3163
+ rb_ary_push(members, rb_str_new2("nth"));
3173
3164
 
3174
- /* Document-method: state
3175
- * always 0
3165
+ /* Document-method: cnt
3166
+ * the index into the local variable table where the match data is
3167
+ * stored
3176
3168
  */
3177
- rb_define_method(rb_cIFUNC, "state", node_state, 0);
3178
- rb_ary_push(members, rb_str_new2("state"));
3169
+ rb_define_method(rb_cBACK_REF, "cnt", node_cnt, 0);
3170
+ rb_ary_push(members, rb_str_new2("cnt"));
3179
3171
  }
3180
3172
 
3181
- /* Document-class: Node::ZSUPER
3182
- * Represents the keyword 'super' when used without parens nor
3183
- * arguments. The arguments to the base class method are obtained from
3184
- * the arguments passed to the current method, which are store in the
3185
- * current frame.
3173
+ /* Document-class: Node::BEGIN
3174
+ * Represents a begin/end block.
3186
3175
  *
3187
- * Can also be a placeholder for a method when its implementation is
3188
- * deferred to the base class.
3189
- */
3190
- {
3191
- VALUE rb_cZSUPER = rb_define_class_under(rb_cNode, "ZSUPER", rb_cNode);
3192
- members = rb_ary_new();
3193
- rb_cNodeSubclass[NODE_ZSUPER] = rb_cZSUPER;
3194
- rb_iv_set(rb_cZSUPER, "__member__", members);
3195
- rb_iv_set(rb_cZSUPER, "__type__", INT2NUM(NODE_ZSUPER));
3196
- rb_define_singleton_method(rb_cZSUPER, "members", node_s_members, 0);
3197
- }
3198
-
3199
- /* Document-class: Node::WHILE
3200
- * Represents a loop constructed with the 'while' keyword, e.g.:
3201
- * while cond do
3202
- * body
3203
- * end
3176
+ * TODO: Need an example
3204
3177
  */
3205
3178
  {
3206
- VALUE rb_cWHILE = rb_define_class_under(rb_cNode, "WHILE", rb_cNode);
3179
+ VALUE rb_cBEGIN = rb_define_class_under(rb_cNode, "BEGIN", rb_cNode);
3207
3180
  members = rb_ary_new();
3208
- rb_cNodeSubclass[NODE_WHILE] = rb_cWHILE;
3209
- rb_iv_set(rb_cWHILE, "__member__", members);
3210
- rb_iv_set(rb_cWHILE, "__type__", INT2NUM(NODE_WHILE));
3211
- rb_define_singleton_method(rb_cWHILE, "members", node_s_members, 0);
3212
-
3213
- /* Document-method: body
3214
- * the body of the loop
3215
- */
3216
- rb_define_method(rb_cWHILE, "body", node_body, 0);
3181
+ rb_cNodeSubclass[NODE_BEGIN] = rb_cBEGIN;
3182
+ rb_iv_set(rb_cBEGIN, "__member__", members);
3183
+ rb_iv_set(rb_cBEGIN, "__type__", INT2NUM(NODE_BEGIN));
3184
+ rb_define_singleton_method(rb_cBEGIN, "members", node_s_members, 0);
3185
+ rb_define_method(rb_cBEGIN, "body", node_body, 0);
3217
3186
  rb_ary_push(members, rb_str_new2("body"));
3218
-
3219
- /* Document-method: cond
3220
- * a condition to terminate the loop when it becomes false
3221
- */
3222
- rb_define_method(rb_cWHILE, "cond", node_cond, 0);
3223
- rb_ary_push(members, rb_str_new2("cond"));
3224
- rb_define_method(rb_cWHILE, "state", node_state, 0);
3225
- rb_ary_push(members, rb_str_new2("state"));
3226
3187
  }
3227
3188
 
3228
3189
  /* Document-class: Node::BLOCK
@@ -3256,138 +3217,244 @@ void define_node_subclass_methods()
3256
3217
  rb_ary_push(members, rb_str_new2("next"));
3257
3218
  }
3258
3219
 
3259
- /* Document-class: Node::FCALL
3260
- * Represents a method call in the form:
3261
- * mid(args).
3262
- *
3263
- * This makes a method call on an object using self as the implicit
3264
- * receiver.
3220
+ /* Document-class: Node::BLOCK_ARG
3221
+ * Represents a block argument in a method definition, e.g.:
3222
+ * def foo(&arg)
3223
+ * end
3265
3224
  */
3266
3225
  {
3267
- VALUE rb_cFCALL = rb_define_class_under(rb_cNode, "FCALL", rb_cNode);
3226
+ VALUE rb_cBLOCK_ARG = rb_define_class_under(rb_cNode, "BLOCK_ARG", rb_cNode);
3268
3227
  members = rb_ary_new();
3269
- rb_cNodeSubclass[NODE_FCALL] = rb_cFCALL;
3270
- rb_iv_set(rb_cFCALL, "__member__", members);
3271
- rb_iv_set(rb_cFCALL, "__type__", INT2NUM(NODE_FCALL));
3272
- rb_define_singleton_method(rb_cFCALL, "members", node_s_members, 0);
3273
-
3274
- /* Document-method: args
3275
- * the arguments to the method
3276
- */
3277
- rb_define_method(rb_cFCALL, "args", node_args, 0);
3278
- rb_ary_push(members, rb_str_new2("args"));
3228
+ rb_cNodeSubclass[NODE_BLOCK_ARG] = rb_cBLOCK_ARG;
3229
+ rb_iv_set(rb_cBLOCK_ARG, "__member__", members);
3230
+ rb_iv_set(rb_cBLOCK_ARG, "__type__", INT2NUM(NODE_BLOCK_ARG));
3231
+ rb_define_singleton_method(rb_cBLOCK_ARG, "members", node_s_members, 0);
3279
3232
 
3280
- /* Document-method: mid
3281
- * the method id
3233
+ /* Document-method: cnt
3234
+ * the index into the local variable table of the name of the block
3235
+ * argument, not including the implicit variables.
3282
3236
  */
3283
- rb_define_method(rb_cFCALL, "mid", node_mid, 0);
3284
- rb_ary_push(members, rb_str_new2("mid"));
3237
+ rb_define_method(rb_cBLOCK_ARG, "cnt", node_cnt, 0);
3238
+ rb_ary_push(members, rb_str_new2("cnt"));
3285
3239
  }
3286
3240
 
3287
- /* Document-class: Node::DREGX_ONCE
3288
- * Represents a regular expression with interpolation with the 'once'
3289
- * flag set. The regular expression is only interpolated the first
3290
- * time it is encountered.
3241
+ /* Document-class: Node::BLOCK_PASS
3242
+ * Represents an object being passed to a method as a block, e.g.:
3243
+ * foo(&bar)
3244
+ *
3245
+ * The body node is first evaluates to get an object, then #to_proc to
3246
+ * convert it into a proc if necessary. The iter node is then
3247
+ * evaluated to call a method, passing the proc as a block parameter to
3248
+ * the method.
3291
3249
  */
3292
3250
  {
3293
- VALUE rb_cDREGX_ONCE = rb_define_class_under(rb_cNode, "DREGX_ONCE", rb_cNode);
3251
+ VALUE rb_cBLOCK_PASS = rb_define_class_under(rb_cNode, "BLOCK_PASS", rb_cNode);
3294
3252
  members = rb_ary_new();
3295
- rb_cNodeSubclass[NODE_DREGX_ONCE] = rb_cDREGX_ONCE;
3296
- rb_iv_set(rb_cDREGX_ONCE, "__member__", members);
3297
- rb_iv_set(rb_cDREGX_ONCE, "__type__", INT2NUM(NODE_DREGX_ONCE));
3298
- rb_define_singleton_method(rb_cDREGX_ONCE, "members", node_s_members, 0);
3299
-
3300
- /* Document-method: lit
3301
- * a string
3302
- */
3303
- rb_define_method(rb_cDREGX_ONCE, "lit", node_lit, 0);
3304
- rb_ary_push(members, rb_str_new2("lit"));
3253
+ rb_cNodeSubclass[NODE_BLOCK_PASS] = rb_cBLOCK_PASS;
3254
+ rb_iv_set(rb_cBLOCK_PASS, "__member__", members);
3255
+ rb_iv_set(rb_cBLOCK_PASS, "__type__", INT2NUM(NODE_BLOCK_PASS));
3256
+ rb_define_singleton_method(rb_cBLOCK_PASS, "members", node_s_members, 0);
3305
3257
 
3306
- /* Document-method: cflag
3307
- * a bitfield containing the options used in the regular
3308
- * expression. See DREGX for a list of valid values.
3258
+ /* Document-method: body
3259
+ * the object to pass as a block
3309
3260
  */
3310
- rb_define_method(rb_cDREGX_ONCE, "cflag", node_cflag, 0);
3311
- rb_ary_push(members, rb_str_new2("cflag"));
3261
+ rb_define_method(rb_cBLOCK_PASS, "body", node_body, 0);
3262
+ rb_ary_push(members, rb_str_new2("body"));
3312
3263
 
3313
- /* Document-method: next
3314
- * a list of expressions to be appended onto the string
3264
+ /* Document-method: iter
3265
+ * an expression which calls a method
3315
3266
  */
3316
- rb_define_method(rb_cDREGX_ONCE, "next", node_next, 0);
3317
- rb_ary_push(members, rb_str_new2("next"));
3267
+ rb_define_method(rb_cBLOCK_PASS, "iter", node_iter, 0);
3268
+ rb_ary_push(members, rb_str_new2("iter"));
3318
3269
  }
3319
3270
 
3320
- /* Document-class: Node::ARGSPUSH
3321
- * Represents the splat portion of the index in an expression:
3322
- * obj[arg, arg, *head] = body
3323
- * Evaluates head to create an array. Evaluates body and pushes the
3324
- * result onto the end of the array, which will then be used to form
3325
- * the arguments of the method call.
3271
+ /* Document-class: Node::BMETHOD
3272
+ * A placeholder for a method defined using define_method, e.g.:
3273
+ * define_method(:foo) {
3274
+ * ...
3275
+ * }
3276
+ *
3277
+ * See also DMETHOD.
3326
3278
  */
3327
3279
  {
3328
- VALUE rb_cARGSPUSH = rb_define_class_under(rb_cNode, "ARGSPUSH", rb_cNode);
3280
+ VALUE rb_cBMETHOD = rb_define_class_under(rb_cNode, "BMETHOD", rb_cNode);
3329
3281
  members = rb_ary_new();
3330
- rb_cNodeSubclass[NODE_ARGSPUSH] = rb_cARGSPUSH;
3331
- rb_iv_set(rb_cARGSPUSH, "__member__", members);
3332
- rb_iv_set(rb_cARGSPUSH, "__type__", INT2NUM(NODE_ARGSPUSH));
3333
- rb_define_singleton_method(rb_cARGSPUSH, "members", node_s_members, 0);
3334
- rb_define_method(rb_cARGSPUSH, "head", node_head, 0);
3335
- rb_ary_push(members, rb_str_new2("head"));
3336
- rb_define_method(rb_cARGSPUSH, "body", node_body, 0);
3337
- rb_ary_push(members, rb_str_new2("body"));
3282
+ rb_cNodeSubclass[NODE_BMETHOD] = rb_cBMETHOD;
3283
+ rb_iv_set(rb_cBMETHOD, "__member__", members);
3284
+ rb_iv_set(rb_cBMETHOD, "__type__", INT2NUM(NODE_BMETHOD));
3285
+ rb_define_singleton_method(rb_cBMETHOD, "members", node_s_members, 0);
3286
+
3287
+ /* Document-method: cval
3288
+ * the Proc object passed to define_method, which contains the body
3289
+ * of the method
3290
+ */
3291
+ rb_define_method(rb_cBMETHOD, "cval", node_cval, 0);
3292
+ rb_ary_push(members, rb_str_new2("cval"));
3338
3293
  }
3339
3294
 
3340
- /* Document-class: Node::OPT_N
3341
- * Represents the top-level loop when the -n or -p options are used
3342
- * with the interpreter.
3295
+ /* Document-class: Node::BREAK
3296
+ * Represents the 'break' keyword. Causes control to be transferred
3297
+ * out of the current loop.
3343
3298
  */
3344
3299
  {
3345
- VALUE rb_cOPT_N = rb_define_class_under(rb_cNode, "OPT_N", rb_cNode);
3300
+ VALUE rb_cBREAK = rb_define_class_under(rb_cNode, "BREAK", rb_cNode);
3346
3301
  members = rb_ary_new();
3347
- rb_cNodeSubclass[NODE_OPT_N] = rb_cOPT_N;
3348
- rb_iv_set(rb_cOPT_N, "__member__", members);
3349
- rb_iv_set(rb_cOPT_N, "__type__", INT2NUM(NODE_OPT_N));
3350
- rb_define_singleton_method(rb_cOPT_N, "members", node_s_members, 0);
3302
+ rb_cNodeSubclass[NODE_BREAK] = rb_cBREAK;
3303
+ rb_iv_set(rb_cBREAK, "__member__", members);
3304
+ rb_iv_set(rb_cBREAK, "__type__", INT2NUM(NODE_BREAK));
3305
+ rb_define_singleton_method(rb_cBREAK, "members", node_s_members, 0);
3306
+
3307
+ /* Document-method: stts
3308
+ * the value to be used as the "return" value of the loop, 0 if nil is to be used.
3309
+ */
3310
+ rb_define_method(rb_cBREAK, "stts", node_stts, 0);
3311
+ rb_ary_push(members, rb_str_new2("stts"));
3312
+ }
3313
+
3314
+ /* Document-class: Node::CALL
3315
+ * Represents a method call in the form recv.mid(args).
3316
+ */
3317
+ {
3318
+ VALUE rb_cCALL = rb_define_class_under(rb_cNode, "CALL", rb_cNode);
3319
+ members = rb_ary_new();
3320
+ rb_cNodeSubclass[NODE_CALL] = rb_cCALL;
3321
+ rb_iv_set(rb_cCALL, "__member__", members);
3322
+ rb_iv_set(rb_cCALL, "__type__", INT2NUM(NODE_CALL));
3323
+ rb_define_singleton_method(rb_cCALL, "members", node_s_members, 0);
3324
+
3325
+ /* Document-method: args
3326
+ * the arguments to the method
3327
+ */
3328
+ rb_define_method(rb_cCALL, "args", node_args, 0);
3329
+ rb_ary_push(members, rb_str_new2("args"));
3330
+
3331
+ /* Document-method: mid
3332
+ * the method id
3333
+ */
3334
+ rb_define_method(rb_cCALL, "mid", node_mid, 0);
3335
+ rb_ary_push(members, rb_str_new2("mid"));
3336
+
3337
+ /* Document-method: recv
3338
+ * the receiver of the method
3339
+ */
3340
+ rb_define_method(rb_cCALL, "recv", node_recv, 0);
3341
+ rb_ary_push(members, rb_str_new2("recv"));
3342
+ }
3343
+
3344
+ /* Document-class: Node::CASE
3345
+ * Represents the value portion of a case/end block, e.g.:
3346
+ * case head
3347
+ * body
3348
+ * end
3349
+ * next
3350
+ */
3351
+ {
3352
+ VALUE rb_cCASE = rb_define_class_under(rb_cNode, "CASE", rb_cNode);
3353
+ members = rb_ary_new();
3354
+ rb_cNodeSubclass[NODE_CASE] = rb_cCASE;
3355
+ rb_iv_set(rb_cCASE, "__member__", members);
3356
+ rb_iv_set(rb_cCASE, "__type__", INT2NUM(NODE_CASE));
3357
+ rb_define_singleton_method(rb_cCASE, "members", node_s_members, 0);
3358
+
3359
+ /* Document-method: head
3360
+ * the value to select on
3361
+ */
3362
+ rb_define_method(rb_cCASE, "head", node_head, 0);
3363
+ rb_ary_push(members, rb_str_new2("head"));
3351
3364
 
3352
3365
  /* Document-method: body
3353
- * the body of the loop
3366
+ * a linked list of nodes, each node representing a when
3367
+ * conditional
3354
3368
  */
3355
- rb_define_method(rb_cOPT_N, "body", node_body, 0);
3369
+ rb_define_method(rb_cCASE, "body", node_body, 0);
3356
3370
  rb_ary_push(members, rb_str_new2("body"));
3371
+ rb_define_method(rb_cCASE, "next", node_next, 0);
3372
+ rb_ary_push(members, rb_str_new2("next"));
3357
3373
  }
3358
3374
 
3359
- /* Document-class: Node::OP_ASGN2_ARG
3360
- * Actually a node of type OP_ASGN2, this is a placeholder for
3361
- * additional information about the assignment than can fit in a single
3362
- * OP_ASGN2 node.
3375
+ /* Document-class: Node::CDECL
3376
+ * Represents constant assignment of the form:
3377
+ * vid = value
3363
3378
  */
3364
3379
  {
3365
- VALUE rb_cOP_ASGN2_ARG = rb_define_class_under(rb_cNode, "OP_ASGN2_ARG", rb_cNode);
3380
+ VALUE rb_cCDECL = rb_define_class_under(rb_cNode, "CDECL", rb_cNode);
3366
3381
  members = rb_ary_new();
3367
- rb_cNodeSubclass[NODE_OP_ASGN2_ARG] = rb_cOP_ASGN2_ARG;
3368
- rb_iv_set(rb_cOP_ASGN2_ARG, "__member__", members);
3369
- rb_iv_set(rb_cOP_ASGN2_ARG, "__type__", INT2NUM(NODE_OP_ASGN2_ARG));
3370
- rb_define_singleton_method(rb_cOP_ASGN2_ARG, "members", node_s_members, 0);
3382
+ rb_cNodeSubclass[NODE_CDECL] = rb_cCDECL;
3383
+ rb_iv_set(rb_cCDECL, "__member__", members);
3384
+ rb_iv_set(rb_cCDECL, "__type__", INT2NUM(NODE_CDECL));
3385
+ rb_define_singleton_method(rb_cCDECL, "members", node_s_members, 0);
3386
+
3387
+ /* Document-method: value
3388
+ * the value to be assigned to the constant
3389
+ */
3390
+ rb_define_method(rb_cCDECL, "value", node_value, 0);
3391
+ rb_ary_push(members, rb_str_new2("value"));
3371
3392
 
3372
3393
  /* Document-method: vid
3373
- * The method to call on the receiver to retrieve the attribute
3394
+ * the name of the constant to be assigned, all uppercase
3374
3395
  */
3375
- rb_define_method(rb_cOP_ASGN2_ARG, "vid", node_vid, 0);
3396
+ rb_define_method(rb_cCDECL, "vid", node_vid, 0);
3376
3397
  rb_ary_push(members, rb_str_new2("vid"));
3398
+ }
3377
3399
 
3378
- /* Document-method: aid
3379
- * The method to call on the receiver to set the attribute
3400
+ /* Document-class: Node::CFUNC
3401
+ * A placeholder for a function implemented in C.
3402
+ */
3403
+ {
3404
+ VALUE rb_cCFUNC = rb_define_class_under(rb_cNode, "CFUNC", rb_cNode);
3405
+ members = rb_ary_new();
3406
+ rb_cNodeSubclass[NODE_CFUNC] = rb_cCFUNC;
3407
+ rb_iv_set(rb_cCFUNC, "__member__", members);
3408
+ rb_iv_set(rb_cCFUNC, "__type__", INT2NUM(NODE_CFUNC));
3409
+ rb_define_singleton_method(rb_cCFUNC, "members", node_s_members, 0);
3410
+ rb_define_method(rb_cCFUNC, "cfnc", node_cfnc, 0);
3411
+ rb_ary_push(members, rb_str_new2("cfnc"));
3412
+ rb_define_method(rb_cCFUNC, "argc", node_argc, 0);
3413
+ rb_ary_push(members, rb_str_new2("argc"));
3414
+ }
3415
+
3416
+ /* Document-class: Node::CLASS
3417
+ * Represents a class definition, e.g.:
3418
+ * class cpath
3419
+ * body
3420
+ * end
3421
+ *
3422
+ * or:
3423
+ * class cpath < super
3424
+ * body
3425
+ * end
3426
+ *
3427
+ * The class definition is evaluated in a new lexical scope.
3428
+ *
3429
+ * The result of the expression is the last expression evaluated in the
3430
+ * body.
3431
+ */
3432
+ {
3433
+ VALUE rb_cCLASS = rb_define_class_under(rb_cNode, "CLASS", rb_cNode);
3434
+ members = rb_ary_new();
3435
+ rb_cNodeSubclass[NODE_CLASS] = rb_cCLASS;
3436
+ rb_iv_set(rb_cCLASS, "__member__", members);
3437
+ rb_iv_set(rb_cCLASS, "__type__", INT2NUM(NODE_CLASS));
3438
+ rb_define_singleton_method(rb_cCLASS, "members", node_s_members, 0);
3439
+
3440
+ /* Document-method: cpath
3441
+ * the name of the class to define
3380
3442
  */
3381
- rb_define_method(rb_cOP_ASGN2_ARG, "aid", node_aid, 0);
3382
- rb_ary_push(members, rb_str_new2("aid"));
3443
+ rb_define_method(rb_cCLASS, "cpath", node_cpath, 0);
3444
+ rb_ary_push(members, rb_str_new2("cpath"));
3383
3445
 
3384
- /* Document-method: mid
3385
- * The operation to apply to the attribute before setting it. May
3386
- * be 0 (false) to indicate "logical or" or 1 (nil) to indicate
3387
- * "logical and".
3446
+ /* Document-method: body
3447
+ * the body of the class definition
3388
3448
  */
3389
- rb_define_method(rb_cOP_ASGN2_ARG, "mid", node_mid, 0);
3390
- rb_ary_push(members, rb_str_new2("mid"));
3449
+ rb_define_method(rb_cCLASS, "body", node_body, 0);
3450
+ rb_ary_push(members, rb_str_new2("body"));
3451
+
3452
+ /* Document-method: super
3453
+ * an expression returning the base class, or false if there is no
3454
+ * base class specified
3455
+ */
3456
+ rb_define_method(rb_cCLASS, "super", node_super, 0);
3457
+ rb_ary_push(members, rb_str_new2("super"));
3391
3458
  }
3392
3459
 
3393
3460
  /* Document-class: Node::COLON2
@@ -3419,38 +3486,6 @@ void define_node_subclass_methods()
3419
3486
  rb_ary_push(members, rb_str_new2("mid"));
3420
3487
  }
3421
3488
 
3422
- /* Document-class: Node::FBODY
3423
- * A placeholder for a method alias, which can be added to a class by
3424
- * using alias or alias_method:
3425
- * alias old new
3426
- */
3427
- {
3428
- VALUE rb_cFBODY = rb_define_class_under(rb_cNode, "FBODY", rb_cNode);
3429
- members = rb_ary_new();
3430
- rb_cNodeSubclass[NODE_FBODY] = rb_cFBODY;
3431
- rb_iv_set(rb_cFBODY, "__member__", members);
3432
- rb_iv_set(rb_cFBODY, "__type__", INT2NUM(NODE_FBODY));
3433
- rb_define_singleton_method(rb_cFBODY, "members", node_s_members, 0);
3434
-
3435
- /* Document-method: head
3436
- * the method body
3437
- */
3438
- rb_define_method(rb_cFBODY, "head", node_head, 0);
3439
- rb_ary_push(members, rb_str_new2("head"));
3440
-
3441
- /* Document-method: orig
3442
- * the origin class
3443
- */
3444
- rb_define_method(rb_cFBODY, "orig", node_orig, 0);
3445
- rb_ary_push(members, rb_str_new2("orig"));
3446
-
3447
- /* Document-method: mid
3448
- * the name of the method
3449
- */
3450
- rb_define_method(rb_cFBODY, "mid", node_mid, 0);
3451
- rb_ary_push(members, rb_str_new2("mid"));
3452
- }
3453
-
3454
3489
  /* Document-class: Node::COLON3
3455
3490
  * Represents a constant lookup or method call in class Object. This
3456
3491
  * expression has the form:
@@ -3471,670 +3506,455 @@ void define_node_subclass_methods()
3471
3506
  rb_ary_push(members, rb_str_new2("mid"));
3472
3507
  }
3473
3508
 
3474
- /* Document-class: Node::ITER
3475
- * Represents an iteration loop, e.g.:
3476
- * iter do |*args|
3477
- * assign args to var
3478
- * body
3479
- * end
3480
- *
3481
- * A new block is created so that dynamic variables created inside the
3482
- * loop do not persist once the loop has terminated.
3483
- *
3484
- * If the iter node is a POSTEXE node, indicates that the expression
3485
- * should be evaluated when the program terminates.
3509
+ /* Document-class: Node::CONST
3510
+ * Represents a constant lookup in the current class. The current
3511
+ * class is the class in which the containing scope was defined. The
3512
+ * result of the expression is the value of the constant.
3486
3513
  */
3487
3514
  {
3488
- VALUE rb_cITER = rb_define_class_under(rb_cNode, "ITER", rb_cNode);
3515
+ VALUE rb_cCONST = rb_define_class_under(rb_cNode, "CONST", rb_cNode);
3489
3516
  members = rb_ary_new();
3490
- rb_cNodeSubclass[NODE_ITER] = rb_cITER;
3491
- rb_iv_set(rb_cITER, "__member__", members);
3492
- rb_iv_set(rb_cITER, "__type__", INT2NUM(NODE_ITER));
3493
- rb_define_singleton_method(rb_cITER, "members", node_s_members, 0);
3517
+ rb_cNodeSubclass[NODE_CONST] = rb_cCONST;
3518
+ rb_iv_set(rb_cCONST, "__member__", members);
3519
+ rb_iv_set(rb_cCONST, "__type__", INT2NUM(NODE_CONST));
3520
+ rb_define_singleton_method(rb_cCONST, "members", node_s_members, 0);
3494
3521
 
3495
- /* Document-method: body
3496
- * the body of the loop
3522
+ /* Document-method: vid
3523
+ * the name of the constant to look up
3497
3524
  */
3498
- rb_define_method(rb_cITER, "body", node_body, 0);
3499
- rb_ary_push(members, rb_str_new2("body"));
3525
+ rb_define_method(rb_cCONST, "vid", node_vid, 0);
3526
+ rb_ary_push(members, rb_str_new2("vid"));
3527
+ }
3500
3528
 
3501
- /* Document-method: iter
3502
- * an expression which calls the desired iteration method, usually
3503
- * recv.each
3504
- */
3505
- rb_define_method(rb_cITER, "iter", node_iter, 0);
3506
- rb_ary_push(members, rb_str_new2("iter"));
3507
-
3508
- /* Document-method: var
3509
- * an assignment node which assigns the next value in the sequence
3510
- * to a variable, which may or may not be local. May also be a
3511
- * multiple assignment.
3512
- */
3513
- rb_define_method(rb_cITER, "var", node_var, 0);
3514
- rb_ary_push(members, rb_str_new2("var"));
3515
- }
3516
-
3517
- /* Document-class: Node::NOT
3518
- * Represents a logical negation.
3529
+ /* Document-class: Node::CREF
3530
+ * A temporary node used to store the value of ruby_cref or
3531
+ * ruby_top_cref and later restore it. The cref holds a reference to
3532
+ * the cbase, which, among other things, is used for constant and class
3533
+ * variable lookup.
3534
+ *
3535
+ * It should never be evaluated as an expression.
3519
3536
  */
3520
3537
  {
3521
- VALUE rb_cNOT = rb_define_class_under(rb_cNode, "NOT", rb_cNode);
3538
+ VALUE rb_cCREF = rb_define_class_under(rb_cNode, "CREF", rb_cNode);
3522
3539
  members = rb_ary_new();
3523
- rb_cNodeSubclass[NODE_NOT] = rb_cNOT;
3524
- rb_iv_set(rb_cNOT, "__member__", members);
3525
- rb_iv_set(rb_cNOT, "__type__", INT2NUM(NODE_NOT));
3526
- rb_define_singleton_method(rb_cNOT, "members", node_s_members, 0);
3540
+ rb_cNodeSubclass[NODE_CREF] = rb_cCREF;
3541
+ rb_iv_set(rb_cCREF, "__member__", members);
3542
+ rb_iv_set(rb_cCREF, "__type__", INT2NUM(NODE_CREF));
3543
+ rb_define_singleton_method(rb_cCREF, "members", node_s_members, 0);
3527
3544
 
3528
3545
  /* Document-method: body
3529
- * the value to negate.
3546
+ * always 0 (false)
3530
3547
  */
3531
- rb_define_method(rb_cNOT, "body", node_body, 0);
3548
+ rb_define_method(rb_cCREF, "body", node_body, 0);
3532
3549
  rb_ary_push(members, rb_str_new2("body"));
3550
+
3551
+ /* Document-method: next
3552
+ * the previous value of ruby_cref or ruby_top_cref
3553
+ */
3554
+ rb_define_method(rb_cCREF, "next", node_next, 0);
3555
+ rb_ary_push(members, rb_str_new2("next"));
3556
+
3557
+ /* Document-method: clss
3558
+ * the new class to use for the cbase.
3559
+ */
3560
+ rb_define_method(rb_cCREF, "clss", node_clss, 0);
3561
+ rb_ary_push(members, rb_str_new2("clss"));
3533
3562
  }
3534
3563
 
3535
- /* Document-class: Node::SUPER
3536
- * Represents the keyword 'super' when used with parens or with arguments.
3564
+ /* Document-class: Node::CVAR
3565
+ * Represents a class variable retrieval. The result of the expression
3566
+ * is the value of the class variable.
3537
3567
  */
3538
3568
  {
3539
- VALUE rb_cSUPER = rb_define_class_under(rb_cNode, "SUPER", rb_cNode);
3569
+ VALUE rb_cCVAR = rb_define_class_under(rb_cNode, "CVAR", rb_cNode);
3540
3570
  members = rb_ary_new();
3541
- rb_cNodeSubclass[NODE_SUPER] = rb_cSUPER;
3542
- rb_iv_set(rb_cSUPER, "__member__", members);
3543
- rb_iv_set(rb_cSUPER, "__type__", INT2NUM(NODE_SUPER));
3544
- rb_define_singleton_method(rb_cSUPER, "members", node_s_members, 0);
3571
+ rb_cNodeSubclass[NODE_CVAR] = rb_cCVAR;
3572
+ rb_iv_set(rb_cCVAR, "__member__", members);
3573
+ rb_iv_set(rb_cCVAR, "__type__", INT2NUM(NODE_CVAR));
3574
+ rb_define_singleton_method(rb_cCVAR, "members", node_s_members, 0);
3545
3575
 
3546
- /* Document-method: args
3547
- * the arguments to be passed to the base class
3576
+ /* Document-method: vid
3577
+ * the name of the class variable, with two leading '@' characters.
3548
3578
  */
3549
- rb_define_method(rb_cSUPER, "args", node_args, 0);
3550
- rb_ary_push(members, rb_str_new2("args"));
3579
+ rb_define_method(rb_cCVAR, "vid", node_vid, 0);
3580
+ rb_ary_push(members, rb_str_new2("vid"));
3551
3581
  }
3552
3582
 
3553
- /* Document-class: Node::FALSE
3554
- * Represents the keyword 'false'.
3583
+ /* Document-class: Node::CVASGN
3584
+ * Represents class variable assignment in a method context.
3555
3585
  */
3556
3586
  {
3557
- VALUE rb_cFALSE = rb_define_class_under(rb_cNode, "FALSE", rb_cNode);
3587
+ VALUE rb_cCVASGN = rb_define_class_under(rb_cNode, "CVASGN", rb_cNode);
3558
3588
  members = rb_ary_new();
3559
- rb_cNodeSubclass[NODE_FALSE] = rb_cFALSE;
3560
- rb_iv_set(rb_cFALSE, "__member__", members);
3561
- rb_iv_set(rb_cFALSE, "__type__", INT2NUM(NODE_FALSE));
3562
- rb_define_singleton_method(rb_cFALSE, "members", node_s_members, 0);
3589
+ rb_cNodeSubclass[NODE_CVASGN] = rb_cCVASGN;
3590
+ rb_iv_set(rb_cCVASGN, "__member__", members);
3591
+ rb_iv_set(rb_cCVASGN, "__type__", INT2NUM(NODE_CVASGN));
3592
+ rb_define_singleton_method(rb_cCVASGN, "members", node_s_members, 0);
3593
+
3594
+ /* Document-method: value
3595
+ * an expression whose result is the new value of the class
3596
+ * variable
3597
+ */
3598
+ rb_define_method(rb_cCVASGN, "value", node_value, 0);
3599
+ rb_ary_push(members, rb_str_new2("value"));
3600
+
3601
+ /* Document-method: vid
3602
+ * the name of the class variable to assign
3603
+ */
3604
+ rb_define_method(rb_cCVASGN, "vid", node_vid, 0);
3605
+ rb_ary_push(members, rb_str_new2("vid"));
3563
3606
  }
3564
3607
 
3565
- /* Document-class: Node::CALL
3566
- * Represents a method call in the form recv.mid(args).
3608
+ /* Document-class: Node::CVDECL
3609
+ * Represents class variable assignment in a class context.
3610
+ *
3611
+ * A warning is emitted if the variable already exists.
3567
3612
  */
3568
3613
  {
3569
- VALUE rb_cCALL = rb_define_class_under(rb_cNode, "CALL", rb_cNode);
3614
+ VALUE rb_cCVDECL = rb_define_class_under(rb_cNode, "CVDECL", rb_cNode);
3570
3615
  members = rb_ary_new();
3571
- rb_cNodeSubclass[NODE_CALL] = rb_cCALL;
3572
- rb_iv_set(rb_cCALL, "__member__", members);
3573
- rb_iv_set(rb_cCALL, "__type__", INT2NUM(NODE_CALL));
3574
- rb_define_singleton_method(rb_cCALL, "members", node_s_members, 0);
3575
-
3576
- /* Document-method: args
3577
- * the arguments to the method
3578
- */
3579
- rb_define_method(rb_cCALL, "args", node_args, 0);
3580
- rb_ary_push(members, rb_str_new2("args"));
3616
+ rb_cNodeSubclass[NODE_CVDECL] = rb_cCVDECL;
3617
+ rb_iv_set(rb_cCVDECL, "__member__", members);
3618
+ rb_iv_set(rb_cCVDECL, "__type__", INT2NUM(NODE_CVDECL));
3619
+ rb_define_singleton_method(rb_cCVDECL, "members", node_s_members, 0);
3581
3620
 
3582
- /* Document-method: mid
3583
- * the method id
3621
+ /* Document-method: value
3622
+ * an expression whose result is the new value of the class
3623
+ * variable
3584
3624
  */
3585
- rb_define_method(rb_cCALL, "mid", node_mid, 0);
3586
- rb_ary_push(members, rb_str_new2("mid"));
3625
+ rb_define_method(rb_cCVDECL, "value", node_value, 0);
3626
+ rb_ary_push(members, rb_str_new2("value"));
3587
3627
 
3588
- /* Document-method: recv
3589
- * the receiver of the method
3628
+ /* Document-method: vid
3629
+ * the name of the class variable to assign
3590
3630
  */
3591
- rb_define_method(rb_cCALL, "recv", node_recv, 0);
3592
- rb_ary_push(members, rb_str_new2("recv"));
3631
+ rb_define_method(rb_cCVDECL, "vid", node_vid, 0);
3632
+ rb_ary_push(members, rb_str_new2("vid"));
3593
3633
  }
3594
3634
 
3595
- /* Document-class: Node::OP_ASGN_OR
3596
- * Represents an expression of the form:
3597
- * recv ||= value
3598
- * Ruby will evaluate the expression on the left hand side. If it is
3599
- * undefined, nil, or false, then ruby will evaluate the expression on
3600
- * the right hand side and assign it to recv. The expression will
3601
- * short-circuit if recv is defined and true (non-false, non-nil).
3635
+ /* Document-class: Node::DASGN
3636
+ * Represents dynamic local variable assignment. Dynamic assignment
3637
+ * differs from static assignment in that the slots for static local
3638
+ * variables are allocated when the method is called, wereas slots for
3639
+ * dynamic variables are allocated when the variable is first assigned
3640
+ * to. When searching for the variable, dynamic assignment searches
3641
+ * backward up the stack to see if the variable exists in any previous
3642
+ * block in the current frame; if it does, it assigns to the slot found
3643
+ * in that block, otherwise it creates a new variable slot. As a
3644
+ * result, dynamic assignment is typically much slower than static
3645
+ * assignment.
3602
3646
  */
3603
3647
  {
3604
- VALUE rb_cOP_ASGN_OR = rb_define_class_under(rb_cNode, "OP_ASGN_OR", rb_cNode);
3648
+ VALUE rb_cDASGN = rb_define_class_under(rb_cNode, "DASGN", rb_cNode);
3605
3649
  members = rb_ary_new();
3606
- rb_cNodeSubclass[NODE_OP_ASGN_OR] = rb_cOP_ASGN_OR;
3607
- rb_iv_set(rb_cOP_ASGN_OR, "__member__", members);
3608
- rb_iv_set(rb_cOP_ASGN_OR, "__type__", INT2NUM(NODE_OP_ASGN_OR));
3609
- rb_define_singleton_method(rb_cOP_ASGN_OR, "members", node_s_members, 0);
3610
-
3611
- /* Document-method: aid
3612
- * if this indicator is nonzero, ruby will check to see if the
3613
- * provided expression is defined, otherwise it will assume that
3614
- * the provided expression is defined.
3615
- */
3616
- rb_define_method(rb_cOP_ASGN_OR, "aid", node_aid, 0);
3617
- rb_ary_push(members, rb_str_new2("aid"));
3650
+ rb_cNodeSubclass[NODE_DASGN] = rb_cDASGN;
3651
+ rb_iv_set(rb_cDASGN, "__member__", members);
3652
+ rb_iv_set(rb_cDASGN, "__type__", INT2NUM(NODE_DASGN));
3653
+ rb_define_singleton_method(rb_cDASGN, "members", node_s_members, 0);
3618
3654
 
3619
3655
  /* Document-method: value
3620
- * the right hand side of the assignment
3656
+ * the value to assign to the local variable
3621
3657
  */
3622
- rb_define_method(rb_cOP_ASGN_OR, "value", node_value, 0);
3658
+ rb_define_method(rb_cDASGN, "value", node_value, 0);
3623
3659
  rb_ary_push(members, rb_str_new2("value"));
3624
3660
 
3625
- /* Document-method: recv
3626
- * the receiver of the assignment
3661
+ /* Document-method: vid
3662
+ * the name of the local variable
3627
3663
  */
3628
- rb_define_method(rb_cOP_ASGN_OR, "recv", node_recv, 0);
3629
- rb_ary_push(members, rb_str_new2("recv"));
3664
+ rb_define_method(rb_cDASGN, "vid", node_vid, 0);
3665
+ rb_ary_push(members, rb_str_new2("vid"));
3630
3666
  }
3631
3667
 
3632
- /* Document-class: Node::TRUE
3633
- * Represents the keyword 'true'.
3668
+ /* Document-class: Node::DASGN_CURR
3669
+ * Represents dynamic local variable assignment in the current frame.
3670
+ * See DASGN for a description of how dynamic assignment works.
3634
3671
  */
3635
3672
  {
3636
- VALUE rb_cTRUE = rb_define_class_under(rb_cNode, "TRUE", rb_cNode);
3673
+ VALUE rb_cDASGN_CURR = rb_define_class_under(rb_cNode, "DASGN_CURR", rb_cNode);
3637
3674
  members = rb_ary_new();
3638
- rb_cNodeSubclass[NODE_TRUE] = rb_cTRUE;
3639
- rb_iv_set(rb_cTRUE, "__member__", members);
3640
- rb_iv_set(rb_cTRUE, "__type__", INT2NUM(NODE_TRUE));
3641
- rb_define_singleton_method(rb_cTRUE, "members", node_s_members, 0);
3675
+ rb_cNodeSubclass[NODE_DASGN_CURR] = rb_cDASGN_CURR;
3676
+ rb_iv_set(rb_cDASGN_CURR, "__member__", members);
3677
+ rb_iv_set(rb_cDASGN_CURR, "__type__", INT2NUM(NODE_DASGN_CURR));
3678
+ rb_define_singleton_method(rb_cDASGN_CURR, "members", node_s_members, 0);
3679
+
3680
+ /* Document-method: value
3681
+ * the value to assign to the local variable
3682
+ */
3683
+ rb_define_method(rb_cDASGN_CURR, "value", node_value, 0);
3684
+ rb_ary_push(members, rb_str_new2("value"));
3685
+
3686
+ /* Document-method: vid
3687
+ * the name of the local variable
3688
+ */
3689
+ rb_define_method(rb_cDASGN_CURR, "vid", node_vid, 0);
3690
+ rb_ary_push(members, rb_str_new2("vid"));
3642
3691
  }
3643
3692
 
3644
- /* Document-class: Node::MASGN
3645
- * Represents multiple assignment.
3693
+ /* Document-class: Node::DEFINED
3694
+ * Represents an expression using the 'defined?' keyword. The result
3695
+ * is either nil or a string describing the expression.
3646
3696
  */
3647
3697
  {
3648
- VALUE rb_cMASGN = rb_define_class_under(rb_cNode, "MASGN", rb_cNode);
3698
+ VALUE rb_cDEFINED = rb_define_class_under(rb_cNode, "DEFINED", rb_cNode);
3649
3699
  members = rb_ary_new();
3650
- rb_cNodeSubclass[NODE_MASGN] = rb_cMASGN;
3651
- rb_iv_set(rb_cMASGN, "__member__", members);
3652
- rb_iv_set(rb_cMASGN, "__type__", INT2NUM(NODE_MASGN));
3653
- rb_define_singleton_method(rb_cMASGN, "members", node_s_members, 0);
3654
-
3655
- /* Document-method: args
3656
- * TODO
3657
- */
3658
- rb_define_method(rb_cMASGN, "args", node_args, 0);
3659
- rb_ary_push(members, rb_str_new2("args"));
3700
+ rb_cNodeSubclass[NODE_DEFINED] = rb_cDEFINED;
3701
+ rb_iv_set(rb_cDEFINED, "__member__", members);
3702
+ rb_iv_set(rb_cDEFINED, "__type__", INT2NUM(NODE_DEFINED));
3703
+ rb_define_singleton_method(rb_cDEFINED, "members", node_s_members, 0);
3660
3704
 
3661
3705
  /* Document-method: head
3662
- * TODO
3706
+ * the expression to inspect
3663
3707
  */
3664
- rb_define_method(rb_cMASGN, "head", node_head, 0);
3708
+ rb_define_method(rb_cDEFINED, "head", node_head, 0);
3665
3709
  rb_ary_push(members, rb_str_new2("head"));
3666
-
3667
- /* Document-method: value
3668
- * TODO
3669
- */
3670
- rb_define_method(rb_cMASGN, "value", node_value, 0);
3671
- rb_ary_push(members, rb_str_new2("value"));
3672
3710
  }
3673
3711
 
3674
- /* Document-class: Node::EVSTR
3675
- * Represents a single string interpolation.
3676
- *
3677
- * Evaluates the given expression and converts its result to a string
3678
- * with #to_s.
3712
+ /* Document-class: Node::DEFN
3713
+ * Represents a method definition, e.g.:
3714
+ * def mid
3715
+ * defn
3716
+ * end
3679
3717
  */
3680
3718
  {
3681
- VALUE rb_cEVSTR = rb_define_class_under(rb_cNode, "EVSTR", rb_cNode);
3719
+ VALUE rb_cDEFN = rb_define_class_under(rb_cNode, "DEFN", rb_cNode);
3682
3720
  members = rb_ary_new();
3683
- rb_cNodeSubclass[NODE_EVSTR] = rb_cEVSTR;
3684
- rb_iv_set(rb_cEVSTR, "__member__", members);
3685
- rb_iv_set(rb_cEVSTR, "__type__", INT2NUM(NODE_EVSTR));
3686
- rb_define_singleton_method(rb_cEVSTR, "members", node_s_members, 0);
3721
+ rb_cNodeSubclass[NODE_DEFN] = rb_cDEFN;
3722
+ rb_iv_set(rb_cDEFN, "__member__", members);
3723
+ rb_iv_set(rb_cDEFN, "__type__", INT2NUM(NODE_DEFN));
3724
+ rb_define_singleton_method(rb_cDEFN, "members", node_s_members, 0);
3687
3725
 
3688
- /* Document-method: body
3689
- * an expression to evaluate
3726
+ /* Document-method: defn
3727
+ * the body of the method definition
3690
3728
  */
3691
- rb_define_method(rb_cEVSTR, "body", node_body, 0);
3692
- rb_ary_push(members, rb_str_new2("body"));
3729
+ rb_define_method(rb_cDEFN, "defn", node_defn, 0);
3730
+ rb_ary_push(members, rb_str_new2("defn"));
3731
+
3732
+ /* Document-method: mid
3733
+ * the name of the method* defn the body of the method
3734
+ */
3735
+ rb_define_method(rb_cDEFN, "mid", node_mid, 0);
3736
+ rb_ary_push(members, rb_str_new2("mid"));
3737
+
3738
+ /* Document-method: noex
3739
+ * the flags which should be used to define the method
3740
+ */
3741
+ rb_define_method(rb_cDEFN, "noex", node_noex, 0);
3742
+ rb_ary_push(members, rb_str_new2("noex"));
3693
3743
  }
3694
3744
 
3695
- /* Document-class: Node::MATCH
3696
- * Represents a regular expression match in a conditional, e.g.:
3697
- * if /lit/ then
3698
- * ...
3699
- * end
3700
- *
3701
- * This expression is equivalent to:
3702
- * if /lit/ =~ $_ then
3703
- * ...
3745
+ /* Document-class: Node::DEFS
3746
+ * Represents a singleton method definition, e.g.:
3747
+ * def recv.mid
3748
+ * defn
3704
3749
  * end
3705
- *
3706
- * On ruby 1.8 and newer, this type of expression causes ruby to emit a
3707
- * warning, unless script is running with -e.
3708
3750
  */
3709
3751
  {
3710
- VALUE rb_cMATCH = rb_define_class_under(rb_cNode, "MATCH", rb_cNode);
3752
+ VALUE rb_cDEFS = rb_define_class_under(rb_cNode, "DEFS", rb_cNode);
3711
3753
  members = rb_ary_new();
3712
- rb_cNodeSubclass[NODE_MATCH] = rb_cMATCH;
3713
- rb_iv_set(rb_cMATCH, "__member__", members);
3714
- rb_iv_set(rb_cMATCH, "__type__", INT2NUM(NODE_MATCH));
3715
- rb_define_singleton_method(rb_cMATCH, "members", node_s_members, 0);
3754
+ rb_cNodeSubclass[NODE_DEFS] = rb_cDEFS;
3755
+ rb_iv_set(rb_cDEFS, "__member__", members);
3756
+ rb_iv_set(rb_cDEFS, "__type__", INT2NUM(NODE_DEFS));
3757
+ rb_define_singleton_method(rb_cDEFS, "members", node_s_members, 0);
3758
+ rb_define_method(rb_cDEFS, "defn", node_defn, 0);
3759
+ rb_ary_push(members, rb_str_new2("defn"));
3716
3760
 
3717
- /* Document-method: lit
3718
- * the regular expression to use in the condition.
3761
+ /* Document-method: mid
3762
+ * the name of the method* defn the body of the method
3719
3763
  */
3720
- rb_define_method(rb_cMATCH, "lit", node_lit, 0);
3721
- rb_ary_push(members, rb_str_new2("lit"));
3764
+ rb_define_method(rb_cDEFS, "mid", node_mid, 0);
3765
+ rb_ary_push(members, rb_str_new2("mid"));
3722
3766
 
3723
- /* Document-method: value
3724
- * the value to compare against
3767
+ /* Document-method: recv
3768
+ * the object to whose singleton class the new method is to be added
3725
3769
  */
3726
- rb_define_method(rb_cMATCH, "value", node_value, 0);
3727
- rb_ary_push(members, rb_str_new2("value"));
3770
+ rb_define_method(rb_cDEFS, "recv", node_recv, 0);
3771
+ rb_ary_push(members, rb_str_new2("recv"));
3728
3772
  }
3729
3773
 
3730
- /* Document-class: Node::ENSURE
3731
- * Represents an ensure expression, e.g.:
3732
- * begin
3733
- * head
3734
- * ensure
3735
- * ensr
3736
- * end
3737
- *
3738
- * The head expression is first evaluated. After the expression is
3739
- * evaluated, whether or not the expression raises an exception, the
3740
- * ensr expression is evaluated.
3774
+ /* Document-class: Node::DMETHOD
3775
+ * A placeholder for a method defined using define_method where the
3776
+ * passed block is created from a Method object, e.g.:
3777
+ * define_method(:name, method(:foo))
3741
3778
  *
3742
- * See also RESCUE and RESBDOY.
3779
+ * See also BMETHOD.
3743
3780
  */
3744
3781
  {
3745
- VALUE rb_cENSURE = rb_define_class_under(rb_cNode, "ENSURE", rb_cNode);
3782
+ VALUE rb_cDMETHOD = rb_define_class_under(rb_cNode, "DMETHOD", rb_cNode);
3746
3783
  members = rb_ary_new();
3747
- rb_cNodeSubclass[NODE_ENSURE] = rb_cENSURE;
3748
- rb_iv_set(rb_cENSURE, "__member__", members);
3749
- rb_iv_set(rb_cENSURE, "__type__", INT2NUM(NODE_ENSURE));
3750
- rb_define_singleton_method(rb_cENSURE, "members", node_s_members, 0);
3784
+ rb_cNodeSubclass[NODE_DMETHOD] = rb_cDMETHOD;
3785
+ rb_iv_set(rb_cDMETHOD, "__member__", members);
3786
+ rb_iv_set(rb_cDMETHOD, "__type__", INT2NUM(NODE_DMETHOD));
3787
+ rb_define_singleton_method(rb_cDMETHOD, "members", node_s_members, 0);
3751
3788
 
3752
- /* Document-method: head
3753
- * the expression to protect
3789
+ /* Document-method: cval
3790
+ * the Method object passed to define_method, which contains the
3791
+ * body of the method
3754
3792
  */
3755
- rb_define_method(rb_cENSURE, "head", node_head, 0);
3756
- rb_ary_push(members, rb_str_new2("head"));
3793
+ rb_define_method(rb_cDMETHOD, "cval", node_cval, 0);
3794
+ rb_ary_push(members, rb_str_new2("cval"));
3795
+ }
3757
3796
 
3758
- /* Document-method: ensr
3759
- * the expression to evaluate after the head is evaluated
3797
+ /* Document-class: Node::DOT2
3798
+ * Represents a range created with the form:
3799
+ * beg..end
3800
+ * Creates a range which does not exclude the range end.
3801
+ */
3802
+ {
3803
+ VALUE rb_cDOT2 = rb_define_class_under(rb_cNode, "DOT2", rb_cNode);
3804
+ members = rb_ary_new();
3805
+ rb_cNodeSubclass[NODE_DOT2] = rb_cDOT2;
3806
+ rb_iv_set(rb_cDOT2, "__member__", members);
3807
+ rb_iv_set(rb_cDOT2, "__type__", INT2NUM(NODE_DOT2));
3808
+ rb_define_singleton_method(rb_cDOT2, "members", node_s_members, 0);
3809
+
3810
+ /* Document-method: beg
3811
+ * the beginning of the range
3760
3812
  */
3761
- rb_define_method(rb_cENSURE, "ensr", node_ensr, 0);
3762
- rb_ary_push(members, rb_str_new2("ensr"));
3813
+ rb_define_method(rb_cDOT2, "beg", node_beg, 0);
3814
+ rb_ary_push(members, rb_str_new2("beg"));
3815
+
3816
+ /* Document-method: end
3817
+ * the end of the range
3818
+ */
3819
+ rb_define_method(rb_cDOT2, "end", node_end, 0);
3820
+ rb_ary_push(members, rb_str_new2("end"));
3821
+ rb_define_method(rb_cDOT2, "state", node_state, 0);
3822
+ rb_ary_push(members, rb_str_new2("state"));
3763
3823
  }
3764
3824
 
3765
- /* Document-class: Node::CDECL
3766
- * Represents constant assignment of the form:
3767
- * vid = value
3825
+ /* Document-class: Node::DOT3
3826
+ * Represents a range created with the form:
3827
+ * beg...end
3828
+ * Creates a range which excludes the range end.
3768
3829
  */
3769
3830
  {
3770
- VALUE rb_cCDECL = rb_define_class_under(rb_cNode, "CDECL", rb_cNode);
3831
+ VALUE rb_cDOT3 = rb_define_class_under(rb_cNode, "DOT3", rb_cNode);
3771
3832
  members = rb_ary_new();
3772
- rb_cNodeSubclass[NODE_CDECL] = rb_cCDECL;
3773
- rb_iv_set(rb_cCDECL, "__member__", members);
3774
- rb_iv_set(rb_cCDECL, "__type__", INT2NUM(NODE_CDECL));
3775
- rb_define_singleton_method(rb_cCDECL, "members", node_s_members, 0);
3833
+ rb_cNodeSubclass[NODE_DOT3] = rb_cDOT3;
3834
+ rb_iv_set(rb_cDOT3, "__member__", members);
3835
+ rb_iv_set(rb_cDOT3, "__type__", INT2NUM(NODE_DOT3));
3836
+ rb_define_singleton_method(rb_cDOT3, "members", node_s_members, 0);
3776
3837
 
3777
- /* Document-method: value
3778
- * the value to be assigned to the constant
3838
+ /* Document-method: beg
3839
+ * the beginning of the range
3779
3840
  */
3780
- rb_define_method(rb_cCDECL, "value", node_value, 0);
3781
- rb_ary_push(members, rb_str_new2("value"));
3841
+ rb_define_method(rb_cDOT3, "beg", node_beg, 0);
3842
+ rb_ary_push(members, rb_str_new2("beg"));
3782
3843
 
3783
- /* Document-method: vid
3784
- * the name of the constant to be assigned, all uppercase
3844
+ /* Document-method: end
3845
+ * the end of the range
3785
3846
  */
3786
- rb_define_method(rb_cCDECL, "vid", node_vid, 0);
3787
- rb_ary_push(members, rb_str_new2("vid"));
3847
+ rb_define_method(rb_cDOT3, "end", node_end, 0);
3848
+ rb_ary_push(members, rb_str_new2("end"));
3849
+ rb_define_method(rb_cDOT3, "state", node_state, 0);
3850
+ rb_ary_push(members, rb_str_new2("state"));
3788
3851
  }
3789
3852
 
3790
- /* Document-class: Node::DXSTR
3791
- * Represents a string object with interpolation inside backticks,
3792
- * e.g.:
3793
- * `lit#{next}`
3794
- *
3795
- * The node is evaluated by duplicating the string stored in the 'lit'
3796
- * element, then iterating over the nodes stored in the 'next' element.
3797
- * Each node found should evalate to an string, and each resulting
3798
- * string is appended onto the original string.
3799
- *
3800
- * The resulting string is executed in a subshell and the output from
3801
- * its stdout stored in a string, which becomes the result of the
3802
- * expression. Interpolation is represented with the EVSTR node.
3853
+ /* Document-class: Node::DREGX
3854
+ * Represents a regular expresion with interpolation. The node is
3855
+ * evaluated by duplicating the regex stored in the 'lit' element, then
3856
+ * iterating over the nodes stored in the 'next' element. Each node
3857
+ * found should evaluate to a string, and each resulting string is
3858
+ * appended onto the original string. Interpolation is represented
3859
+ * with the EVSTR node.
3803
3860
  */
3804
3861
  {
3805
- VALUE rb_cDXSTR = rb_define_class_under(rb_cNode, "DXSTR", rb_cNode);
3862
+ VALUE rb_cDREGX = rb_define_class_under(rb_cNode, "DREGX", rb_cNode);
3806
3863
  members = rb_ary_new();
3807
- rb_cNodeSubclass[NODE_DXSTR] = rb_cDXSTR;
3808
- rb_iv_set(rb_cDXSTR, "__member__", members);
3809
- rb_iv_set(rb_cDXSTR, "__type__", INT2NUM(NODE_DXSTR));
3810
- rb_define_singleton_method(rb_cDXSTR, "members", node_s_members, 0);
3864
+ rb_cNodeSubclass[NODE_DREGX] = rb_cDREGX;
3865
+ rb_iv_set(rb_cDREGX, "__member__", members);
3866
+ rb_iv_set(rb_cDREGX, "__type__", INT2NUM(NODE_DREGX));
3867
+ rb_define_singleton_method(rb_cDREGX, "members", node_s_members, 0);
3811
3868
 
3812
3869
  /* Document-method: lit
3813
3870
  * a string
3814
3871
  */
3815
- rb_define_method(rb_cDXSTR, "lit", node_lit, 0);
3872
+ rb_define_method(rb_cDREGX, "lit", node_lit, 0);
3816
3873
  rb_ary_push(members, rb_str_new2("lit"));
3817
3874
 
3875
+ /* Document-method: cflag
3876
+ * a bitfield containing the options used in the regular
3877
+ * expression. Valid values include:
3878
+ * * RE_OPTION_IGNORECASE
3879
+ * * RE_OPTION_EXTENDED
3880
+ * * RE_OPTION_MULTILINE
3881
+ * * RE_OPTION_SINGLELINE
3882
+ * * RE_OPTION_LONGEST
3883
+ * * RE_MAY_IGNORECASE
3884
+ * * RE_OPTIMIZE_ANCHOR
3885
+ * * RE_OPTIMIZE_EXACTN
3886
+ * * RE_OPTIMIZE_NO_BM
3887
+ * * RE_OPTIMIZE_BMATCH
3888
+ */
3889
+ rb_define_method(rb_cDREGX, "cflag", node_cflag, 0);
3890
+ rb_ary_push(members, rb_str_new2("cflag"));
3891
+
3818
3892
  /* Document-method: next
3819
3893
  * a list of expressions to be appended onto the string
3820
3894
  */
3821
- rb_define_method(rb_cDXSTR, "next", node_next, 0);
3895
+ rb_define_method(rb_cDREGX, "next", node_next, 0);
3822
3896
  rb_ary_push(members, rb_str_new2("next"));
3823
3897
  }
3824
3898
 
3825
- /* Document-class: Node::VCALL
3826
- * Represents a local variable or a method call without an explicit
3827
- * receiver, to be determined at run-time.
3899
+ /* Document-class: Node::DREGX_ONCE
3900
+ * Represents a regular expression with interpolation with the 'once'
3901
+ * flag set. The regular expression is only interpolated the first
3902
+ * time it is encountered.
3828
3903
  */
3829
3904
  {
3830
- VALUE rb_cVCALL = rb_define_class_under(rb_cNode, "VCALL", rb_cNode);
3905
+ VALUE rb_cDREGX_ONCE = rb_define_class_under(rb_cNode, "DREGX_ONCE", rb_cNode);
3831
3906
  members = rb_ary_new();
3832
- rb_cNodeSubclass[NODE_VCALL] = rb_cVCALL;
3833
- rb_iv_set(rb_cVCALL, "__member__", members);
3834
- rb_iv_set(rb_cVCALL, "__type__", INT2NUM(NODE_VCALL));
3835
- rb_define_singleton_method(rb_cVCALL, "members", node_s_members, 0);
3907
+ rb_cNodeSubclass[NODE_DREGX_ONCE] = rb_cDREGX_ONCE;
3908
+ rb_iv_set(rb_cDREGX_ONCE, "__member__", members);
3909
+ rb_iv_set(rb_cDREGX_ONCE, "__type__", INT2NUM(NODE_DREGX_ONCE));
3910
+ rb_define_singleton_method(rb_cDREGX_ONCE, "members", node_s_members, 0);
3836
3911
 
3837
- /* Document-method: mid
3838
- * the name of the variable or method
3912
+ /* Document-method: lit
3913
+ * a string
3839
3914
  */
3840
- rb_define_method(rb_cVCALL, "mid", node_mid, 0);
3841
- rb_ary_push(members, rb_str_new2("mid"));
3842
- }
3843
-
3844
- /* Document-class: Node::ZARRAY
3845
- * Represents an array of zero elements. Evalation of this node
3846
- * creates a new array of length zero.
3847
- */
3848
- {
3849
- VALUE rb_cZARRAY = rb_define_class_under(rb_cNode, "ZARRAY", rb_cNode);
3850
- members = rb_ary_new();
3851
- rb_cNodeSubclass[NODE_ZARRAY] = rb_cZARRAY;
3852
- rb_iv_set(rb_cZARRAY, "__member__", members);
3853
- rb_iv_set(rb_cZARRAY, "__type__", INT2NUM(NODE_ZARRAY));
3854
- rb_define_singleton_method(rb_cZARRAY, "members", node_s_members, 0);
3855
- }
3856
-
3857
- /* Document-class: Node::BLOCK_ARG
3858
- * Represents a block argument in a method definition, e.g.:
3859
- * def foo(&arg)
3860
- * end
3861
- */
3862
- {
3863
- VALUE rb_cBLOCK_ARG = rb_define_class_under(rb_cNode, "BLOCK_ARG", rb_cNode);
3864
- members = rb_ary_new();
3865
- rb_cNodeSubclass[NODE_BLOCK_ARG] = rb_cBLOCK_ARG;
3866
- rb_iv_set(rb_cBLOCK_ARG, "__member__", members);
3867
- rb_iv_set(rb_cBLOCK_ARG, "__type__", INT2NUM(NODE_BLOCK_ARG));
3868
- rb_define_singleton_method(rb_cBLOCK_ARG, "members", node_s_members, 0);
3869
-
3870
- /* Document-method: cnt
3871
- * the index into the local variable table of the name of the block
3872
- * argument, not including the implicit variables.
3873
- */
3874
- rb_define_method(rb_cBLOCK_ARG, "cnt", node_cnt, 0);
3875
- rb_ary_push(members, rb_str_new2("cnt"));
3876
- }
3877
-
3878
- /* Document-class: Node::AND
3879
- * Represents a logical 'and' of the form:
3880
- * first && second
3881
- * The expression will short-circuit and yield the result of the left
3882
- * hand side if it is false or nil, else it will evaluate the right
3883
- * hand side and use it as the result of the expression.
3884
- */
3885
- {
3886
- VALUE rb_cAND = rb_define_class_under(rb_cNode, "AND", rb_cNode);
3887
- members = rb_ary_new();
3888
- rb_cNodeSubclass[NODE_AND] = rb_cAND;
3889
- rb_iv_set(rb_cAND, "__member__", members);
3890
- rb_iv_set(rb_cAND, "__type__", INT2NUM(NODE_AND));
3891
- rb_define_singleton_method(rb_cAND, "members", node_s_members, 0);
3892
-
3893
- /* Document-method: first
3894
- * the expression on the left hand side
3895
- */
3896
- rb_define_method(rb_cAND, "first", node_1st, 0);
3897
- rb_ary_push(members, rb_str_new2("first"));
3898
-
3899
- /* Document-method: second
3900
- * the expression on the right hand side
3901
- */
3902
- rb_define_method(rb_cAND, "second", node_2nd, 0);
3903
- rb_ary_push(members, rb_str_new2("second"));
3904
- }
3905
-
3906
- /* Document-class: Node::SCLASS
3907
- * Represents the body of a singleton class definition, e.g.:
3908
- * class << recv
3909
- * body
3910
- * end
3911
- *
3912
- * The class definition is evaluated in a new lexical scope.
3913
- *
3914
- * The result of the expression is the last expression evaluated in the
3915
- * body.
3916
- */
3917
- {
3918
- VALUE rb_cSCLASS = rb_define_class_under(rb_cNode, "SCLASS", rb_cNode);
3919
- members = rb_ary_new();
3920
- rb_cNodeSubclass[NODE_SCLASS] = rb_cSCLASS;
3921
- rb_iv_set(rb_cSCLASS, "__member__", members);
3922
- rb_iv_set(rb_cSCLASS, "__type__", INT2NUM(NODE_SCLASS));
3923
- rb_define_singleton_method(rb_cSCLASS, "members", node_s_members, 0);
3924
-
3925
- /* Document-method: body
3926
- * the body of the class definition
3927
- */
3928
- rb_define_method(rb_cSCLASS, "body", node_body, 0);
3929
- rb_ary_push(members, rb_str_new2("body"));
3930
-
3931
- /* Document-method: recv
3932
- * the object whose singleton class is to be modified
3933
- */
3934
- rb_define_method(rb_cSCLASS, "recv", node_recv, 0);
3935
- rb_ary_push(members, rb_str_new2("recv"));
3936
- }
3937
-
3938
- /* Document-class: Node::DEFINED
3939
- * Represents an expression using the 'defined?' keyword. The result
3940
- * is either nil or a string describing the expression.
3941
- */
3942
- {
3943
- VALUE rb_cDEFINED = rb_define_class_under(rb_cNode, "DEFINED", rb_cNode);
3944
- members = rb_ary_new();
3945
- rb_cNodeSubclass[NODE_DEFINED] = rb_cDEFINED;
3946
- rb_iv_set(rb_cDEFINED, "__member__", members);
3947
- rb_iv_set(rb_cDEFINED, "__type__", INT2NUM(NODE_DEFINED));
3948
- rb_define_singleton_method(rb_cDEFINED, "members", node_s_members, 0);
3949
-
3950
- /* Document-method: head
3951
- * the expression to inspect
3952
- */
3953
- rb_define_method(rb_cDEFINED, "head", node_head, 0);
3954
- rb_ary_push(members, rb_str_new2("head"));
3955
- }
3956
-
3957
- /* Document-class: Node::VALIAS
3958
- * Represents an alias expression of the form:
3959
- * alias 1st 2nd
3960
- * where 2nd is the name of a variable and 1st is the name of its new
3961
- * alias.
3962
- */
3963
- {
3964
- VALUE rb_cVALIAS = rb_define_class_under(rb_cNode, "VALIAS", rb_cNode);
3965
- members = rb_ary_new();
3966
- rb_cNodeSubclass[NODE_VALIAS] = rb_cVALIAS;
3967
- rb_iv_set(rb_cVALIAS, "__member__", members);
3968
- rb_iv_set(rb_cVALIAS, "__type__", INT2NUM(NODE_VALIAS));
3969
- rb_define_singleton_method(rb_cVALIAS, "members", node_s_members, 0);
3970
- rb_define_method(rb_cVALIAS, "first", node_1st, 0);
3971
- rb_ary_push(members, rb_str_new2("first"));
3972
- rb_define_method(rb_cVALIAS, "second", node_2nd, 0);
3973
- rb_ary_push(members, rb_str_new2("second"));
3974
- }
3975
-
3976
- /* Document-class: Node::REDO
3977
- * Represents the 'redo' keyword. Causes control to be transferred to
3978
- * the beginning of the loop. The loop assignment is not repeated.
3979
- */
3980
- {
3981
- VALUE rb_cREDO = rb_define_class_under(rb_cNode, "REDO", rb_cNode);
3982
- members = rb_ary_new();
3983
- rb_cNodeSubclass[NODE_REDO] = rb_cREDO;
3984
- rb_iv_set(rb_cREDO, "__member__", members);
3985
- rb_iv_set(rb_cREDO, "__type__", INT2NUM(NODE_REDO));
3986
- rb_define_singleton_method(rb_cREDO, "members", node_s_members, 0);
3987
- }
3988
-
3989
- /* Document-class: Node::BLOCK_PASS
3990
- * Represents an object being passed to a method as a block, e.g.:
3991
- * foo(&bar)
3992
- *
3993
- * The body node is first evaluates to get an object, then #to_proc to
3994
- * convert it into a proc if necessary. The iter node is then
3995
- * evaluated to call a method, passing the proc as a block parameter to
3996
- * the method.
3997
- */
3998
- {
3999
- VALUE rb_cBLOCK_PASS = rb_define_class_under(rb_cNode, "BLOCK_PASS", rb_cNode);
4000
- members = rb_ary_new();
4001
- rb_cNodeSubclass[NODE_BLOCK_PASS] = rb_cBLOCK_PASS;
4002
- rb_iv_set(rb_cBLOCK_PASS, "__member__", members);
4003
- rb_iv_set(rb_cBLOCK_PASS, "__type__", INT2NUM(NODE_BLOCK_PASS));
4004
- rb_define_singleton_method(rb_cBLOCK_PASS, "members", node_s_members, 0);
4005
-
4006
- /* Document-method: body
4007
- * the object to pass as a block
4008
- */
4009
- rb_define_method(rb_cBLOCK_PASS, "body", node_body, 0);
4010
- rb_ary_push(members, rb_str_new2("body"));
4011
-
4012
- /* Document-method: iter
4013
- * an expression which calls a method
4014
- */
4015
- rb_define_method(rb_cBLOCK_PASS, "iter", node_iter, 0);
4016
- rb_ary_push(members, rb_str_new2("iter"));
4017
- }
4018
-
4019
- /* Document-class: Node::DREGX
4020
- * Represents a regular expresion with interpolation. The node is
4021
- * evaluated by duplicating the regex stored in the 'lit' element, then
4022
- * iterating over the nodes stored in the 'next' element. Each node
4023
- * found should evaluate to a string, and each resulting string is
4024
- * appended onto the original string. Interpolation is represented
4025
- * with the EVSTR node.
4026
- */
4027
- {
4028
- VALUE rb_cDREGX = rb_define_class_under(rb_cNode, "DREGX", rb_cNode);
4029
- members = rb_ary_new();
4030
- rb_cNodeSubclass[NODE_DREGX] = rb_cDREGX;
4031
- rb_iv_set(rb_cDREGX, "__member__", members);
4032
- rb_iv_set(rb_cDREGX, "__type__", INT2NUM(NODE_DREGX));
4033
- rb_define_singleton_method(rb_cDREGX, "members", node_s_members, 0);
4034
-
4035
- /* Document-method: lit
4036
- * a string
4037
- */
4038
- rb_define_method(rb_cDREGX, "lit", node_lit, 0);
4039
- rb_ary_push(members, rb_str_new2("lit"));
3915
+ rb_define_method(rb_cDREGX_ONCE, "lit", node_lit, 0);
3916
+ rb_ary_push(members, rb_str_new2("lit"));
4040
3917
 
4041
3918
  /* Document-method: cflag
4042
3919
  * a bitfield containing the options used in the regular
4043
- * expression. Valid values include:
4044
- * * RE_OPTION_IGNORECASE
4045
- * * RE_OPTION_EXTENDED
4046
- * * RE_OPTION_MULTILINE
4047
- * * RE_OPTION_SINGLELINE
4048
- * * RE_OPTION_LONGEST
4049
- * * RE_MAY_IGNORECASE
4050
- * * RE_OPTIMIZE_ANCHOR
4051
- * * RE_OPTIMIZE_EXACTN
4052
- * * RE_OPTIMIZE_NO_BM
4053
- * * RE_OPTIMIZE_BMATCH
3920
+ * expression. See DREGX for a list of valid values.
4054
3921
  */
4055
- rb_define_method(rb_cDREGX, "cflag", node_cflag, 0);
3922
+ rb_define_method(rb_cDREGX_ONCE, "cflag", node_cflag, 0);
4056
3923
  rb_ary_push(members, rb_str_new2("cflag"));
4057
3924
 
4058
3925
  /* Document-method: next
4059
3926
  * a list of expressions to be appended onto the string
4060
3927
  */
4061
- rb_define_method(rb_cDREGX, "next", node_next, 0);
3928
+ rb_define_method(rb_cDREGX_ONCE, "next", node_next, 0);
4062
3929
  rb_ary_push(members, rb_str_new2("next"));
4063
3930
  }
4064
3931
 
4065
- /* Document-class: Node::DEFN
4066
- * Represents a method definition, e.g.:
4067
- * def mid
4068
- * defn
4069
- * end
4070
- */
4071
- {
4072
- VALUE rb_cDEFN = rb_define_class_under(rb_cNode, "DEFN", rb_cNode);
4073
- members = rb_ary_new();
4074
- rb_cNodeSubclass[NODE_DEFN] = rb_cDEFN;
4075
- rb_iv_set(rb_cDEFN, "__member__", members);
4076
- rb_iv_set(rb_cDEFN, "__type__", INT2NUM(NODE_DEFN));
4077
- rb_define_singleton_method(rb_cDEFN, "members", node_s_members, 0);
4078
-
4079
- /* Document-method: mid
4080
- * the name of the method* defn the body of the method
4081
- */
4082
- rb_define_method(rb_cDEFN, "mid", node_mid, 0);
4083
- rb_ary_push(members, rb_str_new2("mid"));
4084
-
4085
- /* Document-method: defn
4086
- * the body of the method definition
4087
- */
4088
- rb_define_method(rb_cDEFN, "defn", node_defn, 0);
4089
- rb_ary_push(members, rb_str_new2("defn"));
4090
-
4091
- /* Document-method: noex
4092
- * the flags which should be used to define the method
4093
- */
4094
- rb_define_method(rb_cDEFN, "noex", node_noex, 0);
4095
- rb_ary_push(members, rb_str_new2("noex"));
4096
- }
4097
-
4098
- /* Document-class: Node::SCOPE
4099
- * Represents a lexical scope.
4100
- *
4101
- * A new scope is created when a method is invoked. The scope node
4102
- * holds information about local variables and arguments to the method.
4103
- * The first two variables in the local variable table are the implicit
4104
- * variables $_ and $~.
4105
- *
4106
- * The next variables listed in the local variable table are the
4107
- * arguments to the method. More information about the arguments to
4108
- * the method are stored in the ARGS node, which will either be the
4109
- * first node in the scope or the first node in the BLOCK held by the
4110
- * scope.
3932
+ /* Document-class: Node::DSTR
3933
+ * Represents a string object with interpolation. The node is
3934
+ * evaluated by duplicating the string stored in the 'lit' element,
3935
+ * then iterating over the nodes stored in the 'next' element. Each
3936
+ * node found should evalate to a string, and each resulting string is
3937
+ * appended onto the regex. Interpolation is represented with the
3938
+ * EVSTR node.
4111
3939
  */
4112
3940
  {
4113
- VALUE rb_cSCOPE = rb_define_class_under(rb_cNode, "SCOPE", rb_cNode);
3941
+ VALUE rb_cDSTR = rb_define_class_under(rb_cNode, "DSTR", rb_cNode);
4114
3942
  members = rb_ary_new();
4115
- rb_cNodeSubclass[NODE_SCOPE] = rb_cSCOPE;
4116
- rb_iv_set(rb_cSCOPE, "__member__", members);
4117
- rb_iv_set(rb_cSCOPE, "__type__", INT2NUM(NODE_SCOPE));
4118
- rb_define_singleton_method(rb_cSCOPE, "members", node_s_members, 0);
4119
-
4120
- /* Document-method: tbl
4121
- * the names of the local variables* next the first expression in
4122
- * the scope
4123
- */
4124
- rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0);
4125
- rb_ary_push(members, rb_str_new2("tbl"));
3943
+ rb_cNodeSubclass[NODE_DSTR] = rb_cDSTR;
3944
+ rb_iv_set(rb_cDSTR, "__member__", members);
3945
+ rb_iv_set(rb_cDSTR, "__type__", INT2NUM(NODE_DSTR));
3946
+ rb_define_singleton_method(rb_cDSTR, "members", node_s_members, 0);
4126
3947
 
4127
- /* Document-method: rval
4128
- * holds information about which class(es) to search for constants
4129
- * in this scope
3948
+ /* Document-method: lit
3949
+ * a string
4130
3950
  */
4131
- rb_define_method(rb_cSCOPE, "rval", node_rval, 0);
4132
- rb_ary_push(members, rb_str_new2("rval"));
3951
+ rb_define_method(rb_cDSTR, "lit", node_lit, 0);
3952
+ rb_ary_push(members, rb_str_new2("lit"));
4133
3953
 
4134
3954
  /* Document-method: next
4135
- * the body of the lexical scope
3955
+ * a list of expressions to be appended onto the string
4136
3956
  */
4137
- rb_define_method(rb_cSCOPE, "next", node_next, 0);
3957
+ rb_define_method(rb_cDSTR, "next", node_next, 0);
4138
3958
  rb_ary_push(members, rb_str_new2("next"));
4139
3959
  }
4140
3960
 
@@ -4162,762 +3982,808 @@ void define_node_subclass_methods()
4162
3982
  rb_ary_push(members, rb_str_new2("next"));
4163
3983
  }
4164
3984
 
4165
- /* Document-class: Node::BMETHOD
4166
- * A placeholder for a method defined using define_method, e.g.:
4167
- * define_method(:foo) {
4168
- * ...
4169
- * }
4170
- *
4171
- * See also DMETHOD.
3985
+ /* Document-class: Node::DVAR
3986
+ * Represents dynamic local variable retrieval. See also DASGN.
4172
3987
  */
4173
3988
  {
4174
- VALUE rb_cBMETHOD = rb_define_class_under(rb_cNode, "BMETHOD", rb_cNode);
3989
+ VALUE rb_cDVAR = rb_define_class_under(rb_cNode, "DVAR", rb_cNode);
4175
3990
  members = rb_ary_new();
4176
- rb_cNodeSubclass[NODE_BMETHOD] = rb_cBMETHOD;
4177
- rb_iv_set(rb_cBMETHOD, "__member__", members);
4178
- rb_iv_set(rb_cBMETHOD, "__type__", INT2NUM(NODE_BMETHOD));
4179
- rb_define_singleton_method(rb_cBMETHOD, "members", node_s_members, 0);
3991
+ rb_cNodeSubclass[NODE_DVAR] = rb_cDVAR;
3992
+ rb_iv_set(rb_cDVAR, "__member__", members);
3993
+ rb_iv_set(rb_cDVAR, "__type__", INT2NUM(NODE_DVAR));
3994
+ rb_define_singleton_method(rb_cDVAR, "members", node_s_members, 0);
4180
3995
 
4181
- /* Document-method: cval
4182
- * the Proc object passed to define_method, which contains the body
4183
- * of the method
3996
+ /* Document-method: vid
3997
+ * the name of the local variable to retrieve.
4184
3998
  */
4185
- rb_define_method(rb_cBMETHOD, "cval", node_cval, 0);
4186
- rb_ary_push(members, rb_str_new2("cval"));
3999
+ rb_define_method(rb_cDVAR, "vid", node_vid, 0);
4000
+ rb_ary_push(members, rb_str_new2("vid"));
4187
4001
  }
4188
4002
 
4189
- /* Document-class: Node::IF
4190
- * Represents a conditional of the form:
4191
- * if cond then
4192
- * body
4193
- * end
4194
- *
4195
- * or the form:
4196
- * if cond then
4197
- * body
4198
- * else
4199
- * else
4200
- * end
4003
+ /* Document-class: Node::DXSTR
4004
+ * Represents a string object with interpolation inside backticks,
4005
+ * e.g.:
4006
+ * `lit#{next}`
4201
4007
  *
4202
- * The condition is first evaluated. If it is true, then body is
4203
- * evaluated, otherwise else is evaluated. The result is the value of
4204
- * the expression evaluated, or nil if there was no expression
4205
- * present.
4008
+ * The node is evaluated by duplicating the string stored in the 'lit'
4009
+ * element, then iterating over the nodes stored in the 'next' element.
4010
+ * Each node found should evalate to an string, and each resulting
4011
+ * string is appended onto the original string.
4206
4012
  *
4207
- * A conditional block using elsif has another IF node as the else
4208
- * expression.
4013
+ * The resulting string is executed in a subshell and the output from
4014
+ * its stdout stored in a string, which becomes the result of the
4015
+ * expression. Interpolation is represented with the EVSTR node.
4209
4016
  */
4210
4017
  {
4211
- VALUE rb_cIF = rb_define_class_under(rb_cNode, "IF", rb_cNode);
4018
+ VALUE rb_cDXSTR = rb_define_class_under(rb_cNode, "DXSTR", rb_cNode);
4212
4019
  members = rb_ary_new();
4213
- rb_cNodeSubclass[NODE_IF] = rb_cIF;
4214
- rb_iv_set(rb_cIF, "__member__", members);
4215
- rb_iv_set(rb_cIF, "__type__", INT2NUM(NODE_IF));
4216
- rb_define_singleton_method(rb_cIF, "members", node_s_members, 0);
4217
-
4218
- /* Document-method: cond
4219
- * the condition to evaluate
4220
- */
4221
- rb_define_method(rb_cIF, "cond", node_cond, 0);
4222
- rb_ary_push(members, rb_str_new2("cond"));
4020
+ rb_cNodeSubclass[NODE_DXSTR] = rb_cDXSTR;
4021
+ rb_iv_set(rb_cDXSTR, "__member__", members);
4022
+ rb_iv_set(rb_cDXSTR, "__type__", INT2NUM(NODE_DXSTR));
4023
+ rb_define_singleton_method(rb_cDXSTR, "members", node_s_members, 0);
4223
4024
 
4224
- /* Document-method: body
4225
- * the expression to evaluate if the expression is true, or false
4226
- * if the expression is empty
4025
+ /* Document-method: lit
4026
+ * a string
4227
4027
  */
4228
- rb_define_method(rb_cIF, "body", node_body, 0);
4229
- rb_ary_push(members, rb_str_new2("body"));
4028
+ rb_define_method(rb_cDXSTR, "lit", node_lit, 0);
4029
+ rb_ary_push(members, rb_str_new2("lit"));
4230
4030
 
4231
- /* Document-method: else
4232
- * the expression to evaluate if the expression is false, or false
4233
- * if the expression is empty
4031
+ /* Document-method: next
4032
+ * a list of expressions to be appended onto the string
4234
4033
  */
4235
- rb_define_method(rb_cIF, "else", node_else, 0);
4236
- rb_ary_push(members, rb_str_new2("else"));
4034
+ rb_define_method(rb_cDXSTR, "next", node_next, 0);
4035
+ rb_ary_push(members, rb_str_new2("next"));
4237
4036
  }
4238
4037
 
4239
- /* Document-class: Node::WHEN
4240
- * Represents either a conditional in a case/end block:
4241
- * case value
4242
- * when head
4243
- * body
4244
- * next
4245
- * end
4246
- *
4247
- * or the first element of a a case/end block with no conditional:
4248
- * case
4249
- * when head
4250
- * body
4251
- * next
4038
+ /* Document-class: Node::ENSURE
4039
+ * Represents an ensure expression, e.g.:
4040
+ * begin
4041
+ * head
4042
+ * ensure
4043
+ * ensr
4252
4044
  * end
4253
4045
  *
4254
- * In the first case, value is evaluated and head is evaluated, and
4255
- * they are compared using head === value. If the result is true, then
4256
- * body is evaluated and no more when conditions are tried, otherwise
4257
- * the interpreter evaluates the next node.
4258
- *
4259
- * In the second case, head is tested using rtest(value). If the
4260
- * result is true, then body is evaluated and no more when conditions
4261
- * are tried, otherwise the interpreter evaluates the next node.
4262
- *
4263
- * If the condition evaluates to false and there are no more when
4264
- * conditions to try, the result of the expression is nil.
4046
+ * The head expression is first evaluated. After the expression is
4047
+ * evaluated, whether or not the expression raises an exception, the
4048
+ * ensr expression is evaluated.
4265
4049
  *
4266
- * If the next expression to try is not a WHEN node, then it represents
4267
- * an else element and is evaluated unconditionally.
4050
+ * See also RESCUE and RESBDOY.
4268
4051
  */
4269
4052
  {
4270
- VALUE rb_cWHEN = rb_define_class_under(rb_cNode, "WHEN", rb_cNode);
4053
+ VALUE rb_cENSURE = rb_define_class_under(rb_cNode, "ENSURE", rb_cNode);
4271
4054
  members = rb_ary_new();
4272
- rb_cNodeSubclass[NODE_WHEN] = rb_cWHEN;
4273
- rb_iv_set(rb_cWHEN, "__member__", members);
4274
- rb_iv_set(rb_cWHEN, "__type__", INT2NUM(NODE_WHEN));
4275
- rb_define_singleton_method(rb_cWHEN, "members", node_s_members, 0);
4055
+ rb_cNodeSubclass[NODE_ENSURE] = rb_cENSURE;
4056
+ rb_iv_set(rb_cENSURE, "__member__", members);
4057
+ rb_iv_set(rb_cENSURE, "__type__", INT2NUM(NODE_ENSURE));
4058
+ rb_define_singleton_method(rb_cENSURE, "members", node_s_members, 0);
4276
4059
 
4277
4060
  /* Document-method: head
4278
- * a value to compare against, or a condition to be tested
4061
+ * the expression to protect
4279
4062
  */
4280
- rb_define_method(rb_cWHEN, "head", node_head, 0);
4063
+ rb_define_method(rb_cENSURE, "head", node_head, 0);
4281
4064
  rb_ary_push(members, rb_str_new2("head"));
4282
4065
 
4066
+ /* Document-method: ensr
4067
+ * the expression to evaluate after the head is evaluated
4068
+ */
4069
+ rb_define_method(rb_cENSURE, "ensr", node_ensr, 0);
4070
+ rb_ary_push(members, rb_str_new2("ensr"));
4071
+ }
4072
+
4073
+ /* Document-class: Node::EVSTR
4074
+ * Represents a single string interpolation.
4075
+ *
4076
+ * Evaluates the given expression and converts its result to a string
4077
+ * with #to_s.
4078
+ */
4079
+ {
4080
+ VALUE rb_cEVSTR = rb_define_class_under(rb_cNode, "EVSTR", rb_cNode);
4081
+ members = rb_ary_new();
4082
+ rb_cNodeSubclass[NODE_EVSTR] = rb_cEVSTR;
4083
+ rb_iv_set(rb_cEVSTR, "__member__", members);
4084
+ rb_iv_set(rb_cEVSTR, "__type__", INT2NUM(NODE_EVSTR));
4085
+ rb_define_singleton_method(rb_cEVSTR, "members", node_s_members, 0);
4086
+
4283
4087
  /* Document-method: body
4284
- * an expression to evaluate if the condition evaluates to true
4088
+ * an expression to evaluate
4285
4089
  */
4286
- rb_define_method(rb_cWHEN, "body", node_body, 0);
4090
+ rb_define_method(rb_cEVSTR, "body", node_body, 0);
4287
4091
  rb_ary_push(members, rb_str_new2("body"));
4092
+ }
4288
4093
 
4289
- /* Document-method: next
4290
- * the next expression to be evaluated if the condition is false
4291
- */
4292
- rb_define_method(rb_cWHEN, "next", node_next, 0);
4293
- rb_ary_push(members, rb_str_new2("next"));
4094
+ /* Document-class: Node::FALSE
4095
+ * Represents the keyword 'false'.
4096
+ */
4097
+ {
4098
+ VALUE rb_cFALSE = rb_define_class_under(rb_cNode, "FALSE", rb_cNode);
4099
+ members = rb_ary_new();
4100
+ rb_cNodeSubclass[NODE_FALSE] = rb_cFALSE;
4101
+ rb_iv_set(rb_cFALSE, "__member__", members);
4102
+ rb_iv_set(rb_cFALSE, "__type__", INT2NUM(NODE_FALSE));
4103
+ rb_define_singleton_method(rb_cFALSE, "members", node_s_members, 0);
4294
4104
  }
4295
4105
 
4296
- /* Document-class: Node::ARGSCAT
4297
- * Represents the concatenation of a list of arguments and a splatted
4298
- * value, e.g.:
4299
- * a, b, *value
4300
- * Evaluates head to create an array. Evaluates body and performs a
4301
- * splat operation on the result to create another array (see SPLAT).
4302
- * Concatenates the the second array onto the end of the first to
4303
- * produce the result.
4106
+ /* Document-class: Node::FBODY
4107
+ * A placeholder for a method alias, which can be added to a class by
4108
+ * using alias or alias_method:
4109
+ * alias old new
4304
4110
  */
4305
4111
  {
4306
- VALUE rb_cARGSCAT = rb_define_class_under(rb_cNode, "ARGSCAT", rb_cNode);
4112
+ VALUE rb_cFBODY = rb_define_class_under(rb_cNode, "FBODY", rb_cNode);
4307
4113
  members = rb_ary_new();
4308
- rb_cNodeSubclass[NODE_ARGSCAT] = rb_cARGSCAT;
4309
- rb_iv_set(rb_cARGSCAT, "__member__", members);
4310
- rb_iv_set(rb_cARGSCAT, "__type__", INT2NUM(NODE_ARGSCAT));
4311
- rb_define_singleton_method(rb_cARGSCAT, "members", node_s_members, 0);
4114
+ rb_cNodeSubclass[NODE_FBODY] = rb_cFBODY;
4115
+ rb_iv_set(rb_cFBODY, "__member__", members);
4116
+ rb_iv_set(rb_cFBODY, "__type__", INT2NUM(NODE_FBODY));
4117
+ rb_define_singleton_method(rb_cFBODY, "members", node_s_members, 0);
4312
4118
 
4313
4119
  /* Document-method: head
4314
- * a list of fixed arguments
4120
+ * the method body
4315
4121
  */
4316
- rb_define_method(rb_cARGSCAT, "head", node_head, 0);
4122
+ rb_define_method(rb_cFBODY, "head", node_head, 0);
4317
4123
  rb_ary_push(members, rb_str_new2("head"));
4318
4124
 
4319
- /* Document-method: body
4320
- * the last argument, which will be splatted onto the end of the
4321
- * fixed arguments
4125
+ /* Document-method: orig
4126
+ * the origin class
4322
4127
  */
4323
- rb_define_method(rb_cARGSCAT, "body", node_body, 0);
4324
- rb_ary_push(members, rb_str_new2("body"));
4128
+ rb_define_method(rb_cFBODY, "orig", node_orig, 0);
4129
+ rb_ary_push(members, rb_str_new2("orig"));
4130
+
4131
+ /* Document-method: mid
4132
+ * the name of the method
4133
+ */
4134
+ rb_define_method(rb_cFBODY, "mid", node_mid, 0);
4135
+ rb_ary_push(members, rb_str_new2("mid"));
4325
4136
  }
4326
4137
 
4327
- /* Document-class: Node::HASH
4328
- * Represents a hash table. Evaluation of this node creates a new Hash
4329
- * by evaluating the given expressions and placing them into the table.
4138
+ /* Document-class: Node::FCALL
4139
+ * Represents a method call in the form:
4140
+ * mid(args).
4141
+ *
4142
+ * This makes a method call on an object using self as the implicit
4143
+ * receiver.
4330
4144
  */
4331
4145
  {
4332
- VALUE rb_cHASH = rb_define_class_under(rb_cNode, "HASH", rb_cNode);
4146
+ VALUE rb_cFCALL = rb_define_class_under(rb_cNode, "FCALL", rb_cNode);
4333
4147
  members = rb_ary_new();
4334
- rb_cNodeSubclass[NODE_HASH] = rb_cHASH;
4335
- rb_iv_set(rb_cHASH, "__member__", members);
4336
- rb_iv_set(rb_cHASH, "__type__", INT2NUM(NODE_HASH));
4337
- rb_define_singleton_method(rb_cHASH, "members", node_s_members, 0);
4148
+ rb_cNodeSubclass[NODE_FCALL] = rb_cFCALL;
4149
+ rb_iv_set(rb_cFCALL, "__member__", members);
4150
+ rb_iv_set(rb_cFCALL, "__type__", INT2NUM(NODE_FCALL));
4151
+ rb_define_singleton_method(rb_cFCALL, "members", node_s_members, 0);
4338
4152
 
4339
- /* Document-method: head
4340
- * an array of successive keys and values
4153
+ /* Document-method: args
4154
+ * the arguments to the method
4341
4155
  */
4342
- rb_define_method(rb_cHASH, "head", node_head, 0);
4343
- rb_ary_push(members, rb_str_new2("head"));
4156
+ rb_define_method(rb_cFCALL, "args", node_args, 0);
4157
+ rb_ary_push(members, rb_str_new2("args"));
4158
+
4159
+ /* Document-method: mid
4160
+ * the method id
4161
+ */
4162
+ rb_define_method(rb_cFCALL, "mid", node_mid, 0);
4163
+ rb_ary_push(members, rb_str_new2("mid"));
4344
4164
  }
4345
4165
 
4346
- /* Document-class: Node::ALLOCA
4347
- * A node used for temporary allocation of memory on platforms that do
4348
- * not support alloca.
4349
- *
4350
- * It should never be evaluated as an expression.
4166
+ /* Document-class: Node::FLIP2
4167
+ * Represents part of an awk-like flip-flop expression of the form:
4168
+ * if beg..end then
4169
+ * body
4170
+ * end
4351
4171
  */
4352
- #ifdef HAVE_NODE_ALLOCA
4353
4172
  {
4354
- VALUE rb_cALLOCA = rb_define_class_under(rb_cNode, "ALLOCA", rb_cNode);
4173
+ VALUE rb_cFLIP2 = rb_define_class_under(rb_cNode, "FLIP2", rb_cNode);
4355
4174
  members = rb_ary_new();
4356
- rb_cNodeSubclass[NODE_ALLOCA] = rb_cALLOCA;
4357
- rb_iv_set(rb_cALLOCA, "__member__", members);
4358
- rb_iv_set(rb_cALLOCA, "__type__", INT2NUM(NODE_ALLOCA));
4359
- rb_define_singleton_method(rb_cALLOCA, "members", node_s_members, 0);
4175
+ rb_cNodeSubclass[NODE_FLIP2] = rb_cFLIP2;
4176
+ rb_iv_set(rb_cFLIP2, "__member__", members);
4177
+ rb_iv_set(rb_cFLIP2, "__type__", INT2NUM(NODE_FLIP2));
4178
+ rb_define_singleton_method(rb_cFLIP2, "members", node_s_members, 0);
4360
4179
 
4361
- /* Document-method: cfnc
4362
- * a pointer to the allocated memory
4180
+ /* Document-method: beg
4181
+ * the beginning of the range
4363
4182
  */
4364
- rb_define_method(rb_cALLOCA, "cfnc", node_cfnc, 0);
4365
- rb_ary_push(members, rb_str_new2("cfnc"));
4183
+ rb_define_method(rb_cFLIP2, "beg", node_beg, 0);
4184
+ rb_ary_push(members, rb_str_new2("beg"));
4366
4185
 
4367
- /* Document-method: value
4368
- * a pointer to the previously allocated temporary node
4186
+ /* Document-method: end
4187
+ * the end of the range
4369
4188
  */
4370
- rb_define_method(rb_cALLOCA, "value", node_value, 0);
4371
- rb_ary_push(members, rb_str_new2("value"));
4189
+ rb_define_method(rb_cFLIP2, "end", node_end, 0);
4190
+ rb_ary_push(members, rb_str_new2("end"));
4372
4191
 
4373
4192
  /* Document-method: cnt
4374
- * the number of bytes allocated
4193
+ * the index into the local variable table of the special variable
4194
+ * to use in the flip-flop expression (usually 2 for $_)
4375
4195
  */
4376
- rb_define_method(rb_cALLOCA, "cnt", node_cnt, 0);
4196
+ rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0);
4377
4197
  rb_ary_push(members, rb_str_new2("cnt"));
4378
4198
  }
4379
- #endif
4380
4199
 
4381
- /* Document-class: Node::OP_ASGN1
4382
- * Represents bracket assignment of the form:
4383
- * recv[index] += value or
4384
- * recv[index] ||= value or
4385
- * recv[index] &&= value.
4386
- *
4387
- * The index is obtained from args.body.
4388
- *
4389
- * The value is obtained from args.head.
4390
- *
4391
- * In the case of ||=, mid will be 0. The rhs will be equal to the
4392
- * result of evaluating args.head if the lhs is false, otherwise the
4393
- * rhs will be equal to lhs.
4394
- *
4395
- * In the case of &&=, mid will be 1. The rhs will be equal to the lhs
4396
- * if lhs is false, otherwise the rhs will be equal to the result of
4397
- * evaluating args.head. In all other cases, mid will be the name of
4398
- * the method to call to calculate value, such that the expression is
4399
- * equivalent to:
4400
- * recv[args.body] = recv[args.body].mid(args.head)
4401
- *
4402
- * In no case does ruby short-circuit the assignment.
4200
+ /* Document-class: Node::FLIP3
4201
+ * Represents part of a sed-like flip-flop expression of the form:
4202
+ * if beg..end then
4203
+ * body
4204
+ * end
4403
4205
  */
4404
4206
  {
4405
- VALUE rb_cOP_ASGN1 = rb_define_class_under(rb_cNode, "OP_ASGN1", rb_cNode);
4207
+ VALUE rb_cFLIP3 = rb_define_class_under(rb_cNode, "FLIP3", rb_cNode);
4406
4208
  members = rb_ary_new();
4407
- rb_cNodeSubclass[NODE_OP_ASGN1] = rb_cOP_ASGN1;
4408
- rb_iv_set(rb_cOP_ASGN1, "__member__", members);
4409
- rb_iv_set(rb_cOP_ASGN1, "__type__", INT2NUM(NODE_OP_ASGN1));
4410
- rb_define_singleton_method(rb_cOP_ASGN1, "members", node_s_members, 0);
4209
+ rb_cNodeSubclass[NODE_FLIP3] = rb_cFLIP3;
4210
+ rb_iv_set(rb_cFLIP3, "__member__", members);
4211
+ rb_iv_set(rb_cFLIP3, "__type__", INT2NUM(NODE_FLIP3));
4212
+ rb_define_singleton_method(rb_cFLIP3, "members", node_s_members, 0);
4411
4213
 
4412
- /* Document-method: args
4413
- * the arguments to the assigment
4214
+ /* Document-method: beg
4215
+ * the beginning of the range
4414
4216
  */
4415
- rb_define_method(rb_cOP_ASGN1, "args", node_args, 0);
4416
- rb_ary_push(members, rb_str_new2("args"));
4217
+ rb_define_method(rb_cFLIP3, "beg", node_beg, 0);
4218
+ rb_ary_push(members, rb_str_new2("beg"));
4417
4219
 
4418
- /* Document-method: mid
4419
- * 0, 1, or the name a method to call to calculate the value of the
4420
- * rhs
4220
+ /* Document-method: end
4221
+ * the end of the range
4421
4222
  */
4422
- rb_define_method(rb_cOP_ASGN1, "mid", node_mid, 0);
4423
- rb_ary_push(members, rb_str_new2("mid"));
4223
+ rb_define_method(rb_cFLIP3, "end", node_end, 0);
4224
+ rb_ary_push(members, rb_str_new2("end"));
4424
4225
 
4425
- /* Document-method: recv
4426
- * the receiver of the assignment
4226
+ /* Document-method: cnt
4227
+ * the index into the local variable table of the special variable
4228
+ * to use in the flip-flop expression (usually 2 for $_)
4427
4229
  */
4428
- rb_define_method(rb_cOP_ASGN1, "recv", node_recv, 0);
4429
- rb_ary_push(members, rb_str_new2("recv"));
4230
+ rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0);
4231
+ rb_ary_push(members, rb_str_new2("cnt"));
4430
4232
  }
4431
4233
 
4432
- /* Document-class: Node::CASE
4433
- * Represents the value portion of a case/end block, e.g.:
4434
- * case head
4435
- * body
4234
+ /* Document-class: Node::FOR
4235
+ * Represents a loop constructed with the 'for' keyword, e.g.:
4236
+ * for var in iter do
4237
+ * body
4436
4238
  * end
4437
- * next
4239
+ *
4240
+ * This is equivalent to:
4241
+ * iter.each do |*args|
4242
+ * assign args to var
4243
+ * body
4244
+ * end
4245
+ *
4246
+ * Except that a new block is not created.
4438
4247
  */
4439
4248
  {
4440
- VALUE rb_cCASE = rb_define_class_under(rb_cNode, "CASE", rb_cNode);
4249
+ VALUE rb_cFOR = rb_define_class_under(rb_cNode, "FOR", rb_cNode);
4441
4250
  members = rb_ary_new();
4442
- rb_cNodeSubclass[NODE_CASE] = rb_cCASE;
4443
- rb_iv_set(rb_cCASE, "__member__", members);
4444
- rb_iv_set(rb_cCASE, "__type__", INT2NUM(NODE_CASE));
4445
- rb_define_singleton_method(rb_cCASE, "members", node_s_members, 0);
4446
-
4447
- /* Document-method: head
4448
- * the value to select on
4449
- */
4450
- rb_define_method(rb_cCASE, "head", node_head, 0);
4451
- rb_ary_push(members, rb_str_new2("head"));
4251
+ rb_cNodeSubclass[NODE_FOR] = rb_cFOR;
4252
+ rb_iv_set(rb_cFOR, "__member__", members);
4253
+ rb_iv_set(rb_cFOR, "__type__", INT2NUM(NODE_FOR));
4254
+ rb_define_singleton_method(rb_cFOR, "members", node_s_members, 0);
4452
4255
 
4453
4256
  /* Document-method: body
4454
- * a linked list of nodes, each node representing a when
4455
- * conditional
4257
+ * the body of the loop
4456
4258
  */
4457
- rb_define_method(rb_cCASE, "body", node_body, 0);
4259
+ rb_define_method(rb_cFOR, "body", node_body, 0);
4458
4260
  rb_ary_push(members, rb_str_new2("body"));
4459
- rb_define_method(rb_cCASE, "next", node_next, 0);
4460
- rb_ary_push(members, rb_str_new2("next"));
4461
- }
4462
4261
 
4463
- /* Document-class: Node::CFUNC
4464
- * A placeholder for a function implemented in C.
4465
- */
4466
- {
4467
- VALUE rb_cCFUNC = rb_define_class_under(rb_cNode, "CFUNC", rb_cNode);
4468
- members = rb_ary_new();
4469
- rb_cNodeSubclass[NODE_CFUNC] = rb_cCFUNC;
4470
- rb_iv_set(rb_cCFUNC, "__member__", members);
4471
- rb_iv_set(rb_cCFUNC, "__type__", INT2NUM(NODE_CFUNC));
4472
- rb_define_singleton_method(rb_cCFUNC, "members", node_s_members, 0);
4473
- rb_define_method(rb_cCFUNC, "cfnc", node_cfnc, 0);
4474
- rb_ary_push(members, rb_str_new2("cfnc"));
4475
- rb_define_method(rb_cCFUNC, "argc", node_argc, 0);
4476
- rb_ary_push(members, rb_str_new2("argc"));
4262
+ /* Document-method: iter
4263
+ * the sequence over which to iterate
4264
+ */
4265
+ rb_define_method(rb_cFOR, "iter", node_iter, 0);
4266
+ rb_ary_push(members, rb_str_new2("iter"));
4267
+
4268
+ /* Document-method: var
4269
+ * an assignment node which assigns the next value in the sequence
4270
+ * to a variable, which may or may not be local. May also be a
4271
+ * multiple assignment.
4272
+ */
4273
+ rb_define_method(rb_cFOR, "var", node_var, 0);
4274
+ rb_ary_push(members, rb_str_new2("var"));
4477
4275
  }
4478
4276
 
4479
- /* Document-class: Node::OP_ASGN2
4480
- * Represents attribute assignment of the form:
4481
- * recv.attr op value
4482
- *
4483
- * where recv is the receiver of the attr method, attr is the attribute
4484
- * to which to assign, op is an assignment operation (e.g. +=), and
4485
- * value is the value to assign to the attribute.
4486
- *
4487
- * The 'next' member of this class is also of type OP_ASGN2, though it
4488
- * has different members than its parent. This child node is
4489
- * documented under OP_ASGN2_ARG.
4277
+ /* Document-class: Node::GASGN
4278
+ * Represents global variable assignment.
4490
4279
  */
4491
4280
  {
4492
- VALUE rb_cOP_ASGN2 = rb_define_class_under(rb_cNode, "OP_ASGN2", rb_cNode);
4281
+ VALUE rb_cGASGN = rb_define_class_under(rb_cNode, "GASGN", rb_cNode);
4493
4282
  members = rb_ary_new();
4494
- rb_cNodeSubclass[NODE_OP_ASGN2] = rb_cOP_ASGN2;
4495
- rb_iv_set(rb_cOP_ASGN2, "__member__", members);
4496
- rb_iv_set(rb_cOP_ASGN2, "__type__", INT2NUM(NODE_OP_ASGN2));
4497
- rb_define_singleton_method(rb_cOP_ASGN2, "members", node_s_members, 0);
4498
-
4499
- /* Document-method: value
4500
- * the value to assign to the attribute
4501
- */
4502
- rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
4503
- rb_ary_push(members, rb_str_new2("value"));
4283
+ rb_cNodeSubclass[NODE_GASGN] = rb_cGASGN;
4284
+ rb_iv_set(rb_cGASGN, "__member__", members);
4285
+ rb_iv_set(rb_cGASGN, "__type__", INT2NUM(NODE_GASGN));
4286
+ rb_define_singleton_method(rb_cGASGN, "members", node_s_members, 0);
4504
4287
 
4505
- /* Document-method: next
4506
- * another node of type OP_ASGN2 which contains more information
4507
- * about the assignment operation than can fit in this node alone
4288
+ /* Document-method: value
4289
+ * an expression whose result is the new value of the global variable
4508
4290
  */
4509
- rb_define_method(rb_cOP_ASGN2, "next", node_next, 0);
4510
- rb_ary_push(members, rb_str_new2("next"));
4291
+ rb_define_method(rb_cGASGN, "value", node_value, 0);
4292
+ rb_ary_push(members, rb_str_new2("value"));
4511
4293
 
4512
- /* Document-method: recv
4513
- * the receiver of the attribute
4294
+ /* Document-method: vid
4295
+ * the name of the global variable, with a leading '$' character.
4514
4296
  */
4515
- rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0);
4516
- rb_ary_push(members, rb_str_new2("recv"));
4297
+ rb_define_method(rb_cGASGN, "vid", node_vid, 0);
4298
+ rb_ary_push(members, rb_str_new2("vid"));
4299
+ rb_define_method(rb_cGASGN, "entry", node_entry, 0);
4300
+ rb_ary_push(members, rb_str_new2("entry"));
4517
4301
  }
4518
4302
 
4519
- /* Document-class: Node::DEFS
4520
- * Represents a singleton method definition, e.g.:
4521
- * def recv.mid
4522
- * defn
4523
- * end
4303
+ /* Document-class: Node::GVAR
4304
+ * Represents global variable retrieval.
4524
4305
  */
4525
4306
  {
4526
- VALUE rb_cDEFS = rb_define_class_under(rb_cNode, "DEFS", rb_cNode);
4307
+ VALUE rb_cGVAR = rb_define_class_under(rb_cNode, "GVAR", rb_cNode);
4527
4308
  members = rb_ary_new();
4528
- rb_cNodeSubclass[NODE_DEFS] = rb_cDEFS;
4529
- rb_iv_set(rb_cDEFS, "__member__", members);
4530
- rb_iv_set(rb_cDEFS, "__type__", INT2NUM(NODE_DEFS));
4531
- rb_define_singleton_method(rb_cDEFS, "members", node_s_members, 0);
4309
+ rb_cNodeSubclass[NODE_GVAR] = rb_cGVAR;
4310
+ rb_iv_set(rb_cGVAR, "__member__", members);
4311
+ rb_iv_set(rb_cGVAR, "__type__", INT2NUM(NODE_GVAR));
4312
+ rb_define_singleton_method(rb_cGVAR, "members", node_s_members, 0);
4532
4313
 
4533
- /* Document-method: mid
4534
- * the name of the method* defn the body of the method
4314
+ /* Document-method: vid
4315
+ * the name of the global variable to retrieve, with a leading '$'
4535
4316
  */
4536
- rb_define_method(rb_cDEFS, "mid", node_mid, 0);
4537
- rb_ary_push(members, rb_str_new2("mid"));
4538
- rb_define_method(rb_cDEFS, "defn", node_defn, 0);
4539
- rb_ary_push(members, rb_str_new2("defn"));
4317
+ rb_define_method(rb_cGVAR, "vid", node_vid, 0);
4318
+ rb_ary_push(members, rb_str_new2("vid"));
4319
+ rb_define_method(rb_cGVAR, "entry", node_entry, 0);
4320
+ rb_ary_push(members, rb_str_new2("entry"));
4321
+ }
4540
4322
 
4541
- /* Document-method: recv
4542
- * the object to whose singleton class the new method is to be added
4323
+ /* Document-class: Node::HASH
4324
+ * Represents a hash table. Evaluation of this node creates a new Hash
4325
+ * by evaluating the given expressions and placing them into the table.
4326
+ */
4327
+ {
4328
+ VALUE rb_cHASH = rb_define_class_under(rb_cNode, "HASH", rb_cNode);
4329
+ members = rb_ary_new();
4330
+ rb_cNodeSubclass[NODE_HASH] = rb_cHASH;
4331
+ rb_iv_set(rb_cHASH, "__member__", members);
4332
+ rb_iv_set(rb_cHASH, "__type__", INT2NUM(NODE_HASH));
4333
+ rb_define_singleton_method(rb_cHASH, "members", node_s_members, 0);
4334
+
4335
+ /* Document-method: head
4336
+ * an array of successive keys and values
4543
4337
  */
4544
- rb_define_method(rb_cDEFS, "recv", node_recv, 0);
4545
- rb_ary_push(members, rb_str_new2("recv"));
4338
+ rb_define_method(rb_cHASH, "head", node_head, 0);
4339
+ rb_ary_push(members, rb_str_new2("head"));
4546
4340
  }
4547
4341
 
4548
- /* Document-class: Node::LASGN
4549
- * Represents local variable assignment.
4342
+ /* Document-class: Node::IASGN
4343
+ * Represents instance variable assignment.
4550
4344
  */
4551
4345
  {
4552
- VALUE rb_cLASGN = rb_define_class_under(rb_cNode, "LASGN", rb_cNode);
4346
+ VALUE rb_cIASGN = rb_define_class_under(rb_cNode, "IASGN", rb_cNode);
4553
4347
  members = rb_ary_new();
4554
- rb_cNodeSubclass[NODE_LASGN] = rb_cLASGN;
4555
- rb_iv_set(rb_cLASGN, "__member__", members);
4556
- rb_iv_set(rb_cLASGN, "__type__", INT2NUM(NODE_LASGN));
4557
- rb_define_singleton_method(rb_cLASGN, "members", node_s_members, 0);
4348
+ rb_cNodeSubclass[NODE_IASGN] = rb_cIASGN;
4349
+ rb_iv_set(rb_cIASGN, "__member__", members);
4350
+ rb_iv_set(rb_cIASGN, "__type__", INT2NUM(NODE_IASGN));
4351
+ rb_define_singleton_method(rb_cIASGN, "members", node_s_members, 0);
4558
4352
 
4559
4353
  /* Document-method: value
4560
- * the value to assign to the local variable
4354
+ * the value to assign to the instance variable
4561
4355
  */
4562
- rb_define_method(rb_cLASGN, "value", node_value, 0);
4356
+ rb_define_method(rb_cIASGN, "value", node_value, 0);
4563
4357
  rb_ary_push(members, rb_str_new2("value"));
4564
4358
 
4565
4359
  /* Document-method: vid
4566
- * the name of the local variable
4360
+ * the name of the instance variable, with a leading '@' sign
4567
4361
  */
4568
- rb_define_method(rb_cLASGN, "vid", node_vid, 0);
4362
+ rb_define_method(rb_cIASGN, "vid", node_vid, 0);
4569
4363
  rb_ary_push(members, rb_str_new2("vid"));
4570
- rb_define_method(rb_cLASGN, "cnt", node_cnt, 0);
4571
- rb_ary_push(members, rb_str_new2("cnt"));
4572
4364
  }
4573
4365
 
4574
- /* Document-class: Node::POSTEXE
4575
- * Represents the END keyword, e.g.:
4576
- * END { ... }
4366
+ /* Document-class: Node::IF
4367
+ * Represents a conditional of the form:
4368
+ * if cond then
4369
+ * body
4370
+ * end
4577
4371
  *
4578
- * Indicating that the enclosing ITER node is to be excecuted only
4579
- * once, when the program terminates.
4372
+ * or the form:
4373
+ * if cond then
4374
+ * body
4375
+ * else
4376
+ * else
4377
+ * end
4378
+ *
4379
+ * The condition is first evaluated. If it is true, then body is
4380
+ * evaluated, otherwise else is evaluated. The result is the value of
4381
+ * the expression evaluated, or nil if there was no expression
4382
+ * present.
4383
+ *
4384
+ * A conditional block using elsif has another IF node as the else
4385
+ * expression.
4580
4386
  */
4581
4387
  {
4582
- VALUE rb_cPOSTEXE = rb_define_class_under(rb_cNode, "POSTEXE", rb_cNode);
4388
+ VALUE rb_cIF = rb_define_class_under(rb_cNode, "IF", rb_cNode);
4583
4389
  members = rb_ary_new();
4584
- rb_cNodeSubclass[NODE_POSTEXE] = rb_cPOSTEXE;
4585
- rb_iv_set(rb_cPOSTEXE, "__member__", members);
4586
- rb_iv_set(rb_cPOSTEXE, "__type__", INT2NUM(NODE_POSTEXE));
4587
- rb_define_singleton_method(rb_cPOSTEXE, "members", node_s_members, 0);
4588
- }
4390
+ rb_cNodeSubclass[NODE_IF] = rb_cIF;
4391
+ rb_iv_set(rb_cIF, "__member__", members);
4392
+ rb_iv_set(rb_cIF, "__type__", INT2NUM(NODE_IF));
4393
+ rb_define_singleton_method(rb_cIF, "members", node_s_members, 0);
4589
4394
 
4590
- /* Document-class: Node::STR
4591
- * Represents a string object. Duplicates the string stored in the
4592
- * node.
4593
- */
4594
- {
4595
- VALUE rb_cSTR = rb_define_class_under(rb_cNode, "STR", rb_cNode);
4596
- members = rb_ary_new();
4597
- rb_cNodeSubclass[NODE_STR] = rb_cSTR;
4598
- rb_iv_set(rb_cSTR, "__member__", members);
4599
- rb_iv_set(rb_cSTR, "__type__", INT2NUM(NODE_STR));
4600
- rb_define_singleton_method(rb_cSTR, "members", node_s_members, 0);
4395
+ /* Document-method: cond
4396
+ * the condition to evaluate
4397
+ */
4398
+ rb_define_method(rb_cIF, "cond", node_cond, 0);
4399
+ rb_ary_push(members, rb_str_new2("cond"));
4601
4400
 
4602
- /* Document-method: lit
4603
- * the string to be duplicated
4401
+ /* Document-method: body
4402
+ * the expression to evaluate if the expression is true, or false
4403
+ * if the expression is empty
4604
4404
  */
4605
- rb_define_method(rb_cSTR, "lit", node_lit, 0);
4606
- rb_ary_push(members, rb_str_new2("lit"));
4405
+ rb_define_method(rb_cIF, "body", node_body, 0);
4406
+ rb_ary_push(members, rb_str_new2("body"));
4407
+
4408
+ /* Document-method: else
4409
+ * the expression to evaluate if the expression is false, or false
4410
+ * if the expression is empty
4411
+ */
4412
+ rb_define_method(rb_cIF, "else", node_else, 0);
4413
+ rb_ary_push(members, rb_str_new2("else"));
4607
4414
  }
4608
4415
 
4609
- /* Document-class: Node::ATTRSET
4610
- * A placeholder for an attribute writer method, which can added to a
4611
- * class by using attr_writer:
4612
- * attr_writer :attribute
4613
- * Its reader counterpart is IVAR.
4416
+ /* Document-class: Node::IFUNC
4417
+ * A temporary node used in iteration.
4614
4418
  */
4615
4419
  {
4616
- VALUE rb_cATTRSET = rb_define_class_under(rb_cNode, "ATTRSET", rb_cNode);
4420
+ VALUE rb_cIFUNC = rb_define_class_under(rb_cNode, "IFUNC", rb_cNode);
4617
4421
  members = rb_ary_new();
4618
- rb_cNodeSubclass[NODE_ATTRSET] = rb_cATTRSET;
4619
- rb_iv_set(rb_cATTRSET, "__member__", members);
4620
- rb_iv_set(rb_cATTRSET, "__type__", INT2NUM(NODE_ATTRSET));
4621
- rb_define_singleton_method(rb_cATTRSET, "members", node_s_members, 0);
4422
+ rb_cNodeSubclass[NODE_IFUNC] = rb_cIFUNC;
4423
+ rb_iv_set(rb_cIFUNC, "__member__", members);
4424
+ rb_iv_set(rb_cIFUNC, "__type__", INT2NUM(NODE_IFUNC));
4425
+ rb_define_singleton_method(rb_cIFUNC, "members", node_s_members, 0);
4622
4426
 
4623
- /* Document-method: vid
4624
- * the name of the attribute, with a leading '@' sign
4427
+ /* Document-method: cfnc
4428
+ * a pointer to the C function to which to yield
4625
4429
  */
4626
- rb_define_method(rb_cATTRSET, "vid", node_vid, 0);
4627
- rb_ary_push(members, rb_str_new2("vid"));
4430
+ rb_define_method(rb_cIFUNC, "cfnc", node_cfnc, 0);
4431
+ rb_ary_push(members, rb_str_new2("cfnc"));
4432
+
4433
+ /* Document-method: tval
4434
+ * the user-specified data to be passed as the second argument to
4435
+ * cfnc
4436
+ */
4437
+ rb_define_method(rb_cIFUNC, "tval", node_tval, 0);
4438
+ rb_ary_push(members, rb_str_new2("tval"));
4439
+
4440
+ /* Document-method: state
4441
+ * always 0
4442
+ */
4443
+ rb_define_method(rb_cIFUNC, "state", node_state, 0);
4444
+ rb_ary_push(members, rb_str_new2("state"));
4628
4445
  }
4629
4446
 
4630
- /* Document-class: Node::UNDEF
4631
- * Represents an expression using the undef keyword, e.g.:
4632
- * undef :mid
4447
+ /* Document-class: Node::ITER
4448
+ * Represents an iteration loop, e.g.:
4449
+ * iter do |*args|
4450
+ * assign args to var
4451
+ * body
4452
+ * end
4633
4453
  *
4634
- * This causes the method identified by mid in the current class to be
4635
- * undefined.
4454
+ * A new block is created so that dynamic variables created inside the
4455
+ * loop do not persist once the loop has terminated.
4456
+ *
4457
+ * If the iter node is a POSTEXE node, indicates that the expression
4458
+ * should be evaluated when the program terminates.
4636
4459
  */
4637
4460
  {
4638
- VALUE rb_cUNDEF = rb_define_class_under(rb_cNode, "UNDEF", rb_cNode);
4461
+ VALUE rb_cITER = rb_define_class_under(rb_cNode, "ITER", rb_cNode);
4639
4462
  members = rb_ary_new();
4640
- rb_cNodeSubclass[NODE_UNDEF] = rb_cUNDEF;
4641
- rb_iv_set(rb_cUNDEF, "__member__", members);
4642
- rb_iv_set(rb_cUNDEF, "__type__", INT2NUM(NODE_UNDEF));
4643
- rb_define_singleton_method(rb_cUNDEF, "members", node_s_members, 0);
4463
+ rb_cNodeSubclass[NODE_ITER] = rb_cITER;
4464
+ rb_iv_set(rb_cITER, "__member__", members);
4465
+ rb_iv_set(rb_cITER, "__type__", INT2NUM(NODE_ITER));
4466
+ rb_define_singleton_method(rb_cITER, "members", node_s_members, 0);
4644
4467
 
4645
4468
  /* Document-method: body
4646
- * an expression returning the id of the method to undefine
4469
+ * the body of the loop
4647
4470
  */
4648
- rb_define_method(rb_cUNDEF, "body", node_body, 0);
4471
+ rb_define_method(rb_cITER, "body", node_body, 0);
4649
4472
  rb_ary_push(members, rb_str_new2("body"));
4650
- }
4651
4473
 
4652
- /* Document-class: Node::MEMO
4653
- * A node used for temporary storage.
4654
- *
4655
- * It is used by the rb_protect function so that the cont_protect
4656
- * variable can be restored when the function returns.
4657
- *
4658
- * It is also used in the Enumerable module and by autoload as a
4659
- * temporary placeholder.
4660
- *
4661
- * It should never be evaluated as an expression.
4662
- *
4663
- * It holds up to three nodes or ruby objects, depending on how it is
4664
- * used.
4474
+ /* Document-method: iter
4475
+ * an expression which calls the desired iteration method, usually
4476
+ * recv.each
4477
+ */
4478
+ rb_define_method(rb_cITER, "iter", node_iter, 0);
4479
+ rb_ary_push(members, rb_str_new2("iter"));
4480
+
4481
+ /* Document-method: var
4482
+ * an assignment node which assigns the next value in the sequence
4483
+ * to a variable, which may or may not be local. May also be a
4484
+ * multiple assignment.
4485
+ */
4486
+ rb_define_method(rb_cITER, "var", node_var, 0);
4487
+ rb_ary_push(members, rb_str_new2("var"));
4488
+ }
4489
+
4490
+ /* Document-class: Node::IVAR
4491
+ * A placeholder for an attribute reader method, which can added to a
4492
+ * class by using attr_reader:
4493
+ * attr_reader :attribute
4494
+ * Its writer counterpart is ATTRSET.
4665
4495
  */
4666
4496
  {
4667
- VALUE rb_cMEMO = rb_define_class_under(rb_cNode, "MEMO", rb_cNode);
4497
+ VALUE rb_cIVAR = rb_define_class_under(rb_cNode, "IVAR", rb_cNode);
4668
4498
  members = rb_ary_new();
4669
- rb_cNodeSubclass[NODE_MEMO] = rb_cMEMO;
4670
- rb_iv_set(rb_cMEMO, "__member__", members);
4671
- rb_iv_set(rb_cMEMO, "__type__", INT2NUM(NODE_MEMO));
4672
- rb_define_singleton_method(rb_cMEMO, "members", node_s_members, 0);
4499
+ rb_cNodeSubclass[NODE_IVAR] = rb_cIVAR;
4500
+ rb_iv_set(rb_cIVAR, "__member__", members);
4501
+ rb_iv_set(rb_cIVAR, "__type__", INT2NUM(NODE_IVAR));
4502
+ rb_define_singleton_method(rb_cIVAR, "members", node_s_members, 0);
4503
+
4504
+ /* Document-method: vid
4505
+ * the name of the attribute, with a leading '@' sign
4506
+ */
4507
+ rb_define_method(rb_cIVAR, "vid", node_vid, 0);
4508
+ rb_ary_push(members, rb_str_new2("vid"));
4673
4509
  }
4674
4510
 
4675
- /* Document-class: Node::TO_ARY
4676
- * Represents a conversion from one object type to an array type.
4677
- * Evaluation of this node converts its argument to an array by calling
4678
- * \#to_ary on the argument.
4511
+ /* Document-class: Node::LASGN
4512
+ * Represents local variable assignment.
4679
4513
  */
4680
4514
  {
4681
- VALUE rb_cTO_ARY = rb_define_class_under(rb_cNode, "TO_ARY", rb_cNode);
4515
+ VALUE rb_cLASGN = rb_define_class_under(rb_cNode, "LASGN", rb_cNode);
4682
4516
  members = rb_ary_new();
4683
- rb_cNodeSubclass[NODE_TO_ARY] = rb_cTO_ARY;
4684
- rb_iv_set(rb_cTO_ARY, "__member__", members);
4685
- rb_iv_set(rb_cTO_ARY, "__type__", INT2NUM(NODE_TO_ARY));
4686
- rb_define_singleton_method(rb_cTO_ARY, "members", node_s_members, 0);
4517
+ rb_cNodeSubclass[NODE_LASGN] = rb_cLASGN;
4518
+ rb_iv_set(rb_cLASGN, "__member__", members);
4519
+ rb_iv_set(rb_cLASGN, "__type__", INT2NUM(NODE_LASGN));
4520
+ rb_define_singleton_method(rb_cLASGN, "members", node_s_members, 0);
4687
4521
 
4688
- /* Document-method: head
4689
- * the object to convert to an array
4522
+ /* Document-method: value
4523
+ * the value to assign to the local variable
4690
4524
  */
4691
- rb_define_method(rb_cTO_ARY, "head", node_head, 0);
4692
- rb_ary_push(members, rb_str_new2("head"));
4525
+ rb_define_method(rb_cLASGN, "value", node_value, 0);
4526
+ rb_ary_push(members, rb_str_new2("value"));
4527
+
4528
+ /* Document-method: vid
4529
+ * the name of the local variable
4530
+ */
4531
+ rb_define_method(rb_cLASGN, "vid", node_vid, 0);
4532
+ rb_ary_push(members, rb_str_new2("vid"));
4533
+ rb_define_method(rb_cLASGN, "cnt", node_cnt, 0);
4534
+ rb_ary_push(members, rb_str_new2("cnt"));
4693
4535
  }
4694
4536
 
4695
- /* Document-class: Node::XSTR
4696
- * Represents a string object inside backticks, e.g.:
4697
- * `lit`
4698
- * The given string is executed in a subshell and the output from its
4699
- * stdout stored in a string.
4537
+ /* Document-class: Node::LIT
4538
+ * Represents a literal object. The result of the expression is the
4539
+ * object contained in this node.
4700
4540
  */
4701
4541
  {
4702
- VALUE rb_cXSTR = rb_define_class_under(rb_cNode, "XSTR", rb_cNode);
4542
+ VALUE rb_cLIT = rb_define_class_under(rb_cNode, "LIT", rb_cNode);
4703
4543
  members = rb_ary_new();
4704
- rb_cNodeSubclass[NODE_XSTR] = rb_cXSTR;
4705
- rb_iv_set(rb_cXSTR, "__member__", members);
4706
- rb_iv_set(rb_cXSTR, "__type__", INT2NUM(NODE_XSTR));
4707
- rb_define_singleton_method(rb_cXSTR, "members", node_s_members, 0);
4544
+ rb_cNodeSubclass[NODE_LIT] = rb_cLIT;
4545
+ rb_iv_set(rb_cLIT, "__member__", members);
4546
+ rb_iv_set(rb_cLIT, "__type__", INT2NUM(NODE_LIT));
4547
+ rb_define_singleton_method(rb_cLIT, "members", node_s_members, 0);
4708
4548
 
4709
4549
  /* Document-method: lit
4710
- * the string to be executed
4550
+ * the object
4711
4551
  */
4712
- rb_define_method(rb_cXSTR, "lit", node_lit, 0);
4552
+ rb_define_method(rb_cLIT, "lit", node_lit, 0);
4713
4553
  rb_ary_push(members, rb_str_new2("lit"));
4714
4554
  }
4715
4555
 
4716
- /* Document-class: Node::RESBODY
4717
- * Represents the rescue portion of a rescue expression (see RESCUE for
4718
- * examples).
4719
- *
4720
- * If the head node of the rescue expresion raises an exception, the
4721
- * resq node is evaluated. The resq node is of type RESBDOY.
4722
- *
4723
- * As it is evaluated, the type of the exception is tested against the
4724
- * class(es) listed in the args node. If there is a match, the body
4725
- * node is evaluated, otherwise the head node is evaluated. The head
4726
- * node is either another RESBDOY node or false (0).
4556
+ /* Document-class: Node::LVAR
4557
+ * Represents local variable retrieval.
4727
4558
  */
4728
4559
  {
4729
- VALUE rb_cRESBODY = rb_define_class_under(rb_cNode, "RESBODY", rb_cNode);
4560
+ VALUE rb_cLVAR = rb_define_class_under(rb_cNode, "LVAR", rb_cNode);
4730
4561
  members = rb_ary_new();
4731
- rb_cNodeSubclass[NODE_RESBODY] = rb_cRESBODY;
4732
- rb_iv_set(rb_cRESBODY, "__member__", members);
4733
- rb_iv_set(rb_cRESBODY, "__type__", INT2NUM(NODE_RESBODY));
4734
- rb_define_singleton_method(rb_cRESBODY, "members", node_s_members, 0);
4735
-
4736
- /* Document-method: head
4737
- * the next rescue
4738
- */
4739
- rb_define_method(rb_cRESBODY, "head", node_head, 0);
4740
- rb_ary_push(members, rb_str_new2("head"));
4741
-
4742
- /* Document-method: args
4743
- * the expression type to match against
4744
- */
4745
- rb_define_method(rb_cRESBODY, "args", node_args, 0);
4746
- rb_ary_push(members, rb_str_new2("args"));
4562
+ rb_cNodeSubclass[NODE_LVAR] = rb_cLVAR;
4563
+ rb_iv_set(rb_cLVAR, "__member__", members);
4564
+ rb_iv_set(rb_cLVAR, "__type__", INT2NUM(NODE_LVAR));
4565
+ rb_define_singleton_method(rb_cLVAR, "members", node_s_members, 0);
4747
4566
 
4748
- /* Document-method: body
4749
- * the expresion to evaluate if the exception type matches
4567
+ /* Document-method: vid
4568
+ * the name of the local variable to retrieve.
4750
4569
  */
4751
- rb_define_method(rb_cRESBODY, "body", node_body, 0);
4752
- rb_ary_push(members, rb_str_new2("body"));
4570
+ rb_define_method(rb_cLVAR, "vid", node_vid, 0);
4571
+ rb_ary_push(members, rb_str_new2("vid"));
4572
+ rb_define_method(rb_cLVAR, "cnt", node_cnt, 0);
4573
+ rb_ary_push(members, rb_str_new2("cnt"));
4753
4574
  }
4754
4575
 
4755
- /* Document-class: Node::ALIAS
4756
- * Represents an alias expression of the form:
4757
- * alias 1st 2nd
4758
- * where 2nd is the name of an existing method and 1st is the name of
4759
- * its new alias.
4576
+ /* Document-class: Node::MASGN
4577
+ * Represents multiple assignment.
4760
4578
  */
4761
4579
  {
4762
- VALUE rb_cALIAS = rb_define_class_under(rb_cNode, "ALIAS", rb_cNode);
4580
+ VALUE rb_cMASGN = rb_define_class_under(rb_cNode, "MASGN", rb_cNode);
4763
4581
  members = rb_ary_new();
4764
- rb_cNodeSubclass[NODE_ALIAS] = rb_cALIAS;
4765
- rb_iv_set(rb_cALIAS, "__member__", members);
4766
- rb_iv_set(rb_cALIAS, "__type__", INT2NUM(NODE_ALIAS));
4767
- rb_define_singleton_method(rb_cALIAS, "members", node_s_members, 0);
4768
- rb_define_method(rb_cALIAS, "first", node_1st, 0);
4769
- rb_ary_push(members, rb_str_new2("first"));
4770
- rb_define_method(rb_cALIAS, "second", node_2nd, 0);
4771
- rb_ary_push(members, rb_str_new2("second"));
4772
- }
4582
+ rb_cNodeSubclass[NODE_MASGN] = rb_cMASGN;
4583
+ rb_iv_set(rb_cMASGN, "__member__", members);
4584
+ rb_iv_set(rb_cMASGN, "__type__", INT2NUM(NODE_MASGN));
4585
+ rb_define_singleton_method(rb_cMASGN, "members", node_s_members, 0);
4773
4586
 
4774
- /* Document-class: Node::ARRAY
4775
- * Represents an array of elements. Evaluation of this node creates a
4776
- * new Array by evalating the given expressions and placing them into
4777
- * the array.
4778
- */
4779
- {
4780
- VALUE rb_cARRAY = rb_define_class_under(rb_cNode, "ARRAY", rb_cNode);
4781
- members = rb_ary_new();
4782
- rb_cNodeSubclass[NODE_ARRAY] = rb_cARRAY;
4783
- rb_iv_set(rb_cARRAY, "__member__", members);
4784
- rb_iv_set(rb_cARRAY, "__type__", INT2NUM(NODE_ARRAY));
4785
- rb_define_singleton_method(rb_cARRAY, "members", node_s_members, 0);
4587
+ /* Document-method: args
4588
+ * TODO
4589
+ */
4590
+ rb_define_method(rb_cMASGN, "args", node_args, 0);
4591
+ rb_ary_push(members, rb_str_new2("args"));
4786
4592
 
4787
4593
  /* Document-method: head
4788
- * the first element of the array
4594
+ * TODO
4789
4595
  */
4790
- rb_define_method(rb_cARRAY, "head", node_head, 0);
4596
+ rb_define_method(rb_cMASGN, "head", node_head, 0);
4791
4597
  rb_ary_push(members, rb_str_new2("head"));
4792
- rb_define_method(rb_cARRAY, "alen", node_alen, 0);
4793
- rb_ary_push(members, rb_str_new2("alen"));
4794
4598
 
4795
- /* Document-method: next
4796
- * the tail of the array
4599
+ /* Document-method: value
4600
+ * TODO
4797
4601
  */
4798
- rb_define_method(rb_cARRAY, "next", node_next, 0);
4799
- rb_ary_push(members, rb_str_new2("next"));
4602
+ rb_define_method(rb_cMASGN, "value", node_value, 0);
4603
+ rb_ary_push(members, rb_str_new2("value"));
4800
4604
  }
4801
4605
 
4802
- /* Document-class: Node::NEXT
4803
- * Represents the 'next' keyword.
4804
- * Causes control to be transferred to the end of the loop, causing the
4805
- * next value in the sequence to be retrieved.
4606
+ /* Document-class: Node::MATCH
4607
+ * Represents a regular expression match in a conditional, e.g.:
4608
+ * if /lit/ then
4609
+ * ...
4610
+ * end
4611
+ *
4612
+ * This expression is equivalent to:
4613
+ * if /lit/ =~ $_ then
4614
+ * ...
4615
+ * end
4616
+ *
4617
+ * On ruby 1.8 and newer, this type of expression causes ruby to emit a
4618
+ * warning, unless script is running with -e.
4806
4619
  */
4807
4620
  {
4808
- VALUE rb_cNEXT = rb_define_class_under(rb_cNode, "NEXT", rb_cNode);
4621
+ VALUE rb_cMATCH = rb_define_class_under(rb_cNode, "MATCH", rb_cNode);
4809
4622
  members = rb_ary_new();
4810
- rb_cNodeSubclass[NODE_NEXT] = rb_cNEXT;
4811
- rb_iv_set(rb_cNEXT, "__member__", members);
4812
- rb_iv_set(rb_cNEXT, "__type__", INT2NUM(NODE_NEXT));
4813
- rb_define_singleton_method(rb_cNEXT, "members", node_s_members, 0);
4814
- rb_define_method(rb_cNEXT, "stts", node_stts, 0);
4815
- rb_ary_push(members, rb_str_new2("stts"));
4623
+ rb_cNodeSubclass[NODE_MATCH] = rb_cMATCH;
4624
+ rb_iv_set(rb_cMATCH, "__member__", members);
4625
+ rb_iv_set(rb_cMATCH, "__type__", INT2NUM(NODE_MATCH));
4626
+ rb_define_singleton_method(rb_cMATCH, "members", node_s_members, 0);
4627
+
4628
+ /* Document-method: lit
4629
+ * the regular expression to use in the condition.
4630
+ */
4631
+ rb_define_method(rb_cMATCH, "lit", node_lit, 0);
4632
+ rb_ary_push(members, rb_str_new2("lit"));
4633
+
4634
+ /* Document-method: value
4635
+ * the value to compare against
4636
+ */
4637
+ rb_define_method(rb_cMATCH, "value", node_value, 0);
4638
+ rb_ary_push(members, rb_str_new2("value"));
4816
4639
  }
4817
4640
 
4818
- /* Document-class: Node::GASGN
4819
- * Represents global variable assignment.
4641
+ /* Document-class: Node::MATCH2
4642
+ * Represents a match in a conditional with a regular expression using
4643
+ * interpolation, e.g.:
4644
+ * if /#{recv}/ then
4645
+ * ...
4646
+ * end
4647
+ *
4648
+ * which is equivalent to:
4649
+ * if /#{recv}/ =~ $_ then
4650
+ * ...
4651
+ * end
4652
+ *
4653
+ * or a match with a regular expression on the left hand side and an
4654
+ * expression on the right hand side, e.g.:
4655
+ *
4656
+ * /recv/ =~ value
4820
4657
  */
4821
4658
  {
4822
- VALUE rb_cGASGN = rb_define_class_under(rb_cNode, "GASGN", rb_cNode);
4659
+ VALUE rb_cMATCH2 = rb_define_class_under(rb_cNode, "MATCH2", rb_cNode);
4823
4660
  members = rb_ary_new();
4824
- rb_cNodeSubclass[NODE_GASGN] = rb_cGASGN;
4825
- rb_iv_set(rb_cGASGN, "__member__", members);
4826
- rb_iv_set(rb_cGASGN, "__type__", INT2NUM(NODE_GASGN));
4827
- rb_define_singleton_method(rb_cGASGN, "members", node_s_members, 0);
4661
+ rb_cNodeSubclass[NODE_MATCH2] = rb_cMATCH2;
4662
+ rb_iv_set(rb_cMATCH2, "__member__", members);
4663
+ rb_iv_set(rb_cMATCH2, "__type__", INT2NUM(NODE_MATCH2));
4664
+ rb_define_singleton_method(rb_cMATCH2, "members", node_s_members, 0);
4828
4665
 
4829
4666
  /* Document-method: value
4830
- * an expression whose result is the new value of the global variable
4667
+ * the expression on the right hand side of the match operator, or
4668
+ * an expression returning $_ if there is nothing on the right hand
4669
+ * side
4831
4670
  */
4832
- rb_define_method(rb_cGASGN, "value", node_value, 0);
4671
+ rb_define_method(rb_cMATCH2, "value", node_value, 0);
4833
4672
  rb_ary_push(members, rb_str_new2("value"));
4834
4673
 
4835
- /* Document-method: vid
4836
- * the name of the global variable, with a leading '$' character.
4674
+ /* Document-method: recv
4675
+ * the regular expression on the left hand side of the match
4676
+ * operator
4837
4677
  */
4838
- rb_define_method(rb_cGASGN, "vid", node_vid, 0);
4839
- rb_ary_push(members, rb_str_new2("vid"));
4840
- rb_define_method(rb_cGASGN, "entry", node_entry, 0);
4841
- rb_ary_push(members, rb_str_new2("entry"));
4678
+ rb_define_method(rb_cMATCH2, "recv", node_recv, 0);
4679
+ rb_ary_push(members, rb_str_new2("recv"));
4842
4680
  }
4843
4681
 
4844
- /* Document-class: Node::CVDECL
4845
- * Represents class variable assignment in a class context.
4682
+ /* Document-class: Node::MATCH3
4683
+ * Represents a regular expression match of the form:
4684
+ * recv =~ /value/
4846
4685
  *
4847
- * A warning is emitted if the variable already exists.
4686
+ * where recv is an expression that returns an object and value is a
4687
+ * regular expression literal.
4848
4688
  */
4849
4689
  {
4850
- VALUE rb_cCVDECL = rb_define_class_under(rb_cNode, "CVDECL", rb_cNode);
4690
+ VALUE rb_cMATCH3 = rb_define_class_under(rb_cNode, "MATCH3", rb_cNode);
4851
4691
  members = rb_ary_new();
4852
- rb_cNodeSubclass[NODE_CVDECL] = rb_cCVDECL;
4853
- rb_iv_set(rb_cCVDECL, "__member__", members);
4854
- rb_iv_set(rb_cCVDECL, "__type__", INT2NUM(NODE_CVDECL));
4855
- rb_define_singleton_method(rb_cCVDECL, "members", node_s_members, 0);
4692
+ rb_cNodeSubclass[NODE_MATCH3] = rb_cMATCH3;
4693
+ rb_iv_set(rb_cMATCH3, "__member__", members);
4694
+ rb_iv_set(rb_cMATCH3, "__type__", INT2NUM(NODE_MATCH3));
4695
+ rb_define_singleton_method(rb_cMATCH3, "members", node_s_members, 0);
4856
4696
 
4857
4697
  /* Document-method: value
4858
- * an expression whose result is the new value of the class
4859
- * variable
4698
+ * the right hand side of the match
4860
4699
  */
4861
- rb_define_method(rb_cCVDECL, "value", node_value, 0);
4700
+ rb_define_method(rb_cMATCH3, "value", node_value, 0);
4862
4701
  rb_ary_push(members, rb_str_new2("value"));
4863
4702
 
4864
- /* Document-method: vid
4865
- * the name of the class variable to assign
4703
+ /* Document-method: recv
4704
+ * the left hand side of the match
4866
4705
  */
4867
- rb_define_method(rb_cCVDECL, "vid", node_vid, 0);
4868
- rb_ary_push(members, rb_str_new2("vid"));
4706
+ rb_define_method(rb_cMATCH3, "recv", node_recv, 0);
4707
+ rb_ary_push(members, rb_str_new2("recv"));
4869
4708
  }
4870
4709
 
4871
- /* Document-class: Node::ATTRASGN
4872
- * Represents attribute assignment in the form:
4873
- * recv.mid = args
4874
- * or:
4875
- * recv.mid=(args).
4710
+ /* Document-class: Node::MEMO
4711
+ * A node used for temporary storage.
4712
+ *
4713
+ * It is used by the rb_protect function so that the cont_protect
4714
+ * variable can be restored when the function returns.
4715
+ *
4716
+ * It is also used in the Enumerable module and by autoload as a
4717
+ * temporary placeholder.
4718
+ *
4719
+ * It should never be evaluated as an expression.
4720
+ *
4721
+ * It holds up to three nodes or ruby objects, depending on how it is
4722
+ * used.
4876
4723
  */
4877
4724
  {
4878
- VALUE rb_cATTRASGN = rb_define_class_under(rb_cNode, "ATTRASGN", rb_cNode);
4725
+ VALUE rb_cMEMO = rb_define_class_under(rb_cNode, "MEMO", rb_cNode);
4879
4726
  members = rb_ary_new();
4880
- rb_cNodeSubclass[NODE_ATTRASGN] = rb_cATTRASGN;
4881
- rb_iv_set(rb_cATTRASGN, "__member__", members);
4882
- rb_iv_set(rb_cATTRASGN, "__type__", INT2NUM(NODE_ATTRASGN));
4883
- rb_define_singleton_method(rb_cATTRASGN, "members", node_s_members, 0);
4727
+ rb_cNodeSubclass[NODE_MEMO] = rb_cMEMO;
4728
+ rb_iv_set(rb_cMEMO, "__member__", members);
4729
+ rb_iv_set(rb_cMEMO, "__type__", INT2NUM(NODE_MEMO));
4730
+ rb_define_singleton_method(rb_cMEMO, "members", node_s_members, 0);
4731
+ }
4884
4732
 
4885
- /* Document-method: args
4886
- * the arguments to the method
4887
- */
4888
- rb_define_method(rb_cATTRASGN, "args", node_args, 0);
4889
- rb_ary_push(members, rb_str_new2("args"));
4733
+ /* Document-class: Node::METHOD
4734
+ * A placeholder for a method entry in a class's method table.
4735
+ */
4736
+ {
4737
+ VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode);
4738
+ members = rb_ary_new();
4739
+ rb_cNodeSubclass[NODE_METHOD] = rb_cMETHOD;
4740
+ rb_iv_set(rb_cMETHOD, "__member__", members);
4741
+ rb_iv_set(rb_cMETHOD, "__type__", INT2NUM(NODE_METHOD));
4742
+ rb_define_singleton_method(rb_cMETHOD, "members", node_s_members, 0);
4890
4743
 
4891
- /* Document-method: mid
4892
- * the id of the attribute, with a trailing '=' sign
4744
+ /* Document-method: body
4745
+ * the body of the method
4893
4746
  */
4894
- rb_define_method(rb_cATTRASGN, "mid", node_mid, 0);
4895
- rb_ary_push(members, rb_str_new2("mid"));
4747
+ rb_define_method(rb_cMETHOD, "body", node_body, 0);
4748
+ rb_ary_push(members, rb_str_new2("body"));
4896
4749
 
4897
- /* Document-method: recv
4898
- * the receiver of the method
4750
+ /* Document-method: noex
4751
+ * the method's flags
4899
4752
  */
4900
- rb_define_method(rb_cATTRASGN, "recv", node_recv, 0);
4901
- rb_ary_push(members, rb_str_new2("recv"));
4753
+ rb_define_method(rb_cMETHOD, "noex", node_noex, 0);
4754
+ rb_ary_push(members, rb_str_new2("noex"));
4902
4755
  }
4903
4756
 
4904
- /* Document-class: Node::BREAK
4905
- * Represents the 'break' keyword. Causes control to be transferred
4906
- * out of the current loop.
4757
+ /* Document-class: Node::MODULE
4758
+ * Represents a module definition, e.g.:
4759
+ * module cpath
4760
+ * body
4761
+ * end
4762
+ *
4763
+ * The module definition is evaluated in a new lexical scope.
4764
+ *
4765
+ * The result of the expression is the last expression evaluated in the
4766
+ * body.
4907
4767
  */
4908
4768
  {
4909
- VALUE rb_cBREAK = rb_define_class_under(rb_cNode, "BREAK", rb_cNode);
4769
+ VALUE rb_cMODULE = rb_define_class_under(rb_cNode, "MODULE", rb_cNode);
4910
4770
  members = rb_ary_new();
4911
- rb_cNodeSubclass[NODE_BREAK] = rb_cBREAK;
4912
- rb_iv_set(rb_cBREAK, "__member__", members);
4913
- rb_iv_set(rb_cBREAK, "__type__", INT2NUM(NODE_BREAK));
4914
- rb_define_singleton_method(rb_cBREAK, "members", node_s_members, 0);
4771
+ rb_cNodeSubclass[NODE_MODULE] = rb_cMODULE;
4772
+ rb_iv_set(rb_cMODULE, "__member__", members);
4773
+ rb_iv_set(rb_cMODULE, "__type__", INT2NUM(NODE_MODULE));
4774
+ rb_define_singleton_method(rb_cMODULE, "members", node_s_members, 0);
4915
4775
 
4916
- /* Document-method: stts
4917
- * the value to be used as the "return" value of the loop, 0 if nil is to be used.
4776
+ /* Document-method: cpath
4777
+ * the name of the module to define
4918
4778
  */
4919
- rb_define_method(rb_cBREAK, "stts", node_stts, 0);
4920
- rb_ary_push(members, rb_str_new2("stts"));
4779
+ rb_define_method(rb_cMODULE, "cpath", node_cpath, 0);
4780
+ rb_ary_push(members, rb_str_new2("cpath"));
4781
+
4782
+ /* Document-method: body
4783
+ * the body of the module definition
4784
+ */
4785
+ rb_define_method(rb_cMODULE, "body", node_body, 0);
4786
+ rb_ary_push(members, rb_str_new2("body"));
4921
4787
  }
4922
4788
 
4923
4789
  /* Document-class: Node::NEWLINE
@@ -4939,6 +4805,52 @@ void define_node_subclass_methods()
4939
4805
  rb_ary_push(members, rb_str_new2("next"));
4940
4806
  }
4941
4807
 
4808
+ /* Document-class: Node::NEXT
4809
+ * Represents the 'next' keyword.
4810
+ * Causes control to be transferred to the end of the loop, causing the
4811
+ * next value in the sequence to be retrieved.
4812
+ */
4813
+ {
4814
+ VALUE rb_cNEXT = rb_define_class_under(rb_cNode, "NEXT", rb_cNode);
4815
+ members = rb_ary_new();
4816
+ rb_cNodeSubclass[NODE_NEXT] = rb_cNEXT;
4817
+ rb_iv_set(rb_cNEXT, "__member__", members);
4818
+ rb_iv_set(rb_cNEXT, "__type__", INT2NUM(NODE_NEXT));
4819
+ rb_define_singleton_method(rb_cNEXT, "members", node_s_members, 0);
4820
+ rb_define_method(rb_cNEXT, "stts", node_stts, 0);
4821
+ rb_ary_push(members, rb_str_new2("stts"));
4822
+ }
4823
+
4824
+ /* Document-class: Node::NIL
4825
+ * Represents the keyword 'nil'.
4826
+ */
4827
+ {
4828
+ VALUE rb_cNIL = rb_define_class_under(rb_cNode, "NIL", rb_cNode);
4829
+ members = rb_ary_new();
4830
+ rb_cNodeSubclass[NODE_NIL] = rb_cNIL;
4831
+ rb_iv_set(rb_cNIL, "__member__", members);
4832
+ rb_iv_set(rb_cNIL, "__type__", INT2NUM(NODE_NIL));
4833
+ rb_define_singleton_method(rb_cNIL, "members", node_s_members, 0);
4834
+ }
4835
+
4836
+ /* Document-class: Node::NOT
4837
+ * Represents a logical negation.
4838
+ */
4839
+ {
4840
+ VALUE rb_cNOT = rb_define_class_under(rb_cNode, "NOT", rb_cNode);
4841
+ members = rb_ary_new();
4842
+ rb_cNodeSubclass[NODE_NOT] = rb_cNOT;
4843
+ rb_iv_set(rb_cNOT, "__member__", members);
4844
+ rb_iv_set(rb_cNOT, "__type__", INT2NUM(NODE_NOT));
4845
+ rb_define_singleton_method(rb_cNOT, "members", node_s_members, 0);
4846
+
4847
+ /* Document-method: body
4848
+ * the value to negate.
4849
+ */
4850
+ rb_define_method(rb_cNOT, "body", node_body, 0);
4851
+ rb_ary_push(members, rb_str_new2("body"));
4852
+ }
4853
+
4942
4854
  /* Document-class: Node::NTH_REF
4943
4855
  * Represents the nth match data item, e.g. $1, $2, etc.
4944
4856
  */
@@ -4963,310 +4875,367 @@ void define_node_subclass_methods()
4963
4875
  rb_ary_push(members, rb_str_new2("cnt"));
4964
4876
  }
4965
4877
 
4966
- /* Document-class: Node::DOT2
4967
- * Represents a range created with the form:
4968
- * beg..end
4969
- * Creates a range which does not exclude the range end.
4970
- */
4971
- {
4972
- VALUE rb_cDOT2 = rb_define_class_under(rb_cNode, "DOT2", rb_cNode);
4973
- members = rb_ary_new();
4974
- rb_cNodeSubclass[NODE_DOT2] = rb_cDOT2;
4975
- rb_iv_set(rb_cDOT2, "__member__", members);
4976
- rb_iv_set(rb_cDOT2, "__type__", INT2NUM(NODE_DOT2));
4977
- rb_define_singleton_method(rb_cDOT2, "members", node_s_members, 0);
4978
-
4979
- /* Document-method: beg
4980
- * the beginning of the range
4981
- */
4982
- rb_define_method(rb_cDOT2, "beg", node_beg, 0);
4983
- rb_ary_push(members, rb_str_new2("beg"));
4984
-
4985
- /* Document-method: end
4986
- * the end of the range
4987
- */
4988
- rb_define_method(rb_cDOT2, "end", node_end, 0);
4989
- rb_ary_push(members, rb_str_new2("end"));
4990
- rb_define_method(rb_cDOT2, "state", node_state, 0);
4991
- rb_ary_push(members, rb_str_new2("state"));
4992
- }
4993
-
4994
- /* Document-class: Node::GVAR
4995
- * Represents global variable retrieval.
4878
+ /* Document-class: Node::OPT_N
4879
+ * Represents the top-level loop when the -n or -p options are used
4880
+ * with the interpreter.
4996
4881
  */
4997
4882
  {
4998
- VALUE rb_cGVAR = rb_define_class_under(rb_cNode, "GVAR", rb_cNode);
4883
+ VALUE rb_cOPT_N = rb_define_class_under(rb_cNode, "OPT_N", rb_cNode);
4999
4884
  members = rb_ary_new();
5000
- rb_cNodeSubclass[NODE_GVAR] = rb_cGVAR;
5001
- rb_iv_set(rb_cGVAR, "__member__", members);
5002
- rb_iv_set(rb_cGVAR, "__type__", INT2NUM(NODE_GVAR));
5003
- rb_define_singleton_method(rb_cGVAR, "members", node_s_members, 0);
4885
+ rb_cNodeSubclass[NODE_OPT_N] = rb_cOPT_N;
4886
+ rb_iv_set(rb_cOPT_N, "__member__", members);
4887
+ rb_iv_set(rb_cOPT_N, "__type__", INT2NUM(NODE_OPT_N));
4888
+ rb_define_singleton_method(rb_cOPT_N, "members", node_s_members, 0);
5004
4889
 
5005
- /* Document-method: vid
5006
- * the name of the global variable to retrieve, with a leading '$'
4890
+ /* Document-method: body
4891
+ * the body of the loop
5007
4892
  */
5008
- rb_define_method(rb_cGVAR, "vid", node_vid, 0);
5009
- rb_ary_push(members, rb_str_new2("vid"));
5010
- rb_define_method(rb_cGVAR, "entry", node_entry, 0);
5011
- rb_ary_push(members, rb_str_new2("entry"));
4893
+ rb_define_method(rb_cOPT_N, "body", node_body, 0);
4894
+ rb_ary_push(members, rb_str_new2("body"));
5012
4895
  }
5013
4896
 
5014
- /* Document-class: Node::DOT3
5015
- * Represents a range created with the form:
5016
- * beg...end
5017
- * Creates a range which excludes the range end.
4897
+ /* Document-class: Node::OP_ASGN1
4898
+ * Represents bracket assignment of the form:
4899
+ * recv[index] += value or
4900
+ * recv[index] ||= value or
4901
+ * recv[index] &&= value.
4902
+ *
4903
+ * The index is obtained from args.body.
4904
+ *
4905
+ * The value is obtained from args.head.
4906
+ *
4907
+ * In the case of ||=, mid will be 0. The rhs will be equal to the
4908
+ * result of evaluating args.head if the lhs is false, otherwise the
4909
+ * rhs will be equal to lhs.
4910
+ *
4911
+ * In the case of &&=, mid will be 1. The rhs will be equal to the lhs
4912
+ * if lhs is false, otherwise the rhs will be equal to the result of
4913
+ * evaluating args.head. In all other cases, mid will be the name of
4914
+ * the method to call to calculate value, such that the expression is
4915
+ * equivalent to:
4916
+ * recv[args.body] = recv[args.body].mid(args.head)
4917
+ *
4918
+ * In no case does ruby short-circuit the assignment.
5018
4919
  */
5019
4920
  {
5020
- VALUE rb_cDOT3 = rb_define_class_under(rb_cNode, "DOT3", rb_cNode);
4921
+ VALUE rb_cOP_ASGN1 = rb_define_class_under(rb_cNode, "OP_ASGN1", rb_cNode);
5021
4922
  members = rb_ary_new();
5022
- rb_cNodeSubclass[NODE_DOT3] = rb_cDOT3;
5023
- rb_iv_set(rb_cDOT3, "__member__", members);
5024
- rb_iv_set(rb_cDOT3, "__type__", INT2NUM(NODE_DOT3));
5025
- rb_define_singleton_method(rb_cDOT3, "members", node_s_members, 0);
4923
+ rb_cNodeSubclass[NODE_OP_ASGN1] = rb_cOP_ASGN1;
4924
+ rb_iv_set(rb_cOP_ASGN1, "__member__", members);
4925
+ rb_iv_set(rb_cOP_ASGN1, "__type__", INT2NUM(NODE_OP_ASGN1));
4926
+ rb_define_singleton_method(rb_cOP_ASGN1, "members", node_s_members, 0);
5026
4927
 
5027
- /* Document-method: beg
5028
- * the beginning of the range
4928
+ /* Document-method: args
4929
+ * the arguments to the assigment
5029
4930
  */
5030
- rb_define_method(rb_cDOT3, "beg", node_beg, 0);
5031
- rb_ary_push(members, rb_str_new2("beg"));
4931
+ rb_define_method(rb_cOP_ASGN1, "args", node_args, 0);
4932
+ rb_ary_push(members, rb_str_new2("args"));
5032
4933
 
5033
- /* Document-method: end
5034
- * the end of the range
4934
+ /* Document-method: mid
4935
+ * 0, 1, or the name a method to call to calculate the value of the
4936
+ * rhs
5035
4937
  */
5036
- rb_define_method(rb_cDOT3, "end", node_end, 0);
5037
- rb_ary_push(members, rb_str_new2("end"));
5038
- rb_define_method(rb_cDOT3, "state", node_state, 0);
5039
- rb_ary_push(members, rb_str_new2("state"));
4938
+ rb_define_method(rb_cOP_ASGN1, "mid", node_mid, 0);
4939
+ rb_ary_push(members, rb_str_new2("mid"));
4940
+
4941
+ /* Document-method: recv
4942
+ * the receiver of the assignment
4943
+ */
4944
+ rb_define_method(rb_cOP_ASGN1, "recv", node_recv, 0);
4945
+ rb_ary_push(members, rb_str_new2("recv"));
5040
4946
  }
5041
4947
 
5042
- /* Document-class: Node::CVASGN
5043
- * Represents class variable assignment in a method context.
4948
+ /* Document-class: Node::OP_ASGN2
4949
+ * Represents attribute assignment of the form:
4950
+ * recv.attr op value
4951
+ *
4952
+ * where recv is the receiver of the attr method, attr is the attribute
4953
+ * to which to assign, op is an assignment operation (e.g. +=), and
4954
+ * value is the value to assign to the attribute.
4955
+ *
4956
+ * The 'next' member of this class is also of type OP_ASGN2, though it
4957
+ * has different members than its parent. This child node is
4958
+ * documented under OP_ASGN2_ARG.
5044
4959
  */
5045
4960
  {
5046
- VALUE rb_cCVASGN = rb_define_class_under(rb_cNode, "CVASGN", rb_cNode);
4961
+ VALUE rb_cOP_ASGN2 = rb_define_class_under(rb_cNode, "OP_ASGN2", rb_cNode);
5047
4962
  members = rb_ary_new();
5048
- rb_cNodeSubclass[NODE_CVASGN] = rb_cCVASGN;
5049
- rb_iv_set(rb_cCVASGN, "__member__", members);
5050
- rb_iv_set(rb_cCVASGN, "__type__", INT2NUM(NODE_CVASGN));
5051
- rb_define_singleton_method(rb_cCVASGN, "members", node_s_members, 0);
4963
+ rb_cNodeSubclass[NODE_OP_ASGN2] = rb_cOP_ASGN2;
4964
+ rb_iv_set(rb_cOP_ASGN2, "__member__", members);
4965
+ rb_iv_set(rb_cOP_ASGN2, "__type__", INT2NUM(NODE_OP_ASGN2));
4966
+ rb_define_singleton_method(rb_cOP_ASGN2, "members", node_s_members, 0);
5052
4967
 
5053
4968
  /* Document-method: value
5054
- * an expression whose result is the new value of the class
5055
- * variable
4969
+ * the value to assign to the attribute
5056
4970
  */
5057
- rb_define_method(rb_cCVASGN, "value", node_value, 0);
4971
+ rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
5058
4972
  rb_ary_push(members, rb_str_new2("value"));
5059
4973
 
5060
- /* Document-method: vid
5061
- * the name of the class variable to assign
4974
+ /* Document-method: next
4975
+ * another node of type OP_ASGN2 which contains more information
4976
+ * about the assignment operation than can fit in this node alone
5062
4977
  */
5063
- rb_define_method(rb_cCVASGN, "vid", node_vid, 0);
5064
- rb_ary_push(members, rb_str_new2("vid"));
4978
+ rb_define_method(rb_cOP_ASGN2, "next", node_next, 0);
4979
+ rb_ary_push(members, rb_str_new2("next"));
4980
+
4981
+ /* Document-method: recv
4982
+ * the receiver of the attribute
4983
+ */
4984
+ rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0);
4985
+ rb_ary_push(members, rb_str_new2("recv"));
5065
4986
  }
5066
4987
 
5067
- /* Document-class: Node::CREF
5068
- * A temporary node used to store the value of ruby_cref or
5069
- * ruby_top_cref and later restore it. The cref holds a reference to
5070
- * the cbase, which, among other things, is used for constant and class
5071
- * variable lookup.
5072
- *
5073
- * It should never be evaluated as an expression.
4988
+ /* Document-class: Node::OP_ASGN2_ARG
4989
+ * Actually a node of type OP_ASGN2, this is a placeholder for
4990
+ * additional information about the assignment than can fit in a single
4991
+ * OP_ASGN2 node.
5074
4992
  */
5075
4993
  {
5076
- VALUE rb_cCREF = rb_define_class_under(rb_cNode, "CREF", rb_cNode);
4994
+ VALUE rb_cOP_ASGN2_ARG = rb_define_class_under(rb_cNode, "OP_ASGN2_ARG", rb_cNode);
5077
4995
  members = rb_ary_new();
5078
- rb_cNodeSubclass[NODE_CREF] = rb_cCREF;
5079
- rb_iv_set(rb_cCREF, "__member__", members);
5080
- rb_iv_set(rb_cCREF, "__type__", INT2NUM(NODE_CREF));
5081
- rb_define_singleton_method(rb_cCREF, "members", node_s_members, 0);
4996
+ rb_cNodeSubclass[NODE_OP_ASGN2_ARG] = rb_cOP_ASGN2_ARG;
4997
+ rb_iv_set(rb_cOP_ASGN2_ARG, "__member__", members);
4998
+ rb_iv_set(rb_cOP_ASGN2_ARG, "__type__", INT2NUM(NODE_OP_ASGN2_ARG));
4999
+ rb_define_singleton_method(rb_cOP_ASGN2_ARG, "members", node_s_members, 0);
5082
5000
 
5083
- /* Document-method: body
5084
- * always 0 (false)
5001
+ /* Document-method: vid
5002
+ * The method to call on the receiver to retrieve the attribute
5085
5003
  */
5086
- rb_define_method(rb_cCREF, "body", node_body, 0);
5087
- rb_ary_push(members, rb_str_new2("body"));
5004
+ rb_define_method(rb_cOP_ASGN2_ARG, "vid", node_vid, 0);
5005
+ rb_ary_push(members, rb_str_new2("vid"));
5088
5006
 
5089
- /* Document-method: next
5090
- * the previous value of ruby_cref or ruby_top_cref
5007
+ /* Document-method: aid
5008
+ * The method to call on the receiver to set the attribute
5091
5009
  */
5092
- rb_define_method(rb_cCREF, "next", node_next, 0);
5093
- rb_ary_push(members, rb_str_new2("next"));
5010
+ rb_define_method(rb_cOP_ASGN2_ARG, "aid", node_aid, 0);
5011
+ rb_ary_push(members, rb_str_new2("aid"));
5094
5012
 
5095
- /* Document-method: clss
5096
- * the new class to use for the cbase.
5013
+ /* Document-method: mid
5014
+ * The operation to apply to the attribute before setting it. May
5015
+ * be 0 (false) to indicate "logical or" or 1 (nil) to indicate
5016
+ * "logical and".
5097
5017
  */
5098
- rb_define_method(rb_cCREF, "clss", node_clss, 0);
5099
- rb_ary_push(members, rb_str_new2("clss"));
5018
+ rb_define_method(rb_cOP_ASGN2_ARG, "mid", node_mid, 0);
5019
+ rb_ary_push(members, rb_str_new2("mid"));
5100
5020
  }
5101
5021
 
5102
- /* Document-class: Node::SPLAT
5103
- * Represents the splat (*) operation as an rvalue, e.g.:
5104
- * *head
5105
- * If the argument is an array, returns self.
5106
- * If the argument is nil, returns [nil].
5107
- * If the argument is any other value, returns the result of calling #to_a on the
5108
- * argument.
5022
+ /* Document-class: Node::OP_ASGN_AND
5023
+ * Represents an expression of the form:
5024
+ * recv &&= value
5025
+ * Ruby will evaluate the expression on the left hand side of the
5026
+ * assignment; if it is true, then it will assign the result of the
5027
+ * expression on the right hand side to the receiver on the left hand
5028
+ * side.
5109
5029
  */
5110
5030
  {
5111
- VALUE rb_cSPLAT = rb_define_class_under(rb_cNode, "SPLAT", rb_cNode);
5031
+ VALUE rb_cOP_ASGN_AND = rb_define_class_under(rb_cNode, "OP_ASGN_AND", rb_cNode);
5112
5032
  members = rb_ary_new();
5113
- rb_cNodeSubclass[NODE_SPLAT] = rb_cSPLAT;
5114
- rb_iv_set(rb_cSPLAT, "__member__", members);
5115
- rb_iv_set(rb_cSPLAT, "__type__", INT2NUM(NODE_SPLAT));
5116
- rb_define_singleton_method(rb_cSPLAT, "members", node_s_members, 0);
5033
+ rb_cNodeSubclass[NODE_OP_ASGN_AND] = rb_cOP_ASGN_AND;
5034
+ rb_iv_set(rb_cOP_ASGN_AND, "__member__", members);
5035
+ rb_iv_set(rb_cOP_ASGN_AND, "__type__", INT2NUM(NODE_OP_ASGN_AND));
5036
+ rb_define_singleton_method(rb_cOP_ASGN_AND, "members", node_s_members, 0);
5117
5037
 
5118
- /* Document-method: head
5119
- * the argument to splat.
5038
+ /* Document-method: value
5039
+ * an expression representing the assignment that should be
5040
+ * performed if the left hand side is true
5120
5041
  */
5121
- rb_define_method(rb_cSPLAT, "head", node_head, 0);
5122
- rb_ary_push(members, rb_str_new2("head"));
5042
+ rb_define_method(rb_cOP_ASGN_AND, "value", node_value, 0);
5043
+ rb_ary_push(members, rb_str_new2("value"));
5044
+
5045
+ /* Document-method: recv
5046
+ * an expression representing the left hand side of the assignment
5047
+ */
5048
+ rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0);
5049
+ rb_ary_push(members, rb_str_new2("recv"));
5123
5050
  }
5124
5051
 
5125
- /* Document-class: Node::MODULE
5126
- * Represents a module definition, e.g.:
5127
- * module cpath
5128
- * body
5129
- * end
5130
- *
5131
- * The module definition is evaluated in a new lexical scope.
5132
- *
5133
- * The result of the expression is the last expression evaluated in the
5134
- * body.
5052
+ /* Document-class: Node::OP_ASGN_OR
5053
+ * Represents an expression of the form:
5054
+ * recv ||= value
5055
+ * Ruby will evaluate the expression on the left hand side. If it is
5056
+ * undefined, nil, or false, then ruby will evaluate the expression on
5057
+ * the right hand side and assign it to recv. The expression will
5058
+ * short-circuit if recv is defined and true (non-false, non-nil).
5135
5059
  */
5136
5060
  {
5137
- VALUE rb_cMODULE = rb_define_class_under(rb_cNode, "MODULE", rb_cNode);
5061
+ VALUE rb_cOP_ASGN_OR = rb_define_class_under(rb_cNode, "OP_ASGN_OR", rb_cNode);
5138
5062
  members = rb_ary_new();
5139
- rb_cNodeSubclass[NODE_MODULE] = rb_cMODULE;
5140
- rb_iv_set(rb_cMODULE, "__member__", members);
5141
- rb_iv_set(rb_cMODULE, "__type__", INT2NUM(NODE_MODULE));
5142
- rb_define_singleton_method(rb_cMODULE, "members", node_s_members, 0);
5063
+ rb_cNodeSubclass[NODE_OP_ASGN_OR] = rb_cOP_ASGN_OR;
5064
+ rb_iv_set(rb_cOP_ASGN_OR, "__member__", members);
5065
+ rb_iv_set(rb_cOP_ASGN_OR, "__type__", INT2NUM(NODE_OP_ASGN_OR));
5066
+ rb_define_singleton_method(rb_cOP_ASGN_OR, "members", node_s_members, 0);
5143
5067
 
5144
- /* Document-method: cpath
5145
- * the name of the module to define
5068
+ /* Document-method: aid
5069
+ * if this indicator is nonzero, ruby will check to see if the
5070
+ * provided expression is defined, otherwise it will assume that
5071
+ * the provided expression is defined.
5146
5072
  */
5147
- rb_define_method(rb_cMODULE, "cpath", node_cpath, 0);
5148
- rb_ary_push(members, rb_str_new2("cpath"));
5073
+ rb_define_method(rb_cOP_ASGN_OR, "aid", node_aid, 0);
5074
+ rb_ary_push(members, rb_str_new2("aid"));
5149
5075
 
5150
- /* Document-method: body
5151
- * the body of the module definition
5076
+ /* Document-method: value
5077
+ * the right hand side of the assignment
5152
5078
  */
5153
- rb_define_method(rb_cMODULE, "body", node_body, 0);
5154
- rb_ary_push(members, rb_str_new2("body"));
5079
+ rb_define_method(rb_cOP_ASGN_OR, "value", node_value, 0);
5080
+ rb_ary_push(members, rb_str_new2("value"));
5081
+
5082
+ /* Document-method: recv
5083
+ * the receiver of the assignment
5084
+ */
5085
+ rb_define_method(rb_cOP_ASGN_OR, "recv", node_recv, 0);
5086
+ rb_ary_push(members, rb_str_new2("recv"));
5155
5087
  }
5156
5088
 
5157
- /* Document-class: Node::FOR
5158
- * Represents a loop constructed with the 'for' keyword, e.g.:
5159
- * for var in iter do
5160
- * body
5161
- * end
5162
- *
5163
- * This is equivalent to:
5164
- * iter.each do |*args|
5165
- * assign args to var
5166
- * body
5167
- * end
5168
- *
5169
- * Except that a new block is not created.
5089
+ /* Document-class: Node::OR
5090
+ * Represents a logical 'or' of the form:
5091
+ * first || second
5092
+ * The expression will short-circuit and yield the result of the left
5093
+ * hand side if it is true, else it will evaluate the right hand side
5094
+ * and use it as the result of the expression.
5170
5095
  */
5171
5096
  {
5172
- VALUE rb_cFOR = rb_define_class_under(rb_cNode, "FOR", rb_cNode);
5097
+ VALUE rb_cOR = rb_define_class_under(rb_cNode, "OR", rb_cNode);
5173
5098
  members = rb_ary_new();
5174
- rb_cNodeSubclass[NODE_FOR] = rb_cFOR;
5175
- rb_iv_set(rb_cFOR, "__member__", members);
5176
- rb_iv_set(rb_cFOR, "__type__", INT2NUM(NODE_FOR));
5177
- rb_define_singleton_method(rb_cFOR, "members", node_s_members, 0);
5178
-
5179
- /* Document-method: body
5180
- * the body of the loop
5181
- */
5182
- rb_define_method(rb_cFOR, "body", node_body, 0);
5183
- rb_ary_push(members, rb_str_new2("body"));
5099
+ rb_cNodeSubclass[NODE_OR] = rb_cOR;
5100
+ rb_iv_set(rb_cOR, "__member__", members);
5101
+ rb_iv_set(rb_cOR, "__type__", INT2NUM(NODE_OR));
5102
+ rb_define_singleton_method(rb_cOR, "members", node_s_members, 0);
5184
5103
 
5185
- /* Document-method: iter
5186
- * the sequence over which to iterate
5104
+ /* Document-method: first
5105
+ * the expression on the left hand side
5187
5106
  */
5188
- rb_define_method(rb_cFOR, "iter", node_iter, 0);
5189
- rb_ary_push(members, rb_str_new2("iter"));
5107
+ rb_define_method(rb_cOR, "first", node_1st, 0);
5108
+ rb_ary_push(members, rb_str_new2("first"));
5190
5109
 
5191
- /* Document-method: var
5192
- * an assignment node which assigns the next value in the sequence
5193
- * to a variable, which may or may not be local. May also be a
5194
- * multiple assignment.
5110
+ /* Document-method: second
5111
+ * the expression on the right hand side
5195
5112
  */
5196
- rb_define_method(rb_cFOR, "var", node_var, 0);
5197
- rb_ary_push(members, rb_str_new2("var"));
5113
+ rb_define_method(rb_cOR, "second", node_2nd, 0);
5114
+ rb_ary_push(members, rb_str_new2("second"));
5198
5115
  }
5199
5116
 
5200
- /* Document-class: Node::DVAR
5201
- * Represents dynamic local variable retrieval. See also DASGN.
5117
+ /* Document-class: Node::POSTEXE
5118
+ * Represents the END keyword, e.g.:
5119
+ * END { ... }
5120
+ *
5121
+ * Indicating that the enclosing ITER node is to be excecuted only
5122
+ * once, when the program terminates.
5202
5123
  */
5203
5124
  {
5204
- VALUE rb_cDVAR = rb_define_class_under(rb_cNode, "DVAR", rb_cNode);
5125
+ VALUE rb_cPOSTEXE = rb_define_class_under(rb_cNode, "POSTEXE", rb_cNode);
5205
5126
  members = rb_ary_new();
5206
- rb_cNodeSubclass[NODE_DVAR] = rb_cDVAR;
5207
- rb_iv_set(rb_cDVAR, "__member__", members);
5208
- rb_iv_set(rb_cDVAR, "__type__", INT2NUM(NODE_DVAR));
5209
- rb_define_singleton_method(rb_cDVAR, "members", node_s_members, 0);
5127
+ rb_cNodeSubclass[NODE_POSTEXE] = rb_cPOSTEXE;
5128
+ rb_iv_set(rb_cPOSTEXE, "__member__", members);
5129
+ rb_iv_set(rb_cPOSTEXE, "__type__", INT2NUM(NODE_POSTEXE));
5130
+ rb_define_singleton_method(rb_cPOSTEXE, "members", node_s_members, 0);
5131
+ }
5210
5132
 
5211
- /* Document-method: vid
5212
- * the name of the local variable to retrieve.
5213
- */
5214
- rb_define_method(rb_cDVAR, "vid", node_vid, 0);
5215
- rb_ary_push(members, rb_str_new2("vid"));
5133
+ /* Document-class: Node::REDO
5134
+ * Represents the 'redo' keyword. Causes control to be transferred to
5135
+ * the beginning of the loop. The loop assignment is not repeated.
5136
+ */
5137
+ {
5138
+ VALUE rb_cREDO = rb_define_class_under(rb_cNode, "REDO", rb_cNode);
5139
+ members = rb_ary_new();
5140
+ rb_cNodeSubclass[NODE_REDO] = rb_cREDO;
5141
+ rb_iv_set(rb_cREDO, "__member__", members);
5142
+ rb_iv_set(rb_cREDO, "__type__", INT2NUM(NODE_REDO));
5143
+ rb_define_singleton_method(rb_cREDO, "members", node_s_members, 0);
5216
5144
  }
5217
5145
 
5218
- /* Document-class: Node::DSTR
5219
- * Represents a string object with interpolation. The node is
5220
- * evaluated by duplicating the string stored in the 'lit' element,
5221
- * then iterating over the nodes stored in the 'next' element. Each
5222
- * node found should evalate to a string, and each resulting string is
5223
- * appended onto the regex. Interpolation is represented with the
5224
- * EVSTR node.
5146
+ /* Document-class: Node::RESBODY
5147
+ * Represents the rescue portion of a rescue expression (see RESCUE for
5148
+ * examples).
5149
+ *
5150
+ * If the head node of the rescue expresion raises an exception, the
5151
+ * resq node is evaluated. The resq node is of type RESBDOY.
5152
+ *
5153
+ * As it is evaluated, the type of the exception is tested against the
5154
+ * class(es) listed in the args node. If there is a match, the body
5155
+ * node is evaluated, otherwise the head node is evaluated. The head
5156
+ * node is either another RESBDOY node or false (0).
5225
5157
  */
5226
5158
  {
5227
- VALUE rb_cDSTR = rb_define_class_under(rb_cNode, "DSTR", rb_cNode);
5159
+ VALUE rb_cRESBODY = rb_define_class_under(rb_cNode, "RESBODY", rb_cNode);
5228
5160
  members = rb_ary_new();
5229
- rb_cNodeSubclass[NODE_DSTR] = rb_cDSTR;
5230
- rb_iv_set(rb_cDSTR, "__member__", members);
5231
- rb_iv_set(rb_cDSTR, "__type__", INT2NUM(NODE_DSTR));
5232
- rb_define_singleton_method(rb_cDSTR, "members", node_s_members, 0);
5161
+ rb_cNodeSubclass[NODE_RESBODY] = rb_cRESBODY;
5162
+ rb_iv_set(rb_cRESBODY, "__member__", members);
5163
+ rb_iv_set(rb_cRESBODY, "__type__", INT2NUM(NODE_RESBODY));
5164
+ rb_define_singleton_method(rb_cRESBODY, "members", node_s_members, 0);
5233
5165
 
5234
- /* Document-method: lit
5235
- * a string
5166
+ /* Document-method: head
5167
+ * the next rescue
5236
5168
  */
5237
- rb_define_method(rb_cDSTR, "lit", node_lit, 0);
5238
- rb_ary_push(members, rb_str_new2("lit"));
5169
+ rb_define_method(rb_cRESBODY, "head", node_head, 0);
5170
+ rb_ary_push(members, rb_str_new2("head"));
5239
5171
 
5240
- /* Document-method: next
5241
- * a list of expressions to be appended onto the string
5172
+ /* Document-method: args
5173
+ * the expression type to match against
5242
5174
  */
5243
- rb_define_method(rb_cDSTR, "next", node_next, 0);
5244
- rb_ary_push(members, rb_str_new2("next"));
5175
+ rb_define_method(rb_cRESBODY, "args", node_args, 0);
5176
+ rb_ary_push(members, rb_str_new2("args"));
5177
+
5178
+ /* Document-method: body
5179
+ * the expresion to evaluate if the exception type matches
5180
+ */
5181
+ rb_define_method(rb_cRESBODY, "body", node_body, 0);
5182
+ rb_ary_push(members, rb_str_new2("body"));
5245
5183
  }
5246
5184
 
5247
- /* Document-class: Node::SVALUE
5248
- * Represents the collection of multiple values of the right hand side
5249
- * of an assignment into a single value, for use in single assignment,
5250
- * e.g.:
5251
- * lhs = a, b, c
5252
- * The argument to this node is an Array.
5253
- * If it is length 0, returns nil.
5254
- * If it is length 1, returns the first element in the array.
5255
- * Otherwise, returns the array.
5185
+ /* Document-class: Node::RESCUE
5186
+ * Represents part of a rescue expression of the form:
5187
+ * head rescue expr
5188
+ *
5189
+ * or the longer form:
5190
+ * begin
5191
+ * head
5192
+ * rescue exception
5193
+ * expr
5194
+ * end
5195
+ *
5196
+ * or the form using the else keyword:
5197
+ * begin
5198
+ * head
5199
+ * rescue exception
5200
+ * expr
5201
+ * else
5202
+ * else_expr
5203
+ * end
5204
+ *
5205
+ * The head expression is first evaluated, and if an exception is
5206
+ * raised, evaluates the resq node. If no exception is raised, the
5207
+ * else node is evaluated if it is not false (0).
5208
+ *
5209
+ * The resq node will be a RESBDOY node, which will test the exception
5210
+ * to see if it matches one of the expected types. If it does it will
5211
+ * handle the exception, otherwise it will allow the expression to pass
5212
+ * to the outer scope.
5256
5213
  */
5257
5214
  {
5258
- VALUE rb_cSVALUE = rb_define_class_under(rb_cNode, "SVALUE", rb_cNode);
5215
+ VALUE rb_cRESCUE = rb_define_class_under(rb_cNode, "RESCUE", rb_cNode);
5259
5216
  members = rb_ary_new();
5260
- rb_cNodeSubclass[NODE_SVALUE] = rb_cSVALUE;
5261
- rb_iv_set(rb_cSVALUE, "__member__", members);
5262
- rb_iv_set(rb_cSVALUE, "__type__", INT2NUM(NODE_SVALUE));
5263
- rb_define_singleton_method(rb_cSVALUE, "members", node_s_members, 0);
5217
+ rb_cNodeSubclass[NODE_RESCUE] = rb_cRESCUE;
5218
+ rb_iv_set(rb_cRESCUE, "__member__", members);
5219
+ rb_iv_set(rb_cRESCUE, "__type__", INT2NUM(NODE_RESCUE));
5220
+ rb_define_singleton_method(rb_cRESCUE, "members", node_s_members, 0);
5264
5221
 
5265
5222
  /* Document-method: head
5266
- * an expression which returns an Array.
5223
+ * the body of the block to evaluate
5267
5224
  */
5268
- rb_define_method(rb_cSVALUE, "head", node_head, 0);
5225
+ rb_define_method(rb_cRESCUE, "head", node_head, 0);
5269
5226
  rb_ary_push(members, rb_str_new2("head"));
5227
+
5228
+ /* Document-method: else
5229
+ * the expression to be evaluated if no exception is raised
5230
+ */
5231
+ rb_define_method(rb_cRESCUE, "else", node_else, 0);
5232
+ rb_ary_push(members, rb_str_new2("else"));
5233
+
5234
+ /* Document-method: resq
5235
+ * the expression to be evaluated if an exception is raised
5236
+ */
5237
+ rb_define_method(rb_cRESCUE, "resq", node_resq, 0);
5238
+ rb_ary_push(members, rb_str_new2("resq"));
5270
5239
  }
5271
5240
 
5272
5241
  /* Document-class: Node::RETRY
@@ -5281,14 +5250,30 @@ void define_node_subclass_methods()
5281
5250
  rb_define_singleton_method(rb_cRETRY, "members", node_s_members, 0);
5282
5251
  }
5283
5252
 
5284
- /* Document-class: Node::CLASS
5285
- * Represents a class definition, e.g.:
5286
- * class cpath
5287
- * body
5288
- * end
5289
- *
5290
- * or:
5291
- * class cpath < super
5253
+ /* Document-class: Node::RETURN
5254
+ * Represents the 'return' keyword. Evaluation of this node results in
5255
+ * a return from the current method. If no argument is supplied,
5256
+ * returns nil, otherwise returns the result of the supplied
5257
+ * expression.
5258
+ */
5259
+ {
5260
+ VALUE rb_cRETURN = rb_define_class_under(rb_cNode, "RETURN", rb_cNode);
5261
+ members = rb_ary_new();
5262
+ rb_cNodeSubclass[NODE_RETURN] = rb_cRETURN;
5263
+ rb_iv_set(rb_cRETURN, "__member__", members);
5264
+ rb_iv_set(rb_cRETURN, "__type__", INT2NUM(NODE_RETURN));
5265
+ rb_define_singleton_method(rb_cRETURN, "members", node_s_members, 0);
5266
+
5267
+ /* Document-method: stts
5268
+ * an expression representing the value to return
5269
+ */
5270
+ rb_define_method(rb_cRETURN, "stts", node_stts, 0);
5271
+ rb_ary_push(members, rb_str_new2("stts"));
5272
+ }
5273
+
5274
+ /* Document-class: Node::SCLASS
5275
+ * Represents the body of a singleton class definition, e.g.:
5276
+ * class << recv
5292
5277
  * body
5293
5278
  * end
5294
5279
  *
@@ -5298,392 +5283,392 @@ void define_node_subclass_methods()
5298
5283
  * body.
5299
5284
  */
5300
5285
  {
5301
- VALUE rb_cCLASS = rb_define_class_under(rb_cNode, "CLASS", rb_cNode);
5286
+ VALUE rb_cSCLASS = rb_define_class_under(rb_cNode, "SCLASS", rb_cNode);
5302
5287
  members = rb_ary_new();
5303
- rb_cNodeSubclass[NODE_CLASS] = rb_cCLASS;
5304
- rb_iv_set(rb_cCLASS, "__member__", members);
5305
- rb_iv_set(rb_cCLASS, "__type__", INT2NUM(NODE_CLASS));
5306
- rb_define_singleton_method(rb_cCLASS, "members", node_s_members, 0);
5307
-
5308
- /* Document-method: cpath
5309
- * the name of the class to define
5310
- */
5311
- rb_define_method(rb_cCLASS, "cpath", node_cpath, 0);
5312
- rb_ary_push(members, rb_str_new2("cpath"));
5288
+ rb_cNodeSubclass[NODE_SCLASS] = rb_cSCLASS;
5289
+ rb_iv_set(rb_cSCLASS, "__member__", members);
5290
+ rb_iv_set(rb_cSCLASS, "__type__", INT2NUM(NODE_SCLASS));
5291
+ rb_define_singleton_method(rb_cSCLASS, "members", node_s_members, 0);
5313
5292
 
5314
5293
  /* Document-method: body
5315
5294
  * the body of the class definition
5316
5295
  */
5317
- rb_define_method(rb_cCLASS, "body", node_body, 0);
5296
+ rb_define_method(rb_cSCLASS, "body", node_body, 0);
5318
5297
  rb_ary_push(members, rb_str_new2("body"));
5319
5298
 
5320
- /* Document-method: super
5321
- * an expression returning the base class, or false if there is no
5322
- * base class specified
5299
+ /* Document-method: recv
5300
+ * the object whose singleton class is to be modified
5323
5301
  */
5324
- rb_define_method(rb_cCLASS, "super", node_super, 0);
5325
- rb_ary_push(members, rb_str_new2("super"));
5302
+ rb_define_method(rb_cSCLASS, "recv", node_recv, 0);
5303
+ rb_ary_push(members, rb_str_new2("recv"));
5326
5304
  }
5327
5305
 
5328
- /* Document-class: Node::DASGN
5329
- * Represents dynamic local variable assignment. Dynamic assignment
5330
- * differs from static assignment in that the slots for static local
5331
- * variables are allocated when the method is called, wereas slots for
5332
- * dynamic variables are allocated when the variable is first assigned
5333
- * to. When searching for the variable, dynamic assignment searches
5334
- * backward up the stack to see if the variable exists in any previous
5335
- * block in the current frame; if it does, it assigns to the slot found
5336
- * in that block, otherwise it creates a new variable slot. As a
5337
- * result, dynamic assignment is typically much slower than static
5338
- * assignment.
5306
+ /* Document-class: Node::SCOPE
5307
+ * Represents a lexical scope.
5308
+ *
5309
+ * A new scope is created when a method is invoked. The scope node
5310
+ * holds information about local variables and arguments to the method.
5311
+ * The first two variables in the local variable table are the implicit
5312
+ * variables $_ and $~.
5313
+ *
5314
+ * The next variables listed in the local variable table are the
5315
+ * arguments to the method. More information about the arguments to
5316
+ * the method are stored in the ARGS node, which will either be the
5317
+ * first node in the scope or the first node in the BLOCK held by the
5318
+ * scope.
5339
5319
  */
5340
5320
  {
5341
- VALUE rb_cDASGN = rb_define_class_under(rb_cNode, "DASGN", rb_cNode);
5321
+ VALUE rb_cSCOPE = rb_define_class_under(rb_cNode, "SCOPE", rb_cNode);
5342
5322
  members = rb_ary_new();
5343
- rb_cNodeSubclass[NODE_DASGN] = rb_cDASGN;
5344
- rb_iv_set(rb_cDASGN, "__member__", members);
5345
- rb_iv_set(rb_cDASGN, "__type__", INT2NUM(NODE_DASGN));
5346
- rb_define_singleton_method(rb_cDASGN, "members", node_s_members, 0);
5323
+ rb_cNodeSubclass[NODE_SCOPE] = rb_cSCOPE;
5324
+ rb_iv_set(rb_cSCOPE, "__member__", members);
5325
+ rb_iv_set(rb_cSCOPE, "__type__", INT2NUM(NODE_SCOPE));
5326
+ rb_define_singleton_method(rb_cSCOPE, "members", node_s_members, 0);
5347
5327
 
5348
- /* Document-method: value
5349
- * the value to assign to the local variable
5328
+ /* Document-method: tbl
5329
+ * the names of the local variables* next the first expression in
5330
+ * the scope
5350
5331
  */
5351
- rb_define_method(rb_cDASGN, "value", node_value, 0);
5352
- rb_ary_push(members, rb_str_new2("value"));
5332
+ rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0);
5333
+ rb_ary_push(members, rb_str_new2("tbl"));
5353
5334
 
5354
- /* Document-method: vid
5355
- * the name of the local variable
5335
+ /* Document-method: rval
5336
+ * holds information about which class(es) to search for constants
5337
+ * in this scope
5356
5338
  */
5357
- rb_define_method(rb_cDASGN, "vid", node_vid, 0);
5358
- rb_ary_push(members, rb_str_new2("vid"));
5339
+ rb_define_method(rb_cSCOPE, "rval", node_rval, 0);
5340
+ rb_ary_push(members, rb_str_new2("rval"));
5341
+
5342
+ /* Document-method: next
5343
+ * the body of the lexical scope
5344
+ */
5345
+ rb_define_method(rb_cSCOPE, "next", node_next, 0);
5346
+ rb_ary_push(members, rb_str_new2("next"));
5359
5347
  }
5360
5348
 
5361
- /* Document-class: Node::NIL
5362
- * Represents the keyword 'nil'.
5349
+ /* Document-class: Node::SELF
5350
+ * Represents the keyword 'self'.
5363
5351
  */
5364
5352
  {
5365
- VALUE rb_cNIL = rb_define_class_under(rb_cNode, "NIL", rb_cNode);
5353
+ VALUE rb_cSELF = rb_define_class_under(rb_cNode, "SELF", rb_cNode);
5366
5354
  members = rb_ary_new();
5367
- rb_cNodeSubclass[NODE_NIL] = rb_cNIL;
5368
- rb_iv_set(rb_cNIL, "__member__", members);
5369
- rb_iv_set(rb_cNIL, "__type__", INT2NUM(NODE_NIL));
5370
- rb_define_singleton_method(rb_cNIL, "members", node_s_members, 0);
5355
+ rb_cNodeSubclass[NODE_SELF] = rb_cSELF;
5356
+ rb_iv_set(rb_cSELF, "__member__", members);
5357
+ rb_iv_set(rb_cSELF, "__type__", INT2NUM(NODE_SELF));
5358
+ rb_define_singleton_method(rb_cSELF, "members", node_s_members, 0);
5371
5359
  }
5372
5360
 
5373
- /* Document-class: Node::IVAR
5374
- * A placeholder for an attribute reader method, which can added to a
5375
- * class by using attr_reader:
5376
- * attr_reader :attribute
5377
- * Its writer counterpart is ATTRSET.
5361
+ /* Document-class: Node::SPLAT
5362
+ * Represents the splat (*) operation as an rvalue, e.g.:
5363
+ * *head
5364
+ * If the argument is an array, returns self.
5365
+ * If the argument is nil, returns [nil].
5366
+ * If the argument is any other value, returns the result of calling #to_a on the
5367
+ * argument.
5378
5368
  */
5379
5369
  {
5380
- VALUE rb_cIVAR = rb_define_class_under(rb_cNode, "IVAR", rb_cNode);
5370
+ VALUE rb_cSPLAT = rb_define_class_under(rb_cNode, "SPLAT", rb_cNode);
5381
5371
  members = rb_ary_new();
5382
- rb_cNodeSubclass[NODE_IVAR] = rb_cIVAR;
5383
- rb_iv_set(rb_cIVAR, "__member__", members);
5384
- rb_iv_set(rb_cIVAR, "__type__", INT2NUM(NODE_IVAR));
5385
- rb_define_singleton_method(rb_cIVAR, "members", node_s_members, 0);
5372
+ rb_cNodeSubclass[NODE_SPLAT] = rb_cSPLAT;
5373
+ rb_iv_set(rb_cSPLAT, "__member__", members);
5374
+ rb_iv_set(rb_cSPLAT, "__type__", INT2NUM(NODE_SPLAT));
5375
+ rb_define_singleton_method(rb_cSPLAT, "members", node_s_members, 0);
5386
5376
 
5387
- /* Document-method: vid
5388
- * the name of the attribute, with a leading '@' sign
5377
+ /* Document-method: head
5378
+ * the argument to splat.
5389
5379
  */
5390
- rb_define_method(rb_cIVAR, "vid", node_vid, 0);
5391
- rb_ary_push(members, rb_str_new2("vid"));
5380
+ rb_define_method(rb_cSPLAT, "head", node_head, 0);
5381
+ rb_ary_push(members, rb_str_new2("head"));
5392
5382
  }
5393
5383
 
5394
- /* Document-class: Node::LVAR
5395
- * Represents local variable retrieval.
5384
+ /* Document-class: Node::STR
5385
+ * Represents a string object. Duplicates the string stored in the
5386
+ * node.
5396
5387
  */
5397
5388
  {
5398
- VALUE rb_cLVAR = rb_define_class_under(rb_cNode, "LVAR", rb_cNode);
5389
+ VALUE rb_cSTR = rb_define_class_under(rb_cNode, "STR", rb_cNode);
5399
5390
  members = rb_ary_new();
5400
- rb_cNodeSubclass[NODE_LVAR] = rb_cLVAR;
5401
- rb_iv_set(rb_cLVAR, "__member__", members);
5402
- rb_iv_set(rb_cLVAR, "__type__", INT2NUM(NODE_LVAR));
5403
- rb_define_singleton_method(rb_cLVAR, "members", node_s_members, 0);
5391
+ rb_cNodeSubclass[NODE_STR] = rb_cSTR;
5392
+ rb_iv_set(rb_cSTR, "__member__", members);
5393
+ rb_iv_set(rb_cSTR, "__type__", INT2NUM(NODE_STR));
5394
+ rb_define_singleton_method(rb_cSTR, "members", node_s_members, 0);
5404
5395
 
5405
- /* Document-method: vid
5406
- * the name of the local variable to retrieve.
5396
+ /* Document-method: lit
5397
+ * the string to be duplicated
5407
5398
  */
5408
- rb_define_method(rb_cLVAR, "vid", node_vid, 0);
5409
- rb_ary_push(members, rb_str_new2("vid"));
5410
- rb_define_method(rb_cLVAR, "cnt", node_cnt, 0);
5411
- rb_ary_push(members, rb_str_new2("cnt"));
5399
+ rb_define_method(rb_cSTR, "lit", node_lit, 0);
5400
+ rb_ary_push(members, rb_str_new2("lit"));
5412
5401
  }
5413
5402
 
5414
- /* Document-class: Node::MATCH2
5415
- * Represents a match in a conditional with a regular expression using
5416
- * interpolation, e.g.:
5417
- * if /#{recv}/ then
5418
- * ...
5419
- * end
5420
- *
5421
- * which is equivalent to:
5422
- * if /#{recv}/ =~ $_ then
5423
- * ...
5424
- * end
5425
- *
5426
- * or a match with a regular expression on the left hand side and an
5427
- * expression on the right hand side, e.g.:
5428
- *
5429
- * /recv/ =~ value
5403
+ /* Document-class: Node::SUPER
5404
+ * Represents the keyword 'super' when used with parens or with arguments.
5430
5405
  */
5431
5406
  {
5432
- VALUE rb_cMATCH2 = rb_define_class_under(rb_cNode, "MATCH2", rb_cNode);
5407
+ VALUE rb_cSUPER = rb_define_class_under(rb_cNode, "SUPER", rb_cNode);
5433
5408
  members = rb_ary_new();
5434
- rb_cNodeSubclass[NODE_MATCH2] = rb_cMATCH2;
5435
- rb_iv_set(rb_cMATCH2, "__member__", members);
5436
- rb_iv_set(rb_cMATCH2, "__type__", INT2NUM(NODE_MATCH2));
5437
- rb_define_singleton_method(rb_cMATCH2, "members", node_s_members, 0);
5438
-
5439
- /* Document-method: value
5440
- * the expression on the right hand side of the match operator, or
5441
- * an expression returning $_ if there is nothing on the right hand
5442
- * side
5443
- */
5444
- rb_define_method(rb_cMATCH2, "value", node_value, 0);
5445
- rb_ary_push(members, rb_str_new2("value"));
5409
+ rb_cNodeSubclass[NODE_SUPER] = rb_cSUPER;
5410
+ rb_iv_set(rb_cSUPER, "__member__", members);
5411
+ rb_iv_set(rb_cSUPER, "__type__", INT2NUM(NODE_SUPER));
5412
+ rb_define_singleton_method(rb_cSUPER, "members", node_s_members, 0);
5446
5413
 
5447
- /* Document-method: recv
5448
- * the regular expression on the left hand side of the match
5449
- * operator
5414
+ /* Document-method: args
5415
+ * the arguments to be passed to the base class
5450
5416
  */
5451
- rb_define_method(rb_cMATCH2, "recv", node_recv, 0);
5452
- rb_ary_push(members, rb_str_new2("recv"));
5417
+ rb_define_method(rb_cSUPER, "args", node_args, 0);
5418
+ rb_ary_push(members, rb_str_new2("args"));
5453
5419
  }
5454
5420
 
5455
- /* Document-class: Node::FLIP2
5456
- * Represents part of an awk-like flip-flop expression of the form:
5457
- * if beg..end then
5458
- * body
5459
- * end
5421
+ /* Document-class: Node::SVALUE
5422
+ * Represents the collection of multiple values of the right hand side
5423
+ * of an assignment into a single value, for use in single assignment,
5424
+ * e.g.:
5425
+ * lhs = a, b, c
5426
+ * The argument to this node is an Array.
5427
+ * If it is length 0, returns nil.
5428
+ * If it is length 1, returns the first element in the array.
5429
+ * Otherwise, returns the array.
5460
5430
  */
5461
5431
  {
5462
- VALUE rb_cFLIP2 = rb_define_class_under(rb_cNode, "FLIP2", rb_cNode);
5432
+ VALUE rb_cSVALUE = rb_define_class_under(rb_cNode, "SVALUE", rb_cNode);
5463
5433
  members = rb_ary_new();
5464
- rb_cNodeSubclass[NODE_FLIP2] = rb_cFLIP2;
5465
- rb_iv_set(rb_cFLIP2, "__member__", members);
5466
- rb_iv_set(rb_cFLIP2, "__type__", INT2NUM(NODE_FLIP2));
5467
- rb_define_singleton_method(rb_cFLIP2, "members", node_s_members, 0);
5434
+ rb_cNodeSubclass[NODE_SVALUE] = rb_cSVALUE;
5435
+ rb_iv_set(rb_cSVALUE, "__member__", members);
5436
+ rb_iv_set(rb_cSVALUE, "__type__", INT2NUM(NODE_SVALUE));
5437
+ rb_define_singleton_method(rb_cSVALUE, "members", node_s_members, 0);
5468
5438
 
5469
- /* Document-method: beg
5470
- * the beginning of the range
5439
+ /* Document-method: head
5440
+ * an expression which returns an Array.
5471
5441
  */
5472
- rb_define_method(rb_cFLIP2, "beg", node_beg, 0);
5473
- rb_ary_push(members, rb_str_new2("beg"));
5442
+ rb_define_method(rb_cSVALUE, "head", node_head, 0);
5443
+ rb_ary_push(members, rb_str_new2("head"));
5444
+ }
5474
5445
 
5475
- /* Document-method: end
5476
- * the end of the range
5477
- */
5478
- rb_define_method(rb_cFLIP2, "end", node_end, 0);
5479
- rb_ary_push(members, rb_str_new2("end"));
5446
+ /* Document-class: Node::TO_ARY
5447
+ * Represents a conversion from one object type to an array type.
5448
+ * Evaluation of this node converts its argument to an array by calling
5449
+ * \#to_ary on the argument.
5450
+ */
5451
+ {
5452
+ VALUE rb_cTO_ARY = rb_define_class_under(rb_cNode, "TO_ARY", rb_cNode);
5453
+ members = rb_ary_new();
5454
+ rb_cNodeSubclass[NODE_TO_ARY] = rb_cTO_ARY;
5455
+ rb_iv_set(rb_cTO_ARY, "__member__", members);
5456
+ rb_iv_set(rb_cTO_ARY, "__type__", INT2NUM(NODE_TO_ARY));
5457
+ rb_define_singleton_method(rb_cTO_ARY, "members", node_s_members, 0);
5480
5458
 
5481
- /* Document-method: cnt
5482
- * the index into the local variable table of the special variable
5483
- * to use in the flip-flop expression (usually 2 for $_)
5459
+ /* Document-method: head
5460
+ * the object to convert to an array
5484
5461
  */
5485
- rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0);
5486
- rb_ary_push(members, rb_str_new2("cnt"));
5462
+ rb_define_method(rb_cTO_ARY, "head", node_head, 0);
5463
+ rb_ary_push(members, rb_str_new2("head"));
5487
5464
  }
5488
5465
 
5489
- /* Document-class: Node::CONST
5490
- * Represents a constant lookup in the current class. The current
5491
- * class is the class in which the containing scope was defined. The
5492
- * result of the expression is the value of the constant.
5466
+ /* Document-class: Node::TRUE
5467
+ * Represents the keyword 'true'.
5493
5468
  */
5494
5469
  {
5495
- VALUE rb_cCONST = rb_define_class_under(rb_cNode, "CONST", rb_cNode);
5470
+ VALUE rb_cTRUE = rb_define_class_under(rb_cNode, "TRUE", rb_cNode);
5496
5471
  members = rb_ary_new();
5497
- rb_cNodeSubclass[NODE_CONST] = rb_cCONST;
5498
- rb_iv_set(rb_cCONST, "__member__", members);
5499
- rb_iv_set(rb_cCONST, "__type__", INT2NUM(NODE_CONST));
5500
- rb_define_singleton_method(rb_cCONST, "members", node_s_members, 0);
5501
-
5502
- /* Document-method: vid
5503
- * the name of the constant to look up
5504
- */
5505
- rb_define_method(rb_cCONST, "vid", node_vid, 0);
5506
- rb_ary_push(members, rb_str_new2("vid"));
5472
+ rb_cNodeSubclass[NODE_TRUE] = rb_cTRUE;
5473
+ rb_iv_set(rb_cTRUE, "__member__", members);
5474
+ rb_iv_set(rb_cTRUE, "__type__", INT2NUM(NODE_TRUE));
5475
+ rb_define_singleton_method(rb_cTRUE, "members", node_s_members, 0);
5507
5476
  }
5508
5477
 
5509
- /* Document-class: Node::METHOD
5510
- * A placeholder for a method entry in a class's method table.
5478
+ /* Document-class: Node::UNDEF
5479
+ * Represents an expression using the undef keyword, e.g.:
5480
+ * undef :mid
5481
+ *
5482
+ * This causes the method identified by mid in the current class to be
5483
+ * undefined.
5511
5484
  */
5512
5485
  {
5513
- VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode);
5486
+ VALUE rb_cUNDEF = rb_define_class_under(rb_cNode, "UNDEF", rb_cNode);
5514
5487
  members = rb_ary_new();
5515
- rb_cNodeSubclass[NODE_METHOD] = rb_cMETHOD;
5516
- rb_iv_set(rb_cMETHOD, "__member__", members);
5517
- rb_iv_set(rb_cMETHOD, "__type__", INT2NUM(NODE_METHOD));
5518
- rb_define_singleton_method(rb_cMETHOD, "members", node_s_members, 0);
5488
+ rb_cNodeSubclass[NODE_UNDEF] = rb_cUNDEF;
5489
+ rb_iv_set(rb_cUNDEF, "__member__", members);
5490
+ rb_iv_set(rb_cUNDEF, "__type__", INT2NUM(NODE_UNDEF));
5491
+ rb_define_singleton_method(rb_cUNDEF, "members", node_s_members, 0);
5519
5492
 
5520
5493
  /* Document-method: body
5521
- * the body of the method
5494
+ * an expression returning the id of the method to undefine
5522
5495
  */
5523
- rb_define_method(rb_cMETHOD, "body", node_body, 0);
5496
+ rb_define_method(rb_cUNDEF, "body", node_body, 0);
5524
5497
  rb_ary_push(members, rb_str_new2("body"));
5525
-
5526
- /* Document-method: noex
5527
- * the method's flags
5528
- */
5529
- rb_define_method(rb_cMETHOD, "noex", node_noex, 0);
5530
- rb_ary_push(members, rb_str_new2("noex"));
5531
5498
  }
5532
5499
 
5533
- /* Document-class: Node::MATCH3
5534
- * Represents a regular expression match of the form:
5535
- * recv =~ /value/
5536
- *
5537
- * where recv is an expression that returns an object and value is a
5538
- * regular expression literal.
5500
+ /* Document-class: Node::UNTIL
5501
+ * Represents a loop constructed with the 'until' keyword, e.g.:
5502
+ * until cond do
5503
+ * body
5504
+ * end
5539
5505
  */
5540
5506
  {
5541
- VALUE rb_cMATCH3 = rb_define_class_under(rb_cNode, "MATCH3", rb_cNode);
5507
+ VALUE rb_cUNTIL = rb_define_class_under(rb_cNode, "UNTIL", rb_cNode);
5542
5508
  members = rb_ary_new();
5543
- rb_cNodeSubclass[NODE_MATCH3] = rb_cMATCH3;
5544
- rb_iv_set(rb_cMATCH3, "__member__", members);
5545
- rb_iv_set(rb_cMATCH3, "__type__", INT2NUM(NODE_MATCH3));
5546
- rb_define_singleton_method(rb_cMATCH3, "members", node_s_members, 0);
5509
+ rb_cNodeSubclass[NODE_UNTIL] = rb_cUNTIL;
5510
+ rb_iv_set(rb_cUNTIL, "__member__", members);
5511
+ rb_iv_set(rb_cUNTIL, "__type__", INT2NUM(NODE_UNTIL));
5512
+ rb_define_singleton_method(rb_cUNTIL, "members", node_s_members, 0);
5547
5513
 
5548
- /* Document-method: value
5549
- * the right hand side of the match
5514
+ /* Document-method: body
5515
+ * the body of the loop
5550
5516
  */
5551
- rb_define_method(rb_cMATCH3, "value", node_value, 0);
5552
- rb_ary_push(members, rb_str_new2("value"));
5517
+ rb_define_method(rb_cUNTIL, "body", node_body, 0);
5518
+ rb_ary_push(members, rb_str_new2("body"));
5553
5519
 
5554
- /* Document-method: recv
5555
- * the left hand side of the match
5520
+ /* Document-method: cond
5521
+ * a condition to terminate the loop when it becomes true
5556
5522
  */
5557
- rb_define_method(rb_cMATCH3, "recv", node_recv, 0);
5558
- rb_ary_push(members, rb_str_new2("recv"));
5523
+ rb_define_method(rb_cUNTIL, "cond", node_cond, 0);
5524
+ rb_ary_push(members, rb_str_new2("cond"));
5525
+ rb_define_method(rb_cUNTIL, "state", node_state, 0);
5526
+ rb_ary_push(members, rb_str_new2("state"));
5559
5527
  }
5560
5528
 
5561
- /* Document-class: Node::IASGN
5562
- * Represents instance variable assignment.
5529
+ /* Document-class: Node::VALIAS
5530
+ * Represents an alias expression of the form:
5531
+ * alias 1st 2nd
5532
+ * where 2nd is the name of a variable and 1st is the name of its new
5533
+ * alias.
5563
5534
  */
5564
5535
  {
5565
- VALUE rb_cIASGN = rb_define_class_under(rb_cNode, "IASGN", rb_cNode);
5536
+ VALUE rb_cVALIAS = rb_define_class_under(rb_cNode, "VALIAS", rb_cNode);
5566
5537
  members = rb_ary_new();
5567
- rb_cNodeSubclass[NODE_IASGN] = rb_cIASGN;
5568
- rb_iv_set(rb_cIASGN, "__member__", members);
5569
- rb_iv_set(rb_cIASGN, "__type__", INT2NUM(NODE_IASGN));
5570
- rb_define_singleton_method(rb_cIASGN, "members", node_s_members, 0);
5571
-
5572
- /* Document-method: value
5573
- * the value to assign to the instance variable
5574
- */
5575
- rb_define_method(rb_cIASGN, "value", node_value, 0);
5576
- rb_ary_push(members, rb_str_new2("value"));
5577
-
5578
- /* Document-method: vid
5579
- * the name of the instance variable, with a leading '@' sign
5580
- */
5581
- rb_define_method(rb_cIASGN, "vid", node_vid, 0);
5582
- rb_ary_push(members, rb_str_new2("vid"));
5538
+ rb_cNodeSubclass[NODE_VALIAS] = rb_cVALIAS;
5539
+ rb_iv_set(rb_cVALIAS, "__member__", members);
5540
+ rb_iv_set(rb_cVALIAS, "__type__", INT2NUM(NODE_VALIAS));
5541
+ rb_define_singleton_method(rb_cVALIAS, "members", node_s_members, 0);
5542
+ rb_define_method(rb_cVALIAS, "first", node_1st, 0);
5543
+ rb_ary_push(members, rb_str_new2("first"));
5544
+ rb_define_method(rb_cVALIAS, "second", node_2nd, 0);
5545
+ rb_ary_push(members, rb_str_new2("second"));
5583
5546
  }
5584
5547
 
5585
- /* Document-class: Node::DMETHOD
5586
- * A placeholder for a method defined using define_method where the
5587
- * passed block is created from a Method object, e.g.:
5588
- * define_method(:name, method(:foo))
5589
- *
5590
- * See also BMETHOD.
5548
+ /* Document-class: Node::VCALL
5549
+ * Represents a local variable or a method call without an explicit
5550
+ * receiver, to be determined at run-time.
5591
5551
  */
5592
5552
  {
5593
- VALUE rb_cDMETHOD = rb_define_class_under(rb_cNode, "DMETHOD", rb_cNode);
5553
+ VALUE rb_cVCALL = rb_define_class_under(rb_cNode, "VCALL", rb_cNode);
5594
5554
  members = rb_ary_new();
5595
- rb_cNodeSubclass[NODE_DMETHOD] = rb_cDMETHOD;
5596
- rb_iv_set(rb_cDMETHOD, "__member__", members);
5597
- rb_iv_set(rb_cDMETHOD, "__type__", INT2NUM(NODE_DMETHOD));
5598
- rb_define_singleton_method(rb_cDMETHOD, "members", node_s_members, 0);
5555
+ rb_cNodeSubclass[NODE_VCALL] = rb_cVCALL;
5556
+ rb_iv_set(rb_cVCALL, "__member__", members);
5557
+ rb_iv_set(rb_cVCALL, "__type__", INT2NUM(NODE_VCALL));
5558
+ rb_define_singleton_method(rb_cVCALL, "members", node_s_members, 0);
5599
5559
 
5600
- /* Document-method: cval
5601
- * the Method object passed to define_method, which contains the
5602
- * body of the method
5560
+ /* Document-method: mid
5561
+ * the name of the variable or method
5603
5562
  */
5604
- rb_define_method(rb_cDMETHOD, "cval", node_cval, 0);
5605
- rb_ary_push(members, rb_str_new2("cval"));
5563
+ rb_define_method(rb_cVCALL, "mid", node_mid, 0);
5564
+ rb_ary_push(members, rb_str_new2("mid"));
5606
5565
  }
5607
5566
 
5608
- /* Document-class: Node::FLIP3
5609
- * Represents part of a sed-like flip-flop expression of the form:
5610
- * if beg..end then
5567
+ /* Document-class: Node::WHEN
5568
+ * Represents either a conditional in a case/end block:
5569
+ * case value
5570
+ * when head
5571
+ * body
5572
+ * next
5573
+ * end
5574
+ *
5575
+ * or the first element of a a case/end block with no conditional:
5576
+ * case
5577
+ * when head
5611
5578
  * body
5579
+ * next
5612
5580
  * end
5581
+ *
5582
+ * In the first case, value is evaluated and head is evaluated, and
5583
+ * they are compared using head === value. If the result is true, then
5584
+ * body is evaluated and no more when conditions are tried, otherwise
5585
+ * the interpreter evaluates the next node.
5586
+ *
5587
+ * In the second case, head is tested using rtest(value). If the
5588
+ * result is true, then body is evaluated and no more when conditions
5589
+ * are tried, otherwise the interpreter evaluates the next node.
5590
+ *
5591
+ * If the condition evaluates to false and there are no more when
5592
+ * conditions to try, the result of the expression is nil.
5593
+ *
5594
+ * If the next expression to try is not a WHEN node, then it represents
5595
+ * an else element and is evaluated unconditionally.
5613
5596
  */
5614
5597
  {
5615
- VALUE rb_cFLIP3 = rb_define_class_under(rb_cNode, "FLIP3", rb_cNode);
5598
+ VALUE rb_cWHEN = rb_define_class_under(rb_cNode, "WHEN", rb_cNode);
5616
5599
  members = rb_ary_new();
5617
- rb_cNodeSubclass[NODE_FLIP3] = rb_cFLIP3;
5618
- rb_iv_set(rb_cFLIP3, "__member__", members);
5619
- rb_iv_set(rb_cFLIP3, "__type__", INT2NUM(NODE_FLIP3));
5620
- rb_define_singleton_method(rb_cFLIP3, "members", node_s_members, 0);
5600
+ rb_cNodeSubclass[NODE_WHEN] = rb_cWHEN;
5601
+ rb_iv_set(rb_cWHEN, "__member__", members);
5602
+ rb_iv_set(rb_cWHEN, "__type__", INT2NUM(NODE_WHEN));
5603
+ rb_define_singleton_method(rb_cWHEN, "members", node_s_members, 0);
5621
5604
 
5622
- /* Document-method: beg
5623
- * the beginning of the range
5605
+ /* Document-method: head
5606
+ * a value to compare against, or a condition to be tested
5624
5607
  */
5625
- rb_define_method(rb_cFLIP3, "beg", node_beg, 0);
5626
- rb_ary_push(members, rb_str_new2("beg"));
5608
+ rb_define_method(rb_cWHEN, "head", node_head, 0);
5609
+ rb_ary_push(members, rb_str_new2("head"));
5627
5610
 
5628
- /* Document-method: end
5629
- * the end of the range
5611
+ /* Document-method: body
5612
+ * an expression to evaluate if the condition evaluates to true
5630
5613
  */
5631
- rb_define_method(rb_cFLIP3, "end", node_end, 0);
5632
- rb_ary_push(members, rb_str_new2("end"));
5614
+ rb_define_method(rb_cWHEN, "body", node_body, 0);
5615
+ rb_ary_push(members, rb_str_new2("body"));
5633
5616
 
5634
- /* Document-method: cnt
5635
- * the index into the local variable table of the special variable
5636
- * to use in the flip-flop expression (usually 2 for $_)
5617
+ /* Document-method: next
5618
+ * the next expression to be evaluated if the condition is false
5637
5619
  */
5638
- rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0);
5639
- rb_ary_push(members, rb_str_new2("cnt"));
5620
+ rb_define_method(rb_cWHEN, "next", node_next, 0);
5621
+ rb_ary_push(members, rb_str_new2("next"));
5640
5622
  }
5641
5623
 
5642
- /* Document-class: Node::OR
5643
- * Represents a logical 'or' of the form:
5644
- * first || second
5645
- * The expression will short-circuit and yield the result of the left
5646
- * hand side if it is true, else it will evaluate the right hand side
5647
- * and use it as the result of the expression.
5624
+ /* Document-class: Node::WHILE
5625
+ * Represents a loop constructed with the 'while' keyword, e.g.:
5626
+ * while cond do
5627
+ * body
5628
+ * end
5648
5629
  */
5649
5630
  {
5650
- VALUE rb_cOR = rb_define_class_under(rb_cNode, "OR", rb_cNode);
5631
+ VALUE rb_cWHILE = rb_define_class_under(rb_cNode, "WHILE", rb_cNode);
5651
5632
  members = rb_ary_new();
5652
- rb_cNodeSubclass[NODE_OR] = rb_cOR;
5653
- rb_iv_set(rb_cOR, "__member__", members);
5654
- rb_iv_set(rb_cOR, "__type__", INT2NUM(NODE_OR));
5655
- rb_define_singleton_method(rb_cOR, "members", node_s_members, 0);
5633
+ rb_cNodeSubclass[NODE_WHILE] = rb_cWHILE;
5634
+ rb_iv_set(rb_cWHILE, "__member__", members);
5635
+ rb_iv_set(rb_cWHILE, "__type__", INT2NUM(NODE_WHILE));
5636
+ rb_define_singleton_method(rb_cWHILE, "members", node_s_members, 0);
5656
5637
 
5657
- /* Document-method: first
5658
- * the expression on the left hand side
5638
+ /* Document-method: body
5639
+ * the body of the loop
5659
5640
  */
5660
- rb_define_method(rb_cOR, "first", node_1st, 0);
5661
- rb_ary_push(members, rb_str_new2("first"));
5641
+ rb_define_method(rb_cWHILE, "body", node_body, 0);
5642
+ rb_ary_push(members, rb_str_new2("body"));
5662
5643
 
5663
- /* Document-method: second
5664
- * the expression on the right hand side
5644
+ /* Document-method: cond
5645
+ * a condition to terminate the loop when it becomes false
5665
5646
  */
5666
- rb_define_method(rb_cOR, "second", node_2nd, 0);
5667
- rb_ary_push(members, rb_str_new2("second"));
5647
+ rb_define_method(rb_cWHILE, "cond", node_cond, 0);
5648
+ rb_ary_push(members, rb_str_new2("cond"));
5649
+ rb_define_method(rb_cWHILE, "state", node_state, 0);
5650
+ rb_ary_push(members, rb_str_new2("state"));
5668
5651
  }
5669
5652
 
5670
- /* Document-class: Node::CVAR
5671
- * Represents a class variable retrieval. The result of the expression
5672
- * is the value of the class variable.
5653
+ /* Document-class: Node::XSTR
5654
+ * Represents a string object inside backticks, e.g.:
5655
+ * `lit`
5656
+ * The given string is executed in a subshell and the output from its
5657
+ * stdout stored in a string.
5673
5658
  */
5674
5659
  {
5675
- VALUE rb_cCVAR = rb_define_class_under(rb_cNode, "CVAR", rb_cNode);
5660
+ VALUE rb_cXSTR = rb_define_class_under(rb_cNode, "XSTR", rb_cNode);
5676
5661
  members = rb_ary_new();
5677
- rb_cNodeSubclass[NODE_CVAR] = rb_cCVAR;
5678
- rb_iv_set(rb_cCVAR, "__member__", members);
5679
- rb_iv_set(rb_cCVAR, "__type__", INT2NUM(NODE_CVAR));
5680
- rb_define_singleton_method(rb_cCVAR, "members", node_s_members, 0);
5662
+ rb_cNodeSubclass[NODE_XSTR] = rb_cXSTR;
5663
+ rb_iv_set(rb_cXSTR, "__member__", members);
5664
+ rb_iv_set(rb_cXSTR, "__type__", INT2NUM(NODE_XSTR));
5665
+ rb_define_singleton_method(rb_cXSTR, "members", node_s_members, 0);
5681
5666
 
5682
- /* Document-method: vid
5683
- * the name of the class variable, with two leading '@' characters.
5667
+ /* Document-method: lit
5668
+ * the string to be executed
5684
5669
  */
5685
- rb_define_method(rb_cCVAR, "vid", node_vid, 0);
5686
- rb_ary_push(members, rb_str_new2("vid"));
5670
+ rb_define_method(rb_cXSTR, "lit", node_lit, 0);
5671
+ rb_ary_push(members, rb_str_new2("lit"));
5687
5672
  }
5688
5673
 
5689
5674
  /* Document-class: Node::YIELD
@@ -5712,20 +5697,35 @@ void define_node_subclass_methods()
5712
5697
  rb_ary_push(members, rb_str_new2("state"));
5713
5698
  }
5714
5699
 
5715
- /* Document-class: Node::BEGIN
5716
- * Represents a begin/end block.
5700
+ /* Document-class: Node::ZARRAY
5701
+ * Represents an array of zero elements. Evalation of this node
5702
+ * creates a new array of length zero.
5703
+ */
5704
+ {
5705
+ VALUE rb_cZARRAY = rb_define_class_under(rb_cNode, "ZARRAY", rb_cNode);
5706
+ members = rb_ary_new();
5707
+ rb_cNodeSubclass[NODE_ZARRAY] = rb_cZARRAY;
5708
+ rb_iv_set(rb_cZARRAY, "__member__", members);
5709
+ rb_iv_set(rb_cZARRAY, "__type__", INT2NUM(NODE_ZARRAY));
5710
+ rb_define_singleton_method(rb_cZARRAY, "members", node_s_members, 0);
5711
+ }
5712
+
5713
+ /* Document-class: Node::ZSUPER
5714
+ * Represents the keyword 'super' when used without parens nor
5715
+ * arguments. The arguments to the base class method are obtained from
5716
+ * the arguments passed to the current method, which are store in the
5717
+ * current frame.
5717
5718
  *
5718
- * TODO: Need an example
5719
+ * Can also be a placeholder for a method when its implementation is
5720
+ * deferred to the base class.
5719
5721
  */
5720
5722
  {
5721
- VALUE rb_cBEGIN = rb_define_class_under(rb_cNode, "BEGIN", rb_cNode);
5723
+ VALUE rb_cZSUPER = rb_define_class_under(rb_cNode, "ZSUPER", rb_cNode);
5722
5724
  members = rb_ary_new();
5723
- rb_cNodeSubclass[NODE_BEGIN] = rb_cBEGIN;
5724
- rb_iv_set(rb_cBEGIN, "__member__", members);
5725
- rb_iv_set(rb_cBEGIN, "__type__", INT2NUM(NODE_BEGIN));
5726
- rb_define_singleton_method(rb_cBEGIN, "members", node_s_members, 0);
5727
- rb_define_method(rb_cBEGIN, "body", node_body, 0);
5728
- rb_ary_push(members, rb_str_new2("body"));
5725
+ rb_cNodeSubclass[NODE_ZSUPER] = rb_cZSUPER;
5726
+ rb_iv_set(rb_cZSUPER, "__member__", members);
5727
+ rb_iv_set(rb_cZSUPER, "__type__", INT2NUM(NODE_ZSUPER));
5728
+ rb_define_singleton_method(rb_cZSUPER, "members", node_s_members, 0);
5729
5729
  }
5730
5730
  }
5731
5731