aboutsummaryrefslogtreecommitdiffstats
path: root/eval.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 /eval.c
parentdf896a05608e4041c36488c60218f06ca74830b9 (diff)
downloadruby-bb7a2d40ff6190f819feb3d9eef0caaffec1a3f9.tar.gz
* 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 'eval.c')
-rw-r--r--eval.c73
1 files changed, 20 insertions, 53 deletions
diff --git a/eval.c b/eval.c
index cfd0fbfb42..a96f9b8d9d 100644
--- a/eval.c
+++ b/eval.c
@@ -1942,6 +1942,7 @@ eval(VALUE self, VALUE src, VALUE scope, char *file, int line)
th->parse_in_eval--;
th_set_eval_stack(th, iseqval);
th->base_block = 0;
+
if (0) { /* for debug */
extern VALUE ruby_iseq_disasm(VALUE);
printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
@@ -2803,7 +2804,11 @@ rb_f_local_variables(void)
for (i = 0; i < cfp->iseq->local_table_size; i++) {
ID lid = cfp->iseq->local_table[i];
if (lid) {
- rb_ary_push(ary, rb_str_new2(rb_id2name(lid)));
+ const char *vname = rb_id2name(lid);
+ /* should skip temporary variable */
+ if (vname) {
+ rb_ary_push(ary, rb_str_new2(vname));
+ }
}
}
}
@@ -2984,7 +2989,7 @@ Init_eval(void)
/* for parser */
-VALUE
+int
rb_dvar_defined(ID id)
{
rb_thread_t *th = GET_THREAD();
@@ -2996,72 +3001,34 @@ rb_dvar_defined(ID id)
iseq->type == ISEQ_TYPE_EVAL) {
int i;
- /* printf("local size: %d\n", iseq->local_size); */
for (i = 0; i < iseq->local_table_size; i++) {
- /* printf("id (%4d): %s\n", i, rb_id2name(iseq->local_tbl[i])); */
if (iseq->local_table[i] == id) {
- return Qtrue;
+ return 1;
}
}
iseq = iseq->parent_iseq;
}
}
- return Qfalse;
-}
-
-void
-rb_scope_setup_top_local_tbl(ID *tbl)
-{
- rb_thread_t *th = GET_THREAD();
- if (tbl) {
- if (th->top_local_tbl) {
- xfree(th->top_local_tbl);
- th->top_local_tbl = 0;
- }
- th->top_local_tbl = tbl;
- }
- else {
- th->top_local_tbl = 0;
- }
+ return 0;
}
int
-rb_scope_base_local_tbl_size(void)
+rb_local_defined(ID id)
{
rb_thread_t *th = GET_THREAD();
- if (th->base_block) {
- return th->base_block->iseq->local_iseq->local_size +
- 2 /* $_, $~ */ - 1 /* svar */ ;
- }
- else {
- return 0;
- }
-}
+ rb_iseq_t *iseq;
-ID
-rb_scope_base_local_tbl_id(int i)
-{
- rb_thread_t *th = GET_THREAD();
- switch (i) {
- case 0:
- return rb_intern("$_");
- case 1:
- return rb_intern("$~");
- default:
- return th->base_block->iseq->local_iseq->local_table[i-2];
- }
-}
+ if (th->base_block && th->base_block->iseq) {
+ int i;
+ iseq = th->base_block->iseq->local_iseq;
-int
-rb_dvar_current(void)
-{
- rb_thread_t *th = GET_THREAD();
- if (th->base_block) {
- return 1;
- }
- else {
- return 0;
+ for (i=0; i<iseq->local_table_size; i++) {
+ if (iseq->local_table[i] == id) {
+ return 1;
+ }
+ }
}
+ return 0;
}
int