ruby-internal 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +204 -6
- data/ext/cached/ruby-1.6.8/internal/binding/block.h +35 -0
- data/ext/cached/ruby-1.6.8/internal/method/method.h +19 -0
- data/ext/cached/ruby-1.6.8/internal/module/classpath.c +3 -0
- data/ext/cached/ruby-1.6.8/internal/module/classpath.h +8 -0
- data/ext/cached/ruby-1.6.8/internal/node/block.h +35 -0
- data/ext/cached/ruby-1.6.8/internal/node/global_entry.h +15 -0
- data/ext/cached/ruby-1.6.8/internal/node/node_type_descrip.c +149 -0
- data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.c +5582 -0
- data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.6.8/internal/proc/block.h +35 -0
- data/ext/cached/ruby-1.6.8/internal/tag/tag.h +15 -0
- data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.6.8/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.6.8/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +91 -91
- data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +1909 -1909
- data/ext/cached/ruby-1.8.0/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +1946 -1946
- data/ext/cached/ruby-1.8.1/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +1946 -1946
- data/ext/cached/ruby-1.8.2/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.3/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +1946 -1946
- data/ext/cached/ruby-1.8.3/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +1946 -1946
- data/ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +1909 -1909
- data/ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +1909 -1909
- data/ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +90 -90
- data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +1909 -1909
- data/ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc +9 -0
- data/ext/cached/ruby-1.9.0/internal/node/node_type_descrip.c +85 -85
- data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.c +1800 -1800
- data/ext/cached/ruby-1.9.0/internal/vm/iseq/iseq_load.inc +13 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +51 -51
- data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +85 -85
- data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +1800 -1800
- data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.h +1 -2
- data/ext/cached/ruby-1.9.1/internal/vm/iseq/iseq_load.inc +356 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/eval_intern.h +15 -9
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/id.h +45 -66
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +12 -3
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/node.h +2 -2
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +23 -138
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -1
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/transcode_data.h +9 -2
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/transdb.h +62 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +17 -23
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +20 -29
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_exec.h +4 -7
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +6 -5
- data/ext/internal/module/cfp.h +13 -0
- data/ext/internal/module/extconf.rb +2 -2
- data/ext/internal/module/module.c +3 -8
- data/ext/internal/node/nodes.rb +2 -1
- data/ext/internal/vm/iseq/iseq.c +2 -3
- data/ext/internal/vm/iseq/iseq_load.inc.rpp +61 -0
- data/ext/internal/yarv-headers/debug.h +36 -0
- data/ext/internal/yarv-headers/dln.h +41 -0
- data/ext/internal/yarv-headers/encdb.h +147 -0
- data/ext/internal/yarv-headers/eval_intern.h +215 -0
- data/ext/internal/yarv-headers/gc.h +75 -0
- data/ext/internal/yarv-headers/id.h +163 -0
- data/ext/internal/yarv-headers/iseq.h +103 -0
- data/ext/internal/yarv-headers/node.h +516 -0
- data/ext/internal/yarv-headers/parse.h +188 -0
- data/ext/internal/yarv-headers/regenc.h +207 -0
- data/ext/internal/yarv-headers/regint.h +842 -0
- data/ext/internal/yarv-headers/regparse.h +351 -0
- data/ext/internal/yarv-headers/revision.h +1 -0
- data/ext/internal/yarv-headers/thread_pthread.h +24 -0
- data/ext/internal/yarv-headers/thread_win32.h +33 -0
- data/ext/internal/yarv-headers/transcode_data.h +106 -0
- data/ext/internal/yarv-headers/transdb.h +147 -0
- data/ext/internal/yarv-headers/version.h +54 -0
- data/ext/internal/yarv-headers/vm_core.h +646 -0
- data/ext/internal/yarv-headers/vm_exec.h +184 -0
- data/ext/internal/yarv-headers/vm_insnhelper.h +195 -0
- data/ext/internal/yarv-headers/vm_opts.h +51 -0
- data/publish_rdoc.rb +4 -0
- metadata +52 -2
|
@@ -2895,88 +2895,86 @@ void define_node_subclass_methods()
|
|
|
2895
2895
|
}
|
|
2896
2896
|
|
|
2897
2897
|
|
|
2898
|
-
/* Document-class: Node::
|
|
2899
|
-
* Represents
|
|
2900
|
-
*
|
|
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
|
|
2905
|
+
VALUE rb_cALIAS = rb_define_class_under(rb_cNode, "ALIAS", rb_cNode);
|
|
2904
2906
|
members = rb_ary_new();
|
|
2905
|
-
rb_cNodeSubclass[
|
|
2906
|
-
rb_iv_set(
|
|
2907
|
-
rb_iv_set(
|
|
2908
|
-
rb_define_singleton_method(
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
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::
|
|
2924
|
-
*
|
|
2925
|
-
*
|
|
2926
|
-
*
|
|
2927
|
-
*
|
|
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
|
|
2925
|
+
VALUE rb_cALLOCA = rb_define_class_under(rb_cNode, "ALLOCA", rb_cNode);
|
|
2931
2926
|
members = rb_ary_new();
|
|
2932
|
-
rb_cNodeSubclass[
|
|
2933
|
-
rb_iv_set(
|
|
2934
|
-
rb_iv_set(
|
|
2935
|
-
rb_define_singleton_method(
|
|
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:
|
|
2938
|
-
*
|
|
2932
|
+
/* Document-method: cfnc
|
|
2933
|
+
* a pointer to the allocated memory
|
|
2939
2934
|
*/
|
|
2940
|
-
rb_define_method(
|
|
2941
|
-
rb_ary_push(members, rb_str_new2("
|
|
2935
|
+
rb_define_method(rb_cALLOCA, "cfnc", node_cfnc, 0);
|
|
2936
|
+
rb_ary_push(members, rb_str_new2("cfnc"));
|
|
2942
2937
|
|
|
2943
|
-
/* Document-method:
|
|
2944
|
-
* a
|
|
2938
|
+
/* Document-method: value
|
|
2939
|
+
* a pointer to the previously allocated temporary node
|
|
2945
2940
|
*/
|
|
2946
|
-
rb_define_method(
|
|
2947
|
-
rb_ary_push(members, rb_str_new2("
|
|
2948
|
-
|
|
2949
|
-
|
|
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::
|
|
2953
|
-
* Represents
|
|
2954
|
-
*
|
|
2955
|
-
*
|
|
2956
|
-
*
|
|
2957
|
-
*
|
|
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
|
|
2960
|
+
VALUE rb_cAND = rb_define_class_under(rb_cNode, "AND", rb_cNode);
|
|
2961
2961
|
members = rb_ary_new();
|
|
2962
|
-
rb_cNodeSubclass[
|
|
2963
|
-
rb_iv_set(
|
|
2964
|
-
rb_iv_set(
|
|
2965
|
-
rb_define_singleton_method(
|
|
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:
|
|
2968
|
-
* the
|
|
2969
|
-
* reference, one of '&', '`', '\'', or '+'
|
|
2967
|
+
/* Document-method: first
|
|
2968
|
+
* the expression on the left hand side
|
|
2970
2969
|
*/
|
|
2971
|
-
rb_define_method(
|
|
2972
|
-
rb_ary_push(members, rb_str_new2("
|
|
2970
|
+
rb_define_method(rb_cAND, "first", node_1st, 0);
|
|
2971
|
+
rb_ary_push(members, rb_str_new2("first"));
|
|
2973
2972
|
|
|
2974
|
-
/* Document-method:
|
|
2975
|
-
* the
|
|
2976
|
-
* stored
|
|
2973
|
+
/* Document-method: second
|
|
2974
|
+
* the expression on the right hand side
|
|
2977
2975
|
*/
|
|
2978
|
-
rb_define_method(
|
|
2979
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3014
|
-
* Represents
|
|
3015
|
-
*
|
|
3016
|
-
*
|
|
3017
|
-
*
|
|
3018
|
-
*
|
|
3019
|
-
*
|
|
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
|
|
3021
|
+
VALUE rb_cARGSCAT = rb_define_class_under(rb_cNode, "ARGSCAT", rb_cNode);
|
|
3023
3022
|
members = rb_ary_new();
|
|
3024
|
-
rb_cNodeSubclass[
|
|
3025
|
-
rb_iv_set(
|
|
3026
|
-
rb_iv_set(
|
|
3027
|
-
rb_define_singleton_method(
|
|
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:
|
|
3030
|
-
*
|
|
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(
|
|
3034
|
-
rb_ary_push(members, rb_str_new2("
|
|
3031
|
+
rb_define_method(rb_cARGSCAT, "head", node_head, 0);
|
|
3032
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
3035
3033
|
|
|
3036
|
-
/* Document-method:
|
|
3037
|
-
*
|
|
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(
|
|
3040
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3044
|
-
* Represents the
|
|
3045
|
-
*
|
|
3046
|
-
*
|
|
3047
|
-
*
|
|
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
|
|
3050
|
+
VALUE rb_cARGSPUSH = rb_define_class_under(rb_cNode, "ARGSPUSH", rb_cNode);
|
|
3051
3051
|
members = rb_ary_new();
|
|
3052
|
-
rb_cNodeSubclass[
|
|
3053
|
-
rb_iv_set(
|
|
3054
|
-
rb_iv_set(
|
|
3055
|
-
rb_define_singleton_method(
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
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::
|
|
3065
|
-
* Represents
|
|
3066
|
-
*
|
|
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
|
|
3068
|
+
VALUE rb_cARRAY = rb_define_class_under(rb_cNode, "ARRAY", rb_cNode);
|
|
3095
3069
|
members = rb_ary_new();
|
|
3096
|
-
rb_cNodeSubclass[
|
|
3097
|
-
rb_iv_set(
|
|
3098
|
-
rb_iv_set(
|
|
3099
|
-
rb_define_singleton_method(
|
|
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
|
|
3076
|
+
* the first element of the array
|
|
3103
3077
|
*/
|
|
3104
|
-
rb_define_method(
|
|
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:
|
|
3108
|
-
* the
|
|
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(
|
|
3117
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3121
|
-
* Represents
|
|
3122
|
-
*
|
|
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
|
|
3097
|
+
VALUE rb_cATTRASGN = rb_define_class_under(rb_cNode, "ATTRASGN", rb_cNode);
|
|
3126
3098
|
members = rb_ary_new();
|
|
3127
|
-
rb_cNodeSubclass[
|
|
3128
|
-
rb_iv_set(
|
|
3129
|
-
rb_iv_set(
|
|
3130
|
-
rb_define_singleton_method(
|
|
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:
|
|
3133
|
-
* the
|
|
3104
|
+
/* Document-method: args
|
|
3105
|
+
* the arguments to the method
|
|
3134
3106
|
*/
|
|
3135
|
-
rb_define_method(
|
|
3136
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3140
|
-
*
|
|
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
|
|
3130
|
+
VALUE rb_cATTRSET = rb_define_class_under(rb_cNode, "ATTRSET", rb_cNode);
|
|
3144
3131
|
members = rb_ary_new();
|
|
3145
|
-
rb_cNodeSubclass[
|
|
3146
|
-
rb_iv_set(
|
|
3147
|
-
rb_iv_set(
|
|
3148
|
-
rb_define_singleton_method(
|
|
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::
|
|
3152
|
-
*
|
|
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
|
|
3152
|
+
VALUE rb_cBACK_REF = rb_define_class_under(rb_cNode, "BACK_REF", rb_cNode);
|
|
3156
3153
|
members = rb_ary_new();
|
|
3157
|
-
rb_cNodeSubclass[
|
|
3158
|
-
rb_iv_set(
|
|
3159
|
-
rb_iv_set(
|
|
3160
|
-
rb_define_singleton_method(
|
|
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:
|
|
3169
|
-
* the
|
|
3170
|
-
*
|
|
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(
|
|
3173
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
3176
|
-
*
|
|
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(
|
|
3179
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3183
|
-
* Represents
|
|
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
|
-
*
|
|
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
|
|
3180
|
+
VALUE rb_cBEGIN = rb_define_class_under(rb_cNode, "BEGIN", rb_cNode);
|
|
3208
3181
|
members = rb_ary_new();
|
|
3209
|
-
rb_cNodeSubclass[
|
|
3210
|
-
rb_iv_set(
|
|
3211
|
-
rb_iv_set(
|
|
3212
|
-
rb_define_singleton_method(
|
|
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::
|
|
3261
|
-
* Represents a
|
|
3262
|
-
*
|
|
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
|
|
3227
|
+
VALUE rb_cBLOCK_ARG = rb_define_class_under(rb_cNode, "BLOCK_ARG", rb_cNode);
|
|
3269
3228
|
members = rb_ary_new();
|
|
3270
|
-
rb_cNodeSubclass[
|
|
3271
|
-
rb_iv_set(
|
|
3272
|
-
rb_iv_set(
|
|
3273
|
-
rb_define_singleton_method(
|
|
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:
|
|
3282
|
-
* the
|
|
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(
|
|
3285
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3289
|
-
* Represents
|
|
3290
|
-
*
|
|
3291
|
-
*
|
|
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
|
|
3252
|
+
VALUE rb_cBLOCK_PASS = rb_define_class_under(rb_cNode, "BLOCK_PASS", rb_cNode);
|
|
3295
3253
|
members = rb_ary_new();
|
|
3296
|
-
rb_cNodeSubclass[
|
|
3297
|
-
rb_iv_set(
|
|
3298
|
-
rb_iv_set(
|
|
3299
|
-
rb_define_singleton_method(
|
|
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:
|
|
3308
|
-
*
|
|
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(
|
|
3312
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
3315
|
-
*
|
|
3265
|
+
/* Document-method: iter
|
|
3266
|
+
* an expression which calls a method
|
|
3316
3267
|
*/
|
|
3317
|
-
rb_define_method(
|
|
3318
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3322
|
-
*
|
|
3323
|
-
*
|
|
3324
|
-
*
|
|
3325
|
-
*
|
|
3326
|
-
*
|
|
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
|
|
3281
|
+
VALUE rb_cBMETHOD = rb_define_class_under(rb_cNode, "BMETHOD", rb_cNode);
|
|
3330
3282
|
members = rb_ary_new();
|
|
3331
|
-
rb_cNodeSubclass[
|
|
3332
|
-
rb_iv_set(
|
|
3333
|
-
rb_iv_set(
|
|
3334
|
-
rb_define_singleton_method(
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
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::
|
|
3342
|
-
* Represents the
|
|
3343
|
-
*
|
|
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
|
|
3301
|
+
VALUE rb_cBREAK = rb_define_class_under(rb_cNode, "BREAK", rb_cNode);
|
|
3347
3302
|
members = rb_ary_new();
|
|
3348
|
-
rb_cNodeSubclass[
|
|
3349
|
-
rb_iv_set(
|
|
3350
|
-
rb_iv_set(
|
|
3351
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
3367
|
+
* a linked list of nodes, each node representing a when
|
|
3368
|
+
* conditional
|
|
3355
3369
|
*/
|
|
3356
|
-
rb_define_method(
|
|
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::
|
|
3361
|
-
*
|
|
3362
|
-
*
|
|
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
|
|
3381
|
+
VALUE rb_cCDECL = rb_define_class_under(rb_cNode, "CDECL", rb_cNode);
|
|
3367
3382
|
members = rb_ary_new();
|
|
3368
|
-
rb_cNodeSubclass[
|
|
3369
|
-
rb_iv_set(
|
|
3370
|
-
rb_iv_set(
|
|
3371
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
3395
|
+
* the name of the constant to be assigned, all uppercase
|
|
3375
3396
|
*/
|
|
3376
|
-
rb_define_method(
|
|
3397
|
+
rb_define_method(rb_cCDECL, "vid", node_vid, 0);
|
|
3377
3398
|
rb_ary_push(members, rb_str_new2("vid"));
|
|
3399
|
+
}
|
|
3378
3400
|
|
|
3379
|
-
|
|
3380
|
-
|
|
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(
|
|
3383
|
-
rb_ary_push(members, rb_str_new2("
|
|
3444
|
+
rb_define_method(rb_cCLASS, "cpath", node_cpath, 0);
|
|
3445
|
+
rb_ary_push(members, rb_str_new2("cpath"));
|
|
3384
3446
|
|
|
3385
|
-
/* Document-method:
|
|
3386
|
-
*
|
|
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(
|
|
3391
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3476
|
-
* Represents
|
|
3477
|
-
*
|
|
3478
|
-
*
|
|
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
|
|
3516
|
+
VALUE rb_cCONST = rb_define_class_under(rb_cNode, "CONST", rb_cNode);
|
|
3490
3517
|
members = rb_ary_new();
|
|
3491
|
-
rb_cNodeSubclass[
|
|
3492
|
-
rb_iv_set(
|
|
3493
|
-
rb_iv_set(
|
|
3494
|
-
rb_define_singleton_method(
|
|
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:
|
|
3497
|
-
* the
|
|
3523
|
+
/* Document-method: vid
|
|
3524
|
+
* the name of the constant to look up
|
|
3498
3525
|
*/
|
|
3499
|
-
rb_define_method(
|
|
3500
|
-
rb_ary_push(members, rb_str_new2("
|
|
3526
|
+
rb_define_method(rb_cCONST, "vid", node_vid, 0);
|
|
3527
|
+
rb_ary_push(members, rb_str_new2("vid"));
|
|
3528
|
+
}
|
|
3501
3529
|
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
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
|
|
3539
|
+
VALUE rb_cCREF = rb_define_class_under(rb_cNode, "CREF", rb_cNode);
|
|
3523
3540
|
members = rb_ary_new();
|
|
3524
|
-
rb_cNodeSubclass[
|
|
3525
|
-
rb_iv_set(
|
|
3526
|
-
rb_iv_set(
|
|
3527
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
3547
|
+
* always 0 (false)
|
|
3531
3548
|
*/
|
|
3532
|
-
rb_define_method(
|
|
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::
|
|
3537
|
-
* Represents
|
|
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
|
|
3570
|
+
VALUE rb_cCVAR = rb_define_class_under(rb_cNode, "CVAR", rb_cNode);
|
|
3541
3571
|
members = rb_ary_new();
|
|
3542
|
-
rb_cNodeSubclass[
|
|
3543
|
-
rb_iv_set(
|
|
3544
|
-
rb_iv_set(
|
|
3545
|
-
rb_define_singleton_method(
|
|
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:
|
|
3548
|
-
* the
|
|
3577
|
+
/* Document-method: vid
|
|
3578
|
+
* the name of the class variable, with two leading '@' characters.
|
|
3549
3579
|
*/
|
|
3550
|
-
rb_define_method(
|
|
3551
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3555
|
-
* Represents
|
|
3584
|
+
/* Document-class: Node::CVASGN
|
|
3585
|
+
* Represents class variable assignment in a method context.
|
|
3556
3586
|
*/
|
|
3557
3587
|
{
|
|
3558
|
-
VALUE
|
|
3588
|
+
VALUE rb_cCVASGN = rb_define_class_under(rb_cNode, "CVASGN", rb_cNode);
|
|
3559
3589
|
members = rb_ary_new();
|
|
3560
|
-
rb_cNodeSubclass[
|
|
3561
|
-
rb_iv_set(
|
|
3562
|
-
rb_iv_set(
|
|
3563
|
-
rb_define_singleton_method(
|
|
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::
|
|
3567
|
-
* Represents
|
|
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
|
|
3615
|
+
VALUE rb_cCVDECL = rb_define_class_under(rb_cNode, "CVDECL", rb_cNode);
|
|
3571
3616
|
members = rb_ary_new();
|
|
3572
|
-
rb_cNodeSubclass[
|
|
3573
|
-
rb_iv_set(
|
|
3574
|
-
rb_iv_set(
|
|
3575
|
-
rb_define_singleton_method(
|
|
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:
|
|
3584
|
-
* the
|
|
3622
|
+
/* Document-method: value
|
|
3623
|
+
* an expression whose result is the new value of the class
|
|
3624
|
+
* variable
|
|
3585
3625
|
*/
|
|
3586
|
-
rb_define_method(
|
|
3587
|
-
rb_ary_push(members, rb_str_new2("
|
|
3626
|
+
rb_define_method(rb_cCVDECL, "value", node_value, 0);
|
|
3627
|
+
rb_ary_push(members, rb_str_new2("value"));
|
|
3588
3628
|
|
|
3589
|
-
/* Document-method:
|
|
3590
|
-
* the
|
|
3629
|
+
/* Document-method: vid
|
|
3630
|
+
* the name of the class variable to assign
|
|
3591
3631
|
*/
|
|
3592
|
-
rb_define_method(
|
|
3593
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3597
|
-
* Represents
|
|
3598
|
-
*
|
|
3599
|
-
*
|
|
3600
|
-
*
|
|
3601
|
-
*
|
|
3602
|
-
*
|
|
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
|
|
3649
|
+
VALUE rb_cDASGN = rb_define_class_under(rb_cNode, "DASGN", rb_cNode);
|
|
3606
3650
|
members = rb_ary_new();
|
|
3607
|
-
rb_cNodeSubclass[
|
|
3608
|
-
rb_iv_set(
|
|
3609
|
-
rb_iv_set(
|
|
3610
|
-
rb_define_singleton_method(
|
|
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
|
|
3657
|
+
* the value to assign to the local variable
|
|
3622
3658
|
*/
|
|
3623
|
-
rb_define_method(
|
|
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:
|
|
3627
|
-
* the
|
|
3662
|
+
/* Document-method: vid
|
|
3663
|
+
* the name of the local variable
|
|
3628
3664
|
*/
|
|
3629
|
-
rb_define_method(
|
|
3630
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3634
|
-
* Represents the
|
|
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
|
|
3674
|
+
VALUE rb_cDASGN_CURR = rb_define_class_under(rb_cNode, "DASGN_CURR", rb_cNode);
|
|
3638
3675
|
members = rb_ary_new();
|
|
3639
|
-
rb_cNodeSubclass[
|
|
3640
|
-
rb_iv_set(
|
|
3641
|
-
rb_iv_set(
|
|
3642
|
-
rb_define_singleton_method(
|
|
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::
|
|
3646
|
-
* Represents
|
|
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
|
|
3699
|
+
VALUE rb_cDEFINED = rb_define_class_under(rb_cNode, "DEFINED", rb_cNode);
|
|
3650
3700
|
members = rb_ary_new();
|
|
3651
|
-
rb_cNodeSubclass[
|
|
3652
|
-
rb_iv_set(
|
|
3653
|
-
rb_iv_set(
|
|
3654
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
3707
|
+
* the expression to inspect
|
|
3664
3708
|
*/
|
|
3665
|
-
rb_define_method(
|
|
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::
|
|
3676
|
-
* Represents a
|
|
3677
|
-
*
|
|
3678
|
-
*
|
|
3679
|
-
*
|
|
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
|
|
3720
|
+
VALUE rb_cDEFN = rb_define_class_under(rb_cNode, "DEFN", rb_cNode);
|
|
3683
3721
|
members = rb_ary_new();
|
|
3684
|
-
rb_cNodeSubclass[
|
|
3685
|
-
rb_iv_set(
|
|
3686
|
-
rb_iv_set(
|
|
3687
|
-
rb_define_singleton_method(
|
|
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:
|
|
3690
|
-
*
|
|
3727
|
+
/* Document-method: defn
|
|
3728
|
+
* the body of the method definition
|
|
3691
3729
|
*/
|
|
3692
|
-
rb_define_method(
|
|
3693
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3697
|
-
* Represents a
|
|
3698
|
-
*
|
|
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
|
|
3753
|
+
VALUE rb_cDEFS = rb_define_class_under(rb_cNode, "DEFS", rb_cNode);
|
|
3712
3754
|
members = rb_ary_new();
|
|
3713
|
-
rb_cNodeSubclass[
|
|
3714
|
-
rb_iv_set(
|
|
3715
|
-
rb_iv_set(
|
|
3716
|
-
rb_define_singleton_method(
|
|
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:
|
|
3719
|
-
* the
|
|
3762
|
+
/* Document-method: mid
|
|
3763
|
+
* the name of the method* defn the body of the method
|
|
3720
3764
|
*/
|
|
3721
|
-
rb_define_method(
|
|
3722
|
-
rb_ary_push(members, rb_str_new2("
|
|
3765
|
+
rb_define_method(rb_cDEFS, "mid", node_mid, 0);
|
|
3766
|
+
rb_ary_push(members, rb_str_new2("mid"));
|
|
3723
3767
|
|
|
3724
|
-
/* Document-method:
|
|
3725
|
-
* the
|
|
3768
|
+
/* Document-method: recv
|
|
3769
|
+
* the object to whose singleton class the new method is to be added
|
|
3726
3770
|
*/
|
|
3727
|
-
rb_define_method(
|
|
3728
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3732
|
-
*
|
|
3733
|
-
*
|
|
3734
|
-
*
|
|
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
|
|
3780
|
+
* See also BMETHOD.
|
|
3744
3781
|
*/
|
|
3745
3782
|
{
|
|
3746
|
-
VALUE
|
|
3783
|
+
VALUE rb_cDMETHOD = rb_define_class_under(rb_cNode, "DMETHOD", rb_cNode);
|
|
3747
3784
|
members = rb_ary_new();
|
|
3748
|
-
rb_cNodeSubclass[
|
|
3749
|
-
rb_iv_set(
|
|
3750
|
-
rb_iv_set(
|
|
3751
|
-
rb_define_singleton_method(
|
|
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:
|
|
3754
|
-
* the
|
|
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(
|
|
3757
|
-
rb_ary_push(members, rb_str_new2("
|
|
3794
|
+
rb_define_method(rb_cDMETHOD, "cval", node_cval, 0);
|
|
3795
|
+
rb_ary_push(members, rb_str_new2("cval"));
|
|
3796
|
+
}
|
|
3758
3797
|
|
|
3759
|
-
|
|
3760
|
-
|
|
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(
|
|
3763
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3767
|
-
* Represents
|
|
3768
|
-
*
|
|
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
|
|
3832
|
+
VALUE rb_cDOT3 = rb_define_class_under(rb_cNode, "DOT3", rb_cNode);
|
|
3772
3833
|
members = rb_ary_new();
|
|
3773
|
-
rb_cNodeSubclass[
|
|
3774
|
-
rb_iv_set(
|
|
3775
|
-
rb_iv_set(
|
|
3776
|
-
rb_define_singleton_method(
|
|
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:
|
|
3779
|
-
* the
|
|
3839
|
+
/* Document-method: beg
|
|
3840
|
+
* the beginning of the range
|
|
3780
3841
|
*/
|
|
3781
|
-
rb_define_method(
|
|
3782
|
-
rb_ary_push(members, rb_str_new2("
|
|
3842
|
+
rb_define_method(rb_cDOT3, "beg", node_beg, 0);
|
|
3843
|
+
rb_ary_push(members, rb_str_new2("beg"));
|
|
3783
3844
|
|
|
3784
|
-
/* Document-method:
|
|
3785
|
-
* the
|
|
3845
|
+
/* Document-method: end
|
|
3846
|
+
* the end of the range
|
|
3786
3847
|
*/
|
|
3787
|
-
rb_define_method(
|
|
3788
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3792
|
-
* Represents a
|
|
3793
|
-
*
|
|
3794
|
-
*
|
|
3795
|
-
*
|
|
3796
|
-
*
|
|
3797
|
-
*
|
|
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
|
|
3863
|
+
VALUE rb_cDREGX = rb_define_class_under(rb_cNode, "DREGX", rb_cNode);
|
|
3807
3864
|
members = rb_ary_new();
|
|
3808
|
-
rb_cNodeSubclass[
|
|
3809
|
-
rb_iv_set(
|
|
3810
|
-
rb_iv_set(
|
|
3811
|
-
rb_define_singleton_method(
|
|
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(
|
|
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(
|
|
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::
|
|
3827
|
-
* Represents a
|
|
3828
|
-
*
|
|
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
|
|
3906
|
+
VALUE rb_cDREGX_ONCE = rb_define_class_under(rb_cNode, "DREGX_ONCE", rb_cNode);
|
|
3832
3907
|
members = rb_ary_new();
|
|
3833
|
-
rb_cNodeSubclass[
|
|
3834
|
-
rb_iv_set(
|
|
3835
|
-
rb_iv_set(
|
|
3836
|
-
rb_define_singleton_method(
|
|
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:
|
|
3839
|
-
*
|
|
3913
|
+
/* Document-method: lit
|
|
3914
|
+
* a string
|
|
3840
3915
|
*/
|
|
3841
|
-
rb_define_method(
|
|
3842
|
-
rb_ary_push(members, rb_str_new2("
|
|
3843
|
-
}
|
|
3916
|
+
rb_define_method(rb_cDREGX_ONCE, "lit", node_lit, 0);
|
|
3917
|
+
rb_ary_push(members, rb_str_new2("lit"));
|
|
3844
3918
|
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
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::
|
|
3859
|
-
* Represents a
|
|
3860
|
-
*
|
|
3861
|
-
*
|
|
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
|
|
3942
|
+
VALUE rb_cDSTR = rb_define_class_under(rb_cNode, "DSTR", rb_cNode);
|
|
3865
3943
|
members = rb_ary_new();
|
|
3866
|
-
rb_cNodeSubclass[
|
|
3867
|
-
rb_iv_set(
|
|
3868
|
-
rb_iv_set(
|
|
3869
|
-
rb_define_singleton_method(
|
|
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:
|
|
3872
|
-
*
|
|
3873
|
-
* argument, not including the implicit variables.
|
|
3949
|
+
/* Document-method: lit
|
|
3950
|
+
* a string
|
|
3874
3951
|
*/
|
|
3875
|
-
rb_define_method(
|
|
3876
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3880
|
-
* Represents a
|
|
3881
|
-
*
|
|
3882
|
-
*
|
|
3883
|
-
*
|
|
3884
|
-
*
|
|
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
|
|
3974
|
+
VALUE rb_cDSYM = rb_define_class_under(rb_cNode, "DSYM", rb_cNode);
|
|
3888
3975
|
members = rb_ary_new();
|
|
3889
|
-
rb_cNodeSubclass[
|
|
3890
|
-
rb_iv_set(
|
|
3891
|
-
rb_iv_set(
|
|
3892
|
-
rb_define_singleton_method(
|
|
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
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
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:
|
|
3901
|
-
* the
|
|
3997
|
+
/* Document-method: vid
|
|
3998
|
+
* the name of the local variable to retrieve.
|
|
3902
3999
|
*/
|
|
3903
|
-
rb_define_method(
|
|
3904
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3908
|
-
* Represents
|
|
3909
|
-
*
|
|
3910
|
-
*
|
|
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
|
|
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
|
|
3916
|
-
*
|
|
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
|
|
4019
|
+
VALUE rb_cDXSTR = rb_define_class_under(rb_cNode, "DXSTR", rb_cNode);
|
|
3920
4020
|
members = rb_ary_new();
|
|
3921
|
-
rb_cNodeSubclass[
|
|
3922
|
-
rb_iv_set(
|
|
3923
|
-
rb_iv_set(
|
|
3924
|
-
rb_define_singleton_method(
|
|
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:
|
|
3927
|
-
*
|
|
4026
|
+
/* Document-method: lit
|
|
4027
|
+
* a string
|
|
3928
4028
|
*/
|
|
3929
|
-
rb_define_method(
|
|
3930
|
-
rb_ary_push(members, rb_str_new2("
|
|
4029
|
+
rb_define_method(rb_cDXSTR, "lit", node_lit, 0);
|
|
4030
|
+
rb_ary_push(members, rb_str_new2("lit"));
|
|
3931
4031
|
|
|
3932
|
-
/* Document-method:
|
|
3933
|
-
*
|
|
4032
|
+
/* Document-method: next
|
|
4033
|
+
* a list of expressions to be appended onto the string
|
|
3934
4034
|
*/
|
|
3935
|
-
rb_define_method(
|
|
3936
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
3940
|
-
* Represents an expression
|
|
3941
|
-
*
|
|
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
|
|
4054
|
+
VALUE rb_cENSURE = rb_define_class_under(rb_cNode, "ENSURE", rb_cNode);
|
|
3945
4055
|
members = rb_ary_new();
|
|
3946
|
-
rb_cNodeSubclass[
|
|
3947
|
-
rb_iv_set(
|
|
3948
|
-
rb_iv_set(
|
|
3949
|
-
rb_define_singleton_method(
|
|
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
|
|
4062
|
+
* the expression to protect
|
|
3953
4063
|
*/
|
|
3954
|
-
rb_define_method(
|
|
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::
|
|
3959
|
-
* Represents
|
|
3960
|
-
*
|
|
3961
|
-
*
|
|
3962
|
-
*
|
|
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
|
|
4081
|
+
VALUE rb_cEVSTR = rb_define_class_under(rb_cNode, "EVSTR", rb_cNode);
|
|
3966
4082
|
members = rb_ary_new();
|
|
3967
|
-
rb_cNodeSubclass[
|
|
3968
|
-
rb_iv_set(
|
|
3969
|
-
rb_iv_set(
|
|
3970
|
-
rb_define_singleton_method(
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
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::
|
|
3978
|
-
* Represents the '
|
|
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
|
|
4099
|
+
VALUE rb_cFALSE = rb_define_class_under(rb_cNode, "FALSE", rb_cNode);
|
|
3983
4100
|
members = rb_ary_new();
|
|
3984
|
-
rb_cNodeSubclass[
|
|
3985
|
-
rb_iv_set(
|
|
3986
|
-
rb_iv_set(
|
|
3987
|
-
rb_define_singleton_method(
|
|
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::
|
|
3991
|
-
*
|
|
3992
|
-
*
|
|
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
|
|
4113
|
+
VALUE rb_cFBODY = rb_define_class_under(rb_cNode, "FBODY", rb_cNode);
|
|
4001
4114
|
members = rb_ary_new();
|
|
4002
|
-
rb_cNodeSubclass[
|
|
4003
|
-
rb_iv_set(
|
|
4004
|
-
rb_iv_set(
|
|
4005
|
-
rb_define_singleton_method(
|
|
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:
|
|
4008
|
-
* the
|
|
4009
|
-
*/
|
|
4010
|
-
rb_define_method(
|
|
4011
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
4014
|
-
*
|
|
4126
|
+
/* Document-method: orig
|
|
4127
|
+
* the origin class
|
|
4015
4128
|
*/
|
|
4016
|
-
rb_define_method(
|
|
4017
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4021
|
-
* Represents a
|
|
4022
|
-
*
|
|
4023
|
-
*
|
|
4024
|
-
*
|
|
4025
|
-
*
|
|
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
|
|
4147
|
+
VALUE rb_cFCALL = rb_define_class_under(rb_cNode, "FCALL", rb_cNode);
|
|
4030
4148
|
members = rb_ary_new();
|
|
4031
|
-
rb_cNodeSubclass[
|
|
4032
|
-
rb_iv_set(
|
|
4033
|
-
rb_iv_set(
|
|
4034
|
-
rb_define_singleton_method(
|
|
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:
|
|
4043
|
-
*
|
|
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(
|
|
4057
|
-
rb_ary_push(members, rb_str_new2("
|
|
4157
|
+
rb_define_method(rb_cFCALL, "args", node_args, 0);
|
|
4158
|
+
rb_ary_push(members, rb_str_new2("args"));
|
|
4058
4159
|
|
|
4059
|
-
/* Document-method:
|
|
4060
|
-
*
|
|
4160
|
+
/* Document-method: mid
|
|
4161
|
+
* the method id
|
|
4061
4162
|
*/
|
|
4062
|
-
rb_define_method(
|
|
4063
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4067
|
-
* Represents
|
|
4068
|
-
*
|
|
4069
|
-
*
|
|
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
|
|
4174
|
+
VALUE rb_cFLIP2 = rb_define_class_under(rb_cNode, "FLIP2", rb_cNode);
|
|
4074
4175
|
members = rb_ary_new();
|
|
4075
|
-
rb_cNodeSubclass[
|
|
4076
|
-
rb_iv_set(
|
|
4077
|
-
rb_iv_set(
|
|
4078
|
-
rb_define_singleton_method(
|
|
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:
|
|
4081
|
-
* the
|
|
4181
|
+
/* Document-method: beg
|
|
4182
|
+
* the beginning of the range
|
|
4082
4183
|
*/
|
|
4083
|
-
rb_define_method(
|
|
4084
|
-
rb_ary_push(members, rb_str_new2("
|
|
4184
|
+
rb_define_method(rb_cFLIP2, "beg", node_beg, 0);
|
|
4185
|
+
rb_ary_push(members, rb_str_new2("beg"));
|
|
4085
4186
|
|
|
4086
|
-
/* Document-method:
|
|
4087
|
-
* the
|
|
4187
|
+
/* Document-method: end
|
|
4188
|
+
* the end of the range
|
|
4088
4189
|
*/
|
|
4089
|
-
rb_define_method(
|
|
4090
|
-
rb_ary_push(members, rb_str_new2("
|
|
4190
|
+
rb_define_method(rb_cFLIP2, "end", node_end, 0);
|
|
4191
|
+
rb_ary_push(members, rb_str_new2("end"));
|
|
4091
4192
|
|
|
4092
|
-
/* Document-method:
|
|
4093
|
-
* the
|
|
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(
|
|
4096
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4100
|
-
* Represents a
|
|
4101
|
-
*
|
|
4102
|
-
*
|
|
4103
|
-
*
|
|
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
|
|
4208
|
+
VALUE rb_cFLIP3 = rb_define_class_under(rb_cNode, "FLIP3", rb_cNode);
|
|
4115
4209
|
members = rb_ary_new();
|
|
4116
|
-
rb_cNodeSubclass[
|
|
4117
|
-
rb_iv_set(
|
|
4118
|
-
rb_iv_set(
|
|
4119
|
-
rb_define_singleton_method(
|
|
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:
|
|
4129
|
-
*
|
|
4130
|
-
* in this scope
|
|
4215
|
+
/* Document-method: beg
|
|
4216
|
+
* the beginning of the range
|
|
4131
4217
|
*/
|
|
4132
|
-
rb_define_method(
|
|
4133
|
-
rb_ary_push(members, rb_str_new2("
|
|
4218
|
+
rb_define_method(rb_cFLIP3, "beg", node_beg, 0);
|
|
4219
|
+
rb_ary_push(members, rb_str_new2("beg"));
|
|
4134
4220
|
|
|
4135
|
-
/* Document-method:
|
|
4136
|
-
* the
|
|
4221
|
+
/* Document-method: end
|
|
4222
|
+
* the end of the range
|
|
4137
4223
|
*/
|
|
4138
|
-
rb_define_method(
|
|
4139
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
4183
|
-
* the
|
|
4184
|
-
*
|
|
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(
|
|
4187
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4191
|
-
* Represents a
|
|
4192
|
-
*
|
|
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
|
-
*
|
|
4204
|
-
*
|
|
4205
|
-
*
|
|
4206
|
-
*
|
|
4241
|
+
* This is equivalent to:
|
|
4242
|
+
* iter.each do |*args|
|
|
4243
|
+
* assign args to var
|
|
4244
|
+
* body
|
|
4245
|
+
* end
|
|
4207
4246
|
*
|
|
4208
|
-
*
|
|
4209
|
-
* expression.
|
|
4247
|
+
* Except that a new block is not created.
|
|
4210
4248
|
*/
|
|
4211
4249
|
{
|
|
4212
|
-
VALUE
|
|
4250
|
+
VALUE rb_cFOR = rb_define_class_under(rb_cNode, "FOR", rb_cNode);
|
|
4213
4251
|
members = rb_ary_new();
|
|
4214
|
-
rb_cNodeSubclass[
|
|
4215
|
-
rb_iv_set(
|
|
4216
|
-
rb_iv_set(
|
|
4217
|
-
rb_define_singleton_method(
|
|
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
|
|
4227
|
-
* if the expression is empty
|
|
4258
|
+
* the body of the loop
|
|
4228
4259
|
*/
|
|
4229
|
-
rb_define_method(
|
|
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:
|
|
4233
|
-
* the
|
|
4234
|
-
* if the expression is empty
|
|
4263
|
+
/* Document-method: iter
|
|
4264
|
+
* the sequence over which to iterate
|
|
4235
4265
|
*/
|
|
4236
|
-
rb_define_method(
|
|
4237
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4241
|
-
* Represents
|
|
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
|
|
4282
|
+
VALUE rb_cGASGN = rb_define_class_under(rb_cNode, "GASGN", rb_cNode);
|
|
4272
4283
|
members = rb_ary_new();
|
|
4273
|
-
rb_cNodeSubclass[
|
|
4274
|
-
rb_iv_set(
|
|
4275
|
-
rb_iv_set(
|
|
4276
|
-
rb_define_singleton_method(
|
|
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:
|
|
4285
|
-
* an expression
|
|
4289
|
+
/* Document-method: value
|
|
4290
|
+
* an expression whose result is the new value of the global variable
|
|
4286
4291
|
*/
|
|
4287
|
-
rb_define_method(
|
|
4288
|
-
rb_ary_push(members, rb_str_new2("
|
|
4292
|
+
rb_define_method(rb_cGASGN, "value", node_value, 0);
|
|
4293
|
+
rb_ary_push(members, rb_str_new2("value"));
|
|
4289
4294
|
|
|
4290
|
-
/* Document-method:
|
|
4291
|
-
* the
|
|
4295
|
+
/* Document-method: vid
|
|
4296
|
+
* the name of the global variable, with a leading '$' character.
|
|
4292
4297
|
*/
|
|
4293
|
-
rb_define_method(
|
|
4294
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4298
|
-
* Represents
|
|
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
|
|
4308
|
+
VALUE rb_cGVAR = rb_define_class_under(rb_cNode, "GVAR", rb_cNode);
|
|
4308
4309
|
members = rb_ary_new();
|
|
4309
|
-
rb_cNodeSubclass[
|
|
4310
|
-
rb_iv_set(
|
|
4311
|
-
rb_iv_set(
|
|
4312
|
-
rb_define_singleton_method(
|
|
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:
|
|
4321
|
-
* 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(
|
|
4325
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4348
|
-
*
|
|
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
|
|
4347
|
+
VALUE rb_cIASGN = rb_define_class_under(rb_cNode, "IASGN", rb_cNode);
|
|
4356
4348
|
members = rb_ary_new();
|
|
4357
|
-
rb_cNodeSubclass[
|
|
4358
|
-
rb_iv_set(
|
|
4359
|
-
rb_iv_set(
|
|
4360
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
4355
|
+
* the value to assign to the instance variable
|
|
4370
4356
|
*/
|
|
4371
|
-
rb_define_method(
|
|
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:
|
|
4375
|
-
* the
|
|
4360
|
+
/* Document-method: vid
|
|
4361
|
+
* the name of the instance variable, with a leading '@' sign
|
|
4376
4362
|
*/
|
|
4377
|
-
rb_define_method(
|
|
4378
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4383
|
-
* Represents
|
|
4384
|
-
*
|
|
4385
|
-
*
|
|
4386
|
-
*
|
|
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
|
-
*
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
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
|
-
*
|
|
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
|
|
4389
|
+
VALUE rb_cIF = rb_define_class_under(rb_cNode, "IF", rb_cNode);
|
|
4442
4390
|
members = rb_ary_new();
|
|
4443
|
-
rb_cNodeSubclass[
|
|
4444
|
-
rb_iv_set(
|
|
4445
|
-
rb_iv_set(
|
|
4446
|
-
rb_define_singleton_method(
|
|
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:
|
|
4449
|
-
* the
|
|
4396
|
+
/* Document-method: cond
|
|
4397
|
+
* the condition to evaluate
|
|
4450
4398
|
*/
|
|
4451
|
-
rb_define_method(
|
|
4452
|
-
rb_ary_push(members, rb_str_new2("
|
|
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
|
-
*
|
|
4456
|
-
*
|
|
4403
|
+
* the expression to evaluate if the expression is true, or false
|
|
4404
|
+
* if the expression is empty
|
|
4457
4405
|
*/
|
|
4458
|
-
rb_define_method(
|
|
4406
|
+
rb_define_method(rb_cIF, "body", node_body, 0);
|
|
4459
4407
|
rb_ary_push(members, rb_str_new2("body"));
|
|
4460
|
-
|
|
4461
|
-
|
|
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::
|
|
4465
|
-
* A
|
|
4417
|
+
/* Document-class: Node::IFUNC
|
|
4418
|
+
* A temporary node used in iteration.
|
|
4466
4419
|
*/
|
|
4467
4420
|
{
|
|
4468
|
-
VALUE
|
|
4421
|
+
VALUE rb_cIFUNC = rb_define_class_under(rb_cNode, "IFUNC", rb_cNode);
|
|
4469
4422
|
members = rb_ary_new();
|
|
4470
|
-
rb_cNodeSubclass[
|
|
4471
|
-
rb_iv_set(
|
|
4472
|
-
rb_iv_set(
|
|
4473
|
-
rb_define_singleton_method(
|
|
4474
|
-
|
|
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
|
-
|
|
4477
|
-
|
|
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::
|
|
4481
|
-
* Represents
|
|
4482
|
-
*
|
|
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
|
-
*
|
|
4485
|
-
*
|
|
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
|
-
*
|
|
4489
|
-
*
|
|
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
|
|
4462
|
+
VALUE rb_cITER = rb_define_class_under(rb_cNode, "ITER", rb_cNode);
|
|
4494
4463
|
members = rb_ary_new();
|
|
4495
|
-
rb_cNodeSubclass[
|
|
4496
|
-
rb_iv_set(
|
|
4497
|
-
rb_iv_set(
|
|
4498
|
-
rb_define_singleton_method(
|
|
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:
|
|
4501
|
-
* the
|
|
4469
|
+
/* Document-method: body
|
|
4470
|
+
* the body of the loop
|
|
4502
4471
|
*/
|
|
4503
|
-
rb_define_method(
|
|
4504
|
-
rb_ary_push(members, rb_str_new2("
|
|
4472
|
+
rb_define_method(rb_cITER, "body", node_body, 0);
|
|
4473
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
4505
4474
|
|
|
4506
|
-
/* Document-method:
|
|
4507
|
-
*
|
|
4508
|
-
*
|
|
4475
|
+
/* Document-method: iter
|
|
4476
|
+
* an expression which calls the desired iteration method, usually
|
|
4477
|
+
* recv.each
|
|
4509
4478
|
*/
|
|
4510
|
-
rb_define_method(
|
|
4511
|
-
rb_ary_push(members, rb_str_new2("
|
|
4479
|
+
rb_define_method(rb_cITER, "iter", node_iter, 0);
|
|
4480
|
+
rb_ary_push(members, rb_str_new2("iter"));
|
|
4512
4481
|
|
|
4513
|
-
/* Document-method:
|
|
4514
|
-
* the
|
|
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(
|
|
4517
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4521
|
-
*
|
|
4522
|
-
*
|
|
4523
|
-
*
|
|
4524
|
-
*
|
|
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
|
|
4498
|
+
VALUE rb_cIVAR = rb_define_class_under(rb_cNode, "IVAR", rb_cNode);
|
|
4528
4499
|
members = rb_ary_new();
|
|
4529
|
-
rb_cNodeSubclass[
|
|
4530
|
-
rb_iv_set(
|
|
4531
|
-
rb_iv_set(
|
|
4532
|
-
rb_define_singleton_method(
|
|
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:
|
|
4543
|
-
* the
|
|
4505
|
+
/* Document-method: vid
|
|
4506
|
+
* the name of the attribute, with a leading '@' sign
|
|
4544
4507
|
*/
|
|
4545
|
-
rb_define_method(
|
|
4546
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4576
|
-
* Represents the
|
|
4577
|
-
*
|
|
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
|
|
4543
|
+
VALUE rb_cLIT = rb_define_class_under(rb_cNode, "LIT", rb_cNode);
|
|
4662
4544
|
members = rb_ary_new();
|
|
4663
|
-
rb_cNodeSubclass[
|
|
4664
|
-
rb_iv_set(
|
|
4665
|
-
rb_iv_set(
|
|
4666
|
-
rb_define_singleton_method(
|
|
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
|
|
4551
|
+
* the object
|
|
4670
4552
|
*/
|
|
4671
|
-
rb_define_method(
|
|
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::
|
|
4676
|
-
* Represents
|
|
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
|
|
4561
|
+
VALUE rb_cLVAR = rb_define_class_under(rb_cNode, "LVAR", rb_cNode);
|
|
4689
4562
|
members = rb_ary_new();
|
|
4690
|
-
rb_cNodeSubclass[
|
|
4691
|
-
rb_iv_set(
|
|
4692
|
-
rb_iv_set(
|
|
4693
|
-
rb_define_singleton_method(
|
|
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:
|
|
4708
|
-
* the
|
|
4568
|
+
/* Document-method: vid
|
|
4569
|
+
* the name of the local variable to retrieve.
|
|
4709
4570
|
*/
|
|
4710
|
-
rb_define_method(
|
|
4711
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4715
|
-
* Represents
|
|
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
|
|
4581
|
+
VALUE rb_cMASGN = rb_define_class_under(rb_cNode, "MASGN", rb_cNode);
|
|
4722
4582
|
members = rb_ary_new();
|
|
4723
|
-
rb_cNodeSubclass[
|
|
4724
|
-
rb_iv_set(
|
|
4725
|
-
rb_iv_set(
|
|
4726
|
-
rb_define_singleton_method(
|
|
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
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
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
|
-
*
|
|
4595
|
+
* TODO
|
|
4748
4596
|
*/
|
|
4749
|
-
rb_define_method(
|
|
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:
|
|
4755
|
-
*
|
|
4600
|
+
/* Document-method: value
|
|
4601
|
+
* TODO
|
|
4756
4602
|
*/
|
|
4757
|
-
rb_define_method(
|
|
4758
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4762
|
-
* Represents
|
|
4763
|
-
*
|
|
4764
|
-
*
|
|
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
|
|
4622
|
+
VALUE rb_cMATCH = rb_define_class_under(rb_cNode, "MATCH", rb_cNode);
|
|
4768
4623
|
members = rb_ary_new();
|
|
4769
|
-
rb_cNodeSubclass[
|
|
4770
|
-
rb_iv_set(
|
|
4771
|
-
rb_iv_set(
|
|
4772
|
-
rb_define_singleton_method(
|
|
4773
|
-
|
|
4774
|
-
|
|
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::
|
|
4778
|
-
* Represents
|
|
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
|
|
4660
|
+
VALUE rb_cMATCH2 = rb_define_class_under(rb_cNode, "MATCH2", rb_cNode);
|
|
4782
4661
|
members = rb_ary_new();
|
|
4783
|
-
rb_cNodeSubclass[
|
|
4784
|
-
rb_iv_set(
|
|
4785
|
-
rb_iv_set(
|
|
4786
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
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(
|
|
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:
|
|
4795
|
-
* the
|
|
4675
|
+
/* Document-method: recv
|
|
4676
|
+
* the regular expression on the left hand side of the match
|
|
4677
|
+
* operator
|
|
4796
4678
|
*/
|
|
4797
|
-
rb_define_method(
|
|
4798
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4804
|
-
* Represents
|
|
4683
|
+
/* Document-class: Node::MATCH3
|
|
4684
|
+
* Represents a regular expression match of the form:
|
|
4685
|
+
* recv =~ /value/
|
|
4805
4686
|
*
|
|
4806
|
-
*
|
|
4687
|
+
* where recv is an expression that returns an object and value is a
|
|
4688
|
+
* regular expression literal.
|
|
4807
4689
|
*/
|
|
4808
4690
|
{
|
|
4809
|
-
VALUE
|
|
4691
|
+
VALUE rb_cMATCH3 = rb_define_class_under(rb_cNode, "MATCH3", rb_cNode);
|
|
4810
4692
|
members = rb_ary_new();
|
|
4811
|
-
rb_cNodeSubclass[
|
|
4812
|
-
rb_iv_set(
|
|
4813
|
-
rb_iv_set(
|
|
4814
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
4818
|
-
* variable
|
|
4699
|
+
* the right hand side of the match
|
|
4819
4700
|
*/
|
|
4820
|
-
rb_define_method(
|
|
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:
|
|
4824
|
-
* the
|
|
4704
|
+
/* Document-method: recv
|
|
4705
|
+
* the left hand side of the match
|
|
4825
4706
|
*/
|
|
4826
|
-
rb_define_method(
|
|
4827
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4831
|
-
*
|
|
4832
|
-
*
|
|
4833
|
-
*
|
|
4834
|
-
*
|
|
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
|
|
4738
|
+
VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode);
|
|
4838
4739
|
members = rb_ary_new();
|
|
4839
|
-
rb_cNodeSubclass[
|
|
4840
|
-
rb_iv_set(
|
|
4841
|
-
rb_iv_set(
|
|
4842
|
-
rb_define_singleton_method(
|
|
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:
|
|
4851
|
-
* the
|
|
4745
|
+
/* Document-method: body
|
|
4746
|
+
* the body of the method
|
|
4852
4747
|
*/
|
|
4853
|
-
rb_define_method(
|
|
4854
|
-
rb_ary_push(members, rb_str_new2("
|
|
4748
|
+
rb_define_method(rb_cMETHOD, "body", node_body, 0);
|
|
4749
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
4855
4750
|
|
|
4856
|
-
/* Document-method:
|
|
4857
|
-
* the
|
|
4751
|
+
/* Document-method: noex
|
|
4752
|
+
* the method's flags
|
|
4858
4753
|
*/
|
|
4859
|
-
rb_define_method(
|
|
4860
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4864
|
-
* Represents
|
|
4865
|
-
*
|
|
4758
|
+
/* Document-class: Node::MODULE
|
|
4759
|
+
* Represents a module definition, e.g.:
|
|
4760
|
+
* module cpath
|
|
4761
|
+
* body
|
|
4762
|
+
* end
|
|
4866
4763
|
*
|
|
4867
|
-
*
|
|
4868
|
-
*
|
|
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
|
|
4770
|
+
VALUE rb_cMODULE = rb_define_class_under(rb_cNode, "MODULE", rb_cNode);
|
|
4872
4771
|
members = rb_ary_new();
|
|
4873
|
-
rb_cNodeSubclass[
|
|
4874
|
-
rb_iv_set(
|
|
4875
|
-
rb_iv_set(
|
|
4876
|
-
rb_define_singleton_method(
|
|
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:
|
|
4879
|
-
* the
|
|
4777
|
+
/* Document-method: cpath
|
|
4778
|
+
* the name of the module to define
|
|
4880
4779
|
*/
|
|
4881
|
-
rb_define_method(
|
|
4882
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
4898
|
-
* the
|
|
4783
|
+
/* Document-method: body
|
|
4784
|
+
* the body of the module definition
|
|
4899
4785
|
*/
|
|
4900
|
-
rb_define_method(
|
|
4901
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
4948
|
-
* Represents
|
|
4949
|
-
*
|
|
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
|
|
4884
|
+
VALUE rb_cOPT_N = rb_define_class_under(rb_cNode, "OPT_N", rb_cNode);
|
|
4954
4885
|
members = rb_ary_new();
|
|
4955
|
-
rb_cNodeSubclass[
|
|
4956
|
-
rb_iv_set(
|
|
4957
|
-
rb_iv_set(
|
|
4958
|
-
rb_define_singleton_method(
|
|
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:
|
|
4961
|
-
* the
|
|
4891
|
+
/* Document-method: body
|
|
4892
|
+
* the body of the loop
|
|
4962
4893
|
*/
|
|
4963
|
-
rb_define_method(
|
|
4964
|
-
rb_ary_push(members, rb_str_new2("
|
|
4894
|
+
rb_define_method(rb_cOPT_N, "body", node_body, 0);
|
|
4895
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
4896
|
+
}
|
|
4965
4897
|
|
|
4966
|
-
|
|
4967
|
-
|
|
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(
|
|
4970
|
-
rb_ary_push(members, rb_str_new2("
|
|
4971
|
-
|
|
4972
|
-
|
|
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::
|
|
4976
|
-
* Represents
|
|
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
|
|
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[
|
|
4982
|
-
rb_iv_set(
|
|
4983
|
-
rb_iv_set(
|
|
4984
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
5003
|
+
* The method to call on the receiver to retrieve the attribute
|
|
4988
5004
|
*/
|
|
4989
|
-
rb_define_method(
|
|
5005
|
+
rb_define_method(rb_cOP_ASGN2_ARG, "vid", node_vid, 0);
|
|
4990
5006
|
rb_ary_push(members, rb_str_new2("vid"));
|
|
4991
|
-
|
|
4992
|
-
|
|
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::
|
|
4996
|
-
* Represents
|
|
4997
|
-
*
|
|
4998
|
-
*
|
|
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
|
|
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[
|
|
5004
|
-
rb_iv_set(
|
|
5005
|
-
rb_iv_set(
|
|
5006
|
-
rb_define_singleton_method(
|
|
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:
|
|
5009
|
-
*
|
|
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(
|
|
5012
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
5015
|
-
* the
|
|
5046
|
+
/* Document-method: recv
|
|
5047
|
+
* an expression representing the left hand side of the assignment
|
|
5016
5048
|
*/
|
|
5017
|
-
rb_define_method(
|
|
5018
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5024
|
-
* Represents
|
|
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
|
|
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[
|
|
5030
|
-
rb_iv_set(
|
|
5031
|
-
rb_iv_set(
|
|
5032
|
-
rb_define_singleton_method(
|
|
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
|
-
*
|
|
5036
|
-
* variable
|
|
5078
|
+
* the right hand side of the assignment
|
|
5037
5079
|
*/
|
|
5038
|
-
rb_define_method(
|
|
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:
|
|
5042
|
-
* the
|
|
5083
|
+
/* Document-method: recv
|
|
5084
|
+
* the receiver of the assignment
|
|
5043
5085
|
*/
|
|
5044
|
-
rb_define_method(
|
|
5045
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5049
|
-
*
|
|
5050
|
-
*
|
|
5051
|
-
*
|
|
5052
|
-
*
|
|
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
|
|
5098
|
+
VALUE rb_cOR = rb_define_class_under(rb_cNode, "OR", rb_cNode);
|
|
5058
5099
|
members = rb_ary_new();
|
|
5059
|
-
rb_cNodeSubclass[
|
|
5060
|
-
rb_iv_set(
|
|
5061
|
-
rb_iv_set(
|
|
5062
|
-
rb_define_singleton_method(
|
|
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:
|
|
5071
|
-
* the
|
|
5105
|
+
/* Document-method: first
|
|
5106
|
+
* the expression on the left hand side
|
|
5072
5107
|
*/
|
|
5073
|
-
rb_define_method(
|
|
5074
|
-
rb_ary_push(members, rb_str_new2("
|
|
5108
|
+
rb_define_method(rb_cOR, "first", node_1st, 0);
|
|
5109
|
+
rb_ary_push(members, rb_str_new2("first"));
|
|
5075
5110
|
|
|
5076
|
-
/* Document-method:
|
|
5077
|
-
* the
|
|
5111
|
+
/* Document-method: second
|
|
5112
|
+
* the expression on the right hand side
|
|
5078
5113
|
*/
|
|
5079
|
-
rb_define_method(
|
|
5080
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5084
|
-
* Represents the
|
|
5085
|
-
*
|
|
5086
|
-
*
|
|
5087
|
-
*
|
|
5088
|
-
*
|
|
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
|
|
5126
|
+
VALUE rb_cPOSTEXE = rb_define_class_under(rb_cNode, "POSTEXE", rb_cNode);
|
|
5093
5127
|
members = rb_ary_new();
|
|
5094
|
-
rb_cNodeSubclass[
|
|
5095
|
-
rb_iv_set(
|
|
5096
|
-
rb_iv_set(
|
|
5097
|
-
rb_define_singleton_method(
|
|
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
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
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::
|
|
5107
|
-
* Represents a
|
|
5108
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
5160
|
+
VALUE rb_cRESBODY = rb_define_class_under(rb_cNode, "RESBODY", rb_cNode);
|
|
5119
5161
|
members = rb_ary_new();
|
|
5120
|
-
rb_cNodeSubclass[
|
|
5121
|
-
rb_iv_set(
|
|
5122
|
-
rb_iv_set(
|
|
5123
|
-
rb_define_singleton_method(
|
|
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:
|
|
5126
|
-
* the
|
|
5167
|
+
/* Document-method: head
|
|
5168
|
+
* the next rescue
|
|
5127
5169
|
*/
|
|
5128
|
-
rb_define_method(
|
|
5129
|
-
rb_ary_push(members, rb_str_new2("
|
|
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
|
|
5180
|
+
* the expresion to evaluate if the exception type matches
|
|
5133
5181
|
*/
|
|
5134
|
-
rb_define_method(
|
|
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::
|
|
5139
|
-
* Represents a
|
|
5140
|
-
*
|
|
5141
|
-
*
|
|
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
|
-
*
|
|
5145
|
-
*
|
|
5146
|
-
*
|
|
5147
|
-
*
|
|
5148
|
-
*
|
|
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
|
-
*
|
|
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
|
|
5216
|
+
VALUE rb_cRESCUE = rb_define_class_under(rb_cNode, "RESCUE", rb_cNode);
|
|
5154
5217
|
members = rb_ary_new();
|
|
5155
|
-
rb_cNodeSubclass[
|
|
5156
|
-
rb_iv_set(
|
|
5157
|
-
rb_iv_set(
|
|
5158
|
-
rb_define_singleton_method(
|
|
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:
|
|
5167
|
-
* the
|
|
5223
|
+
/* Document-method: head
|
|
5224
|
+
* the body of the block to evaluate
|
|
5168
5225
|
*/
|
|
5169
|
-
rb_define_method(
|
|
5170
|
-
rb_ary_push(members, rb_str_new2("
|
|
5226
|
+
rb_define_method(rb_cRESCUE, "head", node_head, 0);
|
|
5227
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5171
5228
|
|
|
5172
|
-
/* Document-method:
|
|
5173
|
-
*
|
|
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(
|
|
5178
|
-
rb_ary_push(members, rb_str_new2("
|
|
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:
|
|
5193
|
-
* the
|
|
5235
|
+
/* Document-method: resq
|
|
5236
|
+
* the expression to be evaluated if an exception is raised
|
|
5194
5237
|
*/
|
|
5195
|
-
rb_define_method(
|
|
5196
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5200
|
-
*
|
|
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
|
|
5246
|
+
VALUE rb_cRESTARY = rb_define_class_under(rb_cNode, "RESTARY", rb_cNode);
|
|
5209
5247
|
members = rb_ary_new();
|
|
5210
|
-
rb_cNodeSubclass[
|
|
5211
|
-
rb_iv_set(
|
|
5212
|
-
rb_iv_set(
|
|
5213
|
-
rb_define_singleton_method(
|
|
5214
|
-
|
|
5215
|
-
|
|
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::
|
|
5229
|
-
*
|
|
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
|
|
5260
|
+
VALUE rb_cRESTARY2 = rb_define_class_under(rb_cNode, "RESTARY2", rb_cNode);
|
|
5240
5261
|
members = rb_ary_new();
|
|
5241
|
-
rb_cNodeSubclass[
|
|
5242
|
-
rb_iv_set(
|
|
5243
|
-
rb_iv_set(
|
|
5244
|
-
rb_define_singleton_method(
|
|
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::
|
|
5266
|
-
* Represents
|
|
5267
|
-
*
|
|
5268
|
-
*
|
|
5269
|
-
*
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
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
|
|
5315
|
+
VALUE rb_cSCLASS = rb_define_class_under(rb_cNode, "SCLASS", rb_cNode);
|
|
5283
5316
|
members = rb_ary_new();
|
|
5284
|
-
rb_cNodeSubclass[
|
|
5285
|
-
rb_iv_set(
|
|
5286
|
-
rb_iv_set(
|
|
5287
|
-
rb_define_singleton_method(
|
|
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(
|
|
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:
|
|
5302
|
-
*
|
|
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(
|
|
5339
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5355
|
-
*
|
|
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
|
|
5350
|
+
VALUE rb_cSCOPE = rb_define_class_under(rb_cNode, "SCOPE", rb_cNode);
|
|
5359
5351
|
members = rb_ary_new();
|
|
5360
|
-
rb_cNodeSubclass[
|
|
5361
|
-
rb_iv_set(
|
|
5362
|
-
rb_iv_set(
|
|
5363
|
-
rb_define_singleton_method(
|
|
5364
|
-
|
|
5365
|
-
|
|
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::
|
|
5369
|
-
*
|
|
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
|
|
5382
|
+
VALUE rb_cSELF = rb_define_class_under(rb_cNode, "SELF", rb_cNode);
|
|
5376
5383
|
members = rb_ary_new();
|
|
5377
|
-
rb_cNodeSubclass[
|
|
5378
|
-
rb_iv_set(
|
|
5379
|
-
rb_iv_set(
|
|
5380
|
-
rb_define_singleton_method(
|
|
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::
|
|
5390
|
-
* Represents
|
|
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
|
|
5399
|
+
VALUE rb_cSPLAT = rb_define_class_under(rb_cNode, "SPLAT", rb_cNode);
|
|
5394
5400
|
members = rb_ary_new();
|
|
5395
|
-
rb_cNodeSubclass[
|
|
5396
|
-
rb_iv_set(
|
|
5397
|
-
rb_iv_set(
|
|
5398
|
-
rb_define_singleton_method(
|
|
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:
|
|
5401
|
-
* the
|
|
5406
|
+
/* Document-method: head
|
|
5407
|
+
* the argument to splat.
|
|
5402
5408
|
*/
|
|
5403
|
-
rb_define_method(
|
|
5404
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5410
|
-
* Represents a
|
|
5411
|
-
*
|
|
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
|
|
5418
|
+
VALUE rb_cSTR = rb_define_class_under(rb_cNode, "STR", rb_cNode);
|
|
5428
5419
|
members = rb_ary_new();
|
|
5429
|
-
rb_cNodeSubclass[
|
|
5430
|
-
rb_iv_set(
|
|
5431
|
-
rb_iv_set(
|
|
5432
|
-
rb_define_singleton_method(
|
|
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:
|
|
5443
|
-
* the
|
|
5444
|
-
* operator
|
|
5425
|
+
/* Document-method: lit
|
|
5426
|
+
* the string to be duplicated
|
|
5445
5427
|
*/
|
|
5446
|
-
rb_define_method(
|
|
5447
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5451
|
-
* Represents
|
|
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
|
|
5436
|
+
VALUE rb_cSUPER = rb_define_class_under(rb_cNode, "SUPER", rb_cNode);
|
|
5458
5437
|
members = rb_ary_new();
|
|
5459
|
-
rb_cNodeSubclass[
|
|
5460
|
-
rb_iv_set(
|
|
5461
|
-
rb_iv_set(
|
|
5462
|
-
rb_define_singleton_method(
|
|
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:
|
|
5477
|
-
* the
|
|
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(
|
|
5481
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5485
|
-
* Represents
|
|
5486
|
-
*
|
|
5487
|
-
*
|
|
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
|
|
5461
|
+
VALUE rb_cSVALUE = rb_define_class_under(rb_cNode, "SVALUE", rb_cNode);
|
|
5491
5462
|
members = rb_ary_new();
|
|
5492
|
-
rb_cNodeSubclass[
|
|
5493
|
-
rb_iv_set(
|
|
5494
|
-
rb_iv_set(
|
|
5495
|
-
rb_define_singleton_method(
|
|
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:
|
|
5498
|
-
*
|
|
5468
|
+
/* Document-method: head
|
|
5469
|
+
* an expression which returns an Array.
|
|
5499
5470
|
*/
|
|
5500
|
-
rb_define_method(
|
|
5501
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5505
|
-
*
|
|
5475
|
+
/* Document-class: Node::TRUE
|
|
5476
|
+
* Represents the keyword 'true'.
|
|
5506
5477
|
*/
|
|
5507
5478
|
{
|
|
5508
|
-
VALUE
|
|
5479
|
+
VALUE rb_cTRUE = rb_define_class_under(rb_cNode, "TRUE", rb_cNode);
|
|
5509
5480
|
members = rb_ary_new();
|
|
5510
|
-
rb_cNodeSubclass[
|
|
5511
|
-
rb_iv_set(
|
|
5512
|
-
rb_iv_set(
|
|
5513
|
-
rb_define_singleton_method(
|
|
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::
|
|
5519
|
-
*
|
|
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
|
|
5495
|
+
VALUE rb_cUNDEF = rb_define_class_under(rb_cNode, "UNDEF", rb_cNode);
|
|
5523
5496
|
members = rb_ary_new();
|
|
5524
|
-
rb_cNodeSubclass[
|
|
5525
|
-
rb_iv_set(
|
|
5526
|
-
rb_iv_set(
|
|
5527
|
-
rb_define_singleton_method(
|
|
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:
|
|
5536
|
-
* the method
|
|
5502
|
+
/* Document-method: mid
|
|
5503
|
+
* the id of the method to undefine
|
|
5537
5504
|
*/
|
|
5538
|
-
rb_define_method(
|
|
5539
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5543
|
-
* Represents a
|
|
5544
|
-
*
|
|
5545
|
-
*
|
|
5546
|
-
*
|
|
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
|
|
5516
|
+
VALUE rb_cUNTIL = rb_define_class_under(rb_cNode, "UNTIL", rb_cNode);
|
|
5551
5517
|
members = rb_ary_new();
|
|
5552
|
-
rb_cNodeSubclass[
|
|
5553
|
-
rb_iv_set(
|
|
5554
|
-
rb_iv_set(
|
|
5555
|
-
rb_define_singleton_method(
|
|
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:
|
|
5558
|
-
* the
|
|
5523
|
+
/* Document-method: body
|
|
5524
|
+
* the body of the loop
|
|
5559
5525
|
*/
|
|
5560
|
-
rb_define_method(
|
|
5561
|
-
rb_ary_push(members, rb_str_new2("
|
|
5526
|
+
rb_define_method(rb_cUNTIL, "body", node_body, 0);
|
|
5527
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5562
5528
|
|
|
5563
|
-
/* Document-method:
|
|
5564
|
-
* the
|
|
5529
|
+
/* Document-method: cond
|
|
5530
|
+
* a condition to terminate the loop when it becomes true
|
|
5565
5531
|
*/
|
|
5566
|
-
rb_define_method(
|
|
5567
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5571
|
-
* Represents
|
|
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
|
|
5545
|
+
VALUE rb_cVALIAS = rb_define_class_under(rb_cNode, "VALIAS", rb_cNode);
|
|
5575
5546
|
members = rb_ary_new();
|
|
5576
|
-
rb_cNodeSubclass[
|
|
5577
|
-
rb_iv_set(
|
|
5578
|
-
rb_iv_set(
|
|
5579
|
-
rb_define_singleton_method(
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
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::
|
|
5595
|
-
*
|
|
5596
|
-
*
|
|
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
|
|
5562
|
+
VALUE rb_cVCALL = rb_define_class_under(rb_cNode, "VCALL", rb_cNode);
|
|
5603
5563
|
members = rb_ary_new();
|
|
5604
|
-
rb_cNodeSubclass[
|
|
5605
|
-
rb_iv_set(
|
|
5606
|
-
rb_iv_set(
|
|
5607
|
-
rb_define_singleton_method(
|
|
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:
|
|
5610
|
-
* the
|
|
5611
|
-
* body of the method
|
|
5569
|
+
/* Document-method: mid
|
|
5570
|
+
* the name of the variable or method
|
|
5612
5571
|
*/
|
|
5613
|
-
rb_define_method(
|
|
5614
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5618
|
-
* Represents
|
|
5619
|
-
*
|
|
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
|
|
5607
|
+
VALUE rb_cWHEN = rb_define_class_under(rb_cNode, "WHEN", rb_cNode);
|
|
5625
5608
|
members = rb_ary_new();
|
|
5626
|
-
rb_cNodeSubclass[
|
|
5627
|
-
rb_iv_set(
|
|
5628
|
-
rb_iv_set(
|
|
5629
|
-
rb_define_singleton_method(
|
|
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:
|
|
5632
|
-
*
|
|
5614
|
+
/* Document-method: head
|
|
5615
|
+
* a value to compare against, or a condition to be tested
|
|
5633
5616
|
*/
|
|
5634
|
-
rb_define_method(
|
|
5635
|
-
rb_ary_push(members, rb_str_new2("
|
|
5617
|
+
rb_define_method(rb_cWHEN, "head", node_head, 0);
|
|
5618
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5636
5619
|
|
|
5637
|
-
/* Document-method:
|
|
5638
|
-
*
|
|
5620
|
+
/* Document-method: body
|
|
5621
|
+
* an expression to evaluate if the condition evaluates to true
|
|
5639
5622
|
*/
|
|
5640
|
-
rb_define_method(
|
|
5641
|
-
rb_ary_push(members, rb_str_new2("
|
|
5623
|
+
rb_define_method(rb_cWHEN, "body", node_body, 0);
|
|
5624
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5642
5625
|
|
|
5643
|
-
/* Document-method:
|
|
5644
|
-
* the
|
|
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(
|
|
5648
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5652
|
-
* Represents a
|
|
5653
|
-
*
|
|
5654
|
-
*
|
|
5655
|
-
*
|
|
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
|
|
5640
|
+
VALUE rb_cWHILE = rb_define_class_under(rb_cNode, "WHILE", rb_cNode);
|
|
5660
5641
|
members = rb_ary_new();
|
|
5661
|
-
rb_cNodeSubclass[
|
|
5662
|
-
rb_iv_set(
|
|
5663
|
-
rb_iv_set(
|
|
5664
|
-
rb_define_singleton_method(
|
|
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:
|
|
5667
|
-
* the
|
|
5647
|
+
/* Document-method: body
|
|
5648
|
+
* the body of the loop
|
|
5668
5649
|
*/
|
|
5669
|
-
rb_define_method(
|
|
5670
|
-
rb_ary_push(members, rb_str_new2("
|
|
5650
|
+
rb_define_method(rb_cWHILE, "body", node_body, 0);
|
|
5651
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5671
5652
|
|
|
5672
|
-
/* Document-method:
|
|
5673
|
-
*
|
|
5653
|
+
/* Document-method: cond
|
|
5654
|
+
* a condition to terminate the loop when it becomes false
|
|
5674
5655
|
*/
|
|
5675
|
-
rb_define_method(
|
|
5676
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5680
|
-
* Represents a
|
|
5681
|
-
*
|
|
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
|
|
5669
|
+
VALUE rb_cXSTR = rb_define_class_under(rb_cNode, "XSTR", rb_cNode);
|
|
5685
5670
|
members = rb_ary_new();
|
|
5686
|
-
rb_cNodeSubclass[
|
|
5687
|
-
rb_iv_set(
|
|
5688
|
-
rb_iv_set(
|
|
5689
|
-
rb_define_singleton_method(
|
|
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:
|
|
5692
|
-
* the
|
|
5676
|
+
/* Document-method: lit
|
|
5677
|
+
* the string to be executed
|
|
5693
5678
|
*/
|
|
5694
|
-
rb_define_method(
|
|
5695
|
-
rb_ary_push(members, rb_str_new2("
|
|
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::
|
|
5725
|
-
* Represents
|
|
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
|
-
*
|
|
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
|
|
5732
|
+
VALUE rb_cZSUPER = rb_define_class_under(rb_cNode, "ZSUPER", rb_cNode);
|
|
5731
5733
|
members = rb_ary_new();
|
|
5732
|
-
rb_cNodeSubclass[
|
|
5733
|
-
rb_iv_set(
|
|
5734
|
-
rb_iv_set(
|
|
5735
|
-
rb_define_singleton_method(
|
|
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
|
|