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,1453 +3507,1284 @@ 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(
|
|
4006
|
-
|
|
4007
|
-
/* Document-method: body
|
|
4008
|
-
* the object to pass as a block
|
|
4009
|
-
*/
|
|
4010
|
-
rb_define_method(rb_cBLOCK_PASS, "body", node_body, 0);
|
|
4011
|
-
rb_ary_push(members, rb_str_new2("body"));
|
|
4012
|
-
|
|
4013
|
-
/* Document-method: iter
|
|
4014
|
-
* an expression which calls a method
|
|
4015
|
-
*/
|
|
4016
|
-
rb_define_method(rb_cBLOCK_PASS, "iter", node_iter, 0);
|
|
4017
|
-
rb_ary_push(members, rb_str_new2("iter"));
|
|
4018
|
-
}
|
|
4019
|
-
|
|
4020
|
-
/* Document-class: Node::DREGX
|
|
4021
|
-
* Represents a regular expresion with interpolation. The node is
|
|
4022
|
-
* evaluated by duplicating the regex stored in the 'lit' element, then
|
|
4023
|
-
* iterating over the nodes stored in the 'next' element. Each node
|
|
4024
|
-
* found should evaluate to a string, and each resulting string is
|
|
4025
|
-
* appended onto the original string. Interpolation is represented
|
|
4026
|
-
* with the EVSTR node.
|
|
4027
|
-
*/
|
|
4028
|
-
{
|
|
4029
|
-
VALUE rb_cDREGX = rb_define_class_under(rb_cNode, "DREGX", rb_cNode);
|
|
4030
|
-
members = rb_ary_new();
|
|
4031
|
-
rb_cNodeSubclass[NODE_DREGX] = rb_cDREGX;
|
|
4032
|
-
rb_iv_set(rb_cDREGX, "__member__", members);
|
|
4033
|
-
rb_iv_set(rb_cDREGX, "__type__", INT2NUM(NODE_DREGX));
|
|
4034
|
-
rb_define_singleton_method(rb_cDREGX, "members", node_s_members, 0);
|
|
4035
|
-
|
|
4036
|
-
/* Document-method: lit
|
|
4037
|
-
* a string
|
|
4038
|
-
*/
|
|
4039
|
-
rb_define_method(rb_cDREGX, "lit", node_lit, 0);
|
|
4040
|
-
rb_ary_push(members, rb_str_new2("lit"));
|
|
4041
|
-
|
|
4042
|
-
/* Document-method: cflag
|
|
4043
|
-
* a bitfield containing the options used in the regular
|
|
4044
|
-
* expression. Valid values include:
|
|
4045
|
-
* * RE_OPTION_IGNORECASE
|
|
4046
|
-
* * RE_OPTION_EXTENDED
|
|
4047
|
-
* * RE_OPTION_MULTILINE
|
|
4048
|
-
* * RE_OPTION_SINGLELINE
|
|
4049
|
-
* * RE_OPTION_LONGEST
|
|
4050
|
-
* * RE_MAY_IGNORECASE
|
|
4051
|
-
* * RE_OPTIMIZE_ANCHOR
|
|
4052
|
-
* * RE_OPTIMIZE_EXACTN
|
|
4053
|
-
* * RE_OPTIMIZE_NO_BM
|
|
4054
|
-
* * RE_OPTIMIZE_BMATCH
|
|
4055
|
-
*/
|
|
4056
|
-
rb_define_method(rb_cDREGX, "cflag", node_cflag, 0);
|
|
4057
|
-
rb_ary_push(members, rb_str_new2("cflag"));
|
|
4058
|
-
|
|
4059
|
-
/* Document-method: next
|
|
4060
|
-
* a list of expressions to be appended onto the string
|
|
4061
|
-
*/
|
|
4062
|
-
rb_define_method(rb_cDREGX, "next", node_next, 0);
|
|
4063
|
-
rb_ary_push(members, rb_str_new2("next"));
|
|
4064
|
-
}
|
|
4065
|
-
|
|
4066
|
-
/* Document-class: Node::DEFN
|
|
4067
|
-
* Represents a method definition, e.g.:
|
|
4068
|
-
* def mid
|
|
4069
|
-
* defn
|
|
4070
|
-
* end
|
|
4071
|
-
*/
|
|
4072
|
-
{
|
|
4073
|
-
VALUE rb_cDEFN = rb_define_class_under(rb_cNode, "DEFN", rb_cNode);
|
|
4074
|
-
members = rb_ary_new();
|
|
4075
|
-
rb_cNodeSubclass[NODE_DEFN] = rb_cDEFN;
|
|
4076
|
-
rb_iv_set(rb_cDEFN, "__member__", members);
|
|
4077
|
-
rb_iv_set(rb_cDEFN, "__type__", INT2NUM(NODE_DEFN));
|
|
4078
|
-
rb_define_singleton_method(rb_cDEFN, "members", node_s_members, 0);
|
|
4079
|
-
|
|
4080
|
-
/* Document-method: mid
|
|
4081
|
-
* the name of the method* defn the body of the method
|
|
4082
|
-
*/
|
|
4083
|
-
rb_define_method(rb_cDEFN, "mid", node_mid, 0);
|
|
4084
|
-
rb_ary_push(members, rb_str_new2("mid"));
|
|
4085
|
-
|
|
4086
|
-
/* Document-method: defn
|
|
4087
|
-
* the body of the method definition
|
|
4088
|
-
*/
|
|
4089
|
-
rb_define_method(rb_cDEFN, "defn", node_defn, 0);
|
|
4090
|
-
rb_ary_push(members, rb_str_new2("defn"));
|
|
4091
|
-
|
|
4092
|
-
/* Document-method: noex
|
|
4093
|
-
* the flags which should be used to define the method
|
|
4094
|
-
*/
|
|
4095
|
-
rb_define_method(rb_cDEFN, "noex", node_noex, 0);
|
|
4096
|
-
rb_ary_push(members, rb_str_new2("noex"));
|
|
4097
|
-
}
|
|
4098
|
-
|
|
4099
|
-
/* Document-class: Node::SCOPE
|
|
4100
|
-
* Represents a lexical scope.
|
|
4101
|
-
*
|
|
4102
|
-
* A new scope is created when a method is invoked. The scope node
|
|
4103
|
-
* holds information about local variables and arguments to the method.
|
|
4104
|
-
* The first two variables in the local variable table are the implicit
|
|
4105
|
-
* variables $_ and $~.
|
|
4106
|
-
*
|
|
4107
|
-
* The next variables listed in the local variable table are the
|
|
4108
|
-
* arguments to the method. More information about the arguments to
|
|
4109
|
-
* the method are stored in the ARGS node, which will either be the
|
|
4110
|
-
* first node in the scope or the first node in the BLOCK held by the
|
|
4111
|
-
* scope.
|
|
4112
|
-
*/
|
|
4113
|
-
{
|
|
4114
|
-
VALUE rb_cSCOPE = rb_define_class_under(rb_cNode, "SCOPE", rb_cNode);
|
|
4115
|
-
members = rb_ary_new();
|
|
4116
|
-
rb_cNodeSubclass[NODE_SCOPE] = rb_cSCOPE;
|
|
4117
|
-
rb_iv_set(rb_cSCOPE, "__member__", members);
|
|
4118
|
-
rb_iv_set(rb_cSCOPE, "__type__", INT2NUM(NODE_SCOPE));
|
|
4119
|
-
rb_define_singleton_method(rb_cSCOPE, "members", node_s_members, 0);
|
|
4120
|
-
|
|
4121
|
-
/* Document-method: tbl
|
|
4122
|
-
* the names of the local variables* next the first expression in
|
|
4123
|
-
* the scope
|
|
4124
|
-
*/
|
|
4125
|
-
rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0);
|
|
4126
|
-
rb_ary_push(members, rb_str_new2("tbl"));
|
|
4127
|
-
|
|
4128
|
-
/* Document-method: rval
|
|
4129
|
-
* holds information about which class(es) to search for constants
|
|
4130
|
-
* in this scope
|
|
4131
|
-
*/
|
|
4132
|
-
rb_define_method(rb_cSCOPE, "rval", node_rval, 0);
|
|
4133
|
-
rb_ary_push(members, rb_str_new2("rval"));
|
|
4134
|
-
|
|
4135
|
-
/* Document-method: next
|
|
4136
|
-
* the body of the lexical scope
|
|
4137
|
-
*/
|
|
4138
|
-
rb_define_method(rb_cSCOPE, "next", node_next, 0);
|
|
4139
|
-
rb_ary_push(members, rb_str_new2("next"));
|
|
4140
|
-
}
|
|
4141
|
-
|
|
4142
|
-
/* Document-class: Node::DSYM
|
|
4143
|
-
* Represents a symbol with interpolation, e.g.:
|
|
4144
|
-
* :"#{next}"
|
|
4145
|
-
*
|
|
4146
|
-
* The node is evaluated by duplicating the string stored in the 'lit'
|
|
4147
|
-
* element, then iterating over the nodes stored in the 'next' element.
|
|
4148
|
-
* Each node found should evalate to a string, and each resulting
|
|
4149
|
-
* string is appended onto the original string. The final resulting
|
|
4150
|
-
* string is then converted into a symbol. Interpolation is
|
|
4151
|
-
* represented with the EVSTR node.
|
|
4152
|
-
*/
|
|
4153
|
-
{
|
|
4154
|
-
VALUE rb_cDSYM = rb_define_class_under(rb_cNode, "DSYM", rb_cNode);
|
|
4155
|
-
members = rb_ary_new();
|
|
4156
|
-
rb_cNodeSubclass[NODE_DSYM] = rb_cDSYM;
|
|
4157
|
-
rb_iv_set(rb_cDSYM, "__member__", members);
|
|
4158
|
-
rb_iv_set(rb_cDSYM, "__type__", INT2NUM(NODE_DSYM));
|
|
4159
|
-
rb_define_singleton_method(rb_cDSYM, "members", node_s_members, 0);
|
|
4160
|
-
rb_define_method(rb_cDSYM, "lit", node_lit, 0);
|
|
4161
|
-
rb_ary_push(members, rb_str_new2("lit"));
|
|
4162
|
-
rb_define_method(rb_cDSYM, "next", node_next, 0);
|
|
4163
|
-
rb_ary_push(members, rb_str_new2("next"));
|
|
4164
|
-
}
|
|
4165
|
-
|
|
4166
|
-
/* Document-class: Node::BMETHOD
|
|
4167
|
-
* A placeholder for a method defined using define_method, e.g.:
|
|
4168
|
-
* define_method(:foo) {
|
|
4169
|
-
* ...
|
|
4170
|
-
* }
|
|
4171
|
-
*
|
|
4172
|
-
* See also DMETHOD.
|
|
4173
|
-
*/
|
|
4174
|
-
{
|
|
4175
|
-
VALUE rb_cBMETHOD = rb_define_class_under(rb_cNode, "BMETHOD", rb_cNode);
|
|
4176
|
-
members = rb_ary_new();
|
|
4177
|
-
rb_cNodeSubclass[NODE_BMETHOD] = rb_cBMETHOD;
|
|
4178
|
-
rb_iv_set(rb_cBMETHOD, "__member__", members);
|
|
4179
|
-
rb_iv_set(rb_cBMETHOD, "__type__", INT2NUM(NODE_BMETHOD));
|
|
4180
|
-
rb_define_singleton_method(rb_cBMETHOD, "members", node_s_members, 0);
|
|
4181
|
-
|
|
4182
|
-
/* Document-method: cval
|
|
4183
|
-
* the Proc object passed to define_method, which contains the body
|
|
4184
|
-
* of the method
|
|
4185
|
-
*/
|
|
4186
|
-
rb_define_method(rb_cBMETHOD, "cval", node_cval, 0);
|
|
4187
|
-
rb_ary_push(members, rb_str_new2("cval"));
|
|
4188
|
-
}
|
|
4189
|
-
|
|
4190
|
-
/* Document-class: Node::IF
|
|
4191
|
-
* Represents a conditional of the form:
|
|
4192
|
-
* if cond then
|
|
4193
|
-
* body
|
|
4194
|
-
* end
|
|
4195
|
-
*
|
|
4196
|
-
* or the form:
|
|
4197
|
-
* if cond then
|
|
4198
|
-
* body
|
|
4199
|
-
* else
|
|
4200
|
-
* else
|
|
4201
|
-
* end
|
|
4202
|
-
*
|
|
4203
|
-
* The condition is first evaluated. If it is true, then body is
|
|
4204
|
-
* evaluated, otherwise else is evaluated. The result is the value of
|
|
4205
|
-
* the expression evaluated, or nil if there was no expression
|
|
4206
|
-
* present.
|
|
4207
|
-
*
|
|
4208
|
-
* A conditional block using elsif has another IF node as the else
|
|
4209
|
-
* expression.
|
|
4210
|
-
*/
|
|
4211
|
-
{
|
|
4212
|
-
VALUE rb_cIF = rb_define_class_under(rb_cNode, "IF", rb_cNode);
|
|
4213
|
-
members = rb_ary_new();
|
|
4214
|
-
rb_cNodeSubclass[NODE_IF] = rb_cIF;
|
|
4215
|
-
rb_iv_set(rb_cIF, "__member__", members);
|
|
4216
|
-
rb_iv_set(rb_cIF, "__type__", INT2NUM(NODE_IF));
|
|
4217
|
-
rb_define_singleton_method(rb_cIF, "members", node_s_members, 0);
|
|
4218
|
-
|
|
4219
|
-
/* Document-method: cond
|
|
4220
|
-
* the condition to evaluate
|
|
4221
|
-
*/
|
|
4222
|
-
rb_define_method(rb_cIF, "cond", node_cond, 0);
|
|
4223
|
-
rb_ary_push(members, rb_str_new2("cond"));
|
|
4224
|
-
|
|
4225
|
-
/* Document-method: body
|
|
4226
|
-
* the expression to evaluate if the expression is true, or false
|
|
4227
|
-
* if the expression is empty
|
|
4228
|
-
*/
|
|
4229
|
-
rb_define_method(rb_cIF, "body", node_body, 0);
|
|
4230
|
-
rb_ary_push(members, rb_str_new2("body"));
|
|
4231
|
-
|
|
4232
|
-
/* Document-method: else
|
|
4233
|
-
* the expression to evaluate if the expression is false, or false
|
|
4234
|
-
* if the expression is empty
|
|
4235
|
-
*/
|
|
4236
|
-
rb_define_method(rb_cIF, "else", node_else, 0);
|
|
4237
|
-
rb_ary_push(members, rb_str_new2("else"));
|
|
4238
|
-
}
|
|
4239
|
-
|
|
4240
|
-
/* Document-class: Node::WHEN
|
|
4241
|
-
* Represents either a conditional in a case/end block:
|
|
4242
|
-
* case value
|
|
4243
|
-
* when head
|
|
4244
|
-
* body
|
|
4245
|
-
* next
|
|
4246
|
-
* end
|
|
4247
|
-
*
|
|
4248
|
-
* or the first element of a a case/end block with no conditional:
|
|
4249
|
-
* case
|
|
4250
|
-
* when head
|
|
4251
|
-
* body
|
|
4252
|
-
* next
|
|
4253
|
-
* end
|
|
4254
|
-
*
|
|
4255
|
-
* In the first case, value is evaluated and head is evaluated, and
|
|
4256
|
-
* they are compared using head === value. If the result is true, then
|
|
4257
|
-
* body is evaluated and no more when conditions are tried, otherwise
|
|
4258
|
-
* the interpreter evaluates the next node.
|
|
4259
|
-
*
|
|
4260
|
-
* In the second case, head is tested using rtest(value). If the
|
|
4261
|
-
* result is true, then body is evaluated and no more when conditions
|
|
4262
|
-
* are tried, otherwise the interpreter evaluates the next node.
|
|
4263
|
-
*
|
|
4264
|
-
* If the condition evaluates to false and there are no more when
|
|
4265
|
-
* conditions to try, the result of the expression is nil.
|
|
4266
|
-
*
|
|
4267
|
-
* If the next expression to try is not a WHEN node, then it represents
|
|
4268
|
-
* an else element and is evaluated unconditionally.
|
|
4269
|
-
*/
|
|
4270
|
-
{
|
|
4271
|
-
VALUE rb_cWHEN = rb_define_class_under(rb_cNode, "WHEN", rb_cNode);
|
|
4272
|
-
members = rb_ary_new();
|
|
4273
|
-
rb_cNodeSubclass[NODE_WHEN] = rb_cWHEN;
|
|
4274
|
-
rb_iv_set(rb_cWHEN, "__member__", members);
|
|
4275
|
-
rb_iv_set(rb_cWHEN, "__type__", INT2NUM(NODE_WHEN));
|
|
4276
|
-
rb_define_singleton_method(rb_cWHEN, "members", node_s_members, 0);
|
|
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);
|
|
4277
4119
|
|
|
4278
4120
|
/* Document-method: head
|
|
4279
|
-
*
|
|
4280
|
-
*/
|
|
4281
|
-
rb_define_method(rb_cWHEN, "head", node_head, 0);
|
|
4282
|
-
rb_ary_push(members, rb_str_new2("head"));
|
|
4283
|
-
|
|
4284
|
-
/* Document-method: body
|
|
4285
|
-
* an expression to evaluate if the condition evaluates to true
|
|
4286
|
-
*/
|
|
4287
|
-
rb_define_method(rb_cWHEN, "body", node_body, 0);
|
|
4288
|
-
rb_ary_push(members, rb_str_new2("body"));
|
|
4289
|
-
|
|
4290
|
-
/* Document-method: next
|
|
4291
|
-
* the next expression to be evaluated if the condition is false
|
|
4292
|
-
*/
|
|
4293
|
-
rb_define_method(rb_cWHEN, "next", node_next, 0);
|
|
4294
|
-
rb_ary_push(members, rb_str_new2("next"));
|
|
4295
|
-
}
|
|
4296
|
-
|
|
4297
|
-
/* Document-class: Node::ARGSCAT
|
|
4298
|
-
* Represents the concatenation of a list of arguments and a splatted
|
|
4299
|
-
* value, e.g.:
|
|
4300
|
-
* a, b, *value
|
|
4301
|
-
* Evaluates head to create an array. Evaluates body and performs a
|
|
4302
|
-
* splat operation on the result to create another array (see SPLAT).
|
|
4303
|
-
* Concatenates the the second array onto the end of the first to
|
|
4304
|
-
* produce the result.
|
|
4305
|
-
*/
|
|
4306
|
-
{
|
|
4307
|
-
VALUE rb_cARGSCAT = rb_define_class_under(rb_cNode, "ARGSCAT", rb_cNode);
|
|
4308
|
-
members = rb_ary_new();
|
|
4309
|
-
rb_cNodeSubclass[NODE_ARGSCAT] = rb_cARGSCAT;
|
|
4310
|
-
rb_iv_set(rb_cARGSCAT, "__member__", members);
|
|
4311
|
-
rb_iv_set(rb_cARGSCAT, "__type__", INT2NUM(NODE_ARGSCAT));
|
|
4312
|
-
rb_define_singleton_method(rb_cARGSCAT, "members", node_s_members, 0);
|
|
4313
|
-
|
|
4314
|
-
/* Document-method: head
|
|
4315
|
-
* a list of fixed arguments
|
|
4121
|
+
* the method body
|
|
4316
4122
|
*/
|
|
4317
|
-
rb_define_method(
|
|
4123
|
+
rb_define_method(rb_cFBODY, "head", node_head, 0);
|
|
4318
4124
|
rb_ary_push(members, rb_str_new2("head"));
|
|
4319
4125
|
|
|
4320
|
-
/* Document-method:
|
|
4321
|
-
* the
|
|
4322
|
-
* fixed arguments
|
|
4126
|
+
/* Document-method: orig
|
|
4127
|
+
* the origin class
|
|
4323
4128
|
*/
|
|
4324
|
-
rb_define_method(
|
|
4325
|
-
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"));
|
|
4326
4137
|
}
|
|
4327
4138
|
|
|
4328
|
-
/* Document-class: Node::
|
|
4329
|
-
* Represents a
|
|
4330
|
-
*
|
|
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.
|
|
4331
4145
|
*/
|
|
4332
4146
|
{
|
|
4333
|
-
VALUE
|
|
4147
|
+
VALUE rb_cFCALL = rb_define_class_under(rb_cNode, "FCALL", rb_cNode);
|
|
4334
4148
|
members = rb_ary_new();
|
|
4335
|
-
rb_cNodeSubclass[
|
|
4336
|
-
rb_iv_set(
|
|
4337
|
-
rb_iv_set(
|
|
4338
|
-
rb_define_singleton_method(
|
|
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);
|
|
4339
4153
|
|
|
4340
|
-
/* Document-method:
|
|
4341
|
-
*
|
|
4154
|
+
/* Document-method: args
|
|
4155
|
+
* the arguments to the method
|
|
4342
4156
|
*/
|
|
4343
|
-
rb_define_method(
|
|
4344
|
-
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"));
|
|
4159
|
+
|
|
4160
|
+
/* Document-method: mid
|
|
4161
|
+
* the method id
|
|
4162
|
+
*/
|
|
4163
|
+
rb_define_method(rb_cFCALL, "mid", node_mid, 0);
|
|
4164
|
+
rb_ary_push(members, rb_str_new2("mid"));
|
|
4345
4165
|
}
|
|
4346
4166
|
|
|
4347
|
-
/* Document-class: Node::
|
|
4348
|
-
*
|
|
4349
|
-
*
|
|
4350
|
-
*
|
|
4351
|
-
*
|
|
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
|
|
4171
|
+
* end
|
|
4352
4172
|
*/
|
|
4353
|
-
#ifdef HAVE_NODE_ALLOCA
|
|
4354
4173
|
{
|
|
4355
|
-
VALUE
|
|
4174
|
+
VALUE rb_cFLIP2 = rb_define_class_under(rb_cNode, "FLIP2", rb_cNode);
|
|
4356
4175
|
members = rb_ary_new();
|
|
4357
|
-
rb_cNodeSubclass[
|
|
4358
|
-
rb_iv_set(
|
|
4359
|
-
rb_iv_set(
|
|
4360
|
-
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);
|
|
4361
4180
|
|
|
4362
|
-
/* Document-method:
|
|
4363
|
-
*
|
|
4181
|
+
/* Document-method: beg
|
|
4182
|
+
* the beginning of the range
|
|
4364
4183
|
*/
|
|
4365
|
-
rb_define_method(
|
|
4366
|
-
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"));
|
|
4367
4186
|
|
|
4368
|
-
/* Document-method:
|
|
4369
|
-
*
|
|
4187
|
+
/* Document-method: end
|
|
4188
|
+
* the end of the range
|
|
4370
4189
|
*/
|
|
4371
|
-
rb_define_method(
|
|
4372
|
-
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"));
|
|
4373
4192
|
|
|
4374
4193
|
/* Document-method: cnt
|
|
4375
|
-
* the
|
|
4194
|
+
* the index into the local variable table of the special variable
|
|
4195
|
+
* to use in the flip-flop expression (usually 2 for $_)
|
|
4376
4196
|
*/
|
|
4377
|
-
rb_define_method(
|
|
4197
|
+
rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0);
|
|
4378
4198
|
rb_ary_push(members, rb_str_new2("cnt"));
|
|
4379
4199
|
}
|
|
4380
|
-
#endif
|
|
4381
4200
|
|
|
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)
|
|
4402
|
-
*
|
|
4403
|
-
* In no case does ruby short-circuit the assignment.
|
|
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
|
|
4404
4206
|
*/
|
|
4405
4207
|
{
|
|
4406
|
-
VALUE
|
|
4208
|
+
VALUE rb_cFLIP3 = rb_define_class_under(rb_cNode, "FLIP3", rb_cNode);
|
|
4407
4209
|
members = rb_ary_new();
|
|
4408
|
-
rb_cNodeSubclass[
|
|
4409
|
-
rb_iv_set(
|
|
4410
|
-
rb_iv_set(
|
|
4411
|
-
rb_define_singleton_method(
|
|
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);
|
|
4412
4214
|
|
|
4413
|
-
/* Document-method:
|
|
4414
|
-
* the
|
|
4215
|
+
/* Document-method: beg
|
|
4216
|
+
* the beginning of the range
|
|
4415
4217
|
*/
|
|
4416
|
-
rb_define_method(
|
|
4417
|
-
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"));
|
|
4418
4220
|
|
|
4419
|
-
/* Document-method:
|
|
4420
|
-
*
|
|
4421
|
-
* rhs
|
|
4221
|
+
/* Document-method: end
|
|
4222
|
+
* the end of the range
|
|
4422
4223
|
*/
|
|
4423
|
-
rb_define_method(
|
|
4424
|
-
rb_ary_push(members, rb_str_new2("
|
|
4224
|
+
rb_define_method(rb_cFLIP3, "end", node_end, 0);
|
|
4225
|
+
rb_ary_push(members, rb_str_new2("end"));
|
|
4425
4226
|
|
|
4426
|
-
/* Document-method:
|
|
4427
|
-
* the
|
|
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 $_)
|
|
4428
4230
|
*/
|
|
4429
|
-
rb_define_method(
|
|
4430
|
-
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"));
|
|
4431
4233
|
}
|
|
4432
4234
|
|
|
4433
|
-
/* Document-class: Node::
|
|
4434
|
-
* Represents
|
|
4435
|
-
*
|
|
4436
|
-
*
|
|
4235
|
+
/* Document-class: Node::FOR
|
|
4236
|
+
* Represents a loop constructed with the 'for' keyword, e.g.:
|
|
4237
|
+
* for var in iter do
|
|
4238
|
+
* body
|
|
4437
4239
|
* end
|
|
4438
|
-
*
|
|
4240
|
+
*
|
|
4241
|
+
* This is equivalent to:
|
|
4242
|
+
* iter.each do |*args|
|
|
4243
|
+
* assign args to var
|
|
4244
|
+
* body
|
|
4245
|
+
* end
|
|
4246
|
+
*
|
|
4247
|
+
* Except that a new block is not created.
|
|
4439
4248
|
*/
|
|
4440
4249
|
{
|
|
4441
|
-
VALUE
|
|
4250
|
+
VALUE rb_cFOR = rb_define_class_under(rb_cNode, "FOR", rb_cNode);
|
|
4442
4251
|
members = rb_ary_new();
|
|
4443
|
-
rb_cNodeSubclass[
|
|
4444
|
-
rb_iv_set(
|
|
4445
|
-
rb_iv_set(
|
|
4446
|
-
rb_define_singleton_method(
|
|
4447
|
-
|
|
4448
|
-
/* Document-method: head
|
|
4449
|
-
* the value to select on
|
|
4450
|
-
*/
|
|
4451
|
-
rb_define_method(rb_cCASE, "head", node_head, 0);
|
|
4452
|
-
rb_ary_push(members, rb_str_new2("head"));
|
|
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);
|
|
4453
4256
|
|
|
4454
4257
|
/* Document-method: body
|
|
4455
|
-
*
|
|
4456
|
-
* conditional
|
|
4258
|
+
* the body of the loop
|
|
4457
4259
|
*/
|
|
4458
|
-
rb_define_method(
|
|
4260
|
+
rb_define_method(rb_cFOR, "body", node_body, 0);
|
|
4459
4261
|
rb_ary_push(members, rb_str_new2("body"));
|
|
4460
|
-
rb_define_method(rb_cCASE, "next", node_next, 0);
|
|
4461
|
-
rb_ary_push(members, rb_str_new2("next"));
|
|
4462
|
-
}
|
|
4463
4262
|
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
rb_ary_push(members, rb_str_new2("argc"));
|
|
4263
|
+
/* Document-method: iter
|
|
4264
|
+
* the sequence over which to iterate
|
|
4265
|
+
*/
|
|
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"));
|
|
4478
4276
|
}
|
|
4479
4277
|
|
|
4480
|
-
/* Document-class: Node::
|
|
4481
|
-
* Represents
|
|
4482
|
-
* recv.attr op value
|
|
4483
|
-
*
|
|
4484
|
-
* where recv is the receiver of the attr method, attr is the attribute
|
|
4485
|
-
* to which to assign, op is an assignment operation (e.g. +=), and
|
|
4486
|
-
* value is the value to assign to the attribute.
|
|
4487
|
-
*
|
|
4488
|
-
* The 'next' member of this class is also of type OP_ASGN2, though it
|
|
4489
|
-
* has different members than its parent. This child node is
|
|
4490
|
-
* documented under OP_ASGN2_ARG.
|
|
4278
|
+
/* Document-class: Node::GASGN
|
|
4279
|
+
* Represents global variable assignment.
|
|
4491
4280
|
*/
|
|
4492
4281
|
{
|
|
4493
|
-
VALUE
|
|
4282
|
+
VALUE rb_cGASGN = rb_define_class_under(rb_cNode, "GASGN", rb_cNode);
|
|
4494
4283
|
members = rb_ary_new();
|
|
4495
|
-
rb_cNodeSubclass[
|
|
4496
|
-
rb_iv_set(
|
|
4497
|
-
rb_iv_set(
|
|
4498
|
-
rb_define_singleton_method(
|
|
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);
|
|
4499
4288
|
|
|
4500
4289
|
/* Document-method: value
|
|
4501
|
-
* the value
|
|
4502
|
-
*/
|
|
4503
|
-
rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
|
|
4504
|
-
rb_ary_push(members, rb_str_new2("value"));
|
|
4505
|
-
|
|
4506
|
-
/* Document-method: next
|
|
4507
|
-
* another node of type OP_ASGN2 which contains more information
|
|
4508
|
-
* about the assignment operation than can fit in this node alone
|
|
4290
|
+
* an expression whose result is the new value of the global variable
|
|
4509
4291
|
*/
|
|
4510
|
-
rb_define_method(
|
|
4511
|
-
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"));
|
|
4512
4294
|
|
|
4513
|
-
/* Document-method:
|
|
4514
|
-
* the
|
|
4295
|
+
/* Document-method: vid
|
|
4296
|
+
* the name of the global variable, with a leading '$' character.
|
|
4515
4297
|
*/
|
|
4516
|
-
rb_define_method(
|
|
4517
|
-
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"));
|
|
4518
4302
|
}
|
|
4519
4303
|
|
|
4520
|
-
/* Document-class: Node::
|
|
4521
|
-
* Represents
|
|
4522
|
-
* def recv.mid
|
|
4523
|
-
* defn
|
|
4524
|
-
* end
|
|
4304
|
+
/* Document-class: Node::GVAR
|
|
4305
|
+
* Represents global variable retrieval.
|
|
4525
4306
|
*/
|
|
4526
4307
|
{
|
|
4527
|
-
VALUE
|
|
4308
|
+
VALUE rb_cGVAR = rb_define_class_under(rb_cNode, "GVAR", rb_cNode);
|
|
4528
4309
|
members = rb_ary_new();
|
|
4529
|
-
rb_cNodeSubclass[
|
|
4530
|
-
rb_iv_set(
|
|
4531
|
-
rb_iv_set(
|
|
4532
|
-
rb_define_singleton_method(
|
|
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);
|
|
4533
4314
|
|
|
4534
|
-
/* Document-method:
|
|
4535
|
-
* the name of the
|
|
4315
|
+
/* Document-method: vid
|
|
4316
|
+
* the name of the global variable to retrieve, with a leading '$'
|
|
4536
4317
|
*/
|
|
4537
|
-
rb_define_method(
|
|
4538
|
-
rb_ary_push(members, rb_str_new2("
|
|
4539
|
-
rb_define_method(
|
|
4540
|
-
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"));
|
|
4322
|
+
}
|
|
4541
4323
|
|
|
4542
|
-
|
|
4543
|
-
|
|
4324
|
+
/* Document-class: Node::HASH
|
|
4325
|
+
* Represents a hash table. Evaluation of this node creates a new Hash
|
|
4326
|
+
* by evaluating the given expressions and placing them into the table.
|
|
4327
|
+
*/
|
|
4328
|
+
{
|
|
4329
|
+
VALUE rb_cHASH = rb_define_class_under(rb_cNode, "HASH", rb_cNode);
|
|
4330
|
+
members = rb_ary_new();
|
|
4331
|
+
rb_cNodeSubclass[NODE_HASH] = rb_cHASH;
|
|
4332
|
+
rb_iv_set(rb_cHASH, "__member__", members);
|
|
4333
|
+
rb_iv_set(rb_cHASH, "__type__", INT2NUM(NODE_HASH));
|
|
4334
|
+
rb_define_singleton_method(rb_cHASH, "members", node_s_members, 0);
|
|
4335
|
+
|
|
4336
|
+
/* Document-method: head
|
|
4337
|
+
* an array of successive keys and values
|
|
4544
4338
|
*/
|
|
4545
|
-
rb_define_method(
|
|
4546
|
-
rb_ary_push(members, rb_str_new2("
|
|
4339
|
+
rb_define_method(rb_cHASH, "head", node_head, 0);
|
|
4340
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
4547
4341
|
}
|
|
4548
4342
|
|
|
4549
|
-
/* Document-class: Node::
|
|
4550
|
-
* Represents
|
|
4343
|
+
/* Document-class: Node::IASGN
|
|
4344
|
+
* Represents instance variable assignment.
|
|
4551
4345
|
*/
|
|
4552
4346
|
{
|
|
4553
|
-
VALUE
|
|
4347
|
+
VALUE rb_cIASGN = rb_define_class_under(rb_cNode, "IASGN", rb_cNode);
|
|
4554
4348
|
members = rb_ary_new();
|
|
4555
|
-
rb_cNodeSubclass[
|
|
4556
|
-
rb_iv_set(
|
|
4557
|
-
rb_iv_set(
|
|
4558
|
-
rb_define_singleton_method(
|
|
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);
|
|
4559
4353
|
|
|
4560
4354
|
/* Document-method: value
|
|
4561
|
-
* the value to assign to the
|
|
4355
|
+
* the value to assign to the instance variable
|
|
4562
4356
|
*/
|
|
4563
|
-
rb_define_method(
|
|
4357
|
+
rb_define_method(rb_cIASGN, "value", node_value, 0);
|
|
4564
4358
|
rb_ary_push(members, rb_str_new2("value"));
|
|
4565
4359
|
|
|
4566
4360
|
/* Document-method: vid
|
|
4567
|
-
* the name of the
|
|
4361
|
+
* the name of the instance variable, with a leading '@' sign
|
|
4568
4362
|
*/
|
|
4569
|
-
rb_define_method(
|
|
4363
|
+
rb_define_method(rb_cIASGN, "vid", node_vid, 0);
|
|
4570
4364
|
rb_ary_push(members, rb_str_new2("vid"));
|
|
4571
|
-
rb_define_method(rb_cLASGN, "cnt", node_cnt, 0);
|
|
4572
|
-
rb_ary_push(members, rb_str_new2("cnt"));
|
|
4573
4365
|
}
|
|
4574
4366
|
|
|
4575
|
-
/* Document-class: Node::
|
|
4576
|
-
* Represents
|
|
4577
|
-
*
|
|
4367
|
+
/* Document-class: Node::IF
|
|
4368
|
+
* Represents a conditional of the form:
|
|
4369
|
+
* if cond then
|
|
4370
|
+
* body
|
|
4371
|
+
* end
|
|
4578
4372
|
*
|
|
4579
|
-
*
|
|
4580
|
-
*
|
|
4373
|
+
* or the form:
|
|
4374
|
+
* if cond then
|
|
4375
|
+
* body
|
|
4376
|
+
* else
|
|
4377
|
+
* else
|
|
4378
|
+
* end
|
|
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.
|
|
4581
4387
|
*/
|
|
4582
4388
|
{
|
|
4583
|
-
VALUE
|
|
4389
|
+
VALUE rb_cIF = rb_define_class_under(rb_cNode, "IF", rb_cNode);
|
|
4584
4390
|
members = rb_ary_new();
|
|
4585
|
-
rb_cNodeSubclass[
|
|
4586
|
-
rb_iv_set(
|
|
4587
|
-
rb_iv_set(
|
|
4588
|
-
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);
|
|
4395
|
+
|
|
4396
|
+
/* Document-method: cond
|
|
4397
|
+
* the condition to evaluate
|
|
4398
|
+
*/
|
|
4399
|
+
rb_define_method(rb_cIF, "cond", node_cond, 0);
|
|
4400
|
+
rb_ary_push(members, rb_str_new2("cond"));
|
|
4401
|
+
|
|
4402
|
+
/* Document-method: body
|
|
4403
|
+
* the expression to evaluate if the expression is true, or false
|
|
4404
|
+
* if the expression is empty
|
|
4405
|
+
*/
|
|
4406
|
+
rb_define_method(rb_cIF, "body", node_body, 0);
|
|
4407
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
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"));
|
|
4589
4415
|
}
|
|
4590
4416
|
|
|
4591
|
-
/* Document-class: Node::
|
|
4592
|
-
*
|
|
4593
|
-
* node.
|
|
4417
|
+
/* Document-class: Node::IFUNC
|
|
4418
|
+
* A temporary node used in iteration.
|
|
4594
4419
|
*/
|
|
4595
4420
|
{
|
|
4596
|
-
VALUE
|
|
4421
|
+
VALUE rb_cIFUNC = rb_define_class_under(rb_cNode, "IFUNC", rb_cNode);
|
|
4597
4422
|
members = rb_ary_new();
|
|
4598
|
-
rb_cNodeSubclass[
|
|
4599
|
-
rb_iv_set(
|
|
4600
|
-
rb_iv_set(
|
|
4601
|
-
rb_define_singleton_method(
|
|
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);
|
|
4602
4427
|
|
|
4603
|
-
/* Document-method:
|
|
4604
|
-
* the
|
|
4428
|
+
/* Document-method: cfnc
|
|
4429
|
+
* a pointer to the C function to which to yield
|
|
4605
4430
|
*/
|
|
4606
|
-
rb_define_method(
|
|
4607
|
-
rb_ary_push(members, rb_str_new2("
|
|
4431
|
+
rb_define_method(rb_cIFUNC, "cfnc", node_cfnc, 0);
|
|
4432
|
+
rb_ary_push(members, rb_str_new2("cfnc"));
|
|
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"));
|
|
4608
4446
|
}
|
|
4609
4447
|
|
|
4610
|
-
/* Document-class: Node::
|
|
4611
|
-
*
|
|
4612
|
-
*
|
|
4613
|
-
*
|
|
4614
|
-
*
|
|
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
|
|
4454
|
+
*
|
|
4455
|
+
* A new block is created so that dynamic variables created inside the
|
|
4456
|
+
* loop do not persist once the loop has terminated.
|
|
4457
|
+
*
|
|
4458
|
+
* If the iter node is a POSTEXE node, indicates that the expression
|
|
4459
|
+
* should be evaluated when the program terminates.
|
|
4615
4460
|
*/
|
|
4616
4461
|
{
|
|
4617
|
-
VALUE
|
|
4462
|
+
VALUE rb_cITER = rb_define_class_under(rb_cNode, "ITER", rb_cNode);
|
|
4618
4463
|
members = rb_ary_new();
|
|
4619
|
-
rb_cNodeSubclass[
|
|
4620
|
-
rb_iv_set(
|
|
4621
|
-
rb_iv_set(
|
|
4622
|
-
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);
|
|
4623
4468
|
|
|
4624
|
-
/* Document-method:
|
|
4625
|
-
* the
|
|
4469
|
+
/* Document-method: body
|
|
4470
|
+
* the body of the loop
|
|
4626
4471
|
*/
|
|
4627
|
-
rb_define_method(
|
|
4628
|
-
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"));
|
|
4474
|
+
|
|
4475
|
+
/* Document-method: iter
|
|
4476
|
+
* an expression which calls the desired iteration method, usually
|
|
4477
|
+
* recv.each
|
|
4478
|
+
*/
|
|
4479
|
+
rb_define_method(rb_cITER, "iter", node_iter, 0);
|
|
4480
|
+
rb_ary_push(members, rb_str_new2("iter"));
|
|
4481
|
+
|
|
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.
|
|
4486
|
+
*/
|
|
4487
|
+
rb_define_method(rb_cITER, "var", node_var, 0);
|
|
4488
|
+
rb_ary_push(members, rb_str_new2("var"));
|
|
4629
4489
|
}
|
|
4630
4490
|
|
|
4631
|
-
/* Document-class: Node::
|
|
4632
|
-
* A
|
|
4633
|
-
*
|
|
4634
|
-
*
|
|
4635
|
-
*
|
|
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.
|
|
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.
|
|
4644
4496
|
*/
|
|
4645
4497
|
{
|
|
4646
|
-
VALUE
|
|
4498
|
+
VALUE rb_cIVAR = rb_define_class_under(rb_cNode, "IVAR", rb_cNode);
|
|
4647
4499
|
members = rb_ary_new();
|
|
4648
|
-
rb_cNodeSubclass[
|
|
4649
|
-
rb_iv_set(
|
|
4650
|
-
rb_iv_set(
|
|
4651
|
-
rb_define_singleton_method(
|
|
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);
|
|
4504
|
+
|
|
4505
|
+
/* Document-method: vid
|
|
4506
|
+
* the name of the attribute, with a leading '@' sign
|
|
4507
|
+
*/
|
|
4508
|
+
rb_define_method(rb_cIVAR, "vid", node_vid, 0);
|
|
4509
|
+
rb_ary_push(members, rb_str_new2("vid"));
|
|
4652
4510
|
}
|
|
4653
4511
|
|
|
4654
|
-
/* Document-class: Node::
|
|
4655
|
-
* Represents
|
|
4656
|
-
* Evaluation of this node converts its argument to an array by calling
|
|
4657
|
-
* \#to_ary on the argument.
|
|
4512
|
+
/* Document-class: Node::LASGN
|
|
4513
|
+
* Represents local variable assignment.
|
|
4658
4514
|
*/
|
|
4659
4515
|
{
|
|
4660
|
-
VALUE
|
|
4516
|
+
VALUE rb_cLASGN = rb_define_class_under(rb_cNode, "LASGN", rb_cNode);
|
|
4661
4517
|
members = rb_ary_new();
|
|
4662
|
-
rb_cNodeSubclass[
|
|
4663
|
-
rb_iv_set(
|
|
4664
|
-
rb_iv_set(
|
|
4665
|
-
rb_define_singleton_method(
|
|
4518
|
+
rb_cNodeSubclass[NODE_LASGN] = rb_cLASGN;
|
|
4519
|
+
rb_iv_set(rb_cLASGN, "__member__", members);
|
|
4520
|
+
rb_iv_set(rb_cLASGN, "__type__", INT2NUM(NODE_LASGN));
|
|
4521
|
+
rb_define_singleton_method(rb_cLASGN, "members", node_s_members, 0);
|
|
4666
4522
|
|
|
4667
|
-
/* Document-method:
|
|
4668
|
-
* the
|
|
4523
|
+
/* Document-method: value
|
|
4524
|
+
* the value to assign to the local variable
|
|
4669
4525
|
*/
|
|
4670
|
-
rb_define_method(
|
|
4671
|
-
rb_ary_push(members, rb_str_new2("
|
|
4526
|
+
rb_define_method(rb_cLASGN, "value", node_value, 0);
|
|
4527
|
+
rb_ary_push(members, rb_str_new2("value"));
|
|
4528
|
+
|
|
4529
|
+
/* Document-method: vid
|
|
4530
|
+
* the name of the local variable
|
|
4531
|
+
*/
|
|
4532
|
+
rb_define_method(rb_cLASGN, "vid", node_vid, 0);
|
|
4533
|
+
rb_ary_push(members, rb_str_new2("vid"));
|
|
4534
|
+
rb_define_method(rb_cLASGN, "cnt", node_cnt, 0);
|
|
4535
|
+
rb_ary_push(members, rb_str_new2("cnt"));
|
|
4672
4536
|
}
|
|
4673
4537
|
|
|
4674
|
-
/* Document-class: Node::
|
|
4675
|
-
* Represents a
|
|
4676
|
-
*
|
|
4677
|
-
* The given string is executed in a subshell and the output from its
|
|
4678
|
-
* 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.
|
|
4679
4541
|
*/
|
|
4680
4542
|
{
|
|
4681
|
-
VALUE
|
|
4543
|
+
VALUE rb_cLIT = rb_define_class_under(rb_cNode, "LIT", rb_cNode);
|
|
4682
4544
|
members = rb_ary_new();
|
|
4683
|
-
rb_cNodeSubclass[
|
|
4684
|
-
rb_iv_set(
|
|
4685
|
-
rb_iv_set(
|
|
4686
|
-
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);
|
|
4687
4549
|
|
|
4688
4550
|
/* Document-method: lit
|
|
4689
|
-
* the
|
|
4551
|
+
* the object
|
|
4690
4552
|
*/
|
|
4691
|
-
rb_define_method(
|
|
4553
|
+
rb_define_method(rb_cLIT, "lit", node_lit, 0);
|
|
4692
4554
|
rb_ary_push(members, rb_str_new2("lit"));
|
|
4693
4555
|
}
|
|
4694
4556
|
|
|
4695
|
-
/* Document-class: Node::
|
|
4696
|
-
* Represents
|
|
4697
|
-
* examples).
|
|
4698
|
-
*
|
|
4699
|
-
* If the head node of the rescue expresion raises an exception, the
|
|
4700
|
-
* resq node is evaluated. The resq node is of type RESBDOY.
|
|
4701
|
-
*
|
|
4702
|
-
* As it is evaluated, the type of the exception is tested against the
|
|
4703
|
-
* class(es) listed in the args node. If there is a match, the body
|
|
4704
|
-
* node is evaluated, otherwise the head node is evaluated. The head
|
|
4705
|
-
* node is either another RESBDOY node or false (0).
|
|
4557
|
+
/* Document-class: Node::LVAR
|
|
4558
|
+
* Represents local variable retrieval.
|
|
4706
4559
|
*/
|
|
4707
4560
|
{
|
|
4708
|
-
VALUE
|
|
4561
|
+
VALUE rb_cLVAR = rb_define_class_under(rb_cNode, "LVAR", rb_cNode);
|
|
4709
4562
|
members = rb_ary_new();
|
|
4710
|
-
rb_cNodeSubclass[
|
|
4711
|
-
rb_iv_set(
|
|
4712
|
-
rb_iv_set(
|
|
4713
|
-
rb_define_singleton_method(
|
|
4714
|
-
|
|
4715
|
-
/* Document-method: head
|
|
4716
|
-
* the next rescue
|
|
4717
|
-
*/
|
|
4718
|
-
rb_define_method(rb_cRESBODY, "head", node_head, 0);
|
|
4719
|
-
rb_ary_push(members, rb_str_new2("head"));
|
|
4720
|
-
|
|
4721
|
-
/* Document-method: args
|
|
4722
|
-
* the expression type to match against
|
|
4723
|
-
*/
|
|
4724
|
-
rb_define_method(rb_cRESBODY, "args", node_args, 0);
|
|
4725
|
-
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);
|
|
4726
4567
|
|
|
4727
|
-
/* Document-method:
|
|
4728
|
-
* the
|
|
4568
|
+
/* Document-method: vid
|
|
4569
|
+
* the name of the local variable to retrieve.
|
|
4729
4570
|
*/
|
|
4730
|
-
rb_define_method(
|
|
4731
|
-
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"));
|
|
4732
4575
|
}
|
|
4733
4576
|
|
|
4734
|
-
/* Document-class: Node::
|
|
4735
|
-
* Represents
|
|
4736
|
-
* alias 1st 2nd
|
|
4737
|
-
* where 2nd is the name of an existing method and 1st is the name of
|
|
4738
|
-
* its new alias.
|
|
4577
|
+
/* Document-class: Node::MASGN
|
|
4578
|
+
* Represents multiple assignment.
|
|
4739
4579
|
*/
|
|
4740
4580
|
{
|
|
4741
|
-
VALUE
|
|
4581
|
+
VALUE rb_cMASGN = rb_define_class_under(rb_cNode, "MASGN", rb_cNode);
|
|
4742
4582
|
members = rb_ary_new();
|
|
4743
|
-
rb_cNodeSubclass[
|
|
4744
|
-
rb_iv_set(
|
|
4745
|
-
rb_iv_set(
|
|
4746
|
-
rb_define_singleton_method(
|
|
4747
|
-
rb_define_method(rb_cALIAS, "first", node_1st, 0);
|
|
4748
|
-
rb_ary_push(members, rb_str_new2("first"));
|
|
4749
|
-
rb_define_method(rb_cALIAS, "second", node_2nd, 0);
|
|
4750
|
-
rb_ary_push(members, rb_str_new2("second"));
|
|
4751
|
-
}
|
|
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);
|
|
4752
4587
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
{
|
|
4759
|
-
VALUE rb_cARRAY = rb_define_class_under(rb_cNode, "ARRAY", rb_cNode);
|
|
4760
|
-
members = rb_ary_new();
|
|
4761
|
-
rb_cNodeSubclass[NODE_ARRAY] = rb_cARRAY;
|
|
4762
|
-
rb_iv_set(rb_cARRAY, "__member__", members);
|
|
4763
|
-
rb_iv_set(rb_cARRAY, "__type__", INT2NUM(NODE_ARRAY));
|
|
4764
|
-
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"));
|
|
4765
4593
|
|
|
4766
4594
|
/* Document-method: head
|
|
4767
|
-
*
|
|
4595
|
+
* TODO
|
|
4768
4596
|
*/
|
|
4769
|
-
rb_define_method(
|
|
4597
|
+
rb_define_method(rb_cMASGN, "head", node_head, 0);
|
|
4770
4598
|
rb_ary_push(members, rb_str_new2("head"));
|
|
4771
|
-
rb_define_method(rb_cARRAY, "alen", node_alen, 0);
|
|
4772
|
-
rb_ary_push(members, rb_str_new2("alen"));
|
|
4773
4599
|
|
|
4774
|
-
/* Document-method:
|
|
4775
|
-
*
|
|
4600
|
+
/* Document-method: value
|
|
4601
|
+
* TODO
|
|
4776
4602
|
*/
|
|
4777
|
-
rb_define_method(
|
|
4778
|
-
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"));
|
|
4779
4605
|
}
|
|
4780
4606
|
|
|
4781
|
-
/* Document-class: Node::
|
|
4782
|
-
* Represents
|
|
4783
|
-
*
|
|
4784
|
-
*
|
|
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.
|
|
4785
4620
|
*/
|
|
4786
4621
|
{
|
|
4787
|
-
VALUE
|
|
4622
|
+
VALUE rb_cMATCH = rb_define_class_under(rb_cNode, "MATCH", rb_cNode);
|
|
4788
4623
|
members = rb_ary_new();
|
|
4789
|
-
rb_cNodeSubclass[
|
|
4790
|
-
rb_iv_set(
|
|
4791
|
-
rb_iv_set(
|
|
4792
|
-
rb_define_singleton_method(
|
|
4793
|
-
rb_define_method(rb_cNEXT, "stts", node_stts, 0);
|
|
4794
|
-
rb_ary_push(members, rb_str_new2("stts"));
|
|
4795
|
-
}
|
|
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);
|
|
4796
4628
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
members = rb_ary_new();
|
|
4803
|
-
rb_cNodeSubclass[NODE_GASGN] = rb_cGASGN;
|
|
4804
|
-
rb_iv_set(rb_cGASGN, "__member__", members);
|
|
4805
|
-
rb_iv_set(rb_cGASGN, "__type__", INT2NUM(NODE_GASGN));
|
|
4806
|
-
rb_define_singleton_method(rb_cGASGN, "members", node_s_members, 0);
|
|
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"));
|
|
4807
4634
|
|
|
4808
4635
|
/* Document-method: value
|
|
4809
|
-
*
|
|
4636
|
+
* the value to compare against
|
|
4810
4637
|
*/
|
|
4811
|
-
rb_define_method(
|
|
4638
|
+
rb_define_method(rb_cMATCH, "value", node_value, 0);
|
|
4812
4639
|
rb_ary_push(members, rb_str_new2("value"));
|
|
4813
|
-
|
|
4814
|
-
/* Document-method: vid
|
|
4815
|
-
* the name of the global variable, with a leading '$' character.
|
|
4816
|
-
*/
|
|
4817
|
-
rb_define_method(rb_cGASGN, "vid", node_vid, 0);
|
|
4818
|
-
rb_ary_push(members, rb_str_new2("vid"));
|
|
4819
|
-
rb_define_method(rb_cGASGN, "entry", node_entry, 0);
|
|
4820
|
-
rb_ary_push(members, rb_str_new2("entry"));
|
|
4821
4640
|
}
|
|
4822
4641
|
|
|
4823
|
-
/* Document-class: Node::
|
|
4824
|
-
* 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
|
|
4825
4648
|
*
|
|
4826
|
-
*
|
|
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
|
|
4827
4658
|
*/
|
|
4828
4659
|
{
|
|
4829
|
-
VALUE
|
|
4660
|
+
VALUE rb_cMATCH2 = rb_define_class_under(rb_cNode, "MATCH2", rb_cNode);
|
|
4830
4661
|
members = rb_ary_new();
|
|
4831
|
-
rb_cNodeSubclass[
|
|
4832
|
-
rb_iv_set(
|
|
4833
|
-
rb_iv_set(
|
|
4834
|
-
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);
|
|
4835
4666
|
|
|
4836
4667
|
/* Document-method: value
|
|
4837
|
-
*
|
|
4838
|
-
*
|
|
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
|
|
4839
4671
|
*/
|
|
4840
|
-
rb_define_method(
|
|
4672
|
+
rb_define_method(rb_cMATCH2, "value", node_value, 0);
|
|
4841
4673
|
rb_ary_push(members, rb_str_new2("value"));
|
|
4842
4674
|
|
|
4843
|
-
/* Document-method:
|
|
4844
|
-
* the
|
|
4675
|
+
/* Document-method: recv
|
|
4676
|
+
* the regular expression on the left hand side of the match
|
|
4677
|
+
* operator
|
|
4845
4678
|
*/
|
|
4846
|
-
rb_define_method(
|
|
4847
|
-
rb_ary_push(members, rb_str_new2("
|
|
4679
|
+
rb_define_method(rb_cMATCH2, "recv", node_recv, 0);
|
|
4680
|
+
rb_ary_push(members, rb_str_new2("recv"));
|
|
4848
4681
|
}
|
|
4849
4682
|
|
|
4850
|
-
/* Document-class: Node::
|
|
4851
|
-
* Represents
|
|
4852
|
-
* recv
|
|
4853
|
-
*
|
|
4854
|
-
*
|
|
4683
|
+
/* Document-class: Node::MATCH3
|
|
4684
|
+
* Represents a regular expression match of the form:
|
|
4685
|
+
* recv =~ /value/
|
|
4686
|
+
*
|
|
4687
|
+
* where recv is an expression that returns an object and value is a
|
|
4688
|
+
* regular expression literal.
|
|
4855
4689
|
*/
|
|
4856
4690
|
{
|
|
4857
|
-
VALUE
|
|
4691
|
+
VALUE rb_cMATCH3 = rb_define_class_under(rb_cNode, "MATCH3", rb_cNode);
|
|
4858
4692
|
members = rb_ary_new();
|
|
4859
|
-
rb_cNodeSubclass[
|
|
4860
|
-
rb_iv_set(
|
|
4861
|
-
rb_iv_set(
|
|
4862
|
-
rb_define_singleton_method(
|
|
4863
|
-
|
|
4864
|
-
/* Document-method: args
|
|
4865
|
-
* the arguments to the method
|
|
4866
|
-
*/
|
|
4867
|
-
rb_define_method(rb_cATTRASGN, "args", node_args, 0);
|
|
4868
|
-
rb_ary_push(members, rb_str_new2("args"));
|
|
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);
|
|
4869
4697
|
|
|
4870
|
-
/* Document-method:
|
|
4871
|
-
* the
|
|
4698
|
+
/* Document-method: value
|
|
4699
|
+
* the right hand side of the match
|
|
4872
4700
|
*/
|
|
4873
|
-
rb_define_method(
|
|
4874
|
-
rb_ary_push(members, rb_str_new2("
|
|
4701
|
+
rb_define_method(rb_cMATCH3, "value", node_value, 0);
|
|
4702
|
+
rb_ary_push(members, rb_str_new2("value"));
|
|
4875
4703
|
|
|
4876
4704
|
/* Document-method: recv
|
|
4877
|
-
* the
|
|
4705
|
+
* the left hand side of the match
|
|
4878
4706
|
*/
|
|
4879
|
-
rb_define_method(
|
|
4707
|
+
rb_define_method(rb_cMATCH3, "recv", node_recv, 0);
|
|
4880
4708
|
rb_ary_push(members, rb_str_new2("recv"));
|
|
4881
4709
|
}
|
|
4882
4710
|
|
|
4883
|
-
/* Document-class: Node::
|
|
4884
|
-
*
|
|
4885
|
-
* undef :mid
|
|
4711
|
+
/* Document-class: Node::MEMO
|
|
4712
|
+
* A node used for temporary storage.
|
|
4886
4713
|
*
|
|
4887
|
-
*
|
|
4888
|
-
*
|
|
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.
|
|
4889
4724
|
*/
|
|
4890
4725
|
{
|
|
4891
|
-
VALUE
|
|
4726
|
+
VALUE rb_cMEMO = rb_define_class_under(rb_cNode, "MEMO", rb_cNode);
|
|
4892
4727
|
members = rb_ary_new();
|
|
4893
|
-
rb_cNodeSubclass[
|
|
4894
|
-
rb_iv_set(
|
|
4895
|
-
rb_iv_set(
|
|
4896
|
-
rb_define_singleton_method(
|
|
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
|
+
}
|
|
4897
4733
|
|
|
4898
|
-
|
|
4899
|
-
|
|
4734
|
+
/* Document-class: Node::METHOD
|
|
4735
|
+
* A placeholder for a method entry in a class's method table.
|
|
4736
|
+
*/
|
|
4737
|
+
{
|
|
4738
|
+
VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode);
|
|
4739
|
+
members = rb_ary_new();
|
|
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);
|
|
4744
|
+
|
|
4745
|
+
/* Document-method: body
|
|
4746
|
+
* the body of the method
|
|
4900
4747
|
*/
|
|
4901
|
-
rb_define_method(
|
|
4902
|
-
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"));
|
|
4750
|
+
|
|
4751
|
+
/* Document-method: noex
|
|
4752
|
+
* the method's flags
|
|
4753
|
+
*/
|
|
4754
|
+
rb_define_method(rb_cMETHOD, "noex", node_noex, 0);
|
|
4755
|
+
rb_ary_push(members, rb_str_new2("noex"));
|
|
4903
4756
|
}
|
|
4904
4757
|
|
|
4905
|
-
/* Document-class: Node::
|
|
4906
|
-
* Represents
|
|
4907
|
-
*
|
|
4758
|
+
/* Document-class: Node::MODULE
|
|
4759
|
+
* Represents a module definition, e.g.:
|
|
4760
|
+
* module cpath
|
|
4761
|
+
* body
|
|
4762
|
+
* end
|
|
4763
|
+
*
|
|
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.
|
|
4908
4768
|
*/
|
|
4909
4769
|
{
|
|
4910
|
-
VALUE
|
|
4770
|
+
VALUE rb_cMODULE = rb_define_class_under(rb_cNode, "MODULE", rb_cNode);
|
|
4911
4771
|
members = rb_ary_new();
|
|
4912
|
-
rb_cNodeSubclass[
|
|
4913
|
-
rb_iv_set(
|
|
4914
|
-
rb_iv_set(
|
|
4915
|
-
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);
|
|
4916
4776
|
|
|
4917
|
-
/* Document-method:
|
|
4918
|
-
* the
|
|
4777
|
+
/* Document-method: cpath
|
|
4778
|
+
* the name of the module to define
|
|
4919
4779
|
*/
|
|
4920
|
-
rb_define_method(
|
|
4921
|
-
rb_ary_push(members, rb_str_new2("
|
|
4780
|
+
rb_define_method(rb_cMODULE, "cpath", node_cpath, 0);
|
|
4781
|
+
rb_ary_push(members, rb_str_new2("cpath"));
|
|
4782
|
+
|
|
4783
|
+
/* Document-method: body
|
|
4784
|
+
* the body of the module definition
|
|
4785
|
+
*/
|
|
4786
|
+
rb_define_method(rb_cMODULE, "body", node_body, 0);
|
|
4787
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
4922
4788
|
}
|
|
4923
4789
|
|
|
4924
4790
|
/* Document-class: Node::NEWLINE
|
|
@@ -4940,6 +4806,52 @@ void define_node_subclass_methods()
|
|
|
4940
4806
|
rb_ary_push(members, rb_str_new2("next"));
|
|
4941
4807
|
}
|
|
4942
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
|
+
|
|
4943
4855
|
/* Document-class: Node::NTH_REF
|
|
4944
4856
|
* Represents the nth match data item, e.g. $1, $2, etc.
|
|
4945
4857
|
*/
|
|
@@ -4964,310 +4876,367 @@ void define_node_subclass_methods()
|
|
|
4964
4876
|
rb_ary_push(members, rb_str_new2("cnt"));
|
|
4965
4877
|
}
|
|
4966
4878
|
|
|
4967
|
-
/* Document-class: Node::
|
|
4968
|
-
* Represents
|
|
4969
|
-
*
|
|
4970
|
-
* Creates a range which does not exclude the range end.
|
|
4971
|
-
*/
|
|
4972
|
-
{
|
|
4973
|
-
VALUE rb_cDOT2 = rb_define_class_under(rb_cNode, "DOT2", rb_cNode);
|
|
4974
|
-
members = rb_ary_new();
|
|
4975
|
-
rb_cNodeSubclass[NODE_DOT2] = rb_cDOT2;
|
|
4976
|
-
rb_iv_set(rb_cDOT2, "__member__", members);
|
|
4977
|
-
rb_iv_set(rb_cDOT2, "__type__", INT2NUM(NODE_DOT2));
|
|
4978
|
-
rb_define_singleton_method(rb_cDOT2, "members", node_s_members, 0);
|
|
4979
|
-
|
|
4980
|
-
/* Document-method: beg
|
|
4981
|
-
* the beginning of the range
|
|
4982
|
-
*/
|
|
4983
|
-
rb_define_method(rb_cDOT2, "beg", node_beg, 0);
|
|
4984
|
-
rb_ary_push(members, rb_str_new2("beg"));
|
|
4985
|
-
|
|
4986
|
-
/* Document-method: end
|
|
4987
|
-
* the end of the range
|
|
4988
|
-
*/
|
|
4989
|
-
rb_define_method(rb_cDOT2, "end", node_end, 0);
|
|
4990
|
-
rb_ary_push(members, rb_str_new2("end"));
|
|
4991
|
-
rb_define_method(rb_cDOT2, "state", node_state, 0);
|
|
4992
|
-
rb_ary_push(members, rb_str_new2("state"));
|
|
4993
|
-
}
|
|
4994
|
-
|
|
4995
|
-
/* Document-class: Node::GVAR
|
|
4996
|
-
* Represents global variable retrieval.
|
|
4879
|
+
/* Document-class: Node::OPT_N
|
|
4880
|
+
* Represents the top-level loop when the -n or -p options are used
|
|
4881
|
+
* with the interpreter.
|
|
4997
4882
|
*/
|
|
4998
4883
|
{
|
|
4999
|
-
VALUE
|
|
4884
|
+
VALUE rb_cOPT_N = rb_define_class_under(rb_cNode, "OPT_N", rb_cNode);
|
|
5000
4885
|
members = rb_ary_new();
|
|
5001
|
-
rb_cNodeSubclass[
|
|
5002
|
-
rb_iv_set(
|
|
5003
|
-
rb_iv_set(
|
|
5004
|
-
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);
|
|
5005
4890
|
|
|
5006
|
-
/* Document-method:
|
|
5007
|
-
* the
|
|
4891
|
+
/* Document-method: body
|
|
4892
|
+
* the body of the loop
|
|
5008
4893
|
*/
|
|
5009
|
-
rb_define_method(
|
|
5010
|
-
rb_ary_push(members, rb_str_new2("
|
|
5011
|
-
rb_define_method(rb_cGVAR, "entry", node_entry, 0);
|
|
5012
|
-
rb_ary_push(members, rb_str_new2("entry"));
|
|
4894
|
+
rb_define_method(rb_cOPT_N, "body", node_body, 0);
|
|
4895
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5013
4896
|
}
|
|
5014
4897
|
|
|
5015
|
-
/* Document-class: Node::
|
|
5016
|
-
* Represents
|
|
5017
|
-
*
|
|
5018
|
-
*
|
|
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.
|
|
5019
4920
|
*/
|
|
5020
4921
|
{
|
|
5021
|
-
VALUE
|
|
4922
|
+
VALUE rb_cOP_ASGN1 = rb_define_class_under(rb_cNode, "OP_ASGN1", rb_cNode);
|
|
5022
4923
|
members = rb_ary_new();
|
|
5023
|
-
rb_cNodeSubclass[
|
|
5024
|
-
rb_iv_set(
|
|
5025
|
-
rb_iv_set(
|
|
5026
|
-
rb_define_singleton_method(
|
|
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);
|
|
5027
4928
|
|
|
5028
|
-
/* Document-method:
|
|
5029
|
-
* the
|
|
4929
|
+
/* Document-method: args
|
|
4930
|
+
* the arguments to the assigment
|
|
5030
4931
|
*/
|
|
5031
|
-
rb_define_method(
|
|
5032
|
-
rb_ary_push(members, rb_str_new2("
|
|
4932
|
+
rb_define_method(rb_cOP_ASGN1, "args", node_args, 0);
|
|
4933
|
+
rb_ary_push(members, rb_str_new2("args"));
|
|
5033
4934
|
|
|
5034
|
-
/* Document-method:
|
|
5035
|
-
* the
|
|
4935
|
+
/* Document-method: mid
|
|
4936
|
+
* 0, 1, or the name a method to call to calculate the value of the
|
|
4937
|
+
* rhs
|
|
5036
4938
|
*/
|
|
5037
|
-
rb_define_method(
|
|
5038
|
-
rb_ary_push(members, rb_str_new2("
|
|
5039
|
-
|
|
5040
|
-
|
|
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"));
|
|
5041
4947
|
}
|
|
5042
4948
|
|
|
5043
|
-
/* Document-class: Node::
|
|
5044
|
-
* 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.
|
|
5045
4960
|
*/
|
|
5046
4961
|
{
|
|
5047
|
-
VALUE
|
|
4962
|
+
VALUE rb_cOP_ASGN2 = rb_define_class_under(rb_cNode, "OP_ASGN2", rb_cNode);
|
|
5048
4963
|
members = rb_ary_new();
|
|
5049
|
-
rb_cNodeSubclass[
|
|
5050
|
-
rb_iv_set(
|
|
5051
|
-
rb_iv_set(
|
|
5052
|
-
rb_define_singleton_method(
|
|
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);
|
|
5053
4968
|
|
|
5054
4969
|
/* Document-method: value
|
|
5055
|
-
*
|
|
5056
|
-
* variable
|
|
4970
|
+
* the value to assign to the attribute
|
|
5057
4971
|
*/
|
|
5058
|
-
rb_define_method(
|
|
4972
|
+
rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
|
|
5059
4973
|
rb_ary_push(members, rb_str_new2("value"));
|
|
5060
4974
|
|
|
5061
|
-
/* Document-method:
|
|
5062
|
-
*
|
|
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
|
|
5063
4978
|
*/
|
|
5064
|
-
rb_define_method(
|
|
5065
|
-
rb_ary_push(members, rb_str_new2("
|
|
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"));
|
|
5066
4987
|
}
|
|
5067
4988
|
|
|
5068
|
-
/* Document-class: Node::
|
|
5069
|
-
*
|
|
5070
|
-
*
|
|
5071
|
-
*
|
|
5072
|
-
* variable lookup.
|
|
5073
|
-
*
|
|
5074
|
-
* It should never be evaluated as an expression.
|
|
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.
|
|
5075
4993
|
*/
|
|
5076
4994
|
{
|
|
5077
|
-
VALUE
|
|
4995
|
+
VALUE rb_cOP_ASGN2_ARG = rb_define_class_under(rb_cNode, "OP_ASGN2_ARG", rb_cNode);
|
|
5078
4996
|
members = rb_ary_new();
|
|
5079
|
-
rb_cNodeSubclass[
|
|
5080
|
-
rb_iv_set(
|
|
5081
|
-
rb_iv_set(
|
|
5082
|
-
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);
|
|
5083
5001
|
|
|
5084
|
-
/* Document-method:
|
|
5085
|
-
*
|
|
5002
|
+
/* Document-method: vid
|
|
5003
|
+
* The method to call on the receiver to retrieve the attribute
|
|
5086
5004
|
*/
|
|
5087
|
-
rb_define_method(
|
|
5088
|
-
rb_ary_push(members, rb_str_new2("
|
|
5005
|
+
rb_define_method(rb_cOP_ASGN2_ARG, "vid", node_vid, 0);
|
|
5006
|
+
rb_ary_push(members, rb_str_new2("vid"));
|
|
5089
5007
|
|
|
5090
|
-
/* Document-method:
|
|
5091
|
-
* the
|
|
5008
|
+
/* Document-method: aid
|
|
5009
|
+
* The method to call on the receiver to set the attribute
|
|
5092
5010
|
*/
|
|
5093
|
-
rb_define_method(
|
|
5094
|
-
rb_ary_push(members, rb_str_new2("
|
|
5011
|
+
rb_define_method(rb_cOP_ASGN2_ARG, "aid", node_aid, 0);
|
|
5012
|
+
rb_ary_push(members, rb_str_new2("aid"));
|
|
5095
5013
|
|
|
5096
|
-
/* Document-method:
|
|
5097
|
-
*
|
|
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".
|
|
5098
5018
|
*/
|
|
5099
|
-
rb_define_method(
|
|
5100
|
-
rb_ary_push(members, rb_str_new2("
|
|
5019
|
+
rb_define_method(rb_cOP_ASGN2_ARG, "mid", node_mid, 0);
|
|
5020
|
+
rb_ary_push(members, rb_str_new2("mid"));
|
|
5101
5021
|
}
|
|
5102
5022
|
|
|
5103
|
-
/* Document-class: Node::
|
|
5104
|
-
* Represents
|
|
5105
|
-
*
|
|
5106
|
-
*
|
|
5107
|
-
*
|
|
5108
|
-
*
|
|
5109
|
-
*
|
|
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.
|
|
5110
5030
|
*/
|
|
5111
5031
|
{
|
|
5112
|
-
VALUE
|
|
5032
|
+
VALUE rb_cOP_ASGN_AND = rb_define_class_under(rb_cNode, "OP_ASGN_AND", rb_cNode);
|
|
5113
5033
|
members = rb_ary_new();
|
|
5114
|
-
rb_cNodeSubclass[
|
|
5115
|
-
rb_iv_set(
|
|
5116
|
-
rb_iv_set(
|
|
5117
|
-
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);
|
|
5118
5038
|
|
|
5119
|
-
/* Document-method:
|
|
5120
|
-
* the
|
|
5039
|
+
/* Document-method: value
|
|
5040
|
+
* an expression representing the assignment that should be
|
|
5041
|
+
* performed if the left hand side is true
|
|
5121
5042
|
*/
|
|
5122
|
-
rb_define_method(
|
|
5123
|
-
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"));
|
|
5045
|
+
|
|
5046
|
+
/* Document-method: recv
|
|
5047
|
+
* an expression representing the left hand side of the assignment
|
|
5048
|
+
*/
|
|
5049
|
+
rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0);
|
|
5050
|
+
rb_ary_push(members, rb_str_new2("recv"));
|
|
5124
5051
|
}
|
|
5125
5052
|
|
|
5126
|
-
/* Document-class: Node::
|
|
5127
|
-
* Represents
|
|
5128
|
-
*
|
|
5129
|
-
*
|
|
5130
|
-
*
|
|
5131
|
-
*
|
|
5132
|
-
*
|
|
5133
|
-
*
|
|
5134
|
-
* The result of the expression is the last expression evaluated in the
|
|
5135
|
-
* body.
|
|
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).
|
|
5136
5060
|
*/
|
|
5137
5061
|
{
|
|
5138
|
-
VALUE
|
|
5062
|
+
VALUE rb_cOP_ASGN_OR = rb_define_class_under(rb_cNode, "OP_ASGN_OR", rb_cNode);
|
|
5139
5063
|
members = rb_ary_new();
|
|
5140
|
-
rb_cNodeSubclass[
|
|
5141
|
-
rb_iv_set(
|
|
5142
|
-
rb_iv_set(
|
|
5143
|
-
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);
|
|
5144
5068
|
|
|
5145
|
-
/* Document-method:
|
|
5146
|
-
*
|
|
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.
|
|
5147
5073
|
*/
|
|
5148
|
-
rb_define_method(
|
|
5149
|
-
rb_ary_push(members, rb_str_new2("
|
|
5074
|
+
rb_define_method(rb_cOP_ASGN_OR, "aid", node_aid, 0);
|
|
5075
|
+
rb_ary_push(members, rb_str_new2("aid"));
|
|
5150
5076
|
|
|
5151
|
-
/* Document-method:
|
|
5152
|
-
* the
|
|
5077
|
+
/* Document-method: value
|
|
5078
|
+
* the right hand side of the assignment
|
|
5153
5079
|
*/
|
|
5154
|
-
rb_define_method(
|
|
5155
|
-
rb_ary_push(members, rb_str_new2("
|
|
5080
|
+
rb_define_method(rb_cOP_ASGN_OR, "value", node_value, 0);
|
|
5081
|
+
rb_ary_push(members, rb_str_new2("value"));
|
|
5082
|
+
|
|
5083
|
+
/* Document-method: recv
|
|
5084
|
+
* the receiver of the assignment
|
|
5085
|
+
*/
|
|
5086
|
+
rb_define_method(rb_cOP_ASGN_OR, "recv", node_recv, 0);
|
|
5087
|
+
rb_ary_push(members, rb_str_new2("recv"));
|
|
5156
5088
|
}
|
|
5157
5089
|
|
|
5158
|
-
/* Document-class: Node::
|
|
5159
|
-
* Represents a
|
|
5160
|
-
*
|
|
5161
|
-
*
|
|
5162
|
-
*
|
|
5163
|
-
*
|
|
5164
|
-
* This is equivalent to:
|
|
5165
|
-
* iter.each do |*args|
|
|
5166
|
-
* assign args to var
|
|
5167
|
-
* body
|
|
5168
|
-
* end
|
|
5169
|
-
*
|
|
5170
|
-
* Except that a new block is not created.
|
|
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.
|
|
5171
5096
|
*/
|
|
5172
5097
|
{
|
|
5173
|
-
VALUE
|
|
5098
|
+
VALUE rb_cOR = rb_define_class_under(rb_cNode, "OR", rb_cNode);
|
|
5174
5099
|
members = rb_ary_new();
|
|
5175
|
-
rb_cNodeSubclass[
|
|
5176
|
-
rb_iv_set(
|
|
5177
|
-
rb_iv_set(
|
|
5178
|
-
rb_define_singleton_method(
|
|
5179
|
-
|
|
5180
|
-
/* Document-method: body
|
|
5181
|
-
* the body of the loop
|
|
5182
|
-
*/
|
|
5183
|
-
rb_define_method(rb_cFOR, "body", node_body, 0);
|
|
5184
|
-
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);
|
|
5185
5104
|
|
|
5186
|
-
/* Document-method:
|
|
5187
|
-
* the
|
|
5105
|
+
/* Document-method: first
|
|
5106
|
+
* the expression on the left hand side
|
|
5188
5107
|
*/
|
|
5189
|
-
rb_define_method(
|
|
5190
|
-
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"));
|
|
5191
5110
|
|
|
5192
|
-
/* Document-method:
|
|
5193
|
-
*
|
|
5194
|
-
* to a variable, which may or may not be local. May also be a
|
|
5195
|
-
* multiple assignment.
|
|
5111
|
+
/* Document-method: second
|
|
5112
|
+
* the expression on the right hand side
|
|
5196
5113
|
*/
|
|
5197
|
-
rb_define_method(
|
|
5198
|
-
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"));
|
|
5199
5116
|
}
|
|
5200
5117
|
|
|
5201
|
-
/* Document-class: Node::
|
|
5202
|
-
* Represents
|
|
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.
|
|
5203
5124
|
*/
|
|
5204
5125
|
{
|
|
5205
|
-
VALUE
|
|
5126
|
+
VALUE rb_cPOSTEXE = rb_define_class_under(rb_cNode, "POSTEXE", rb_cNode);
|
|
5206
5127
|
members = rb_ary_new();
|
|
5207
|
-
rb_cNodeSubclass[
|
|
5208
|
-
rb_iv_set(
|
|
5209
|
-
rb_iv_set(
|
|
5210
|
-
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
|
+
}
|
|
5211
5133
|
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
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);
|
|
5217
5145
|
}
|
|
5218
5146
|
|
|
5219
|
-
/* Document-class: Node::
|
|
5220
|
-
* Represents a
|
|
5221
|
-
*
|
|
5222
|
-
*
|
|
5223
|
-
*
|
|
5224
|
-
*
|
|
5225
|
-
*
|
|
5147
|
+
/* Document-class: Node::RESBODY
|
|
5148
|
+
* Represents the rescue portion of a rescue expression (see RESCUE for
|
|
5149
|
+
* examples).
|
|
5150
|
+
*
|
|
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.
|
|
5153
|
+
*
|
|
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).
|
|
5226
5158
|
*/
|
|
5227
5159
|
{
|
|
5228
|
-
VALUE
|
|
5160
|
+
VALUE rb_cRESBODY = rb_define_class_under(rb_cNode, "RESBODY", rb_cNode);
|
|
5229
5161
|
members = rb_ary_new();
|
|
5230
|
-
rb_cNodeSubclass[
|
|
5231
|
-
rb_iv_set(
|
|
5232
|
-
rb_iv_set(
|
|
5233
|
-
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);
|
|
5234
5166
|
|
|
5235
|
-
/* Document-method:
|
|
5236
|
-
*
|
|
5167
|
+
/* Document-method: head
|
|
5168
|
+
* the next rescue
|
|
5237
5169
|
*/
|
|
5238
|
-
rb_define_method(
|
|
5239
|
-
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"));
|
|
5240
5172
|
|
|
5241
|
-
/* Document-method:
|
|
5242
|
-
*
|
|
5173
|
+
/* Document-method: args
|
|
5174
|
+
* the expression type to match against
|
|
5243
5175
|
*/
|
|
5244
|
-
rb_define_method(
|
|
5245
|
-
rb_ary_push(members, rb_str_new2("
|
|
5176
|
+
rb_define_method(rb_cRESBODY, "args", node_args, 0);
|
|
5177
|
+
rb_ary_push(members, rb_str_new2("args"));
|
|
5178
|
+
|
|
5179
|
+
/* Document-method: body
|
|
5180
|
+
* the expresion to evaluate if the exception type matches
|
|
5181
|
+
*/
|
|
5182
|
+
rb_define_method(rb_cRESBODY, "body", node_body, 0);
|
|
5183
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5246
5184
|
}
|
|
5247
5185
|
|
|
5248
|
-
/* Document-class: Node::
|
|
5249
|
-
* Represents
|
|
5250
|
-
*
|
|
5251
|
-
*
|
|
5252
|
-
*
|
|
5253
|
-
*
|
|
5254
|
-
*
|
|
5255
|
-
*
|
|
5256
|
-
*
|
|
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
|
|
5195
|
+
* end
|
|
5196
|
+
*
|
|
5197
|
+
* or the form using the else keyword:
|
|
5198
|
+
* begin
|
|
5199
|
+
* head
|
|
5200
|
+
* rescue exception
|
|
5201
|
+
* expr
|
|
5202
|
+
* else
|
|
5203
|
+
* else_expr
|
|
5204
|
+
* end
|
|
5205
|
+
*
|
|
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.
|
|
5257
5214
|
*/
|
|
5258
5215
|
{
|
|
5259
|
-
VALUE
|
|
5216
|
+
VALUE rb_cRESCUE = rb_define_class_under(rb_cNode, "RESCUE", rb_cNode);
|
|
5260
5217
|
members = rb_ary_new();
|
|
5261
|
-
rb_cNodeSubclass[
|
|
5262
|
-
rb_iv_set(
|
|
5263
|
-
rb_iv_set(
|
|
5264
|
-
rb_define_singleton_method(
|
|
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);
|
|
5265
5222
|
|
|
5266
5223
|
/* Document-method: head
|
|
5267
|
-
*
|
|
5224
|
+
* the body of the block to evaluate
|
|
5268
5225
|
*/
|
|
5269
|
-
rb_define_method(
|
|
5226
|
+
rb_define_method(rb_cRESCUE, "head", node_head, 0);
|
|
5270
5227
|
rb_ary_push(members, rb_str_new2("head"));
|
|
5228
|
+
|
|
5229
|
+
/* Document-method: else
|
|
5230
|
+
* the expression to be evaluated if no exception is raised
|
|
5231
|
+
*/
|
|
5232
|
+
rb_define_method(rb_cRESCUE, "else", node_else, 0);
|
|
5233
|
+
rb_ary_push(members, rb_str_new2("else"));
|
|
5234
|
+
|
|
5235
|
+
/* Document-method: resq
|
|
5236
|
+
* the expression to be evaluated if an exception is raised
|
|
5237
|
+
*/
|
|
5238
|
+
rb_define_method(rb_cRESCUE, "resq", node_resq, 0);
|
|
5239
|
+
rb_ary_push(members, rb_str_new2("resq"));
|
|
5271
5240
|
}
|
|
5272
5241
|
|
|
5273
5242
|
/* Document-class: Node::RETRY
|
|
@@ -5282,14 +5251,30 @@ void define_node_subclass_methods()
|
|
|
5282
5251
|
rb_define_singleton_method(rb_cRETRY, "members", node_s_members, 0);
|
|
5283
5252
|
}
|
|
5284
5253
|
|
|
5285
|
-
/* Document-class: Node::
|
|
5286
|
-
* Represents
|
|
5287
|
-
*
|
|
5288
|
-
*
|
|
5289
|
-
*
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5254
|
+
/* Document-class: Node::RETURN
|
|
5255
|
+
* Represents the 'return' keyword. Evaluation of this node results in
|
|
5256
|
+
* a return from the current method. If no argument is supplied,
|
|
5257
|
+
* returns nil, otherwise returns the result of the supplied
|
|
5258
|
+
* expression.
|
|
5259
|
+
*/
|
|
5260
|
+
{
|
|
5261
|
+
VALUE rb_cRETURN = rb_define_class_under(rb_cNode, "RETURN", rb_cNode);
|
|
5262
|
+
members = rb_ary_new();
|
|
5263
|
+
rb_cNodeSubclass[NODE_RETURN] = rb_cRETURN;
|
|
5264
|
+
rb_iv_set(rb_cRETURN, "__member__", members);
|
|
5265
|
+
rb_iv_set(rb_cRETURN, "__type__", INT2NUM(NODE_RETURN));
|
|
5266
|
+
rb_define_singleton_method(rb_cRETURN, "members", node_s_members, 0);
|
|
5267
|
+
|
|
5268
|
+
/* Document-method: stts
|
|
5269
|
+
* an expression representing the value to return
|
|
5270
|
+
*/
|
|
5271
|
+
rb_define_method(rb_cRETURN, "stts", node_stts, 0);
|
|
5272
|
+
rb_ary_push(members, rb_str_new2("stts"));
|
|
5273
|
+
}
|
|
5274
|
+
|
|
5275
|
+
/* Document-class: Node::SCLASS
|
|
5276
|
+
* Represents the body of a singleton class definition, e.g.:
|
|
5277
|
+
* class << recv
|
|
5293
5278
|
* body
|
|
5294
5279
|
* end
|
|
5295
5280
|
*
|
|
@@ -5299,392 +5284,392 @@ void define_node_subclass_methods()
|
|
|
5299
5284
|
* body.
|
|
5300
5285
|
*/
|
|
5301
5286
|
{
|
|
5302
|
-
VALUE
|
|
5287
|
+
VALUE rb_cSCLASS = rb_define_class_under(rb_cNode, "SCLASS", rb_cNode);
|
|
5303
5288
|
members = rb_ary_new();
|
|
5304
|
-
rb_cNodeSubclass[
|
|
5305
|
-
rb_iv_set(
|
|
5306
|
-
rb_iv_set(
|
|
5307
|
-
rb_define_singleton_method(
|
|
5308
|
-
|
|
5309
|
-
/* Document-method: cpath
|
|
5310
|
-
* the name of the class to define
|
|
5311
|
-
*/
|
|
5312
|
-
rb_define_method(rb_cCLASS, "cpath", node_cpath, 0);
|
|
5313
|
-
rb_ary_push(members, rb_str_new2("cpath"));
|
|
5289
|
+
rb_cNodeSubclass[NODE_SCLASS] = rb_cSCLASS;
|
|
5290
|
+
rb_iv_set(rb_cSCLASS, "__member__", members);
|
|
5291
|
+
rb_iv_set(rb_cSCLASS, "__type__", INT2NUM(NODE_SCLASS));
|
|
5292
|
+
rb_define_singleton_method(rb_cSCLASS, "members", node_s_members, 0);
|
|
5314
5293
|
|
|
5315
5294
|
/* Document-method: body
|
|
5316
5295
|
* the body of the class definition
|
|
5317
5296
|
*/
|
|
5318
|
-
rb_define_method(
|
|
5297
|
+
rb_define_method(rb_cSCLASS, "body", node_body, 0);
|
|
5319
5298
|
rb_ary_push(members, rb_str_new2("body"));
|
|
5320
5299
|
|
|
5321
|
-
/* Document-method:
|
|
5322
|
-
*
|
|
5323
|
-
* base class specified
|
|
5300
|
+
/* Document-method: recv
|
|
5301
|
+
* the object whose singleton class is to be modified
|
|
5324
5302
|
*/
|
|
5325
|
-
rb_define_method(
|
|
5326
|
-
rb_ary_push(members, rb_str_new2("
|
|
5303
|
+
rb_define_method(rb_cSCLASS, "recv", node_recv, 0);
|
|
5304
|
+
rb_ary_push(members, rb_str_new2("recv"));
|
|
5327
5305
|
}
|
|
5328
5306
|
|
|
5329
|
-
/* Document-class: Node::
|
|
5330
|
-
* Represents
|
|
5331
|
-
*
|
|
5332
|
-
*
|
|
5333
|
-
*
|
|
5334
|
-
*
|
|
5335
|
-
*
|
|
5336
|
-
*
|
|
5337
|
-
*
|
|
5338
|
-
*
|
|
5339
|
-
*
|
|
5307
|
+
/* Document-class: Node::SCOPE
|
|
5308
|
+
* Represents a lexical scope.
|
|
5309
|
+
*
|
|
5310
|
+
* A new scope is created when a method is invoked. The scope node
|
|
5311
|
+
* holds information about local variables and arguments to the method.
|
|
5312
|
+
* The first two variables in the local variable table are the implicit
|
|
5313
|
+
* variables $_ and $~.
|
|
5314
|
+
*
|
|
5315
|
+
* The next variables listed in the local variable table are the
|
|
5316
|
+
* arguments to the method. More information about the arguments to
|
|
5317
|
+
* the method are stored in the ARGS node, which will either be the
|
|
5318
|
+
* first node in the scope or the first node in the BLOCK held by the
|
|
5319
|
+
* scope.
|
|
5340
5320
|
*/
|
|
5341
5321
|
{
|
|
5342
|
-
VALUE
|
|
5322
|
+
VALUE rb_cSCOPE = rb_define_class_under(rb_cNode, "SCOPE", rb_cNode);
|
|
5343
5323
|
members = rb_ary_new();
|
|
5344
|
-
rb_cNodeSubclass[
|
|
5345
|
-
rb_iv_set(
|
|
5346
|
-
rb_iv_set(
|
|
5347
|
-
rb_define_singleton_method(
|
|
5324
|
+
rb_cNodeSubclass[NODE_SCOPE] = rb_cSCOPE;
|
|
5325
|
+
rb_iv_set(rb_cSCOPE, "__member__", members);
|
|
5326
|
+
rb_iv_set(rb_cSCOPE, "__type__", INT2NUM(NODE_SCOPE));
|
|
5327
|
+
rb_define_singleton_method(rb_cSCOPE, "members", node_s_members, 0);
|
|
5328
|
+
|
|
5329
|
+
/* Document-method: tbl
|
|
5330
|
+
* the names of the local variables* next the first expression in
|
|
5331
|
+
* the scope
|
|
5332
|
+
*/
|
|
5333
|
+
rb_define_method(rb_cSCOPE, "tbl", node_tbl, 0);
|
|
5334
|
+
rb_ary_push(members, rb_str_new2("tbl"));
|
|
5348
5335
|
|
|
5349
|
-
/* Document-method:
|
|
5350
|
-
*
|
|
5336
|
+
/* Document-method: rval
|
|
5337
|
+
* holds information about which class(es) to search for constants
|
|
5338
|
+
* in this scope
|
|
5351
5339
|
*/
|
|
5352
|
-
rb_define_method(
|
|
5353
|
-
rb_ary_push(members, rb_str_new2("
|
|
5340
|
+
rb_define_method(rb_cSCOPE, "rval", node_rval, 0);
|
|
5341
|
+
rb_ary_push(members, rb_str_new2("rval"));
|
|
5354
5342
|
|
|
5355
|
-
/* Document-method:
|
|
5356
|
-
* the
|
|
5343
|
+
/* Document-method: next
|
|
5344
|
+
* the body of the lexical scope
|
|
5357
5345
|
*/
|
|
5358
|
-
rb_define_method(
|
|
5359
|
-
rb_ary_push(members, rb_str_new2("
|
|
5346
|
+
rb_define_method(rb_cSCOPE, "next", node_next, 0);
|
|
5347
|
+
rb_ary_push(members, rb_str_new2("next"));
|
|
5360
5348
|
}
|
|
5361
5349
|
|
|
5362
|
-
/* Document-class: Node::
|
|
5363
|
-
* Represents the keyword '
|
|
5350
|
+
/* Document-class: Node::SELF
|
|
5351
|
+
* Represents the keyword 'self'.
|
|
5364
5352
|
*/
|
|
5365
5353
|
{
|
|
5366
|
-
VALUE
|
|
5354
|
+
VALUE rb_cSELF = rb_define_class_under(rb_cNode, "SELF", rb_cNode);
|
|
5367
5355
|
members = rb_ary_new();
|
|
5368
|
-
rb_cNodeSubclass[
|
|
5369
|
-
rb_iv_set(
|
|
5370
|
-
rb_iv_set(
|
|
5371
|
-
rb_define_singleton_method(
|
|
5356
|
+
rb_cNodeSubclass[NODE_SELF] = rb_cSELF;
|
|
5357
|
+
rb_iv_set(rb_cSELF, "__member__", members);
|
|
5358
|
+
rb_iv_set(rb_cSELF, "__type__", INT2NUM(NODE_SELF));
|
|
5359
|
+
rb_define_singleton_method(rb_cSELF, "members", node_s_members, 0);
|
|
5372
5360
|
}
|
|
5373
5361
|
|
|
5374
|
-
/* Document-class: Node::
|
|
5375
|
-
*
|
|
5376
|
-
*
|
|
5377
|
-
*
|
|
5378
|
-
*
|
|
5362
|
+
/* Document-class: Node::SPLAT
|
|
5363
|
+
* Represents the splat (*) operation as an rvalue, e.g.:
|
|
5364
|
+
* *head
|
|
5365
|
+
* If the argument is an array, returns self.
|
|
5366
|
+
* If the argument is nil, returns [nil].
|
|
5367
|
+
* If the argument is any other value, returns the result of calling #to_a on the
|
|
5368
|
+
* argument.
|
|
5379
5369
|
*/
|
|
5380
5370
|
{
|
|
5381
|
-
VALUE
|
|
5371
|
+
VALUE rb_cSPLAT = rb_define_class_under(rb_cNode, "SPLAT", rb_cNode);
|
|
5382
5372
|
members = rb_ary_new();
|
|
5383
|
-
rb_cNodeSubclass[
|
|
5384
|
-
rb_iv_set(
|
|
5385
|
-
rb_iv_set(
|
|
5386
|
-
rb_define_singleton_method(
|
|
5373
|
+
rb_cNodeSubclass[NODE_SPLAT] = rb_cSPLAT;
|
|
5374
|
+
rb_iv_set(rb_cSPLAT, "__member__", members);
|
|
5375
|
+
rb_iv_set(rb_cSPLAT, "__type__", INT2NUM(NODE_SPLAT));
|
|
5376
|
+
rb_define_singleton_method(rb_cSPLAT, "members", node_s_members, 0);
|
|
5387
5377
|
|
|
5388
|
-
/* Document-method:
|
|
5389
|
-
* the
|
|
5378
|
+
/* Document-method: head
|
|
5379
|
+
* the argument to splat.
|
|
5390
5380
|
*/
|
|
5391
|
-
rb_define_method(
|
|
5392
|
-
rb_ary_push(members, rb_str_new2("
|
|
5381
|
+
rb_define_method(rb_cSPLAT, "head", node_head, 0);
|
|
5382
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5393
5383
|
}
|
|
5394
5384
|
|
|
5395
|
-
/* Document-class: Node::
|
|
5396
|
-
* Represents
|
|
5385
|
+
/* Document-class: Node::STR
|
|
5386
|
+
* Represents a string object. Duplicates the string stored in the
|
|
5387
|
+
* node.
|
|
5397
5388
|
*/
|
|
5398
5389
|
{
|
|
5399
|
-
VALUE
|
|
5390
|
+
VALUE rb_cSTR = rb_define_class_under(rb_cNode, "STR", rb_cNode);
|
|
5400
5391
|
members = rb_ary_new();
|
|
5401
|
-
rb_cNodeSubclass[
|
|
5402
|
-
rb_iv_set(
|
|
5403
|
-
rb_iv_set(
|
|
5404
|
-
rb_define_singleton_method(
|
|
5392
|
+
rb_cNodeSubclass[NODE_STR] = rb_cSTR;
|
|
5393
|
+
rb_iv_set(rb_cSTR, "__member__", members);
|
|
5394
|
+
rb_iv_set(rb_cSTR, "__type__", INT2NUM(NODE_STR));
|
|
5395
|
+
rb_define_singleton_method(rb_cSTR, "members", node_s_members, 0);
|
|
5405
5396
|
|
|
5406
|
-
/* Document-method:
|
|
5407
|
-
* the
|
|
5397
|
+
/* Document-method: lit
|
|
5398
|
+
* the string to be duplicated
|
|
5408
5399
|
*/
|
|
5409
|
-
rb_define_method(
|
|
5410
|
-
rb_ary_push(members, rb_str_new2("
|
|
5411
|
-
rb_define_method(rb_cLVAR, "cnt", node_cnt, 0);
|
|
5412
|
-
rb_ary_push(members, rb_str_new2("cnt"));
|
|
5400
|
+
rb_define_method(rb_cSTR, "lit", node_lit, 0);
|
|
5401
|
+
rb_ary_push(members, rb_str_new2("lit"));
|
|
5413
5402
|
}
|
|
5414
5403
|
|
|
5415
|
-
/* Document-class: Node::
|
|
5416
|
-
* Represents
|
|
5417
|
-
* interpolation, e.g.:
|
|
5418
|
-
* if /#{recv}/ then
|
|
5419
|
-
* ...
|
|
5420
|
-
* end
|
|
5421
|
-
*
|
|
5422
|
-
* which is equivalent to:
|
|
5423
|
-
* if /#{recv}/ =~ $_ then
|
|
5424
|
-
* ...
|
|
5425
|
-
* end
|
|
5426
|
-
*
|
|
5427
|
-
* or a match with a regular expression on the left hand side and an
|
|
5428
|
-
* expression on the right hand side, e.g.:
|
|
5429
|
-
*
|
|
5430
|
-
* /recv/ =~ value
|
|
5404
|
+
/* Document-class: Node::SUPER
|
|
5405
|
+
* Represents the keyword 'super' when used with parens or with arguments.
|
|
5431
5406
|
*/
|
|
5432
5407
|
{
|
|
5433
|
-
VALUE
|
|
5408
|
+
VALUE rb_cSUPER = rb_define_class_under(rb_cNode, "SUPER", rb_cNode);
|
|
5434
5409
|
members = rb_ary_new();
|
|
5435
|
-
rb_cNodeSubclass[
|
|
5436
|
-
rb_iv_set(
|
|
5437
|
-
rb_iv_set(
|
|
5438
|
-
rb_define_singleton_method(
|
|
5439
|
-
|
|
5440
|
-
/* Document-method: value
|
|
5441
|
-
* the expression on the right hand side of the match operator, or
|
|
5442
|
-
* an expression returning $_ if there is nothing on the right hand
|
|
5443
|
-
* side
|
|
5444
|
-
*/
|
|
5445
|
-
rb_define_method(rb_cMATCH2, "value", node_value, 0);
|
|
5446
|
-
rb_ary_push(members, rb_str_new2("value"));
|
|
5410
|
+
rb_cNodeSubclass[NODE_SUPER] = rb_cSUPER;
|
|
5411
|
+
rb_iv_set(rb_cSUPER, "__member__", members);
|
|
5412
|
+
rb_iv_set(rb_cSUPER, "__type__", INT2NUM(NODE_SUPER));
|
|
5413
|
+
rb_define_singleton_method(rb_cSUPER, "members", node_s_members, 0);
|
|
5447
5414
|
|
|
5448
|
-
/* Document-method:
|
|
5449
|
-
* the
|
|
5450
|
-
* operator
|
|
5415
|
+
/* Document-method: args
|
|
5416
|
+
* the arguments to be passed to the base class
|
|
5451
5417
|
*/
|
|
5452
|
-
rb_define_method(
|
|
5453
|
-
rb_ary_push(members, rb_str_new2("
|
|
5418
|
+
rb_define_method(rb_cSUPER, "args", node_args, 0);
|
|
5419
|
+
rb_ary_push(members, rb_str_new2("args"));
|
|
5454
5420
|
}
|
|
5455
5421
|
|
|
5456
|
-
/* Document-class: Node::
|
|
5457
|
-
* Represents
|
|
5458
|
-
*
|
|
5459
|
-
*
|
|
5460
|
-
*
|
|
5422
|
+
/* Document-class: Node::SVALUE
|
|
5423
|
+
* Represents the collection of multiple values of the right hand side
|
|
5424
|
+
* of an assignment into a single value, for use in single assignment,
|
|
5425
|
+
* e.g.:
|
|
5426
|
+
* lhs = a, b, c
|
|
5427
|
+
* The argument to this node is an Array.
|
|
5428
|
+
* If it is length 0, returns nil.
|
|
5429
|
+
* If it is length 1, returns the first element in the array.
|
|
5430
|
+
* Otherwise, returns the array.
|
|
5461
5431
|
*/
|
|
5462
5432
|
{
|
|
5463
|
-
VALUE
|
|
5433
|
+
VALUE rb_cSVALUE = rb_define_class_under(rb_cNode, "SVALUE", rb_cNode);
|
|
5464
5434
|
members = rb_ary_new();
|
|
5465
|
-
rb_cNodeSubclass[
|
|
5466
|
-
rb_iv_set(
|
|
5467
|
-
rb_iv_set(
|
|
5468
|
-
rb_define_singleton_method(
|
|
5469
|
-
|
|
5470
|
-
/* Document-method: beg
|
|
5471
|
-
* the beginning of the range
|
|
5472
|
-
*/
|
|
5473
|
-
rb_define_method(rb_cFLIP2, "beg", node_beg, 0);
|
|
5474
|
-
rb_ary_push(members, rb_str_new2("beg"));
|
|
5475
|
-
|
|
5476
|
-
/* Document-method: end
|
|
5477
|
-
* the end of the range
|
|
5478
|
-
*/
|
|
5479
|
-
rb_define_method(rb_cFLIP2, "end", node_end, 0);
|
|
5480
|
-
rb_ary_push(members, rb_str_new2("end"));
|
|
5435
|
+
rb_cNodeSubclass[NODE_SVALUE] = rb_cSVALUE;
|
|
5436
|
+
rb_iv_set(rb_cSVALUE, "__member__", members);
|
|
5437
|
+
rb_iv_set(rb_cSVALUE, "__type__", INT2NUM(NODE_SVALUE));
|
|
5438
|
+
rb_define_singleton_method(rb_cSVALUE, "members", node_s_members, 0);
|
|
5481
5439
|
|
|
5482
|
-
/* Document-method:
|
|
5483
|
-
*
|
|
5484
|
-
* to use in the flip-flop expression (usually 2 for $_)
|
|
5440
|
+
/* Document-method: head
|
|
5441
|
+
* an expression which returns an Array.
|
|
5485
5442
|
*/
|
|
5486
|
-
rb_define_method(
|
|
5487
|
-
rb_ary_push(members, rb_str_new2("
|
|
5443
|
+
rb_define_method(rb_cSVALUE, "head", node_head, 0);
|
|
5444
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5488
5445
|
}
|
|
5489
5446
|
|
|
5490
|
-
/* Document-class: Node::
|
|
5491
|
-
* Represents a
|
|
5492
|
-
*
|
|
5493
|
-
*
|
|
5447
|
+
/* Document-class: Node::TO_ARY
|
|
5448
|
+
* Represents a conversion from one object type to an array type.
|
|
5449
|
+
* Evaluation of this node converts its argument to an array by calling
|
|
5450
|
+
* \#to_ary on the argument.
|
|
5494
5451
|
*/
|
|
5495
5452
|
{
|
|
5496
|
-
VALUE
|
|
5453
|
+
VALUE rb_cTO_ARY = rb_define_class_under(rb_cNode, "TO_ARY", rb_cNode);
|
|
5497
5454
|
members = rb_ary_new();
|
|
5498
|
-
rb_cNodeSubclass[
|
|
5499
|
-
rb_iv_set(
|
|
5500
|
-
rb_iv_set(
|
|
5501
|
-
rb_define_singleton_method(
|
|
5455
|
+
rb_cNodeSubclass[NODE_TO_ARY] = rb_cTO_ARY;
|
|
5456
|
+
rb_iv_set(rb_cTO_ARY, "__member__", members);
|
|
5457
|
+
rb_iv_set(rb_cTO_ARY, "__type__", INT2NUM(NODE_TO_ARY));
|
|
5458
|
+
rb_define_singleton_method(rb_cTO_ARY, "members", node_s_members, 0);
|
|
5502
5459
|
|
|
5503
|
-
/* Document-method:
|
|
5504
|
-
* the
|
|
5460
|
+
/* Document-method: head
|
|
5461
|
+
* the object to convert to an array
|
|
5505
5462
|
*/
|
|
5506
|
-
rb_define_method(
|
|
5507
|
-
rb_ary_push(members, rb_str_new2("
|
|
5463
|
+
rb_define_method(rb_cTO_ARY, "head", node_head, 0);
|
|
5464
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5508
5465
|
}
|
|
5509
5466
|
|
|
5510
|
-
/* Document-class: Node::
|
|
5511
|
-
*
|
|
5467
|
+
/* Document-class: Node::TRUE
|
|
5468
|
+
* Represents the keyword 'true'.
|
|
5512
5469
|
*/
|
|
5513
5470
|
{
|
|
5514
|
-
VALUE
|
|
5471
|
+
VALUE rb_cTRUE = rb_define_class_under(rb_cNode, "TRUE", rb_cNode);
|
|
5515
5472
|
members = rb_ary_new();
|
|
5516
|
-
rb_cNodeSubclass[
|
|
5517
|
-
rb_iv_set(
|
|
5518
|
-
rb_iv_set(
|
|
5519
|
-
rb_define_singleton_method(
|
|
5473
|
+
rb_cNodeSubclass[NODE_TRUE] = rb_cTRUE;
|
|
5474
|
+
rb_iv_set(rb_cTRUE, "__member__", members);
|
|
5475
|
+
rb_iv_set(rb_cTRUE, "__type__", INT2NUM(NODE_TRUE));
|
|
5476
|
+
rb_define_singleton_method(rb_cTRUE, "members", node_s_members, 0);
|
|
5477
|
+
}
|
|
5520
5478
|
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5479
|
+
/* Document-class: Node::UNDEF
|
|
5480
|
+
* Represents an expression using the undef keyword, e.g.:
|
|
5481
|
+
* undef :mid
|
|
5482
|
+
*
|
|
5483
|
+
* This causes the method identified by mid in the current class to be
|
|
5484
|
+
* undefined.
|
|
5485
|
+
*/
|
|
5486
|
+
{
|
|
5487
|
+
VALUE rb_cUNDEF = rb_define_class_under(rb_cNode, "UNDEF", rb_cNode);
|
|
5488
|
+
members = rb_ary_new();
|
|
5489
|
+
rb_cNodeSubclass[NODE_UNDEF] = rb_cUNDEF;
|
|
5490
|
+
rb_iv_set(rb_cUNDEF, "__member__", members);
|
|
5491
|
+
rb_iv_set(rb_cUNDEF, "__type__", INT2NUM(NODE_UNDEF));
|
|
5492
|
+
rb_define_singleton_method(rb_cUNDEF, "members", node_s_members, 0);
|
|
5526
5493
|
|
|
5527
|
-
/* Document-method:
|
|
5528
|
-
* the method
|
|
5494
|
+
/* Document-method: mid
|
|
5495
|
+
* the id of the method to undefine
|
|
5529
5496
|
*/
|
|
5530
|
-
rb_define_method(
|
|
5531
|
-
rb_ary_push(members, rb_str_new2("
|
|
5497
|
+
rb_define_method(rb_cUNDEF, "mid", node_mid, 0);
|
|
5498
|
+
rb_ary_push(members, rb_str_new2("mid"));
|
|
5532
5499
|
}
|
|
5533
5500
|
|
|
5534
|
-
/* Document-class: Node::
|
|
5535
|
-
* Represents a
|
|
5536
|
-
*
|
|
5537
|
-
*
|
|
5538
|
-
*
|
|
5539
|
-
* regular expression literal.
|
|
5501
|
+
/* Document-class: Node::UNTIL
|
|
5502
|
+
* Represents a loop constructed with the 'until' keyword, e.g.:
|
|
5503
|
+
* until cond do
|
|
5504
|
+
* body
|
|
5505
|
+
* end
|
|
5540
5506
|
*/
|
|
5541
5507
|
{
|
|
5542
|
-
VALUE
|
|
5508
|
+
VALUE rb_cUNTIL = rb_define_class_under(rb_cNode, "UNTIL", rb_cNode);
|
|
5543
5509
|
members = rb_ary_new();
|
|
5544
|
-
rb_cNodeSubclass[
|
|
5545
|
-
rb_iv_set(
|
|
5546
|
-
rb_iv_set(
|
|
5547
|
-
rb_define_singleton_method(
|
|
5510
|
+
rb_cNodeSubclass[NODE_UNTIL] = rb_cUNTIL;
|
|
5511
|
+
rb_iv_set(rb_cUNTIL, "__member__", members);
|
|
5512
|
+
rb_iv_set(rb_cUNTIL, "__type__", INT2NUM(NODE_UNTIL));
|
|
5513
|
+
rb_define_singleton_method(rb_cUNTIL, "members", node_s_members, 0);
|
|
5548
5514
|
|
|
5549
|
-
/* Document-method:
|
|
5550
|
-
* the
|
|
5515
|
+
/* Document-method: body
|
|
5516
|
+
* the body of the loop
|
|
5551
5517
|
*/
|
|
5552
|
-
rb_define_method(
|
|
5553
|
-
rb_ary_push(members, rb_str_new2("
|
|
5518
|
+
rb_define_method(rb_cUNTIL, "body", node_body, 0);
|
|
5519
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5554
5520
|
|
|
5555
|
-
/* Document-method:
|
|
5556
|
-
* the
|
|
5521
|
+
/* Document-method: cond
|
|
5522
|
+
* a condition to terminate the loop when it becomes true
|
|
5557
5523
|
*/
|
|
5558
|
-
rb_define_method(
|
|
5559
|
-
rb_ary_push(members, rb_str_new2("
|
|
5524
|
+
rb_define_method(rb_cUNTIL, "cond", node_cond, 0);
|
|
5525
|
+
rb_ary_push(members, rb_str_new2("cond"));
|
|
5526
|
+
rb_define_method(rb_cUNTIL, "state", node_state, 0);
|
|
5527
|
+
rb_ary_push(members, rb_str_new2("state"));
|
|
5560
5528
|
}
|
|
5561
5529
|
|
|
5562
|
-
/* Document-class: Node::
|
|
5563
|
-
* Represents
|
|
5530
|
+
/* Document-class: Node::VALIAS
|
|
5531
|
+
* Represents an alias expression of the form:
|
|
5532
|
+
* alias 1st 2nd
|
|
5533
|
+
* where 2nd is the name of a variable and 1st is the name of its new
|
|
5534
|
+
* alias.
|
|
5564
5535
|
*/
|
|
5565
5536
|
{
|
|
5566
|
-
VALUE
|
|
5537
|
+
VALUE rb_cVALIAS = rb_define_class_under(rb_cNode, "VALIAS", rb_cNode);
|
|
5567
5538
|
members = rb_ary_new();
|
|
5568
|
-
rb_cNodeSubclass[
|
|
5569
|
-
rb_iv_set(
|
|
5570
|
-
rb_iv_set(
|
|
5571
|
-
rb_define_singleton_method(
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
rb_define_method(rb_cIASGN, "value", node_value, 0);
|
|
5577
|
-
rb_ary_push(members, rb_str_new2("value"));
|
|
5578
|
-
|
|
5579
|
-
/* Document-method: vid
|
|
5580
|
-
* the name of the instance variable, with a leading '@' sign
|
|
5581
|
-
*/
|
|
5582
|
-
rb_define_method(rb_cIASGN, "vid", node_vid, 0);
|
|
5583
|
-
rb_ary_push(members, rb_str_new2("vid"));
|
|
5539
|
+
rb_cNodeSubclass[NODE_VALIAS] = rb_cVALIAS;
|
|
5540
|
+
rb_iv_set(rb_cVALIAS, "__member__", members);
|
|
5541
|
+
rb_iv_set(rb_cVALIAS, "__type__", INT2NUM(NODE_VALIAS));
|
|
5542
|
+
rb_define_singleton_method(rb_cVALIAS, "members", node_s_members, 0);
|
|
5543
|
+
rb_define_method(rb_cVALIAS, "first", node_1st, 0);
|
|
5544
|
+
rb_ary_push(members, rb_str_new2("first"));
|
|
5545
|
+
rb_define_method(rb_cVALIAS, "second", node_2nd, 0);
|
|
5546
|
+
rb_ary_push(members, rb_str_new2("second"));
|
|
5584
5547
|
}
|
|
5585
5548
|
|
|
5586
|
-
/* Document-class: Node::
|
|
5587
|
-
*
|
|
5588
|
-
*
|
|
5589
|
-
* define_method(:name, method(:foo))
|
|
5590
|
-
*
|
|
5591
|
-
* See also BMETHOD.
|
|
5549
|
+
/* Document-class: Node::VCALL
|
|
5550
|
+
* Represents a local variable or a method call without an explicit
|
|
5551
|
+
* receiver, to be determined at run-time.
|
|
5592
5552
|
*/
|
|
5593
5553
|
{
|
|
5594
|
-
VALUE
|
|
5554
|
+
VALUE rb_cVCALL = rb_define_class_under(rb_cNode, "VCALL", rb_cNode);
|
|
5595
5555
|
members = rb_ary_new();
|
|
5596
|
-
rb_cNodeSubclass[
|
|
5597
|
-
rb_iv_set(
|
|
5598
|
-
rb_iv_set(
|
|
5599
|
-
rb_define_singleton_method(
|
|
5556
|
+
rb_cNodeSubclass[NODE_VCALL] = rb_cVCALL;
|
|
5557
|
+
rb_iv_set(rb_cVCALL, "__member__", members);
|
|
5558
|
+
rb_iv_set(rb_cVCALL, "__type__", INT2NUM(NODE_VCALL));
|
|
5559
|
+
rb_define_singleton_method(rb_cVCALL, "members", node_s_members, 0);
|
|
5600
5560
|
|
|
5601
|
-
/* Document-method:
|
|
5602
|
-
* the
|
|
5603
|
-
* body of the method
|
|
5561
|
+
/* Document-method: mid
|
|
5562
|
+
* the name of the variable or method
|
|
5604
5563
|
*/
|
|
5605
|
-
rb_define_method(
|
|
5606
|
-
rb_ary_push(members, rb_str_new2("
|
|
5564
|
+
rb_define_method(rb_cVCALL, "mid", node_mid, 0);
|
|
5565
|
+
rb_ary_push(members, rb_str_new2("mid"));
|
|
5607
5566
|
}
|
|
5608
5567
|
|
|
5609
|
-
/* Document-class: Node::
|
|
5610
|
-
* Represents
|
|
5611
|
-
*
|
|
5568
|
+
/* Document-class: Node::WHEN
|
|
5569
|
+
* Represents either a conditional in a case/end block:
|
|
5570
|
+
* case value
|
|
5571
|
+
* when head
|
|
5572
|
+
* body
|
|
5573
|
+
* next
|
|
5574
|
+
* end
|
|
5575
|
+
*
|
|
5576
|
+
* or the first element of a a case/end block with no conditional:
|
|
5577
|
+
* case
|
|
5578
|
+
* when head
|
|
5612
5579
|
* body
|
|
5580
|
+
* next
|
|
5613
5581
|
* end
|
|
5582
|
+
*
|
|
5583
|
+
* In the first case, value is evaluated and head is evaluated, and
|
|
5584
|
+
* they are compared using head === value. If the result is true, then
|
|
5585
|
+
* body is evaluated and no more when conditions are tried, otherwise
|
|
5586
|
+
* the interpreter evaluates the next node.
|
|
5587
|
+
*
|
|
5588
|
+
* In the second case, head is tested using rtest(value). If the
|
|
5589
|
+
* result is true, then body is evaluated and no more when conditions
|
|
5590
|
+
* are tried, otherwise the interpreter evaluates the next node.
|
|
5591
|
+
*
|
|
5592
|
+
* If the condition evaluates to false and there are no more when
|
|
5593
|
+
* conditions to try, the result of the expression is nil.
|
|
5594
|
+
*
|
|
5595
|
+
* If the next expression to try is not a WHEN node, then it represents
|
|
5596
|
+
* an else element and is evaluated unconditionally.
|
|
5614
5597
|
*/
|
|
5615
5598
|
{
|
|
5616
|
-
VALUE
|
|
5599
|
+
VALUE rb_cWHEN = rb_define_class_under(rb_cNode, "WHEN", rb_cNode);
|
|
5617
5600
|
members = rb_ary_new();
|
|
5618
|
-
rb_cNodeSubclass[
|
|
5619
|
-
rb_iv_set(
|
|
5620
|
-
rb_iv_set(
|
|
5621
|
-
rb_define_singleton_method(
|
|
5601
|
+
rb_cNodeSubclass[NODE_WHEN] = rb_cWHEN;
|
|
5602
|
+
rb_iv_set(rb_cWHEN, "__member__", members);
|
|
5603
|
+
rb_iv_set(rb_cWHEN, "__type__", INT2NUM(NODE_WHEN));
|
|
5604
|
+
rb_define_singleton_method(rb_cWHEN, "members", node_s_members, 0);
|
|
5622
5605
|
|
|
5623
|
-
/* Document-method:
|
|
5624
|
-
*
|
|
5606
|
+
/* Document-method: head
|
|
5607
|
+
* a value to compare against, or a condition to be tested
|
|
5625
5608
|
*/
|
|
5626
|
-
rb_define_method(
|
|
5627
|
-
rb_ary_push(members, rb_str_new2("
|
|
5609
|
+
rb_define_method(rb_cWHEN, "head", node_head, 0);
|
|
5610
|
+
rb_ary_push(members, rb_str_new2("head"));
|
|
5628
5611
|
|
|
5629
|
-
/* Document-method:
|
|
5630
|
-
*
|
|
5612
|
+
/* Document-method: body
|
|
5613
|
+
* an expression to evaluate if the condition evaluates to true
|
|
5631
5614
|
*/
|
|
5632
|
-
rb_define_method(
|
|
5633
|
-
rb_ary_push(members, rb_str_new2("
|
|
5615
|
+
rb_define_method(rb_cWHEN, "body", node_body, 0);
|
|
5616
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5634
5617
|
|
|
5635
|
-
/* Document-method:
|
|
5636
|
-
* the
|
|
5637
|
-
* to use in the flip-flop expression (usually 2 for $_)
|
|
5618
|
+
/* Document-method: next
|
|
5619
|
+
* the next expression to be evaluated if the condition is false
|
|
5638
5620
|
*/
|
|
5639
|
-
rb_define_method(
|
|
5640
|
-
rb_ary_push(members, rb_str_new2("
|
|
5621
|
+
rb_define_method(rb_cWHEN, "next", node_next, 0);
|
|
5622
|
+
rb_ary_push(members, rb_str_new2("next"));
|
|
5641
5623
|
}
|
|
5642
5624
|
|
|
5643
|
-
/* Document-class: Node::
|
|
5644
|
-
* Represents a
|
|
5645
|
-
*
|
|
5646
|
-
*
|
|
5647
|
-
*
|
|
5648
|
-
* and use it as the result of the expression.
|
|
5625
|
+
/* Document-class: Node::WHILE
|
|
5626
|
+
* Represents a loop constructed with the 'while' keyword, e.g.:
|
|
5627
|
+
* while cond do
|
|
5628
|
+
* body
|
|
5629
|
+
* end
|
|
5649
5630
|
*/
|
|
5650
5631
|
{
|
|
5651
|
-
VALUE
|
|
5632
|
+
VALUE rb_cWHILE = rb_define_class_under(rb_cNode, "WHILE", rb_cNode);
|
|
5652
5633
|
members = rb_ary_new();
|
|
5653
|
-
rb_cNodeSubclass[
|
|
5654
|
-
rb_iv_set(
|
|
5655
|
-
rb_iv_set(
|
|
5656
|
-
rb_define_singleton_method(
|
|
5634
|
+
rb_cNodeSubclass[NODE_WHILE] = rb_cWHILE;
|
|
5635
|
+
rb_iv_set(rb_cWHILE, "__member__", members);
|
|
5636
|
+
rb_iv_set(rb_cWHILE, "__type__", INT2NUM(NODE_WHILE));
|
|
5637
|
+
rb_define_singleton_method(rb_cWHILE, "members", node_s_members, 0);
|
|
5657
5638
|
|
|
5658
|
-
/* Document-method:
|
|
5659
|
-
* the
|
|
5639
|
+
/* Document-method: body
|
|
5640
|
+
* the body of the loop
|
|
5660
5641
|
*/
|
|
5661
|
-
rb_define_method(
|
|
5662
|
-
rb_ary_push(members, rb_str_new2("
|
|
5642
|
+
rb_define_method(rb_cWHILE, "body", node_body, 0);
|
|
5643
|
+
rb_ary_push(members, rb_str_new2("body"));
|
|
5663
5644
|
|
|
5664
|
-
/* Document-method:
|
|
5665
|
-
*
|
|
5645
|
+
/* Document-method: cond
|
|
5646
|
+
* a condition to terminate the loop when it becomes false
|
|
5666
5647
|
*/
|
|
5667
|
-
rb_define_method(
|
|
5668
|
-
rb_ary_push(members, rb_str_new2("
|
|
5648
|
+
rb_define_method(rb_cWHILE, "cond", node_cond, 0);
|
|
5649
|
+
rb_ary_push(members, rb_str_new2("cond"));
|
|
5650
|
+
rb_define_method(rb_cWHILE, "state", node_state, 0);
|
|
5651
|
+
rb_ary_push(members, rb_str_new2("state"));
|
|
5669
5652
|
}
|
|
5670
5653
|
|
|
5671
|
-
/* Document-class: Node::
|
|
5672
|
-
* Represents a
|
|
5673
|
-
*
|
|
5654
|
+
/* Document-class: Node::XSTR
|
|
5655
|
+
* Represents a string object inside backticks, e.g.:
|
|
5656
|
+
* `lit`
|
|
5657
|
+
* The given string is executed in a subshell and the output from its
|
|
5658
|
+
* stdout stored in a string.
|
|
5674
5659
|
*/
|
|
5675
5660
|
{
|
|
5676
|
-
VALUE
|
|
5661
|
+
VALUE rb_cXSTR = rb_define_class_under(rb_cNode, "XSTR", rb_cNode);
|
|
5677
5662
|
members = rb_ary_new();
|
|
5678
|
-
rb_cNodeSubclass[
|
|
5679
|
-
rb_iv_set(
|
|
5680
|
-
rb_iv_set(
|
|
5681
|
-
rb_define_singleton_method(
|
|
5663
|
+
rb_cNodeSubclass[NODE_XSTR] = rb_cXSTR;
|
|
5664
|
+
rb_iv_set(rb_cXSTR, "__member__", members);
|
|
5665
|
+
rb_iv_set(rb_cXSTR, "__type__", INT2NUM(NODE_XSTR));
|
|
5666
|
+
rb_define_singleton_method(rb_cXSTR, "members", node_s_members, 0);
|
|
5682
5667
|
|
|
5683
|
-
/* Document-method:
|
|
5684
|
-
* the
|
|
5668
|
+
/* Document-method: lit
|
|
5669
|
+
* the string to be executed
|
|
5685
5670
|
*/
|
|
5686
|
-
rb_define_method(
|
|
5687
|
-
rb_ary_push(members, rb_str_new2("
|
|
5671
|
+
rb_define_method(rb_cXSTR, "lit", node_lit, 0);
|
|
5672
|
+
rb_ary_push(members, rb_str_new2("lit"));
|
|
5688
5673
|
}
|
|
5689
5674
|
|
|
5690
5675
|
/* Document-class: Node::YIELD
|
|
@@ -5713,20 +5698,35 @@ void define_node_subclass_methods()
|
|
|
5713
5698
|
rb_ary_push(members, rb_str_new2("state"));
|
|
5714
5699
|
}
|
|
5715
5700
|
|
|
5716
|
-
/* Document-class: Node::
|
|
5717
|
-
* Represents
|
|
5701
|
+
/* Document-class: Node::ZARRAY
|
|
5702
|
+
* Represents an array of zero elements. Evalation of this node
|
|
5703
|
+
* creates a new array of length zero.
|
|
5704
|
+
*/
|
|
5705
|
+
{
|
|
5706
|
+
VALUE rb_cZARRAY = rb_define_class_under(rb_cNode, "ZARRAY", rb_cNode);
|
|
5707
|
+
members = rb_ary_new();
|
|
5708
|
+
rb_cNodeSubclass[NODE_ZARRAY] = rb_cZARRAY;
|
|
5709
|
+
rb_iv_set(rb_cZARRAY, "__member__", members);
|
|
5710
|
+
rb_iv_set(rb_cZARRAY, "__type__", INT2NUM(NODE_ZARRAY));
|
|
5711
|
+
rb_define_singleton_method(rb_cZARRAY, "members", node_s_members, 0);
|
|
5712
|
+
}
|
|
5713
|
+
|
|
5714
|
+
/* Document-class: Node::ZSUPER
|
|
5715
|
+
* Represents the keyword 'super' when used without parens nor
|
|
5716
|
+
* arguments. The arguments to the base class method are obtained from
|
|
5717
|
+
* the arguments passed to the current method, which are store in the
|
|
5718
|
+
* current frame.
|
|
5718
5719
|
*
|
|
5719
|
-
*
|
|
5720
|
+
* Can also be a placeholder for a method when its implementation is
|
|
5721
|
+
* deferred to the base class.
|
|
5720
5722
|
*/
|
|
5721
5723
|
{
|
|
5722
|
-
VALUE
|
|
5724
|
+
VALUE rb_cZSUPER = rb_define_class_under(rb_cNode, "ZSUPER", rb_cNode);
|
|
5723
5725
|
members = rb_ary_new();
|
|
5724
|
-
rb_cNodeSubclass[
|
|
5725
|
-
rb_iv_set(
|
|
5726
|
-
rb_iv_set(
|
|
5727
|
-
rb_define_singleton_method(
|
|
5728
|
-
rb_define_method(rb_cBEGIN, "body", node_body, 0);
|
|
5729
|
-
rb_ary_push(members, rb_str_new2("body"));
|
|
5726
|
+
rb_cNodeSubclass[NODE_ZSUPER] = rb_cZSUPER;
|
|
5727
|
+
rb_iv_set(rb_cZSUPER, "__member__", members);
|
|
5728
|
+
rb_iv_set(rb_cZSUPER, "__type__", INT2NUM(NODE_ZSUPER));
|
|
5729
|
+
rb_define_singleton_method(rb_cZSUPER, "members", node_s_members, 0);
|
|
5730
5730
|
}
|
|
5731
5731
|
}
|
|
5732
5732
|
|