ruby-internal 0.7.2 → 0.7.3

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.
Files changed (63) hide show
  1. data/bin/ruby-internal-node-dump +1 -1
  2. data/bin/ruby-internal-obfuscate +1 -1
  3. data/ext/internal/method/extconf.rb +4 -0
  4. data/ext/internal/method/internal_method.h +65 -0
  5. data/ext/internal/method/{method.h.rpp → internal_method.h.rpp} +21 -0
  6. data/ext/internal/method/method.c +69 -13
  7. data/ext/internal/module/classpath.c +12 -14
  8. data/ext/internal/module/extconf.rb +3 -2
  9. data/ext/internal/module/module.c +36 -15
  10. data/ext/internal/node/block.h.rpp +1 -0
  11. data/ext/internal/node/extconf.rb +0 -22
  12. data/ext/internal/node/global_entry.h +45 -3
  13. data/ext/internal/node/global_entry.h.rpp +12 -3
  14. data/ext/internal/node/node.c +42 -15
  15. data/ext/internal/node/node_type_descrip.c +16 -20
  16. data/ext/internal/node/node_type_descrip.c.rpp +1 -0
  17. data/ext/internal/node/nodeinfo.c +133 -281
  18. data/ext/internal/node/nodeinfo.c.rpp +8 -4
  19. data/ext/internal/node/nodeinfo.h.rpp +2 -1
  20. data/ext/internal/noex/noex.c +4 -0
  21. data/ext/internal/proc/proc.c +2 -2
  22. data/ext/internal/vm/constants/constants.c +2 -0
  23. data/ext/internal/vm/constants/extconf.rb +2 -0
  24. data/ext/internal/vm/control_frame/control_frame.c +21 -3
  25. data/ext/internal/vm/control_frame/extconf.rb +4 -0
  26. data/ext/internal/vm/inline_cache/inline_cache.c +12 -5
  27. data/ext/internal/vm/instruction/insns_info.c +141 -64
  28. data/ext/internal/vm/instruction/insns_info.c.rpp +3 -0
  29. data/ext/internal/vm/instruction/insns_info.h +80 -71
  30. data/ext/internal/vm/iseq/iseq.c +6 -6
  31. data/ext/internal/vm/iseq/iseq_load.inc.rpp +6 -3
  32. data/ext/mkmf-ruby-internal.rb +21 -1
  33. data/ext/ruby_source_dir.rb +6 -2
  34. data/post-setup.rb +1 -0
  35. data/pre-config.rb +9 -0
  36. data/run_tests.rb +1 -0
  37. data/test/test_method.rb +1 -1
  38. data/test/test_module.rb +1 -1
  39. metadata +309 -321
  40. data/ext/internal/method/method.h +0 -20
  41. data/ext/internal/yarv-headers/debug.h +0 -36
  42. data/ext/internal/yarv-headers/dln.h +0 -41
  43. data/ext/internal/yarv-headers/encdb.h +0 -147
  44. data/ext/internal/yarv-headers/eval_intern.h +0 -215
  45. data/ext/internal/yarv-headers/gc.h +0 -75
  46. data/ext/internal/yarv-headers/id.h +0 -163
  47. data/ext/internal/yarv-headers/iseq.h +0 -103
  48. data/ext/internal/yarv-headers/node.h +0 -516
  49. data/ext/internal/yarv-headers/parse.h +0 -188
  50. data/ext/internal/yarv-headers/regenc.h +0 -207
  51. data/ext/internal/yarv-headers/regint.h +0 -842
  52. data/ext/internal/yarv-headers/regparse.h +0 -351
  53. data/ext/internal/yarv-headers/revision.h +0 -1
  54. data/ext/internal/yarv-headers/thread_pthread.h +0 -24
  55. data/ext/internal/yarv-headers/thread_win32.h +0 -33
  56. data/ext/internal/yarv-headers/transcode_data.h +0 -106
  57. data/ext/internal/yarv-headers/transdb.h +0 -147
  58. data/ext/internal/yarv-headers/version.h +0 -54
  59. data/ext/internal/yarv-headers/vm_core.h +0 -646
  60. data/ext/internal/yarv-headers/vm_exec.h +0 -184
  61. data/ext/internal/yarv-headers/vm_insnhelper.h +0 -195
  62. data/ext/internal/yarv-headers/vm_opts.h +0 -51
  63. data/ext/rubypp.rb +0 -97
@@ -9,6 +9,7 @@
9
9
 
10
10
  #ruby <<END
11
11
  $: << '../..'
12
+ $: << '.' # TODO: hack
12
13
  require 'ruby_source_dir'
13
14
  vm_c_location = "#{RUBY_SOURCE_DIR}/vm.c"
14
15
  eval_c_location = "#{RUBY_SOURCE_DIR}/eval.c"
@@ -1,28 +1,6 @@
1
1
  $: << '../..'
2
2
  require 'mkmf-ruby-internal'
3
3
 
4
- module Kernel
5
- if not method_defined?(:try_const)
6
- alias_method :try_const, :try_constant
7
- end
8
-
9
- if not method_defined?(:checking_message)
10
- def checking_message(checking_for, headers = nil, opt = "")
11
- return checking_for
12
- end
13
- end
14
-
15
- if not method_defined?(:have_const)
16
- def have_const(const, headers = nil, opt = "", &b)
17
- checking_for checking_message([*const].compact.join(' '), headers, opt) do
18
- try_const(const, headers, opt, &b)
19
- end
20
- end
21
- end
22
- end
23
-
24
- ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i
25
-
26
4
  have_type('st_data_t', [ 'ruby.h', 'st.h' ]) or
27
5
  have_type('st_data_t', [ 'ruby.h', 'ruby/st.h'])
28
6
 
@@ -1,10 +1,52 @@
1
1
  #ifndef global_entry__h_
2
2
  #define global_entry__h_
3
3
 
4
- struct global_entry {
5
- struct global_variable *var;
6
- ID id;
4
+ st_table * rb_global_tbl;
5
+
6
+ #define global_entry rb_global_entry
7
+ #define gvar_getter_t rb_gvar_getter_t
8
+ #define gvar_setter_t rb_gvar_setter_t
9
+ #define gvar_marker_t rb_gvar_marker_t
10
+
11
+ struct global_variable {
12
+ int counter;
13
+ void *data;
14
+ gvar_getter_t *getter;
15
+ gvar_setter_t *setter;
16
+ gvar_marker_t *marker;
17
+ int block_trace;
18
+ struct trace_var *trace;
7
19
  };
20
+ #define undef_getter rb_gvar_undef_getter
21
+ #define undef_setter rb_gvar_undef_setter
22
+ #define undef_marker rb_gvar_undef_marker
23
+ struct global_entry*
24
+ rb_global_entry(ID id)
25
+ {
26
+ struct global_entry *entry;
27
+ st_data_t data;
28
+
29
+ if (!st_lookup(rb_global_tbl, (st_data_t)id, &data)) {
30
+ struct global_variable *var;
31
+ entry = ALLOC(struct global_entry);
32
+ var = ALLOC(struct global_variable);
33
+ entry->id = id;
34
+ entry->var = var;
35
+ var->counter = 1;
36
+ var->data = 0;
37
+ var->getter = undef_getter;
38
+ var->setter = undef_setter;
39
+ var->marker = undef_marker;
40
+
41
+ var->block_trace = 0;
42
+ var->trace = 0;
43
+ st_add_direct(rb_global_tbl, id, (st_data_t)entry);
44
+ }
45
+ else {
46
+ entry = (struct global_entry *)data;
47
+ }
48
+ return entry;
49
+ }
8
50
 
9
51
  #endif
10
52
 
@@ -1,23 +1,32 @@
1
1
  #ifndef global_entry__h_
2
2
  #define global_entry__h_
3
3
 
4
+ st_table * rb_global_tbl;
5
+
4
6
  #ruby <<END
5
7
  $: << '../..'
8
+ $: << '.' # TODO: hack
6
9
  require 'ruby_source_dir'
7
10
  variable_c_location = "#{RUBY_SOURCE_DIR}/variable.c"
8
11
  File.open(variable_c_location) do |variable_c|
9
12
  write = false
10
13
  stopwrite = false
14
+ prev_line = ''
11
15
  while (line = variable_c.gets) != nil do
12
16
  case line
13
- when /^struct global_entry/
17
+ when /^rb_global_entry\(.*\)/,
18
+ /^struct global_variable {/
19
+ puts prev_line
14
20
  write = true
15
21
  stopwrite = false
22
+ when /^#define (global_entry|gvar_getter_t|gvar_setter_t|gvar_marker_t|undef_getter|undef_setter|undef_marker)/
23
+ puts line
16
24
  when /^\}/
17
- stopwrite = true if write
25
+ stopwrite = true
18
26
  end
19
27
  puts line if write
20
- break if stopwrite
28
+ write = false if stopwrite
29
+ prev_line = line
21
30
  end
22
31
  end
23
32
  END
@@ -224,9 +224,9 @@ static VALUE node_flags(VALUE self)
224
224
  */
225
225
  static VALUE node_nd_file(VALUE self)
226
226
  {
227
+ #ifdef HAVE_RB_SOURCE_FILENAME
227
228
  NODE * n;
228
229
  Data_Get_Struct(self, NODE, n);
229
- #ifdef HAVE_RB_SOURCE_FILENAME
230
230
  if(n->nd_file)
231
231
  {
232
232
  return rb_str_new2(n->nd_file);
@@ -306,19 +306,25 @@ static VALUE node_bracket(VALUE node, VALUE member)
306
306
  {
307
307
  ID id = SYMBOL_P(member)
308
308
  ? SYM2ID(member)
309
- : rb_intern(STR2CSTR(member));
309
+ : rb_intern(StringValuePtr(member));
310
310
  return rb_funcall(node, id, 0);
311
311
  }
312
312
 
313
+ static VALUE node_classname(VALUE node)
314
+ {
315
+ VALUE str = rb_str_new2("#<");
316
+ rb_str_cat2(str, rb_class2name(CLASS_OF(node)));
317
+ rb_str_cat2(str, " ");
318
+ return str;
319
+ }
320
+
313
321
  #ifdef HAVE_RB_PROTECT_INSPECT
314
322
  static VALUE node_inspect_protect(VALUE node)
315
323
  #else
316
324
  static VALUE node_inspect_protect(VALUE node, VALUE dummy, int recur)
317
325
  #endif
318
326
  {
319
- VALUE str = rb_str_new2("#<");
320
- rb_str_cat2(str, rb_class2name(CLASS_OF(node)));
321
- rb_str_cat2(str, " ");
327
+ VALUE str = node_classname(node);
322
328
  VALUE members = node_members(node);
323
329
  int j;
324
330
 
@@ -501,10 +507,19 @@ VALUE eval_ruby_node(NODE * node, VALUE self, VALUE cref)
501
507
  }
502
508
  else
503
509
  {
510
+ #ifdef HAVE_RB_SOURCE_FILENAME
504
511
  VALUE filename = node->nd_file
505
512
  ? rb_str_new2(node->nd_file)
506
513
  : rb_str_new2("<unknown>");
514
+ #else
515
+ VALUE filename = Qnil;
516
+ #endif
517
+
518
+ VALUE filepath = Qnil; /* TODO */
519
+
507
520
  VALUE iseq;
521
+ rb_proc_t * p;
522
+ VALUE proc;
508
523
 
509
524
  if(nd_type(node) != NODE_SCOPE)
510
525
  {
@@ -519,6 +534,9 @@ VALUE eval_ruby_node(NODE * node, VALUE self, VALUE cref)
519
534
  node,
520
535
  rb_str_new2("<compiled>"),
521
536
  filename,
537
+ #if RUBY_VERSION_CODE >= 192
538
+ filepath,
539
+ #endif
522
540
  self,
523
541
  ISEQ_TYPE_TOP);
524
542
 
@@ -528,9 +546,6 @@ VALUE eval_ruby_node(NODE * node, VALUE self, VALUE cref)
528
546
  /* VALUE result = rb_iseq_eval(iseq);
529
547
  return result; */
530
548
 
531
- rb_proc_t * p;
532
- VALUE proc;
533
-
534
549
  proc = create_proc(rb_cProc, Qnil, iseq_check(iseq));
535
550
  GetProcPtr(proc, p);
536
551
  p->block.self = self;
@@ -646,17 +661,20 @@ NODE * load_node_from_hash(VALUE arr, VALUE orig_node_id, VALUE node_hash, VALUE
646
661
  NODE * n = NEW_NIL();
647
662
  VALUE s3, s2, s1, rb_nd_file, rb_flags;
648
663
  unsigned long flags;
649
- char *nd_file = 0;
650
664
  Node_Type_Descrip const *descrip;
651
665
  NODE tmp_node;
652
666
 
667
+ #ifdef HAVE_RB_SOURCE_FILENAME
668
+ char *nd_file = 0;
669
+ #endif
670
+
653
671
  nd_set_type(&tmp_node, NODE_NIL);
654
672
 
655
673
  Check_Type(arr, T_ARRAY);
656
674
  s3 = rb_ary_pop(arr);
657
675
  s2 = rb_ary_pop(arr);
658
676
  s1 = rb_ary_pop(arr);
659
- rb_nd_file = rb_ary_pop(arr);
677
+ rb_nd_file = rb_ary_pop(arr); /* TODO: warning: set but not used */
660
678
  rb_flags = rb_ary_pop(arr);
661
679
  flags = NUM2INT(rb_flags);
662
680
  tmp_node.flags = flags;
@@ -686,7 +704,10 @@ NODE * load_node_from_hash(VALUE arr, VALUE orig_node_id, VALUE node_hash, VALUE
686
704
  */
687
705
  memcpy(n, &tmp_node, sizeof(NODE));
688
706
  n->flags = flags;
707
+
708
+ #ifdef HAVE_RB_SOURCE_FILENAME
689
709
  n->nd_file = nd_file;
710
+ #endif
690
711
 
691
712
  return n;
692
713
  }
@@ -758,7 +779,7 @@ static VALUE node_compile_string(int argc, VALUE * argv, VALUE self)
758
779
  file = NIL_P(file) ? rb_str_new2("(compiled)") : file;
759
780
  line = NIL_P(line) ? INT2NUM(1) : line;
760
781
 
761
- node = rb_compile_string(STR2CSTR(file), str, NUM2INT(line));
782
+ node = rb_compile_string(StringValuePtr(file), str, NUM2INT(line));
762
783
 
763
784
  #ifdef RUBY_VM
764
785
  if(!node)
@@ -788,8 +809,11 @@ static VALUE node_compile_string(int argc, VALUE * argv, VALUE self)
788
809
  */
789
810
  static VALUE node_bytecode_compile(int argc, VALUE * argv, VALUE self)
790
811
  {
812
+ NODE * node;
791
813
  VALUE name = Qnil;
792
814
  VALUE filename = Qnil;
815
+ VALUE filepath = Qnil; /* TODO */
816
+
793
817
  rb_scan_args(argc, argv, "02", &name, &filename);
794
818
 
795
819
  if(name == Qnil)
@@ -802,12 +826,15 @@ static VALUE node_bytecode_compile(int argc, VALUE * argv, VALUE self)
802
826
  filename = name;
803
827
  }
804
828
 
805
- NODE * node = unwrap_node(self);
829
+ node = unwrap_node(self);
806
830
 
807
831
  return rb_iseq_new(
808
832
  node,
809
833
  name,
810
834
  filename,
835
+ #if RUBY_VERSION_CODE >= 192
836
+ filepath,
837
+ #endif
811
838
  Qfalse,
812
839
  ISEQ_TYPE_TOP);
813
840
  }
@@ -823,7 +850,7 @@ static VALUE node_bytecode_compile(int argc, VALUE * argv, VALUE self)
823
850
  static VALUE node_dump(VALUE self, VALUE limit)
824
851
  {
825
852
  NODE * n;
826
- VALUE node_hash, arr;
853
+ VALUE node_hash, arr, s;
827
854
 
828
855
  if(rb_safe_level() >= 4)
829
856
  {
@@ -836,7 +863,7 @@ static VALUE node_dump(VALUE self, VALUE limit)
836
863
  arr = rb_ary_new();
837
864
  rb_ary_push(arr, node_id(n));
838
865
  rb_ary_push(arr, node_hash);
839
- VALUE s = marshal_dump(arr, limit);
866
+ s = marshal_dump(arr, limit);
840
867
  return s;
841
868
  }
842
869
 
@@ -1051,7 +1078,7 @@ void Init_node(void)
1051
1078
  {
1052
1079
  int actual_ruby_version_code = 0;
1053
1080
  VALUE ruby_version_str = rb_const_get(rb_cObject, rb_intern("RUBY_VERSION"));
1054
- char const * s = STR2CSTR(ruby_version_str);
1081
+ char const * s = StringValuePtr(ruby_version_str);
1055
1082
 
1056
1083
  for(; *s != '\0'; ++s)
1057
1084
  {
@@ -6,13 +6,12 @@ Node_Type_Descrip node_type_descrips_unsorted[] = {
6
6
  #ifdef HAVE_NODE_ALLOCA
7
7
  { NODE_ALLOCA, NEN_CFNC, NEN_VALUE, NEN_CNT, "ALLOCA" },
8
8
  #endif
9
- { NODE_AND, NEN_1ST, NEN_2ND, NEN_NONE, "AND" },
9
+ { NODE_AND, NEN_2ND, NEN_1ST, NEN_NONE, "AND" },
10
10
  { NODE_ARGS, NEN_REST, NEN_OPT, NEN_CNT, "ARGS" },
11
11
  { NODE_ARGSCAT, NEN_HEAD, NEN_BODY, NEN_NONE, "ARGSCAT" },
12
12
  { NODE_ARGSPUSH, NEN_HEAD, NEN_BODY, NEN_NONE, "ARGSPUSH" },
13
- { NODE_ARRAY, NEN_HEAD, NEN_ALEN, NEN_NEXT, "ARRAY" },
14
- { NODE_ATTRASGN, NEN_ARGS, NEN_MID, NEN_RECV, "ATTRASGN" },
15
- { NODE_ATTRSET, NEN_VID, NEN_NONE, NEN_NONE, "ATTRSET" },
13
+ { NODE_ARRAY, NEN_ALEN, NEN_HEAD, NEN_NEXT, "ARRAY" },
14
+ { NODE_ATTRASGN, NEN_RECV, NEN_ARGS, NEN_MID, "ATTRASGN" },
16
15
  { NODE_BACK_REF, NEN_NTH, NEN_CNT, NEN_NONE, "BACK_REF" },
17
16
  { NODE_BEGIN, NEN_BODY, NEN_NONE, NEN_NONE, "BEGIN" },
18
17
  { NODE_BLOCK, NEN_HEAD, NEN_NEXT, NEN_NONE, "BLOCK" },
@@ -23,8 +22,7 @@ Node_Type_Descrip node_type_descrips_unsorted[] = {
23
22
  { NODE_CALL, NEN_ARGS, NEN_MID, NEN_RECV, "CALL" },
24
23
  { NODE_CASE, NEN_HEAD, NEN_BODY, NEN_NEXT, "CASE" },
25
24
  { NODE_CDECL, NEN_VALUE, NEN_VID, NEN_NONE, "CDECL" },
26
- { NODE_CFUNC, NEN_CFNC, NEN_ARGC, NEN_NONE, "CFUNC" },
27
- { NODE_CLASS, NEN_CPATH, NEN_BODY, NEN_SUPER, "CLASS" },
25
+ { NODE_CLASS, NEN_SUPER, NEN_CPATH, NEN_BODY, "CLASS" },
28
26
  { NODE_COLON2, NEN_HEAD, NEN_MID, NEN_NONE, "COLON2" },
29
27
  { NODE_COLON3, NEN_MID, NEN_NONE, NEN_NONE, "COLON3" },
30
28
  { NODE_CONST, NEN_VID, NEN_NONE, NEN_NONE, "CONST" },
@@ -35,11 +33,11 @@ Node_Type_Descrip node_type_descrips_unsorted[] = {
35
33
  { NODE_DASGN_CURR, NEN_VALUE, NEN_VID, NEN_NONE, "DASGN_CURR" },
36
34
  { NODE_DEFINED, NEN_HEAD, NEN_NONE, NEN_NONE, "DEFINED" },
37
35
  { NODE_DEFN, NEN_DEFN, NEN_MID, NEN_NOEX, "DEFN" },
38
- { NODE_DEFS, NEN_DEFN, NEN_MID, NEN_RECV, "DEFS" },
36
+ { NODE_DEFS, NEN_DEFN, NEN_RECV, NEN_MID, "DEFS" },
39
37
  { NODE_DOT2, NEN_BEG, NEN_END, NEN_STATE, "DOT2" },
40
38
  { NODE_DOT3, NEN_BEG, NEN_END, NEN_STATE, "DOT3" },
41
- { NODE_DREGX, NEN_LIT, NEN_CFLAG, NEN_NEXT, "DREGX" },
42
- { NODE_DREGX_ONCE, NEN_LIT, NEN_CFLAG, NEN_NEXT, "DREGX_ONCE" },
39
+ { NODE_DREGX, NEN_LIT, NEN_NEXT, NEN_CFLAG, "DREGX" },
40
+ { NODE_DREGX_ONCE, NEN_LIT, NEN_NEXT, NEN_CFLAG, "DREGX_ONCE" },
43
41
  { NODE_DSTR, NEN_LIT, NEN_NEXT, NEN_NONE, "DSTR" },
44
42
  { NODE_DSYM, NEN_LIT, NEN_NEXT, NEN_NONE, "DSYM" },
45
43
  { NODE_DVAR, NEN_VID, NEN_NONE, NEN_NONE, "DVAR" },
@@ -47,10 +45,9 @@ Node_Type_Descrip node_type_descrips_unsorted[] = {
47
45
  { NODE_ENSURE, NEN_HEAD, NEN_ENSR, NEN_NONE, "ENSURE" },
48
46
  { NODE_EVSTR, NEN_BODY, NEN_NONE, NEN_NONE, "EVSTR" },
49
47
  { NODE_FALSE, NEN_NONE, NEN_NONE, NEN_NONE, "FALSE" },
50
- { NODE_FBODY, NEN_BODY, NEN_CNT, NEN_OID, "FBODY" },
51
48
  { NODE_FCALL, NEN_ARGS, NEN_MID, NEN_NONE, "FCALL" },
52
- { NODE_FLIP2, NEN_BEG, NEN_END, NEN_CNT, "FLIP2" },
53
- { NODE_FLIP3, NEN_BEG, NEN_END, NEN_CNT, "FLIP3" },
49
+ { NODE_FLIP2, NEN_CNT, NEN_BEG, NEN_END, "FLIP2" },
50
+ { NODE_FLIP3, NEN_CNT, NEN_BEG, NEN_END, "FLIP3" },
54
51
  { NODE_FOR, NEN_BODY, NEN_ITER, NEN_VAR, "FOR" },
55
52
  { NODE_GASGN, NEN_VALUE, NEN_VID, NEN_ENTRY, "GASGN" },
56
53
  { NODE_GVAR, NEN_VID, NEN_ENTRY, NEN_NONE, "GVAR" },
@@ -65,25 +62,24 @@ Node_Type_Descrip node_type_descrips_unsorted[] = {
65
62
  { NODE_LVAR, NEN_VID, NEN_CNT, NEN_NONE, "LVAR" },
66
63
  { NODE_MASGN, NEN_ARGS, NEN_HEAD, NEN_VALUE, "MASGN" },
67
64
  { NODE_MATCH, NEN_LIT, NEN_VALUE, NEN_NONE, "MATCH" },
68
- { NODE_MATCH2, NEN_VALUE, NEN_RECV, NEN_NONE, "MATCH2" },
69
- { NODE_MATCH3, NEN_VALUE, NEN_RECV, NEN_NONE, "MATCH3" },
65
+ { NODE_MATCH2, NEN_RECV, NEN_VALUE, NEN_NONE, "MATCH2" },
66
+ { NODE_MATCH3, NEN_RECV, NEN_VALUE, NEN_NONE, "MATCH3" },
70
67
  { NODE_MEMO, NEN_NONE, NEN_NONE, NEN_NONE, "MEMO" },
71
- { NODE_METHOD, NEN_BODY, NEN_CLSS, NEN_NOEX, "METHOD" },
72
68
  { NODE_MODULE, NEN_CPATH, NEN_BODY, NEN_NONE, "MODULE" },
73
69
  { NODE_NEXT, NEN_STTS, NEN_NONE, NEN_NONE, "NEXT" },
74
70
  { NODE_NIL, NEN_NONE, NEN_NONE, NEN_NONE, "NIL" },
75
71
  { NODE_NTH_REF, NEN_NTH, NEN_CNT, NEN_NONE, "NTH_REF" },
76
72
  { NODE_OPT_N, NEN_BODY, NEN_NONE, NEN_NONE, "OPT_N" },
77
73
  { NODE_OP_ASGN1, NEN_ARGS, NEN_MID, NEN_RECV, "OP_ASGN1" },
78
- { NODE_OP_ASGN2, NEN_VALUE, NEN_NEXT, NEN_RECV, "OP_ASGN2" },
74
+ { NODE_OP_ASGN2, NEN_RECV, NEN_NEXT, NEN_VALUE, "OP_ASGN2" },
79
75
  { NODE_OP_ASGN2_ARG, NEN_VID, NEN_AID, NEN_MID, "OP_ASGN2_ARG" },
80
- { NODE_OP_ASGN_AND, NEN_VALUE, NEN_RECV, NEN_NONE, "OP_ASGN_AND" },
76
+ { NODE_OP_ASGN_AND, NEN_RECV, NEN_VALUE, NEN_NONE, "OP_ASGN_AND" },
81
77
  { NODE_OP_ASGN_OR, NEN_AID, NEN_VALUE, NEN_RECV, "OP_ASGN_OR" },
82
- { NODE_OR, NEN_1ST, NEN_2ND, NEN_NONE, "OR" },
78
+ { NODE_OR, NEN_2ND, NEN_1ST, NEN_NONE, "OR" },
83
79
  { NODE_POSTEXE, NEN_NONE, NEN_NONE, NEN_NONE, "POSTEXE" },
84
80
  { NODE_REDO, NEN_NONE, NEN_NONE, NEN_NONE, "REDO" },
85
- { NODE_RESBODY, NEN_HEAD, NEN_ARGS, NEN_BODY, "RESBODY" },
86
- { NODE_RESCUE, NEN_HEAD, NEN_ELSE, NEN_RESQ, "RESCUE" },
81
+ { NODE_RESBODY, NEN_HEAD, NEN_BODY, NEN_ARGS, "RESBODY" },
82
+ { NODE_RESCUE, NEN_HEAD, NEN_RESQ, NEN_ELSE, "RESCUE" },
87
83
  { NODE_RETRY, NEN_NONE, NEN_NONE, NEN_NONE, "RETRY" },
88
84
  { NODE_RETURN, NEN_STTS, NEN_NONE, NEN_NONE, "RETURN" },
89
85
  { NODE_SCLASS, NEN_BODY, NEN_RECV, NEN_NONE, "SCLASS" },
@@ -3,6 +3,7 @@
3
3
 
4
4
  Node_Type_Descrip node_type_descrips_unsorted[] = {
5
5
  #ruby <<END
6
+ $: << '.' # TODO: hack
6
7
  require 'node_type_descrip'
7
8
  NODE_TYPE_DESCRIPS.each do |descrip|
8
9
  name = descrip.name
@@ -228,7 +228,7 @@ VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash)
228
228
  else
229
229
  {
230
230
  path = rb_class_path(klass);
231
- if(STR2CSTR(path)[0] == '#')
231
+ if(StringValuePtr(path)[0] == '#')
232
232
  {
233
233
  rb_raise(rb_eArgError, "cannot dump anonymous class");
234
234
  }
@@ -322,7 +322,7 @@ VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash)
322
322
  else
323
323
  {
324
324
  path = rb_class_path(klass);
325
- if(STR2CSTR(path)[0] == '#')
325
+ if(StringValuePtr(path)[0] == '#')
326
326
  {
327
327
  rb_raise(rb_eArgError, "cannot dump anonymous class");
328
328
  }
@@ -521,7 +521,7 @@ VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash)
521
521
  else
522
522
  {
523
523
  path = rb_class_path(klass);
524
- if(STR2CSTR(path)[0] == '#')
524
+ if(StringValuePtr(path)[0] == '#')
525
525
  {
526
526
  rb_raise(rb_eArgError, "cannot dump anonymous class");
527
527
  }
@@ -658,7 +658,7 @@ VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash)
658
658
  else
659
659
  {
660
660
  path = rb_class_path(klass);
661
- if(STR2CSTR(path)[0] == '#')
661
+ if(StringValuePtr(path)[0] == '#')
662
662
  {
663
663
  rb_raise(rb_eArgError, "cannot dump anonymous class");
664
664
  }
@@ -872,7 +872,7 @@ VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash)
872
872
  else
873
873
  {
874
874
  path = rb_class_path(klass);
875
- if(STR2CSTR(path)[0] == '#')
875
+ if(StringValuePtr(path)[0] == '#')
876
876
  {
877
877
  rb_raise(rb_eArgError, "cannot dump anonymous class");
878
878
  }
@@ -1131,20 +1131,23 @@ void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash,
1131
1131
  }
1132
1132
  case NEN_CLSS:
1133
1133
  {
1134
+ int flags;
1134
1135
  Check_Type(v, T_ARRAY);
1135
1136
  if(RARRAY_LEN(v) != 2)
1136
1137
  {
1137
1138
  rb_raise(rb_eArgError, "wrong size for array");
1138
1139
  }
1139
- int flags = NUM2INT(RARRAY_PTR(v)[0]);
1140
+ flags = NUM2INT(RARRAY_PTR(v)[0]);
1140
1141
  switch(flags & T_MASK)
1141
1142
  {
1142
1143
  case T_CLASS:
1143
1144
  case T_MODULE:
1144
1145
  {
1145
- VALUE str = RARRAY_PTR(v)[1];
1146
+ VALUE str, klass;
1147
+
1148
+ str = RARRAY_PTR(v)[1];
1146
1149
  Check_Type(str, T_STRING);
1147
- VALUE klass = rb_path2class(STR2CSTR(str));
1150
+ klass = rb_path2class(StringValuePtr(str));
1148
1151
  if(flags & FL_SINGLETON)
1149
1152
  {
1150
1153
  *(VALUE *)(&n->nd_clss) =
@@ -1220,20 +1223,23 @@ void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash,
1220
1223
  }
1221
1224
  case NEN_CVAL:
1222
1225
  {
1226
+ int flags;
1223
1227
  Check_Type(v, T_ARRAY);
1224
1228
  if(RARRAY_LEN(v) != 2)
1225
1229
  {
1226
1230
  rb_raise(rb_eArgError, "wrong size for array");
1227
1231
  }
1228
- int flags = NUM2INT(RARRAY_PTR(v)[0]);
1232
+ flags = NUM2INT(RARRAY_PTR(v)[0]);
1229
1233
  switch(flags & T_MASK)
1230
1234
  {
1231
1235
  case T_CLASS:
1232
1236
  case T_MODULE:
1233
1237
  {
1234
- VALUE str = RARRAY_PTR(v)[1];
1238
+ VALUE str, klass;
1239
+
1240
+ str = RARRAY_PTR(v)[1];
1235
1241
  Check_Type(str, T_STRING);
1236
- VALUE klass = rb_path2class(STR2CSTR(str));
1242
+ klass = rb_path2class(StringValuePtr(str));
1237
1243
  if(flags & FL_SINGLETON)
1238
1244
  {
1239
1245
  *(VALUE *)(&n->nd_cval) =
@@ -1414,20 +1420,23 @@ void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash,
1414
1420
  }
1415
1421
  case NEN_LIT:
1416
1422
  {
1423
+ int flags;
1417
1424
  Check_Type(v, T_ARRAY);
1418
1425
  if(RARRAY_LEN(v) != 2)
1419
1426
  {
1420
1427
  rb_raise(rb_eArgError, "wrong size for array");
1421
1428
  }
1422
- int flags = NUM2INT(RARRAY_PTR(v)[0]);
1429
+ flags = NUM2INT(RARRAY_PTR(v)[0]);
1423
1430
  switch(flags & T_MASK)
1424
1431
  {
1425
1432
  case T_CLASS:
1426
1433
  case T_MODULE:
1427
1434
  {
1428
- VALUE str = RARRAY_PTR(v)[1];
1435
+ VALUE str, klass;
1436
+
1437
+ str = RARRAY_PTR(v)[1];
1429
1438
  Check_Type(str, T_STRING);
1430
- VALUE klass = rb_path2class(STR2CSTR(str));
1439
+ klass = rb_path2class(StringValuePtr(str));
1431
1440
  if(flags & FL_SINGLETON)
1432
1441
  {
1433
1442
  *(VALUE *)(&n->nd_lit) =
@@ -1556,20 +1565,23 @@ void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash,
1556
1565
  }
1557
1566
  case NEN_ORIG:
1558
1567
  {
1568
+ int flags;
1559
1569
  Check_Type(v, T_ARRAY);
1560
1570
  if(RARRAY_LEN(v) != 2)
1561
1571
  {
1562
1572
  rb_raise(rb_eArgError, "wrong size for array");
1563
1573
  }
1564
- int flags = NUM2INT(RARRAY_PTR(v)[0]);
1574
+ flags = NUM2INT(RARRAY_PTR(v)[0]);
1565
1575
  switch(flags & T_MASK)
1566
1576
  {
1567
1577
  case T_CLASS:
1568
1578
  case T_MODULE:
1569
1579
  {
1570
- VALUE str = RARRAY_PTR(v)[1];
1580
+ VALUE str, klass;
1581
+
1582
+ str = RARRAY_PTR(v)[1];
1571
1583
  Check_Type(str, T_STRING);
1572
- VALUE klass = rb_path2class(STR2CSTR(str));
1584
+ klass = rb_path2class(StringValuePtr(str));
1573
1585
  if(flags & FL_SINGLETON)
1574
1586
  {
1575
1587
  *(VALUE *)(&n->nd_orig) =
@@ -1808,20 +1820,23 @@ void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash,
1808
1820
  }
1809
1821
  case NEN_TVAL:
1810
1822
  {
1823
+ int flags;
1811
1824
  Check_Type(v, T_ARRAY);
1812
1825
  if(RARRAY_LEN(v) != 2)
1813
1826
  {
1814
1827
  rb_raise(rb_eArgError, "wrong size for array");
1815
1828
  }
1816
- int flags = NUM2INT(RARRAY_PTR(v)[0]);
1829
+ flags = NUM2INT(RARRAY_PTR(v)[0]);
1817
1830
  switch(flags & T_MASK)
1818
1831
  {
1819
1832
  case T_CLASS:
1820
1833
  case T_MODULE:
1821
1834
  {
1822
- VALUE str = RARRAY_PTR(v)[1];
1835
+ VALUE str, klass;
1836
+
1837
+ str = RARRAY_PTR(v)[1];
1823
1838
  Check_Type(str, T_STRING);
1824
- VALUE klass = rb_path2class(STR2CSTR(str));
1839
+ klass = rb_path2class(StringValuePtr(str));
1825
1840
  if(flags & FL_SINGLETON)
1826
1841
  {
1827
1842
  *(VALUE *)(&n->nd_tval) =
@@ -2000,16 +2015,6 @@ static VALUE node_alen(VALUE self)
2000
2015
  Data_Get_Struct(self, NODE, n);
2001
2016
  return LONG2NUM(n->nd_alen);
2002
2017
  }
2003
- /*
2004
- * Return the Node's _argc_ member. The return type is an
2005
- * Integer.
2006
- */
2007
- static VALUE node_argc(VALUE self)
2008
- {
2009
- NODE * n;
2010
- Data_Get_Struct(self, NODE, n);
2011
- return LONG2NUM(n->nd_argc);
2012
- }
2013
2018
  /*
2014
2019
  * Return the Node's _args_ member. The return type is
2015
2020
  * either a Node or an Object.
@@ -2107,33 +2112,6 @@ static VALUE node_cfnc(VALUE self)
2107
2112
  Data_Get_Struct(self, NODE, n);
2108
2113
  return LONG2NUM((long)(n->nd_cfnc));
2109
2114
  }
2110
- /*
2111
- * Return the Node's _clss_ member. The return type is
2112
- * either a Node or an Object.
2113
- */
2114
- static VALUE node_clss(VALUE self)
2115
- {
2116
- NODE * n;
2117
- Data_Get_Struct(self, NODE, n);
2118
-
2119
- if(TYPE(n->nd_clss) == T_NODE)
2120
- {
2121
- if(0 && nd_type(n) == NODE_OP_ASGN2)
2122
- {
2123
- return wrap_node_as(
2124
- (NODE *)n->nd_clss,
2125
- rb_cNodeSubclass[NODE_OP_ASGN2_ARG]);
2126
- }
2127
- else
2128
- {
2129
- return wrap_node((NODE *)n->nd_clss);
2130
- }
2131
- }
2132
- else
2133
- {
2134
- return (VALUE)n->nd_clss;
2135
- }
2136
- }
2137
2115
  /*
2138
2116
  * Return the Node's _cnt_ member. The return type is an
2139
2117
  * Integer.
@@ -2499,27 +2477,6 @@ static VALUE node_nth(VALUE self)
2499
2477
  Data_Get_Struct(self, NODE, n);
2500
2478
  return LONG2NUM(n->nd_nth);
2501
2479
  }
2502
- /*
2503
- * Return the Node's _oid_ member. The return type is a
2504
- * Symbol.
2505
- */
2506
- static VALUE node_oid(VALUE self)
2507
- {
2508
- NODE * n;
2509
- Data_Get_Struct(self, NODE, n);
2510
- if(n->nd_oid == 0)
2511
- {
2512
- return Qfalse;
2513
- }
2514
- else if(n->nd_oid == 1)
2515
- {
2516
- return Qtrue;
2517
- }
2518
- else
2519
- {
2520
- return ID2SYM(n->nd_oid);
2521
- }
2522
- }
2523
2480
  /*
2524
2481
  * Return the Node's _opt_ member. The return type is
2525
2482
  * either a Node or an Object.
@@ -2921,17 +2878,17 @@ void define_node_subclass_methods()
2921
2878
  rb_iv_set(rb_cAND, "__type__", INT2NUM(NODE_AND));
2922
2879
  rb_define_singleton_method(rb_cAND, "members", node_s_members, 0);
2923
2880
 
2924
- /* Document-method: first
2925
- * the expression on the left hand side
2926
- */
2927
- rb_define_method(rb_cAND, "first", node_1st, 0);
2928
- rb_ary_push(members, rb_str_new2("first"));
2929
-
2930
2881
  /* Document-method: second
2931
2882
  * the expression on the right hand side
2932
2883
  */
2933
2884
  rb_define_method(rb_cAND, "second", node_2nd, 0);
2934
2885
  rb_ary_push(members, rb_str_new2("second"));
2886
+
2887
+ /* Document-method: first
2888
+ * the expression on the left hand side
2889
+ */
2890
+ rb_define_method(rb_cAND, "first", node_1st, 0);
2891
+ rb_ary_push(members, rb_str_new2("first"));
2935
2892
  }
2936
2893
 
2937
2894
  /* Document-class: Node::ARGS
@@ -3028,14 +2985,14 @@ void define_node_subclass_methods()
3028
2985
  rb_iv_set(rb_cARRAY, "__member__", members);
3029
2986
  rb_iv_set(rb_cARRAY, "__type__", INT2NUM(NODE_ARRAY));
3030
2987
  rb_define_singleton_method(rb_cARRAY, "members", node_s_members, 0);
2988
+ rb_define_method(rb_cARRAY, "alen", node_alen, 0);
2989
+ rb_ary_push(members, rb_str_new2("alen"));
3031
2990
 
3032
2991
  /* Document-method: head
3033
2992
  * the first element of the array
3034
2993
  */
3035
2994
  rb_define_method(rb_cARRAY, "head", node_head, 0);
3036
2995
  rb_ary_push(members, rb_str_new2("head"));
3037
- rb_define_method(rb_cARRAY, "alen", node_alen, 0);
3038
- rb_ary_push(members, rb_str_new2("alen"));
3039
2996
 
3040
2997
  /* Document-method: next
3041
2998
  * the tail of the array
@@ -3058,6 +3015,12 @@ void define_node_subclass_methods()
3058
3015
  rb_iv_set(rb_cATTRASGN, "__type__", INT2NUM(NODE_ATTRASGN));
3059
3016
  rb_define_singleton_method(rb_cATTRASGN, "members", node_s_members, 0);
3060
3017
 
3018
+ /* Document-method: recv
3019
+ * the receiver of the method
3020
+ */
3021
+ rb_define_method(rb_cATTRASGN, "recv", node_recv, 0);
3022
+ rb_ary_push(members, rb_str_new2("recv"));
3023
+
3061
3024
  /* Document-method: args
3062
3025
  * the arguments to the method
3063
3026
  */
@@ -3069,33 +3032,6 @@ void define_node_subclass_methods()
3069
3032
  */
3070
3033
  rb_define_method(rb_cATTRASGN, "mid", node_mid, 0);
3071
3034
  rb_ary_push(members, rb_str_new2("mid"));
3072
-
3073
- /* Document-method: recv
3074
- * the receiver of the method
3075
- */
3076
- rb_define_method(rb_cATTRASGN, "recv", node_recv, 0);
3077
- rb_ary_push(members, rb_str_new2("recv"));
3078
- }
3079
-
3080
- /* Document-class: Node::ATTRSET
3081
- * A placeholder for an attribute writer method, which can added to a
3082
- * class by using attr_writer:
3083
- * attr_writer :attribute
3084
- * Its reader counterpart is IVAR.
3085
- */
3086
- {
3087
- VALUE rb_cATTRSET = rb_define_class_under(rb_cNode, "ATTRSET", rb_cNode);
3088
- members = rb_ary_new();
3089
- rb_cNodeSubclass[NODE_ATTRSET] = rb_cATTRSET;
3090
- rb_iv_set(rb_cATTRSET, "__member__", members);
3091
- rb_iv_set(rb_cATTRSET, "__type__", INT2NUM(NODE_ATTRSET));
3092
- rb_define_singleton_method(rb_cATTRSET, "members", node_s_members, 0);
3093
-
3094
- /* Document-method: vid
3095
- * the name of the attribute, with a leading '@' sign
3096
- */
3097
- rb_define_method(rb_cATTRSET, "vid", node_vid, 0);
3098
- rb_ary_push(members, rb_str_new2("vid"));
3099
3035
  }
3100
3036
 
3101
3037
  /* Document-class: Node::BACK_REF
@@ -3355,22 +3291,6 @@ void define_node_subclass_methods()
3355
3291
  rb_ary_push(members, rb_str_new2("vid"));
3356
3292
  }
3357
3293
 
3358
- /* Document-class: Node::CFUNC
3359
- * A placeholder for a function implemented in C.
3360
- */
3361
- {
3362
- VALUE rb_cCFUNC = rb_define_class_under(rb_cNode, "CFUNC", rb_cNode);
3363
- members = rb_ary_new();
3364
- rb_cNodeSubclass[NODE_CFUNC] = rb_cCFUNC;
3365
- rb_iv_set(rb_cCFUNC, "__member__", members);
3366
- rb_iv_set(rb_cCFUNC, "__type__", INT2NUM(NODE_CFUNC));
3367
- rb_define_singleton_method(rb_cCFUNC, "members", node_s_members, 0);
3368
- rb_define_method(rb_cCFUNC, "cfnc", node_cfnc, 0);
3369
- rb_ary_push(members, rb_str_new2("cfnc"));
3370
- rb_define_method(rb_cCFUNC, "argc", node_argc, 0);
3371
- rb_ary_push(members, rb_str_new2("argc"));
3372
- }
3373
-
3374
3294
  /* Document-class: Node::CLASS
3375
3295
  * Represents a class definition, e.g.:
3376
3296
  * class cpath
@@ -3395,6 +3315,13 @@ void define_node_subclass_methods()
3395
3315
  rb_iv_set(rb_cCLASS, "__type__", INT2NUM(NODE_CLASS));
3396
3316
  rb_define_singleton_method(rb_cCLASS, "members", node_s_members, 0);
3397
3317
 
3318
+ /* Document-method: super
3319
+ * an expression returning the base class, or false if there is no
3320
+ * base class specified
3321
+ */
3322
+ rb_define_method(rb_cCLASS, "super", node_super, 0);
3323
+ rb_ary_push(members, rb_str_new2("super"));
3324
+
3398
3325
  /* Document-method: cpath
3399
3326
  * the name of the class to define
3400
3327
  */
@@ -3406,13 +3333,6 @@ void define_node_subclass_methods()
3406
3333
  */
3407
3334
  rb_define_method(rb_cCLASS, "body", node_body, 0);
3408
3335
  rb_ary_push(members, rb_str_new2("body"));
3409
-
3410
- /* Document-method: super
3411
- * an expression returning the base class, or false if there is no
3412
- * base class specified
3413
- */
3414
- rb_define_method(rb_cCLASS, "super", node_super, 0);
3415
- rb_ary_push(members, rb_str_new2("super"));
3416
3336
  }
3417
3337
 
3418
3338
  /* Document-class: Node::COLON2
@@ -3681,17 +3601,17 @@ void define_node_subclass_methods()
3681
3601
  rb_define_method(rb_cDEFS, "defn", node_defn, 0);
3682
3602
  rb_ary_push(members, rb_str_new2("defn"));
3683
3603
 
3684
- /* Document-method: mid
3685
- * the name of the method* defn the body of the method
3686
- */
3687
- rb_define_method(rb_cDEFS, "mid", node_mid, 0);
3688
- rb_ary_push(members, rb_str_new2("mid"));
3689
-
3690
3604
  /* Document-method: recv
3691
3605
  * the object to whose singleton class the new method is to be added
3692
3606
  */
3693
3607
  rb_define_method(rb_cDEFS, "recv", node_recv, 0);
3694
3608
  rb_ary_push(members, rb_str_new2("recv"));
3609
+
3610
+ /* Document-method: mid
3611
+ * the name of the method* defn the body of the method
3612
+ */
3613
+ rb_define_method(rb_cDEFS, "mid", node_mid, 0);
3614
+ rb_ary_push(members, rb_str_new2("mid"));
3695
3615
  }
3696
3616
 
3697
3617
  /* Document-class: Node::DOT2
@@ -3772,6 +3692,12 @@ void define_node_subclass_methods()
3772
3692
  rb_define_method(rb_cDREGX, "lit", node_lit, 0);
3773
3693
  rb_ary_push(members, rb_str_new2("lit"));
3774
3694
 
3695
+ /* Document-method: next
3696
+ * a list of expressions to be appended onto the string
3697
+ */
3698
+ rb_define_method(rb_cDREGX, "next", node_next, 0);
3699
+ rb_ary_push(members, rb_str_new2("next"));
3700
+
3775
3701
  /* Document-method: cflag
3776
3702
  * a bitfield containing the options used in the regular
3777
3703
  * expression. Valid values include:
@@ -3788,12 +3714,6 @@ void define_node_subclass_methods()
3788
3714
  */
3789
3715
  rb_define_method(rb_cDREGX, "cflag", node_cflag, 0);
3790
3716
  rb_ary_push(members, rb_str_new2("cflag"));
3791
-
3792
- /* Document-method: next
3793
- * a list of expressions to be appended onto the string
3794
- */
3795
- rb_define_method(rb_cDREGX, "next", node_next, 0);
3796
- rb_ary_push(members, rb_str_new2("next"));
3797
3717
  }
3798
3718
 
3799
3719
  /* Document-class: Node::DREGX_ONCE
@@ -3815,18 +3735,18 @@ void define_node_subclass_methods()
3815
3735
  rb_define_method(rb_cDREGX_ONCE, "lit", node_lit, 0);
3816
3736
  rb_ary_push(members, rb_str_new2("lit"));
3817
3737
 
3738
+ /* Document-method: next
3739
+ * a list of expressions to be appended onto the string
3740
+ */
3741
+ rb_define_method(rb_cDREGX_ONCE, "next", node_next, 0);
3742
+ rb_ary_push(members, rb_str_new2("next"));
3743
+
3818
3744
  /* Document-method: cflag
3819
3745
  * a bitfield containing the options used in the regular
3820
3746
  * expression. See DREGX for a list of valid values.
3821
3747
  */
3822
3748
  rb_define_method(rb_cDREGX_ONCE, "cflag", node_cflag, 0);
3823
3749
  rb_ary_push(members, rb_str_new2("cflag"));
3824
-
3825
- /* Document-method: next
3826
- * a list of expressions to be appended onto the string
3827
- */
3828
- rb_define_method(rb_cDREGX_ONCE, "next", node_next, 0);
3829
- rb_ary_push(members, rb_str_new2("next"));
3830
3750
  }
3831
3751
 
3832
3752
  /* Document-class: Node::DSTR
@@ -4003,38 +3923,6 @@ void define_node_subclass_methods()
4003
3923
  rb_define_singleton_method(rb_cFALSE, "members", node_s_members, 0);
4004
3924
  }
4005
3925
 
4006
- /* Document-class: Node::FBODY
4007
- * A placeholder for a method alias, which can be added to a class by
4008
- * using alias or alias_method:
4009
- * alias old new
4010
- */
4011
- {
4012
- VALUE rb_cFBODY = rb_define_class_under(rb_cNode, "FBODY", rb_cNode);
4013
- members = rb_ary_new();
4014
- rb_cNodeSubclass[NODE_FBODY] = rb_cFBODY;
4015
- rb_iv_set(rb_cFBODY, "__member__", members);
4016
- rb_iv_set(rb_cFBODY, "__type__", INT2NUM(NODE_FBODY));
4017
- rb_define_singleton_method(rb_cFBODY, "members", node_s_members, 0);
4018
-
4019
- /* Document-method: body
4020
- * the method body
4021
- */
4022
- rb_define_method(rb_cFBODY, "body", node_body, 0);
4023
- rb_ary_push(members, rb_str_new2("body"));
4024
-
4025
- /* Document-method: cnt
4026
- * the method's flags
4027
- */
4028
- rb_define_method(rb_cFBODY, "cnt", node_cnt, 0);
4029
- rb_ary_push(members, rb_str_new2("cnt"));
4030
-
4031
- /* Document-method: oid
4032
- * the original name of the method
4033
- */
4034
- rb_define_method(rb_cFBODY, "oid", node_oid, 0);
4035
- rb_ary_push(members, rb_str_new2("oid"));
4036
- }
4037
-
4038
3926
  /* Document-class: Node::FCALL
4039
3927
  * Represents a method call in the form:
4040
3928
  * mid(args).
@@ -4077,6 +3965,13 @@ void define_node_subclass_methods()
4077
3965
  rb_iv_set(rb_cFLIP2, "__type__", INT2NUM(NODE_FLIP2));
4078
3966
  rb_define_singleton_method(rb_cFLIP2, "members", node_s_members, 0);
4079
3967
 
3968
+ /* Document-method: cnt
3969
+ * the index into the local variable table of the special variable
3970
+ * to use in the flip-flop expression (usually 2 for $_)
3971
+ */
3972
+ rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0);
3973
+ rb_ary_push(members, rb_str_new2("cnt"));
3974
+
4080
3975
  /* Document-method: beg
4081
3976
  * the beginning of the range
4082
3977
  */
@@ -4088,13 +3983,6 @@ void define_node_subclass_methods()
4088
3983
  */
4089
3984
  rb_define_method(rb_cFLIP2, "end", node_end, 0);
4090
3985
  rb_ary_push(members, rb_str_new2("end"));
4091
-
4092
- /* Document-method: cnt
4093
- * the index into the local variable table of the special variable
4094
- * to use in the flip-flop expression (usually 2 for $_)
4095
- */
4096
- rb_define_method(rb_cFLIP2, "cnt", node_cnt, 0);
4097
- rb_ary_push(members, rb_str_new2("cnt"));
4098
3986
  }
4099
3987
 
4100
3988
  /* Document-class: Node::FLIP3
@@ -4111,6 +3999,13 @@ void define_node_subclass_methods()
4111
3999
  rb_iv_set(rb_cFLIP3, "__type__", INT2NUM(NODE_FLIP3));
4112
4000
  rb_define_singleton_method(rb_cFLIP3, "members", node_s_members, 0);
4113
4001
 
4002
+ /* Document-method: cnt
4003
+ * the index into the local variable table of the special variable
4004
+ * to use in the flip-flop expression (usually 2 for $_)
4005
+ */
4006
+ rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0);
4007
+ rb_ary_push(members, rb_str_new2("cnt"));
4008
+
4114
4009
  /* Document-method: beg
4115
4010
  * the beginning of the range
4116
4011
  */
@@ -4122,13 +4017,6 @@ void define_node_subclass_methods()
4122
4017
  */
4123
4018
  rb_define_method(rb_cFLIP3, "end", node_end, 0);
4124
4019
  rb_ary_push(members, rb_str_new2("end"));
4125
-
4126
- /* Document-method: cnt
4127
- * the index into the local variable table of the special variable
4128
- * to use in the flip-flop expression (usually 2 for $_)
4129
- */
4130
- rb_define_method(rb_cFLIP3, "cnt", node_cnt, 0);
4131
- rb_ary_push(members, rb_str_new2("cnt"));
4132
4020
  }
4133
4021
 
4134
4022
  /* Document-class: Node::FOR
@@ -4563,6 +4451,13 @@ void define_node_subclass_methods()
4563
4451
  rb_iv_set(rb_cMATCH2, "__type__", INT2NUM(NODE_MATCH2));
4564
4452
  rb_define_singleton_method(rb_cMATCH2, "members", node_s_members, 0);
4565
4453
 
4454
+ /* Document-method: recv
4455
+ * the regular expression on the left hand side of the match
4456
+ * operator
4457
+ */
4458
+ rb_define_method(rb_cMATCH2, "recv", node_recv, 0);
4459
+ rb_ary_push(members, rb_str_new2("recv"));
4460
+
4566
4461
  /* Document-method: value
4567
4462
  * the expression on the right hand side of the match operator, or
4568
4463
  * an expression returning $_ if there is nothing on the right hand
@@ -4570,13 +4465,6 @@ void define_node_subclass_methods()
4570
4465
  */
4571
4466
  rb_define_method(rb_cMATCH2, "value", node_value, 0);
4572
4467
  rb_ary_push(members, rb_str_new2("value"));
4573
-
4574
- /* Document-method: recv
4575
- * the regular expression on the left hand side of the match
4576
- * operator
4577
- */
4578
- rb_define_method(rb_cMATCH2, "recv", node_recv, 0);
4579
- rb_ary_push(members, rb_str_new2("recv"));
4580
4468
  }
4581
4469
 
4582
4470
  /* Document-class: Node::MATCH3
@@ -4594,17 +4482,17 @@ void define_node_subclass_methods()
4594
4482
  rb_iv_set(rb_cMATCH3, "__type__", INT2NUM(NODE_MATCH3));
4595
4483
  rb_define_singleton_method(rb_cMATCH3, "members", node_s_members, 0);
4596
4484
 
4597
- /* Document-method: value
4598
- * the right hand side of the match
4599
- */
4600
- rb_define_method(rb_cMATCH3, "value", node_value, 0);
4601
- rb_ary_push(members, rb_str_new2("value"));
4602
-
4603
4485
  /* Document-method: recv
4604
4486
  * the left hand side of the match
4605
4487
  */
4606
4488
  rb_define_method(rb_cMATCH3, "recv", node_recv, 0);
4607
4489
  rb_ary_push(members, rb_str_new2("recv"));
4490
+
4491
+ /* Document-method: value
4492
+ * the right hand side of the match
4493
+ */
4494
+ rb_define_method(rb_cMATCH3, "value", node_value, 0);
4495
+ rb_ary_push(members, rb_str_new2("value"));
4608
4496
  }
4609
4497
 
4610
4498
  /* Document-class: Node::MEMO
@@ -4630,42 +4518,6 @@ void define_node_subclass_methods()
4630
4518
  rb_define_singleton_method(rb_cMEMO, "members", node_s_members, 0);
4631
4519
  }
4632
4520
 
4633
- /* Document-class: Node::METHOD
4634
- * A placeholder for a method entry in a class's method table.
4635
- *
4636
- * On ruby 1.9 this node type is also known as RUBY_VM_METHOD_NODE.
4637
- * Its use differs from that of NODE_METHOD in that it is used as the
4638
- * body of another METHOD node and is used to store the method's
4639
- * instruction sequence.
4640
- */
4641
- {
4642
- VALUE rb_cMETHOD = rb_define_class_under(rb_cNode, "METHOD", rb_cNode);
4643
- members = rb_ary_new();
4644
- rb_cNodeSubclass[NODE_METHOD] = rb_cMETHOD;
4645
- rb_iv_set(rb_cMETHOD, "__member__", members);
4646
- rb_iv_set(rb_cMETHOD, "__type__", INT2NUM(NODE_METHOD));
4647
- rb_define_singleton_method(rb_cMETHOD, "members", node_s_members, 0);
4648
-
4649
- /* Document-method: body
4650
- * the body of the method
4651
- */
4652
- rb_define_method(rb_cMETHOD, "body", node_body, 0);
4653
- rb_ary_push(members, rb_str_new2("body"));
4654
-
4655
- /* Document-method: clss
4656
- * the class to which the method was added or the instruction
4657
- * sequence used to implement this method
4658
- */
4659
- rb_define_method(rb_cMETHOD, "clss", node_clss, 0);
4660
- rb_ary_push(members, rb_str_new2("clss"));
4661
-
4662
- /* Document-method: noex
4663
- * the method's flags
4664
- */
4665
- rb_define_method(rb_cMETHOD, "noex", node_noex, 0);
4666
- rb_ary_push(members, rb_str_new2("noex"));
4667
- }
4668
-
4669
4521
  /* Document-class: Node::MODULE
4670
4522
  * Represents a module definition, e.g.:
4671
4523
  * module cpath
@@ -4840,11 +4692,11 @@ void define_node_subclass_methods()
4840
4692
  rb_iv_set(rb_cOP_ASGN2, "__type__", INT2NUM(NODE_OP_ASGN2));
4841
4693
  rb_define_singleton_method(rb_cOP_ASGN2, "members", node_s_members, 0);
4842
4694
 
4843
- /* Document-method: value
4844
- * the value to assign to the attribute
4695
+ /* Document-method: recv
4696
+ * the receiver of the attribute
4845
4697
  */
4846
- rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
4847
- rb_ary_push(members, rb_str_new2("value"));
4698
+ rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0);
4699
+ rb_ary_push(members, rb_str_new2("recv"));
4848
4700
 
4849
4701
  /* Document-method: next
4850
4702
  * another node of type OP_ASGN2 which contains more information
@@ -4853,11 +4705,11 @@ void define_node_subclass_methods()
4853
4705
  rb_define_method(rb_cOP_ASGN2, "next", node_next, 0);
4854
4706
  rb_ary_push(members, rb_str_new2("next"));
4855
4707
 
4856
- /* Document-method: recv
4857
- * the receiver of the attribute
4708
+ /* Document-method: value
4709
+ * the value to assign to the attribute
4858
4710
  */
4859
- rb_define_method(rb_cOP_ASGN2, "recv", node_recv, 0);
4860
- rb_ary_push(members, rb_str_new2("recv"));
4711
+ rb_define_method(rb_cOP_ASGN2, "value", node_value, 0);
4712
+ rb_ary_push(members, rb_str_new2("value"));
4861
4713
  }
4862
4714
 
4863
4715
  /* Document-class: Node::OP_ASGN2_ARG
@@ -4910,18 +4762,18 @@ void define_node_subclass_methods()
4910
4762
  rb_iv_set(rb_cOP_ASGN_AND, "__type__", INT2NUM(NODE_OP_ASGN_AND));
4911
4763
  rb_define_singleton_method(rb_cOP_ASGN_AND, "members", node_s_members, 0);
4912
4764
 
4765
+ /* Document-method: recv
4766
+ * an expression representing the left hand side of the assignment
4767
+ */
4768
+ rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0);
4769
+ rb_ary_push(members, rb_str_new2("recv"));
4770
+
4913
4771
  /* Document-method: value
4914
4772
  * an expression representing the assignment that should be
4915
4773
  * performed if the left hand side is true
4916
4774
  */
4917
4775
  rb_define_method(rb_cOP_ASGN_AND, "value", node_value, 0);
4918
4776
  rb_ary_push(members, rb_str_new2("value"));
4919
-
4920
- /* Document-method: recv
4921
- * an expression representing the left hand side of the assignment
4922
- */
4923
- rb_define_method(rb_cOP_ASGN_AND, "recv", node_recv, 0);
4924
- rb_ary_push(members, rb_str_new2("recv"));
4925
4777
  }
4926
4778
 
4927
4779
  /* Document-class: Node::OP_ASGN_OR
@@ -4976,17 +4828,17 @@ void define_node_subclass_methods()
4976
4828
  rb_iv_set(rb_cOR, "__type__", INT2NUM(NODE_OR));
4977
4829
  rb_define_singleton_method(rb_cOR, "members", node_s_members, 0);
4978
4830
 
4979
- /* Document-method: first
4980
- * the expression on the left hand side
4981
- */
4982
- rb_define_method(rb_cOR, "first", node_1st, 0);
4983
- rb_ary_push(members, rb_str_new2("first"));
4984
-
4985
4831
  /* Document-method: second
4986
4832
  * the expression on the right hand side
4987
4833
  */
4988
4834
  rb_define_method(rb_cOR, "second", node_2nd, 0);
4989
4835
  rb_ary_push(members, rb_str_new2("second"));
4836
+
4837
+ /* Document-method: first
4838
+ * the expression on the left hand side
4839
+ */
4840
+ rb_define_method(rb_cOR, "first", node_1st, 0);
4841
+ rb_ary_push(members, rb_str_new2("first"));
4990
4842
  }
4991
4843
 
4992
4844
  /* Document-class: Node::POSTEXE
@@ -5044,17 +4896,17 @@ void define_node_subclass_methods()
5044
4896
  rb_define_method(rb_cRESBODY, "head", node_head, 0);
5045
4897
  rb_ary_push(members, rb_str_new2("head"));
5046
4898
 
5047
- /* Document-method: args
5048
- * the expression type to match against
5049
- */
5050
- rb_define_method(rb_cRESBODY, "args", node_args, 0);
5051
- rb_ary_push(members, rb_str_new2("args"));
5052
-
5053
4899
  /* Document-method: body
5054
4900
  * the expresion to evaluate if the exception type matches
5055
4901
  */
5056
4902
  rb_define_method(rb_cRESBODY, "body", node_body, 0);
5057
4903
  rb_ary_push(members, rb_str_new2("body"));
4904
+
4905
+ /* Document-method: args
4906
+ * the expression type to match against
4907
+ */
4908
+ rb_define_method(rb_cRESBODY, "args", node_args, 0);
4909
+ rb_ary_push(members, rb_str_new2("args"));
5058
4910
  }
5059
4911
 
5060
4912
  /* Document-class: Node::RESCUE
@@ -5100,17 +4952,17 @@ void define_node_subclass_methods()
5100
4952
  rb_define_method(rb_cRESCUE, "head", node_head, 0);
5101
4953
  rb_ary_push(members, rb_str_new2("head"));
5102
4954
 
5103
- /* Document-method: else
5104
- * the expression to be evaluated if no exception is raised
5105
- */
5106
- rb_define_method(rb_cRESCUE, "else", node_else, 0);
5107
- rb_ary_push(members, rb_str_new2("else"));
5108
-
5109
4955
  /* Document-method: resq
5110
4956
  * the expression to be evaluated if an exception is raised
5111
4957
  */
5112
4958
  rb_define_method(rb_cRESCUE, "resq", node_resq, 0);
5113
4959
  rb_ary_push(members, rb_str_new2("resq"));
4960
+
4961
+ /* Document-method: else
4962
+ * the expression to be evaluated if no exception is raised
4963
+ */
4964
+ rb_define_method(rb_cRESCUE, "else", node_else, 0);
4965
+ rb_ary_push(members, rb_str_new2("else"));
5114
4966
  }
5115
4967
 
5116
4968
  /* Document-class: Node::RETRY