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