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.
Files changed (90) hide show
  1. data/README +204 -6
  2. data/ext/cached/ruby-1.6.8/internal/binding/block.h +35 -0
  3. data/ext/cached/ruby-1.6.8/internal/method/method.h +19 -0
  4. data/ext/cached/ruby-1.6.8/internal/module/classpath.c +3 -0
  5. data/ext/cached/ruby-1.6.8/internal/module/classpath.h +8 -0
  6. data/ext/cached/ruby-1.6.8/internal/node/block.h +35 -0
  7. data/ext/cached/ruby-1.6.8/internal/node/global_entry.h +15 -0
  8. data/ext/cached/ruby-1.6.8/internal/node/node_type_descrip.c +149 -0
  9. data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.c +5582 -0
  10. data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.h +69 -0
  11. data/ext/cached/ruby-1.6.8/internal/proc/block.h +35 -0
  12. data/ext/cached/ruby-1.6.8/internal/tag/tag.h +15 -0
  13. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.c +39 -0
  14. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.h +21 -0
  15. data/ext/cached/ruby-1.6.8/internal/vm/iseq/insns_info.inc +12 -0
  16. data/ext/cached/ruby-1.6.8/internal/vm/iseq/iseq_load.inc +9 -0
  17. data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +91 -91
  18. data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +1909 -1909
  19. data/ext/cached/ruby-1.8.0/internal/vm/iseq/iseq_load.inc +9 -0
  20. data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +90 -90
  21. data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +1946 -1946
  22. data/ext/cached/ruby-1.8.1/internal/vm/iseq/iseq_load.inc +9 -0
  23. data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +90 -90
  24. data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +1946 -1946
  25. data/ext/cached/ruby-1.8.2/internal/vm/iseq/iseq_load.inc +9 -0
  26. data/ext/cached/ruby-1.8.3/internal/node/node_type_descrip.c +90 -90
  27. data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +1946 -1946
  28. data/ext/cached/ruby-1.8.3/internal/vm/iseq/iseq_load.inc +9 -0
  29. data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +90 -90
  30. data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +1946 -1946
  31. data/ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc +9 -0
  32. data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +90 -90
  33. data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +1909 -1909
  34. data/ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc +9 -0
  35. data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +90 -90
  36. data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +1909 -1909
  37. data/ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc +9 -0
  38. data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +90 -90
  39. data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +1909 -1909
  40. data/ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc +9 -0
  41. data/ext/cached/ruby-1.9.0/internal/node/node_type_descrip.c +85 -85
  42. data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.c +1800 -1800
  43. data/ext/cached/ruby-1.9.0/internal/vm/iseq/iseq_load.inc +13 -0
  44. data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +51 -51
  45. data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +85 -85
  46. data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +1800 -1800
  47. data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.h +1 -2
  48. data/ext/cached/ruby-1.9.1/internal/vm/iseq/iseq_load.inc +356 -0
  49. data/ext/cached/ruby-1.9.1/internal/yarv-headers/eval_intern.h +15 -9
  50. data/ext/cached/ruby-1.9.1/internal/yarv-headers/id.h +45 -66
  51. data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +12 -3
  52. data/ext/cached/ruby-1.9.1/internal/yarv-headers/node.h +2 -2
  53. data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +23 -138
  54. data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -1
  55. data/ext/cached/ruby-1.9.1/internal/yarv-headers/transcode_data.h +9 -2
  56. data/ext/cached/ruby-1.9.1/internal/yarv-headers/transdb.h +62 -0
  57. data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +17 -23
  58. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +20 -29
  59. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_exec.h +4 -7
  60. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +6 -5
  61. data/ext/internal/module/cfp.h +13 -0
  62. data/ext/internal/module/extconf.rb +2 -2
  63. data/ext/internal/module/module.c +3 -8
  64. data/ext/internal/node/nodes.rb +2 -1
  65. data/ext/internal/vm/iseq/iseq.c +2 -3
  66. data/ext/internal/vm/iseq/iseq_load.inc.rpp +61 -0
  67. data/ext/internal/yarv-headers/debug.h +36 -0
  68. data/ext/internal/yarv-headers/dln.h +41 -0
  69. data/ext/internal/yarv-headers/encdb.h +147 -0
  70. data/ext/internal/yarv-headers/eval_intern.h +215 -0
  71. data/ext/internal/yarv-headers/gc.h +75 -0
  72. data/ext/internal/yarv-headers/id.h +163 -0
  73. data/ext/internal/yarv-headers/iseq.h +103 -0
  74. data/ext/internal/yarv-headers/node.h +516 -0
  75. data/ext/internal/yarv-headers/parse.h +188 -0
  76. data/ext/internal/yarv-headers/regenc.h +207 -0
  77. data/ext/internal/yarv-headers/regint.h +842 -0
  78. data/ext/internal/yarv-headers/regparse.h +351 -0
  79. data/ext/internal/yarv-headers/revision.h +1 -0
  80. data/ext/internal/yarv-headers/thread_pthread.h +24 -0
  81. data/ext/internal/yarv-headers/thread_win32.h +33 -0
  82. data/ext/internal/yarv-headers/transcode_data.h +106 -0
  83. data/ext/internal/yarv-headers/transdb.h +147 -0
  84. data/ext/internal/yarv-headers/version.h +54 -0
  85. data/ext/internal/yarv-headers/vm_core.h +646 -0
  86. data/ext/internal/yarv-headers/vm_exec.h +184 -0
  87. data/ext/internal/yarv-headers/vm_insnhelper.h +195 -0
  88. data/ext/internal/yarv-headers/vm_opts.h +51 -0
  89. data/publish_rdoc.rb +4 -0
  90. metadata +52 -2
@@ -185,10 +185,9 @@ enum ruby_vminsn_type {
185
185
 
186
186
  BIN(answer) = 78,
187
187
 
188
+ VM_INSTRUCTION_SIZE = 79
188
189
  };
189
190
 
190
- #define VM_INSTRUCTION_SIZE 79
191
-
192
191
  /** -*-c-*-
193
192
  This file contains instruction information for yarv instruction sequence.
194
193
 
@@ -0,0 +1,356 @@
1
+ #ifndef ruby_internal_iseq_load__inc_
2
+ #define ruby_internal_iseq_load__inc_
3
+
4
+ #include "internal/yarv-headers/gc.h"
5
+ #include "internal/yarv-headers/iseq.h"
6
+
7
+ static void
8
+ compile_data_free(struct iseq_compile_data *compile_data)
9
+ {
10
+ if (compile_data) {
11
+ struct iseq_compile_data_storage *cur, *next;
12
+ cur = compile_data->storage_head;
13
+ while (cur) {
14
+ next = cur->next;
15
+ ruby_xfree(cur);
16
+ cur = next;
17
+ }
18
+ ruby_xfree(compile_data);
19
+ }
20
+ }
21
+ static void
22
+ iseq_free(void *ptr)
23
+ {
24
+ rb_iseq_t *iseq;
25
+ RUBY_FREE_ENTER("iseq");
26
+
27
+ if (ptr) {
28
+ iseq = ptr;
29
+ if (!iseq->orig) {
30
+ /* It's possible that strings are freed
31
+ * GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
32
+ * RSTRING_PTR(iseq->filename));
33
+ */
34
+ if (iseq->iseq != iseq->iseq_encoded) {
35
+ RUBY_FREE_UNLESS_NULL(iseq->iseq_encoded);
36
+ }
37
+
38
+ RUBY_FREE_UNLESS_NULL(iseq->iseq);
39
+ RUBY_FREE_UNLESS_NULL(iseq->insn_info_table);
40
+ RUBY_FREE_UNLESS_NULL(iseq->local_table);
41
+ RUBY_FREE_UNLESS_NULL(iseq->catch_table);
42
+ RUBY_FREE_UNLESS_NULL(iseq->arg_opt_table);
43
+ compile_data_free(iseq->compile_data);
44
+ }
45
+ ruby_xfree(ptr);
46
+ }
47
+ RUBY_FREE_LEAVE("iseq");
48
+ }
49
+ static void
50
+ iseq_mark(void *ptr)
51
+ {
52
+ rb_iseq_t *iseq;
53
+ RUBY_MARK_ENTER("iseq");
54
+
55
+ if (ptr) {
56
+ iseq = ptr;
57
+ RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
58
+ RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
59
+ RUBY_MARK_UNLESS_NULL(iseq->name);
60
+ RUBY_MARK_UNLESS_NULL(iseq->filename);
61
+ RUBY_MARK_UNLESS_NULL((VALUE)iseq->cref_stack);
62
+ RUBY_MARK_UNLESS_NULL(iseq->klass);
63
+ RUBY_MARK_UNLESS_NULL(iseq->coverage);
64
+ /* RUBY_MARK_UNLESS_NULL((VALUE)iseq->node); */
65
+ /* RUBY_MARK_UNLESS_NULL(iseq->cached_special_block); */
66
+ RUBY_MARK_UNLESS_NULL(iseq->orig);
67
+
68
+ if (iseq->compile_data != 0) {
69
+ RUBY_MARK_UNLESS_NULL(iseq->compile_data->mark_ary);
70
+ RUBY_MARK_UNLESS_NULL(iseq->compile_data->err_info);
71
+ RUBY_MARK_UNLESS_NULL(iseq->compile_data->catch_table_ary);
72
+ }
73
+ }
74
+ RUBY_MARK_LEAVE("iseq");
75
+ }
76
+ static VALUE
77
+ iseq_alloc(VALUE klass)
78
+ {
79
+ VALUE volatile obj;
80
+ rb_iseq_t *iseq;
81
+
82
+ obj = Data_Make_Struct(klass, rb_iseq_t, iseq_mark, iseq_free, iseq);
83
+ MEMZERO(iseq, rb_iseq_t, 1);
84
+ return obj;
85
+ }
86
+ static void
87
+ set_relation(rb_iseq_t *iseq, const VALUE parent)
88
+ {
89
+ const int type = iseq->type;
90
+ rb_thread_t *th = GET_THREAD();
91
+
92
+ /* set class nest stack */
93
+ if (type == ISEQ_TYPE_TOP) {
94
+ /* toplevel is private */
95
+ iseq->cref_stack = NEW_BLOCK(th->top_wrapper ? th->top_wrapper : rb_cObject);
96
+ iseq->cref_stack->nd_file = 0;
97
+ iseq->cref_stack->nd_visi = NOEX_PRIVATE;
98
+ }
99
+ else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
100
+ iseq->cref_stack = NEW_BLOCK(0); /* place holder */
101
+ iseq->cref_stack->nd_file = 0;
102
+ }
103
+ else if (RTEST(parent)) {
104
+ rb_iseq_t *piseq;
105
+ GetISeqPtr(parent, piseq);
106
+ iseq->cref_stack = piseq->cref_stack;
107
+ }
108
+
109
+ if (type == ISEQ_TYPE_TOP ||
110
+ type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
111
+ iseq->local_iseq = iseq;
112
+ }
113
+ else if (RTEST(parent)) {
114
+ rb_iseq_t *piseq;
115
+ GetISeqPtr(parent, piseq);
116
+ iseq->local_iseq = piseq->local_iseq;
117
+ }
118
+
119
+ if (RTEST(parent)) {
120
+ rb_iseq_t *piseq;
121
+ GetISeqPtr(parent, piseq);
122
+ iseq->parent_iseq = piseq;
123
+ }
124
+ }
125
+ static VALUE
126
+ prepare_iseq_build(rb_iseq_t *iseq,
127
+ VALUE name, VALUE filename,
128
+ VALUE parent, VALUE type, VALUE block_opt,
129
+ const rb_compile_option_t *option)
130
+ {
131
+ OBJ_FREEZE(name);
132
+ OBJ_FREEZE(filename);
133
+
134
+ iseq->name = name;
135
+ iseq->filename = filename;
136
+ iseq->defined_method_id = 0;
137
+ iseq->mark_ary = rb_ary_new();
138
+ RBASIC(iseq->mark_ary)->klass = 0;
139
+
140
+ iseq->type = type;
141
+ iseq->arg_rest = -1;
142
+ iseq->arg_block = -1;
143
+ iseq->klass = 0;
144
+
145
+ /*
146
+ * iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
147
+ * iseq->cached_special_block_builder = 0;
148
+ * iseq->cached_special_block = 0;
149
+ */
150
+
151
+ iseq->compile_data = ALLOC(struct iseq_compile_data);
152
+ MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
153
+ iseq->compile_data->mark_ary = rb_ary_new();
154
+ RBASIC(iseq->compile_data->mark_ary)->klass = 0;
155
+
156
+ iseq->compile_data->storage_head = iseq->compile_data->storage_current =
157
+ (struct iseq_compile_data_storage *)
158
+ ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
159
+ sizeof(struct iseq_compile_data_storage));
160
+
161
+ iseq->compile_data->catch_table_ary = rb_ary_new();
162
+ iseq->compile_data->storage_head->pos = 0;
163
+ iseq->compile_data->storage_head->next = 0;
164
+ iseq->compile_data->storage_head->size =
165
+ INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
166
+ iseq->compile_data->storage_head->buff =
167
+ (char *)(&iseq->compile_data->storage_head->buff + 1);
168
+ iseq->compile_data->option = option;
169
+
170
+ set_relation(iseq, parent);
171
+
172
+ iseq->coverage = Qfalse;
173
+ if (!GET_THREAD()->parse_in_eval) {
174
+ extern VALUE rb_get_coverages(void);
175
+ VALUE coverages = rb_get_coverages();
176
+ if (RTEST(coverages)) {
177
+ iseq->coverage = rb_hash_lookup(coverages, filename);
178
+ if (NIL_P(iseq->coverage)) iseq->coverage = Qfalse;
179
+ }
180
+ }
181
+
182
+ return Qtrue;
183
+ }
184
+ static VALUE
185
+ cleanup_iseq_build(rb_iseq_t *iseq)
186
+ {
187
+ struct iseq_compile_data *data = iseq->compile_data;
188
+ VALUE err = data->err_info;
189
+ iseq->compile_data = 0;
190
+ compile_data_free(data);
191
+
192
+ if (RTEST(err)) {
193
+ rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->filename);
194
+ rb_exc_raise(err);
195
+ }
196
+ return Qtrue;
197
+ }
198
+ static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
199
+ OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */
200
+ OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */
201
+ OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */
202
+ OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */
203
+ OPT_OPERANDS_UNIFICATION, /* int operands_unification; */
204
+ OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */
205
+ OPT_STACK_CACHING, /* int stack_caching; */
206
+ OPT_TRACE_INSTRUCTION, /* int trace_instruction */
207
+ };
208
+ static const rb_compile_option_t COMPILE_OPTION_FALSE = {0};
209
+ static void
210
+ make_compile_option(rb_compile_option_t *option, VALUE opt)
211
+ {
212
+ if (opt == Qnil) {
213
+ *option = COMPILE_OPTION_DEFAULT;
214
+ }
215
+ else if (opt == Qfalse) {
216
+ *option = COMPILE_OPTION_FALSE;
217
+ }
218
+ else if (opt == Qtrue) {
219
+ memset(option, 1, sizeof(rb_compile_option_t));
220
+ }
221
+ else if (CLASS_OF(opt) == rb_cHash) {
222
+ *option = COMPILE_OPTION_DEFAULT;
223
+
224
+ #define SET_COMPILE_OPTION(o, h, mem) \
225
+ { VALUE flag = rb_hash_aref(h, ID2SYM(rb_intern(#mem))); \
226
+ if (flag == Qtrue) { o->mem = 1; } \
227
+ else if (flag == Qfalse) { o->mem = 0; } \
228
+ }
229
+ #define SET_COMPILE_OPTION_NUM(o, h, mem) \
230
+ { VALUE num = rb_hash_aref(opt, ID2SYM(rb_intern(#mem))); \
231
+ if (!NIL_P(num)) o->mem = NUM2INT(num); \
232
+ }
233
+ SET_COMPILE_OPTION(option, opt, inline_const_cache);
234
+ SET_COMPILE_OPTION(option, opt, peephole_optimization);
235
+ SET_COMPILE_OPTION(option, opt, tailcall_optimization);
236
+ SET_COMPILE_OPTION(option, opt, specialized_instruction);
237
+ SET_COMPILE_OPTION(option, opt, operands_unification);
238
+ SET_COMPILE_OPTION(option, opt, instructions_unification);
239
+ SET_COMPILE_OPTION(option, opt, stack_caching);
240
+ SET_COMPILE_OPTION(option, opt, trace_instruction);
241
+ SET_COMPILE_OPTION_NUM(option, opt, debug_level);
242
+ #undef SET_COMPILE_OPTION
243
+ #undef SET_COMPILE_OPTION_NUM
244
+ }
245
+ else {
246
+ rb_raise(rb_eTypeError, "Compile option must be Hash/true/false/nil");
247
+ }
248
+ }
249
+ static VALUE
250
+ make_compile_option_value(rb_compile_option_t *option)
251
+ {
252
+ VALUE opt = rb_hash_new();
253
+ #define SET_COMPILE_OPTION(o, h, mem) \
254
+ rb_hash_aset(h, ID2SYM(rb_intern(#mem)), o->mem ? Qtrue : Qfalse)
255
+ #define SET_COMPILE_OPTION_NUM(o, h, mem) \
256
+ rb_hash_aset(h, ID2SYM(rb_intern(#mem)), INT2NUM(o->mem))
257
+ {
258
+ SET_COMPILE_OPTION(option, opt, inline_const_cache);
259
+ SET_COMPILE_OPTION(option, opt, peephole_optimization);
260
+ SET_COMPILE_OPTION(option, opt, tailcall_optimization);
261
+ SET_COMPILE_OPTION(option, opt, specialized_instruction);
262
+ SET_COMPILE_OPTION(option, opt, operands_unification);
263
+ SET_COMPILE_OPTION(option, opt, instructions_unification);
264
+ SET_COMPILE_OPTION(option, opt, stack_caching);
265
+ SET_COMPILE_OPTION_NUM(option, opt, debug_level);
266
+ }
267
+ #undef SET_COMPILE_OPTION
268
+ #undef SET_COMPILE_OPTION_NUM
269
+ return opt;
270
+ }
271
+ #define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary")
272
+ #define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str")
273
+ #define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym")
274
+ static inline VALUE CHECK_INTEGER(VALUE v) {NUM2LONG(v); return v;}
275
+ static VALUE
276
+ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
277
+ {
278
+ VALUE iseqval = iseq_alloc(self);
279
+
280
+ VALUE magic, version1, version2, format_type, misc;
281
+ VALUE name, filename;
282
+ VALUE type, body, locals, args, exception;
283
+
284
+ VALUE iseq_type;
285
+ struct st_table *type_map = 0;
286
+ rb_iseq_t *iseq;
287
+ rb_compile_option_t option;
288
+ int i = 0;
289
+
290
+ /* [magic, major_version, minor_version, format_type, misc,
291
+ * name, filename,
292
+ * type, locals, args, exception_table, body]
293
+ */
294
+
295
+ data = CHECK_ARRAY(data);
296
+
297
+ magic = CHECK_STRING(rb_ary_entry(data, i++));
298
+ version1 = CHECK_INTEGER(rb_ary_entry(data, i++));
299
+ version2 = CHECK_INTEGER(rb_ary_entry(data, i++));
300
+ format_type = CHECK_INTEGER(rb_ary_entry(data, i++));
301
+ misc = rb_ary_entry(data, i++); /* TODO */
302
+
303
+ name = CHECK_STRING(rb_ary_entry(data, i++));
304
+ filename = CHECK_STRING(rb_ary_entry(data, i++));
305
+
306
+ type = CHECK_SYMBOL(rb_ary_entry(data, i++));
307
+ locals = CHECK_ARRAY(rb_ary_entry(data, i++));
308
+
309
+ args = rb_ary_entry(data, i++);
310
+ if (FIXNUM_P(args) || (args = CHECK_ARRAY(args))) {
311
+ /* */
312
+ }
313
+
314
+ exception = CHECK_ARRAY(rb_ary_entry(data, i++));
315
+ body = CHECK_ARRAY(rb_ary_entry(data, i++));
316
+
317
+ GetISeqPtr(iseqval, iseq);
318
+ iseq->self = iseqval;
319
+
320
+ if (type_map == 0) {
321
+ type_map = st_init_numtable();
322
+ st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP);
323
+ st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD);
324
+ st_insert(type_map, ID2SYM(rb_intern("block")), ISEQ_TYPE_BLOCK);
325
+ st_insert(type_map, ID2SYM(rb_intern("class")), ISEQ_TYPE_CLASS);
326
+ st_insert(type_map, ID2SYM(rb_intern("rescue")), ISEQ_TYPE_RESCUE);
327
+ st_insert(type_map, ID2SYM(rb_intern("ensure")), ISEQ_TYPE_ENSURE);
328
+ st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL);
329
+ st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN);
330
+ st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD);
331
+ }
332
+
333
+ if (st_lookup(type_map, type, &iseq_type) == 0) {
334
+ const char *typename = rb_id2name(type);
335
+ if (typename)
336
+ rb_raise(rb_eTypeError, "unsupport type: :%s", typename);
337
+ else
338
+ rb_raise(rb_eTypeError, "unsupport type: %p", (void *)type);
339
+ }
340
+
341
+ if (parent == Qnil) {
342
+ parent = 0;
343
+ }
344
+
345
+ make_compile_option(&option, opt);
346
+ prepare_iseq_build(iseq, name, filename,
347
+ parent, iseq_type, 0, &option);
348
+
349
+ rb_iseq_build_from_ary(iseq, locals, args, exception, body);
350
+
351
+ cleanup_iseq_build(iseq);
352
+ return iseqval;
353
+ }
354
+
355
+ #endif
356
+
@@ -67,7 +67,12 @@ char *strrchr(const char *, const char);
67
67
  #define ruby_setjmp(env) RUBY_SETJMP(env)
68
68
  #define ruby_longjmp(env,val) RUBY_LONGJMP(env,val)
69
69
  #ifdef __CYGWIN__
70
- int _setjmp(), _longjmp();
70
+ # ifndef _setjmp
71
+ int _setjmp(jmp_buf);
72
+ # endif
73
+ # ifndef _longjmp
74
+ NORETURN(void _longjmp(jmp_buf, int));
75
+ # endif
71
76
  #endif
72
77
 
73
78
  #include <sys/types.h>
@@ -162,9 +167,9 @@ enum ruby_tag_type {
162
167
  #define GET_THROWOBJ_CATCH_POINT(obj) ((VALUE*)RNODE((obj))->u2.value)
163
168
  #define GET_THROWOBJ_STATE(obj) ((int)RNODE((obj))->u3.value)
164
169
 
165
- #define SCOPE_TEST(f) (vm_cref()->nd_visi & (f))
166
- #define SCOPE_CHECK(f) (vm_cref()->nd_visi == (f))
167
- #define SCOPE_SET(f) (vm_cref()->nd_visi = (f))
170
+ #define SCOPE_TEST(f) (rb_vm_cref()->nd_visi & (f))
171
+ #define SCOPE_CHECK(f) (rb_vm_cref()->nd_visi == (f))
172
+ #define SCOPE_SET(f) (rb_vm_cref()->nd_visi = (f))
168
173
 
169
174
  #define CHECK_STACK_OVERFLOW(cfp, margin) do \
170
175
  if (((VALUE *)(cfp)->sp) + (margin) + sizeof(rb_control_frame_t) >= ((VALUE *)cfp)) { \
@@ -193,12 +198,13 @@ VALUE rb_make_exception(int argc, VALUE *argv);
193
198
  NORETURN(void rb_fiber_start(void));
194
199
 
195
200
  NORETURN(void rb_print_undef(VALUE, ID, int));
196
- NORETURN(void vm_localjump_error(const char *,VALUE, int));
197
- NORETURN(void vm_jump_tag_but_local_jump(int, VALUE));
201
+ NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
202
+ NORETURN(void rb_vm_jump_tag_but_local_jump(int, VALUE));
203
+ NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, VALUE *argv,
204
+ VALUE obj, int call_status));
198
205
 
199
- VALUE vm_make_jump_tag_but_local_jump(int state, VALUE val);
200
- NODE *vm_cref(void);
201
- rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
206
+ VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
207
+ NODE *rb_vm_cref(void);
202
208
  VALUE rb_obj_is_proc(VALUE);
203
209
  VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
204
210
  void rb_thread_terminate_all(void);
@@ -3,8 +3,8 @@
3
3
 
4
4
  id.h -
5
5
 
6
- $Author: ko1 $
7
- created at: Thu Jul 12 04:38:07 2007
6
+ $Author: nobu $
7
+ created at: Sun Oct 19 21:12:51 2008
8
8
 
9
9
  Copyright (C) 2007 Koichi Sasada
10
10
 
@@ -31,6 +31,10 @@
31
31
  #define symIFUNC ID2SYM(idIFUNC)
32
32
  #define symCFUNC ID2SYM(idCFUNC)
33
33
 
34
+ #if !defined tLAST_TOKEN && defined YYTOKENTYPE
35
+ #define tLAST_TOKEN tLAST_TOKEN
36
+ #endif
37
+
34
38
  enum ruby_method_ids {
35
39
  #ifndef tLAST_TOKEN
36
40
  tUPLUS = 321,
@@ -65,70 +69,6 @@ enum ruby_method_ids {
65
69
  id_core_define_singleton_method = 374,
66
70
  id_core_set_postexe = 375,
67
71
  tLAST_TOKEN = 376,
68
- #elif tUPLUS != 321
69
- #error tUPLUS differs
70
- #elif tUMINUS != 322
71
- #error tUMINUS differs
72
- #elif tPOW != 323
73
- #error tPOW differs
74
- #elif tCMP != 324
75
- #error tCMP differs
76
- #elif tEQ != 325
77
- #error tEQ differs
78
- #elif tEQQ != 326
79
- #error tEQQ differs
80
- #elif tNEQ != 327
81
- #error tNEQ differs
82
- #elif tGEQ != 328
83
- #error tGEQ differs
84
- #elif tLEQ != 329
85
- #error tLEQ differs
86
- #elif tANDOP != 330
87
- #error tANDOP differs
88
- #elif tOROP != 331
89
- #error tOROP differs
90
- #elif tMATCH != 332
91
- #error tMATCH differs
92
- #elif tNMATCH != 333
93
- #error tNMATCH differs
94
- #elif tDOT2 != 334
95
- #error tDOT2 differs
96
- #elif tDOT3 != 335
97
- #error tDOT3 differs
98
- #elif tAREF != 336
99
- #error tAREF differs
100
- #elif tASET != 337
101
- #error tASET differs
102
- #elif tLSHFT != 338
103
- #error tLSHFT differs
104
- #elif tRSHFT != 339
105
- #error tRSHFT differs
106
- #elif tLAMBDA != 352
107
- #error tLAMBDA differs
108
- #elif idNULL != 365
109
- #error idNULL differs
110
- #elif idRespond_to != 366
111
- #error idRespond_to differs
112
- #elif idIFUNC != 367
113
- #error idIFUNC differs
114
- #elif idCFUNC != 368
115
- #error idCFUNC differs
116
- #elif idThrowState != 369
117
- #error idThrowState differs
118
- #elif id_core_set_method_alias != 370
119
- #error id_core_set_method_alias differs
120
- #elif id_core_set_variable_alias != 371
121
- #error id_core_set_variable_alias differs
122
- #elif id_core_undef_method != 372
123
- #error id_core_undef_method differs
124
- #elif id_core_define_method != 373
125
- #error id_core_define_method differs
126
- #elif id_core_define_singleton_method != 374
127
- #error id_core_define_singleton_method differs
128
- #elif id_core_set_postexe != 375
129
- #error id_core_set_postexe differs
130
- #elif tLAST_TOKEN != 376
131
- #error tLAST_TOKEN differs
132
72
  #endif
133
73
  idPLUS = '+',
134
74
  idMINUS = '-',
@@ -181,4 +121,43 @@ enum ruby_method_ids {
181
121
  TOKEN2ID(Initialize)
182
122
  };
183
123
 
124
+ #ifdef tLAST_TOKEN
125
+ struct ruby_method_ids_check {
126
+ #define ruby_method_id_check_for(name, value) \
127
+ int checking_for_##name[name == value ? 1 : -1]
128
+ ruby_method_id_check_for(tUPLUS, 321);
129
+ ruby_method_id_check_for(tUMINUS, 322);
130
+ ruby_method_id_check_for(tPOW, 323);
131
+ ruby_method_id_check_for(tCMP, 324);
132
+ ruby_method_id_check_for(tEQ, 325);
133
+ ruby_method_id_check_for(tEQQ, 326);
134
+ ruby_method_id_check_for(tNEQ, 327);
135
+ ruby_method_id_check_for(tGEQ, 328);
136
+ ruby_method_id_check_for(tLEQ, 329);
137
+ ruby_method_id_check_for(tANDOP, 330);
138
+ ruby_method_id_check_for(tOROP, 331);
139
+ ruby_method_id_check_for(tMATCH, 332);
140
+ ruby_method_id_check_for(tNMATCH, 333);
141
+ ruby_method_id_check_for(tDOT2, 334);
142
+ ruby_method_id_check_for(tDOT3, 335);
143
+ ruby_method_id_check_for(tAREF, 336);
144
+ ruby_method_id_check_for(tASET, 337);
145
+ ruby_method_id_check_for(tLSHFT, 338);
146
+ ruby_method_id_check_for(tRSHFT, 339);
147
+ ruby_method_id_check_for(tLAMBDA, 352);
148
+ ruby_method_id_check_for(idNULL, 365);
149
+ ruby_method_id_check_for(idRespond_to, 366);
150
+ ruby_method_id_check_for(idIFUNC, 367);
151
+ ruby_method_id_check_for(idCFUNC, 368);
152
+ ruby_method_id_check_for(idThrowState, 369);
153
+ ruby_method_id_check_for(id_core_set_method_alias, 370);
154
+ ruby_method_id_check_for(id_core_set_variable_alias, 371);
155
+ ruby_method_id_check_for(id_core_undef_method, 372);
156
+ ruby_method_id_check_for(id_core_define_method, 373);
157
+ ruby_method_id_check_for(id_core_define_singleton_method, 374);
158
+ ruby_method_id_check_for(id_core_set_postexe, 375);
159
+ ruby_method_id_check_for(tLAST_TOKEN, 376);
160
+ };
161
+ #endif
162
+
184
163
  #endif /* RUBY_ID_H */
@@ -2,7 +2,7 @@
2
2
 
3
3
  iseq.h -
4
4
 
5
- $Author: ko1 $
5
+ $Author: yugui $
6
6
  created at: 04/01/01 23:36:57 JST
7
7
 
8
8
  Copyright (C) 2004-2008 Koichi Sasada
@@ -12,7 +12,15 @@
12
12
  #ifndef RUBY_COMPILE_H
13
13
  #define RUBY_COMPILE_H
14
14
 
15
- VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt);
15
+ /* compile.c */
16
+ VALUE rb_iseq_compile_node(VALUE self, NODE *node);
17
+ int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
18
+ VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
19
+ VALUE exception, VALUE body);
20
+
21
+ /* iseq.c */
22
+ VALUE ruby_iseq_load(VALUE data, VALUE parent, VALUE opt);
23
+ struct st_table *ruby_insn_make_insn_table(void);
16
24
 
17
25
  #define ISEQ_TYPE_TOP INT2FIX(1)
18
26
  #define ISEQ_TYPE_METHOD INT2FIX(2)
@@ -21,7 +29,8 @@ VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt);
21
29
  #define ISEQ_TYPE_RESCUE INT2FIX(5)
22
30
  #define ISEQ_TYPE_ENSURE INT2FIX(6)
23
31
  #define ISEQ_TYPE_EVAL INT2FIX(7)
24
- #define ISEQ_TYPE_DEFINED_GUARD INT2FIX(8)
32
+ #define ISEQ_TYPE_MAIN INT2FIX(8)
33
+ #define ISEQ_TYPE_DEFINED_GUARD INT2FIX(9)
25
34
 
26
35
  #define CATCH_TYPE_RESCUE INT2FIX(1)
27
36
  #define CATCH_TYPE_ENSURE INT2FIX(2)
@@ -2,7 +2,7 @@
2
2
 
3
3
  node.h -
4
4
 
5
- $Author: ko1 $
5
+ $Author: yugui $
6
6
  created at: Fri May 28 15:14:02 JST 1993
7
7
 
8
8
  Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -468,7 +468,7 @@ typedef struct RNode {
468
468
 
469
469
  #define NOEX_UNDEF NOEX_NOSUPER
470
470
 
471
- #define NOEX_MODFUNC 0x10
471
+ #define NOEX_MODFUNC 0x12
472
472
  #define NOEX_SUPER 0x20
473
473
  #define NOEX_VCALL 0x40
474
474