ruby-internal 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #! /home/cout/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
2
2
 
3
3
  require 'pp'
4
4
  require 'internal/node/pp'
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #! /home/cout/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
2
2
 
3
3
  require 'internal/node/obfusc'
4
4
 
@@ -1,8 +1,12 @@
1
1
  $: << '../..'
2
2
  require 'mkmf-ruby-internal'
3
3
 
4
+ ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i
5
+ $CPPFLAGS << " -DRUBY_VERSION_CODE=#{ruby_version_code}"
6
+
4
7
  have_var('rb_cMethod', 'ruby.h')
5
8
  have_var('rb_cUnboundMethod', 'ruby.h')
6
9
  have_header('ruby/node.h') or have_header('node.h')
10
+ have_type('struct RTypedData')
7
11
 
8
12
  create_ruby_internal_makefile 'internal/method/method'
@@ -0,0 +1,65 @@
1
+ #ifndef ruby_internal_method__h_
2
+ #define ruby_internal_method__h_
3
+
4
+ #include <ruby.h>
5
+
6
+ #ifdef RUBY_VM
7
+ #include "method.h"
8
+ #endif
9
+
10
+ #include "internal/node/ruby_internal_node.h"
11
+
12
+ #ifndef FALSE
13
+ #define FALSE 0
14
+ #endif
15
+
16
+ #ifndef TRUE
17
+ #define TRUE (!FALSE)
18
+ #endif
19
+
20
+ struct METHOD {
21
+ VALUE recv;
22
+ VALUE rclass;
23
+ ID id;
24
+ rb_method_entry_t me;
25
+ };
26
+
27
+ static void
28
+ bm_mark(void *ptr)
29
+ {
30
+ struct METHOD *data = ptr;
31
+ rb_gc_mark(data->rclass);
32
+ rb_gc_mark(data->recv);
33
+ rb_mark_method_entry(&data->me);
34
+ }
35
+
36
+ static void
37
+ bm_free(void *ptr)
38
+ {
39
+ struct METHOD *data = ptr;
40
+ rb_method_definition_t *def = data->me.def;
41
+ if (def->alias_count == 0)
42
+ xfree(def);
43
+ else if (def->alias_count > 0)
44
+ def->alias_count--;
45
+ xfree(ptr);
46
+ }
47
+
48
+ static size_t
49
+ bm_memsize(const void *ptr)
50
+ {
51
+ return ptr ? sizeof(struct METHOD) : 0;
52
+ }
53
+
54
+ static const rb_data_type_t method_data_type = {
55
+ "method",
56
+ bm_mark,
57
+ bm_free,
58
+ bm_memsize,
59
+ };
60
+
61
+ #define METHOD_OCLASS(m) m->klass
62
+ #define METHOD_RCLASS(m) m->rclass
63
+
64
+ #endif
65
+
@@ -3,8 +3,20 @@
3
3
 
4
4
  #include <ruby.h>
5
5
 
6
+ #ifdef RUBY_VM
7
+ #include "method.h"
8
+ #endif
9
+
6
10
  #include "internal/node/ruby_internal_node.h"
7
11
 
12
+ #ifndef FALSE
13
+ #define FALSE 0
14
+ #endif
15
+
16
+ #ifndef TRUE
17
+ #define TRUE (!FALSE)
18
+ #endif
19
+
8
20
  #ruby <<END
9
21
  $: << '../..'
10
22
  require 'ruby_source_dir'
@@ -20,11 +32,19 @@
20
32
  File.open(file) do |eval_c|
21
33
  write = false
22
34
  stopwrite = false
35
+ prev_line = nil
23
36
  while (line = eval_c.gets) != nil do
24
37
  case line
25
38
  when /^struct (METHOD)/
26
39
  write = true
27
40
  stopwrite = false
41
+ when /rb_data_type_t method_data_type = {/
42
+ write = true
43
+ stopwrite = false
44
+ when /^(bm_mark|bm_free|bm_memsize)/
45
+ puts prev_line
46
+ write = true
47
+ stopwrite = false
28
48
  when /^\}/
29
49
  stopwrite = true
30
50
  when /VALUE oclass/
@@ -42,6 +62,7 @@
42
62
  write = false
43
63
  puts ''
44
64
  end
65
+ prev_line = line
45
66
  end
46
67
  end
47
68
  end
@@ -1,6 +1,6 @@
1
1
  #include <ruby.h>
2
2
  #include "internal/node/ruby_internal_node.h"
3
- #include "method.h"
3
+ #include "internal_method.h"
4
4
 
5
5
  #ifdef RUBY_VM
6
6
  #include "vm_core.h"
@@ -22,6 +22,14 @@ static VALUE rb_cUnboundMethod = Qnil;
22
22
  #define RARRAY_PTR(a) RARRAY(a)->ptr
23
23
  #endif
24
24
 
25
+ #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
26
+ # define UNWRAP_METHOD(method, m) \
27
+ TypedData_Get_Struct(method, struct METHOD, &method_data_type, m);
28
+ #else
29
+ # define UNWRAP_METHOD(method, m) \
30
+ Data_Get_Struct(method, struct METHOD, m)
31
+ #endif
32
+
25
33
  static VALUE rb_mMarshal;
26
34
 
27
35
  static VALUE marshal_dump(VALUE obj, VALUE limit)
@@ -58,7 +66,7 @@ static VALUE lookup_module_proc = Qnil;
58
66
  static VALUE method_receiver(VALUE method)
59
67
  {
60
68
  struct METHOD * m;
61
- Data_Get_Struct(method, struct METHOD, m);
69
+ UNWRAP_METHOD(method, m);
62
70
  return m->recv;
63
71
  }
64
72
 
@@ -74,7 +82,7 @@ static VALUE method_receiver(VALUE method)
74
82
  static VALUE method_id(VALUE method)
75
83
  {
76
84
  struct METHOD * m;
77
- Data_Get_Struct(method, struct METHOD, m);
85
+ UNWRAP_METHOD(method, m);
78
86
  return ID2SYM(m->id);
79
87
  }
80
88
 
@@ -90,8 +98,14 @@ static VALUE method_id(VALUE method)
90
98
  static VALUE method_oid(VALUE method)
91
99
  {
92
100
  struct METHOD * m;
93
- Data_Get_Struct(method, struct METHOD, m);
101
+ UNWRAP_METHOD(method, m);
102
+ #if RUBY_VERSION_CODE >= 193
103
+ return ID2SYM(m->me->def->original_id);
104
+ #elif RUBY_VERSION_CODE >= 192
105
+ return ID2SYM(m->me.def->original_id);
106
+ #else
94
107
  return ID2SYM(m->oid);
108
+ #endif
95
109
  }
96
110
 
97
111
  /*
@@ -106,8 +120,14 @@ static VALUE method_oid(VALUE method)
106
120
  static VALUE method_origin_class(VALUE method)
107
121
  {
108
122
  struct METHOD * m;
109
- Data_Get_Struct(method, struct METHOD, m);
123
+ UNWRAP_METHOD(method, m);
124
+ #if RUBY_VERSION_CODE >= 193
125
+ return m->me->klass;
126
+ #elif RUBY_VERSION_CODE >= 192
127
+ return m->me.klass;
128
+ #else
110
129
  return METHOD_OCLASS(m);
130
+ #endif
111
131
  }
112
132
 
113
133
  /*
@@ -119,7 +139,7 @@ static VALUE method_origin_class(VALUE method)
119
139
  static VALUE method_attached_class(VALUE method)
120
140
  {
121
141
  struct METHOD * m;
122
- Data_Get_Struct(method, struct METHOD, m);
142
+ UNWRAP_METHOD(method, m);
123
143
  return CLASS_OF(m->recv);
124
144
  }
125
145
 
@@ -139,8 +159,14 @@ static VALUE method_body(VALUE method)
139
159
  /* no access to potentially sensitive data from the sandbox */
140
160
  rb_raise(rb_eSecurityError, "Insecure: can't get method body");
141
161
  }
142
- Data_Get_Struct(method, struct METHOD, m);
162
+ UNWRAP_METHOD(method, m);
163
+ #if RUBY_VERSION_CODE >= 193
164
+ return m->me->def->body.iseq->self; /* TODO: body is a union; is this right? */
165
+ #elif RUBY_VERSION_CODE >= 192
166
+ return m->me.def->body.iseq->self; /* TODO: body is a union; is this right? */
167
+ #else
143
168
  return wrap_node(m->body);
169
+ #endif
144
170
  }
145
171
 
146
172
  /*
@@ -165,9 +191,17 @@ static VALUE method_dump(VALUE self, VALUE limit)
165
191
  }
166
192
 
167
193
  arr = rb_ary_new();
168
- Data_Get_Struct(self, struct METHOD, method);
194
+ UNWRAP_METHOD(self, method);
195
+ #if RUBY_VERSION_CODE >= 193
196
+ rb_ary_push(arr, rb_mod_name(method->me->klass));
197
+ rb_ary_push(arr, Qnil); /* TODO */
198
+ #elif RUBY_VERSION_CODE >= 192
199
+ rb_ary_push(arr, rb_mod_name(method->me.klass));
200
+ rb_ary_push(arr, Qnil); /* TODO */
201
+ #else
169
202
  rb_ary_push(arr, rb_mod_name(METHOD_OCLASS(method)));
170
203
  rb_ary_push(arr, rb_mod_name(METHOD_RCLASS(method)));
204
+ #endif
171
205
  if(rb_class_of(self) == rb_cUnboundMethod)
172
206
  {
173
207
  rb_ary_push(arr, Qnil);
@@ -177,7 +211,13 @@ static VALUE method_dump(VALUE self, VALUE limit)
177
211
  rb_ary_push(arr, method->recv);
178
212
  }
179
213
  rb_ary_push(arr, ID2SYM(method->id));
214
+ #if RUBY_VERSION_CODE >= 193
215
+ rb_ary_push(arr, ID2SYM(method->me->def->original_id));
216
+ #elif RUBY_VERSION_CODE >= 192
217
+ rb_ary_push(arr, ID2SYM(method->me.def->original_id));
218
+ #else
180
219
  rb_ary_push(arr, ID2SYM(method->oid));
220
+ #endif
181
221
  rb_ary_push(arr, method_body(self));
182
222
 
183
223
  return marshal_dump(arr, limit);
@@ -194,7 +234,6 @@ static VALUE method_load(VALUE klass, VALUE str)
194
234
  struct METHOD * method;
195
235
  VALUE rarr = marshal_load(str);
196
236
  VALUE * arr;
197
- NODE * n;
198
237
  VALUE retval;
199
238
 
200
239
  if( rb_safe_level() >= 4
@@ -213,17 +252,32 @@ static VALUE method_load(VALUE klass, VALUE str)
213
252
  /* Create a METHOD object -- doesn't matter which method we use */
214
253
  retval = rb_funcall(
215
254
  rb_cObject, rb_intern("method"), 1, ID2SYM(rb_intern("__id__")));
216
- Data_Get_Struct(retval, struct METHOD, method);
255
+ UNWRAP_METHOD(retval, method);
217
256
  arr = RARRAY_PTR(rarr);
257
+ #if RUBY_VERSION_CODE >= 193
258
+ method->me->klass =
259
+ rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[0]);
260
+ method->me->def->original_id = SYM2ID(arr[4]);
261
+ GetISeqPtr(arr[5], method->me->def->body.iseq);
262
+ #elif RUBY_VERSION_CODE >= 192
263
+ method->me.klass =
264
+ rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[0]);
265
+ method->me.def->original_id = SYM2ID(arr[4]);
266
+ GetISeqPtr(arr[5], method->me.def->body.iseq);
267
+ #else
218
268
  METHOD_OCLASS(method) =
219
269
  rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[0]);
220
270
  METHOD_RCLASS(method) =
221
271
  rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[1]);
272
+ method->oid = SYM2ID(arr[4]);
273
+ {
274
+ NODE * n;
275
+ Data_Get_Struct(arr[5], NODE, n);
276
+ method->body = n;
277
+ }
278
+ #endif
222
279
  method->recv = arr[2];
223
280
  method->id = SYM2ID(arr[3]);
224
- method->oid = SYM2ID(arr[4]);
225
- Data_Get_Struct(arr[5], NODE, n);
226
- method->body = n;
227
281
 
228
282
  if(klass == rb_cUnboundMethod)
229
283
  {
@@ -243,6 +297,8 @@ void Init_method(void)
243
297
  #ifndef HAVE_RB_CMETHOD
244
298
  rb_cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
245
299
  #endif
300
+
301
+ /* TODO: ruby 1.9 has this function but not 1.8 */
246
302
  rb_define_method(rb_cMethod, "receiver", method_receiver, 0);
247
303
 
248
304
  /* For rdoc: rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject) */
@@ -4,37 +4,35 @@ VALUE
4
4
  class2path(VALUE klass)
5
5
  {
6
6
  VALUE path = rb_class_path(klass);
7
- char *n = RSTRING_PTR(path);
7
+ const char *n;
8
8
 
9
- if (n[0] == '#') {
10
- rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
11
- (TYPE(klass) == T_CLASS ? "class" : "module"),
12
- n);
13
- }
14
- if (rb_path2class(n) != rb_class_real(klass)) {
15
- rb_raise(rb_eTypeError, "%s can't be referred", n);
9
+ n = must_not_be_anonymous((TYPE(klass) == T_CLASS ? "class" : "module"), path);
10
+ if (rb_path_to_class(path) != rb_class_real(klass)) {
11
+ rb_raise(rb_eTypeError, "%s can't be referred to", n);
16
12
  }
17
13
  return path;
18
14
  }
19
15
 
20
16
  VALUE
21
- path2class(const char *path)
17
+ path2class(VALUE path)
22
18
  {
23
- VALUE v = rb_path2class(path);
19
+ VALUE v = rb_path_to_class(path);
24
20
 
25
21
  if (TYPE(v) != T_CLASS) {
26
- rb_raise(rb_eArgError, "%s does not refer class", path);
22
+ rb_raise(rb_eArgError, "%.*s does not refer to class",
23
+ (int)RSTRING_LEN(path), RSTRING_PTR(path));
27
24
  }
28
25
  return v;
29
26
  }
30
27
 
31
28
  VALUE
32
- path2module(const char *path)
29
+ path2module(VALUE path)
33
30
  {
34
- VALUE v = rb_path2class(path);
31
+ VALUE v = rb_path_to_class(path);
35
32
 
36
33
  if (TYPE(v) != T_MODULE) {
37
- rb_raise(rb_eArgError, "%s does not refer module", path);
34
+ rb_raise(rb_eArgError, "%.*s does not refer to module",
35
+ (int)RSTRING_LEN(path), RSTRING_PTR(path));
38
36
  }
39
37
  return v;
40
38
  }
@@ -1,9 +1,10 @@
1
1
  $: << '../..'
2
2
  require 'mkmf-ruby-internal'
3
3
 
4
- have_func('vm_get_ruby_level_cfp', 'cfp.h')
5
- have_func('rb_vm_get_ruby_level_next_cfp', 'cfp.h')
4
+ have_func('vm_get_ruby_level_cfp', [ 'cfp.h', 'vm_core.h' ])
5
+ have_func('rb_vm_get_ruby_level_next_cfp', [ 'cfp.h', 'vm_core.h' ])
6
6
  have_header('ruby/node.h') or have_header('node.h')
7
+ have_struct_member('struct RClass', 'iv_index_tbl')
7
8
 
8
9
  ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i
9
10
  $CPPFLAGS << " -DRUBY_VERSION_CODE=#{ruby_version_code}"
@@ -16,7 +16,11 @@
16
16
  #endif
17
17
 
18
18
  #ifndef RCLASS_IV_TBL
19
- #define RCLASS_IV_TBL(c) RCLASS(c)->iv_tbl
19
+ # ifdef HAVE_STRUCT_RCLASS_IV_INDEX_TBL
20
+ # define RCLASS_IV_TBL(c) RCLASS(c)->iv_index_tbl
21
+ # else
22
+ # define RCLASS_IV_TBL(c) RCLASS(c)->iv_tbl
23
+ # endif
20
24
  #endif
21
25
 
22
26
  #ifndef RCLASS_M_TBL
@@ -214,7 +218,7 @@ static VALUE included_modules_list(VALUE module)
214
218
  {
215
219
  VALUE included_modules = rb_mod_included_modules(module);
216
220
  VALUE included_module_list = rb_ary_new();
217
- size_t j;
221
+ long j;
218
222
 
219
223
  for(j = 0; j < RARRAY_LEN(included_modules); ++j)
220
224
  {
@@ -391,7 +395,9 @@ static VALUE module_add_method(VALUE klass, VALUE id, VALUE node, VALUE noex)
391
395
  rb_raise(rb_eSecurityError, "Insecure: can't add method");
392
396
  }
393
397
 
394
- #ifdef RUBY_VM
398
+ #if RUBY_VERSION_CODE >= 192
399
+ rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
400
+ #elif RUBY_VERSION_CODE >= 190
395
401
  if(rb_obj_is_kind_of(node, rb_cISeq))
396
402
  {
397
403
  rb_iseq_t *iseqdat = iseq_check(node);
@@ -415,7 +421,9 @@ static VALUE module_add_method(VALUE klass, VALUE id, VALUE node, VALUE noex)
415
421
 
416
422
  Data_Get_Struct(node, NODE, n);
417
423
 
418
- #ifdef RUBY_VM
424
+ #if RUBY_VERSION_CODE >= 192
425
+ rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
426
+ #elif RUBY_VERSION_CODE >= 190
419
427
  if(nd_type(n) != NODE_METHOD)
420
428
  {
421
429
  rb_raise(
@@ -424,19 +432,26 @@ static VALUE module_add_method(VALUE klass, VALUE id, VALUE node, VALUE noex)
424
432
  rb_class2name(CLASS_OF(n)));
425
433
  }
426
434
 
427
- rb_iseq_t *iseqdat = iseq_check((VALUE)n->nd_body);
428
- set_cref_stack(iseqdat, klass, noex);
429
- iseqdat->klass = klass;
430
- iseqdat->defined_method_id = SYM2ID(id);
431
- n = NEW_METHOD(iseqdat->self, klass, NUM2INT(noex));
435
+ {
436
+ rb_iseq_t *iseqdat = iseq_check((VALUE)n->nd_body);
437
+ set_cref_stack(iseqdat, klass, noex);
438
+ iseqdat->klass = klass;
439
+ iseqdat->defined_method_id = SYM2ID(id);
440
+ n = NEW_METHOD(iseqdat->self, klass, NUM2INT(noex));
441
+ }
432
442
 
433
443
  add_node:
434
444
  #endif
445
+
446
+ #if RUBY_VERSION_CODE >= 192
447
+ rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
448
+ #else
435
449
  /* TODO: if noex is NOEX_MODFUNC, add this method as a module function
436
450
  * (that is, both as an instance and singleton method)
437
451
  */
438
452
  rb_add_method(klass, SYM2ID(id), n, NUM2INT(noex));
439
453
  return Qnil;
454
+ #endif
440
455
  }
441
456
 
442
457
  /*
@@ -609,9 +624,9 @@ static VALUE module_dump(VALUE self, VALUE limit)
609
624
  return str;
610
625
  }
611
626
 
612
- static void include_modules(module, included_modules)
627
+ static void include_modules(VALUE module, VALUE included_modules)
613
628
  {
614
- size_t j;
629
+ long j;
615
630
  VALUE v;
616
631
  VALUE name;
617
632
 
@@ -636,7 +651,11 @@ static int add_method_iter(VALUE name, VALUE value, VALUE module)
636
651
  rb_class2name(CLASS_OF(value)));
637
652
  }
638
653
  Data_Get_Struct(value, NODE, n);
654
+ #if RUBY_VERSION_CODE >= 192
655
+ rb_raise(rb_eRuntimeError, "NOT SUPPORTED");
656
+ #elif RUBY_VERSION_CODE >= 190
639
657
  rb_add_method(module, SYM2ID(name), n->nd_body, n->nd_noex);
658
+ #endif
640
659
  return ST_CONTINUE;
641
660
  }
642
661
 
@@ -775,10 +794,12 @@ void Init_module(void)
775
794
  rb_global_variable(&module_name_proc);
776
795
 
777
796
  #if RUBY_VERSION_CODE >= 180
778
- VALUE rb_mNodewrap = rb_define_module("Nodewrap");
779
- rb_cClass_Restorer = rb_define_class_under(rb_mNodewrap, "ClassRestorer", rb_cObject);
780
- rb_define_method(rb_cClass_Restorer, "_dump", class_restorer_dump, 1);
781
- rb_define_singleton_method(rb_cClass_Restorer, "_load", class_restorer_load, 1);
797
+ {
798
+ VALUE rb_mNodewrap = rb_define_module("Nodewrap");
799
+ rb_cClass_Restorer = rb_define_class_under(rb_mNodewrap, "ClassRestorer", rb_cObject);
800
+ rb_define_method(rb_cClass_Restorer, "_dump", class_restorer_dump, 1);
801
+ rb_define_singleton_method(rb_cClass_Restorer, "_load", class_restorer_load, 1);
802
+ }
782
803
  #endif
783
804
 
784
805
  #if RUBY_VERSION_CODE == 180