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