summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-21 11:15:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-21 11:15:15 +0000
commitbb7a2d40ff6190f819feb3d9eef0caaffec1a3f9 (patch)
treee50ce2d744f47f485bc2d1a4bb7eae57f5a9ed87 /iseq.c
parentdf896a05608e4041c36488c60218f06ca74830b9 (diff)
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h, debug.c, debug.h: merge half-baked-1.9 changes. The biggest change is to change node structure around NODE_SCOPE, NODE_ARGS. Every scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS represents more details of arguments information. I'll write a document about detail of node structure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/iseq.c b/iseq.c
index 06ca48f613..4a2bed7c5a 100644
--- a/iseq.c
+++ b/iseq.c
@@ -116,8 +116,8 @@ prepare_iseq_build(rb_iseq_t *iseq,
RBASIC(iseq->iseq_mark_ary)->klass = 0;
iseq->type = type;
- iseq->arg_rest = 0;
- iseq->arg_block = 0;
+ iseq->arg_rest = -1;
+ iseq->arg_block = -1;
iseq->klass = 0;
iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
iseq->cached_special_block_builder = 0;
@@ -545,10 +545,10 @@ insn_operand_intern(rb_iseq_t *iseq,
{
rb_iseq_t *ip = iseq->local_iseq;
int lidx = ip->local_size - op;
- ID id = ip->local_table[lidx];
+ const char *name = rb_id2name(ip->local_table[lidx]);
- if (id) {
- ret = rb_str_new2(rb_id2name(id));
+ if (name) {
+ ret = rb_str_new2(name);
}
else {
ret = rb_str_new2("*");
@@ -558,12 +558,17 @@ insn_operand_intern(rb_iseq_t *iseq,
case TS_DINDEX:{
if (insn == BIN(getdynamic) || insn == BIN(setdynamic)) {
rb_iseq_t *ip = iseq;
- int level = *pnop;
- int i;
+ int level = *pnop, i;
+ const char *name;
for (i = 0; i < level; i++) {
ip = ip->parent_iseq;
}
- ret = rb_str_new2(rb_id2name(ip->local_table[ip->local_size - op]));
+ name = rb_id2name(ip->local_table[ip->local_size - op]);
+
+ if (!name) {
+ name = "*";
+ }
+ ret = rb_str_new2(name);
}
else {
ret = rb_inspect(INT2FIX(op));
@@ -704,7 +709,7 @@ ruby_iseq_disasm(VALUE self)
VALUE str = rb_str_new(0, 0);
VALUE child = rb_ary_new();
unsigned long size;
- int i;
+ int i, d = iseqdat->local_size - iseqdat->local_table_size;
ID *tbl;
char buff[0x200];
@@ -744,8 +749,11 @@ ruby_iseq_disasm(VALUE self)
if (tbl) {
snprintf(buff, sizeof(buff),
- "local scope table (size: %d, argc: %d)\n",
- iseqdat->local_size, iseqdat->argc);
+ "local table (size: %d, argc: %d "
+ "[opts: %d, rest: %d, block: %d] %s)\n",
+ iseqdat->local_size, iseqdat->argc,
+ iseqdat->arg_opts, iseqdat->arg_rest, iseqdat->arg_block,
+ iseqdat->arg_simple ? "s" : "c");
rb_str_cat2(str, buff);
for (i = 0; i < iseqdat->local_table_size; i++) {
@@ -766,8 +774,8 @@ ruby_iseq_disasm(VALUE self)
snprintf(argi, sizeof(argi), "%s%s%s%s", /* arg, opts, rest, block */
iseqdat->argc > i ? "Arg" : "",
opti,
- iseqdat->arg_rest - 1 == i ? "Rest" : "",
- iseqdat->arg_block - 1 == i ? "Block" : "");
+ iseqdat->arg_rest - d == i ? "Rest" : "",
+ iseqdat->arg_block - d == i ? "Block" : "");
snprintf(info, sizeof(info), "%s%s%s%s", name ? name : "?",
*argi ? "<" : "", argi, *argi ? ">" : "");