ruby-internal 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -226,6 +226,74 @@ static VALUE iseq_arg_opt_table(VALUE self)
226
226
  return ary;
227
227
  }
228
228
 
229
+ #define hidden_obj_p(obj) (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass)
230
+
231
+ static VALUE operand_to_value(VALUE insn, int op_idx, VALUE operand)
232
+ {
233
+ switch(insn_op_type(insn, op_idx))
234
+ {
235
+ case TS_VALUE:
236
+ if (hidden_obj_p(operand)) {
237
+ switch (BUILTIN_TYPE(operand)) {
238
+ case T_STRING:
239
+ operand = rb_str_replace(rb_str_new(0, 0), operand);
240
+ break;
241
+ case T_ARRAY:
242
+ operand = rb_ary_replace(rb_ary_new2(0), operand);
243
+ break;
244
+ }
245
+ }
246
+ return operand;
247
+
248
+ case TS_LINDEX:
249
+ case TS_DINDEX:
250
+ case TS_NUM:
251
+ return INT2FIX(operand);
252
+
253
+ case TS_ISEQ:
254
+ {
255
+ rb_iseq_t * iseq = (rb_iseq_t *)operand;
256
+ if(iseq)
257
+ {
258
+ return iseq->self;
259
+ }
260
+ else
261
+ {
262
+ return Qnil;
263
+ }
264
+ }
265
+
266
+ case TS_GENTRY:
267
+ {
268
+ struct global_entry *entry = (struct global_entry *)operand;
269
+ return ID2SYM(rb_intern(rb_id2name(entry->id)));
270
+ }
271
+
272
+ case TS_OFFSET:
273
+ /* TODO */
274
+ return Qnil;
275
+
276
+ case TS_VARIABLE:
277
+ /* TODO */
278
+ return Qnil;
279
+
280
+ case TS_CDHASH:
281
+ /* TODO */
282
+ return Qnil;
283
+
284
+ case TS_IC:
285
+ {
286
+ NODE * ic = (NODE *)operand;
287
+ return wrap_node_as(ic, rb_cInlineCache);
288
+ }
289
+
290
+ case TS_ID:
291
+ return ID2SYM(operand);
292
+ }
293
+
294
+ rb_raise(rb_eArgError, "Unknown operand type");
295
+ }
296
+
229
297
  /* call-seq:
230
298
  * iseq.each(pc_start=0, &block) => nil
231
299
  *
@@ -253,75 +321,20 @@ static VALUE iseq_each(int argc, VALUE * argv, VALUE self)
253
321
  seq < iseqdat->iseq + iseqdat->iseq_size;
254
322
  )
255
323
  {
256
- VALUE insn = *seq++;
257
- int op_type_idx;
324
+ VALUE insn = *seq;
325
+ int op_idx;
258
326
  int len = insn_len(insn);
259
- VALUE args = rb_ary_new();
327
+ VALUE operands = rb_ary_new();
260
328
 
261
- for(op_type_idx = 0; op_type_idx < len-1; ++op_type_idx, ++seq)
329
+ for(op_idx = 0; op_idx < len-1; ++op_idx)
262
330
  {
263
- switch(insn_op_type(insn, op_type_idx))
264
- {
265
- case TS_VALUE:
266
- rb_ary_push(args, *seq);
267
- break;
268
-
269
- case TS_LINDEX:
270
- case TS_DINDEX:
271
- case TS_NUM:
272
- rb_ary_push(args, INT2FIX(*seq));
273
- break;
274
-
275
- case TS_ISEQ:
276
- {
277
- rb_iseq_t * iseq = (rb_iseq_t *)*seq;
278
- if(iseq)
279
- {
280
- rb_ary_push(args, iseq->self);
281
- }
282
- else
283
- {
284
- rb_ary_push(args, Qnil);
285
- }
286
- break;
287
- }
288
-
289
- case TS_GENTRY:
290
- {
291
- struct global_entry *entry = (struct global_entry *)*seq;
292
- rb_ary_push(args, ID2SYM(rb_intern(rb_id2name(entry->id))));
293
- break;
294
- }
295
-
296
- case TS_OFFSET:
297
- rb_ary_push(args, LONG2NUM(*seq));
298
- /* TODO */
299
- break;
300
-
301
- case TS_VARIABLE:
302
- rb_ary_push(args, Qnil);
303
- /* TODO */
304
- break;
305
-
306
- case TS_CDHASH:
307
- rb_ary_push(args, Qnil);
308
- /* TODO */
309
- break;
310
-
311
- case TS_IC:
312
- {
313
- NODE * ic = (NODE *)*seq;
314
- rb_ary_push(args, wrap_node_as(ic, rb_cInlineCache));
315
- break;
316
- }
317
-
318
- case TS_ID:
319
- rb_ary_push(args, ID2SYM(*seq));
320
- break;
321
- }
331
+ VALUE operand = seq[op_idx + 1];
332
+ rb_ary_push(operands, operand_to_value(insn, op_idx, operand));
322
333
  }
323
334
 
324
- rb_yield(allocate_instruction(insn, args));
335
+ rb_yield(allocate_instruction(insn, operands));
336
+
337
+ seq += len;
325
338
  }
326
339
 
327
340
  return Qnil;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-internal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Brannan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-06 00:00:00 -05:00
12
+ date: 2009-12-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -84,21 +84,29 @@ files:
84
84
  - ext/internal/vm/iseq/iseq.c
85
85
  - ext/internal/vm/constants/constants.c
86
86
  - ext/internal/vm/control_frame/control_frame.c
87
+ - ext/internal/vm/instruction/insns_info.c
87
88
  - ext/internal/vm/instruction/instruction.c
88
89
  - ext/internal/thread/thread.c
89
90
  - ext/internal/object/object.c
91
+ - ext/internal/node/nodeinfo.c
90
92
  - ext/internal/node/node.c
93
+ - ext/internal/node/node_type_descrip.c
91
94
  - ext/internal/noex/noex.c
92
95
  - ext/internal/binding/binding.c
93
96
  - ext/internal/tag/tag.c
94
97
  - ext/internal/proc/proc.c
95
98
  - ext/internal/method/method.c
99
+ - ext/internal/module/classpath.c
96
100
  - ext/internal/module/module.c
97
101
  - ext/internal/vm/iseq/internal_iseq.h
98
102
  - ext/internal/vm/control_frame/control_frame.h
103
+ - ext/internal/vm/instruction/insns_info.h
99
104
  - ext/internal/vm/instruction/instruction.h
100
105
  - ext/internal/node/ruby_internal_node.h
101
106
  - ext/internal/node/node_type_descrip.h
107
+ - ext/internal/node/block.h
108
+ - ext/internal/node/nodeinfo.h
109
+ - ext/internal/node/global_entry.h
102
110
  - ext/internal/node/builtins.h
103
111
  - ext/internal/yarv-headers/thread_win32.h
104
112
  - ext/internal/yarv-headers/vm_insnhelper.h
@@ -122,7 +130,12 @@ files:
122
130
  - ext/internal/yarv-headers/encdb.h
123
131
  - ext/internal/yarv-headers/dln.h
124
132
  - ext/internal/yarv-headers/vm_opts.h
133
+ - ext/internal/binding/block.h
134
+ - ext/internal/tag/tag.h
135
+ - ext/internal/proc/block.h
136
+ - ext/internal/method/method.h
125
137
  - ext/internal/module/cfp.h
138
+ - ext/internal/module/classpath.h
126
139
  - ext/internal/module/module.h
127
140
  - ext/internal/vm/inline_cache/extconf.rb
128
141
  - ext/internal/vm/iseq/extconf.rb