yarv-diff:269
From: ko1 atdot.net
Date: 16 Feb 2006 16:13:06 -0000
Subject: [yarv-diff:269] r432 - in trunk: . sample
Author: ko1
Date: 2006-02-17 01:13:06 +0900 (Fri, 17 Feb 2006)
New Revision: 432
Modified:
trunk/
trunk/ChangeLog
trunk/compile.c
trunk/eval_load.c
trunk/eval_proc.c
trunk/insns.def
trunk/sample/test.rb
trunk/test.rb
trunk/version.c
trunk/vm.c
trunk/yarvcore.c
Log:
r654@lermite: ko1 | 2006-02-17 01:12:26 +0900
* compile.c, insns.def : remove a setspecial second unused operand
* eval_load.c : remove unused variable th
* eval_proc.c, yarvcore.c : remove some functions from eval_proc.c
and move to yarvcore.c
* insns.def : fix to delete warnings
* sample/test.rb : comment out Proc#clone tests
* version.c : add constant RUBY_VM_DATE
* vm.c : fix some functions
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:652
+ 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:654
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/ChangeLog 2006-02-16 16:13:06 UTC (rev 432)
@@ -4,6 +4,24 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-02-17(Fri) 01:08:23 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * compile.c, insns.def : remove a setspecial second unused operand
+
+ * eval_load.c : remove unused variable th
+
+ * eval_proc.c, yarvcore.c : remove some functions from eval_proc.c
+ and move to yarvcore.c
+
+ * insns.def : fix to delete warnings
+
+ * sample/test.rb : comment out Proc#clone tests
+
+ * version.c : add constant RUBY_VM_DATE
+
+ * vm.c : fix some functions
+
+
2006-02-16(Thu) 22:58:27 +0900 Koichi Sasada <ko1 atdot.net>
* insns.def, vm.c : use th_yield_setup_args at yield and Proc#call
Modified: trunk/compile.c
===================================================================
--- trunk/compile.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/compile.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -4201,13 +4201,11 @@
ADD_INSNL(ret, nd_line(node), unless, lfin);
if (nd_type(node) == NODE_FLIP3) {
ADD_INSN(ret, nd_line(node), dup);
- ADD_INSN2(ret, nd_line(node), setspecial,
- INT2FIX(node->nd_cnt), INT2FIX(0));
+ ADD_INSN1(ret, nd_line(node), setspecial, INT2FIX(node->nd_cnt));
ADD_INSNL(ret, nd_line(node), jump, lfin);
}
else {
- ADD_INSN2(ret, nd_line(node), setspecial,
- INT2FIX(node->nd_cnt), INT2FIX(0));
+ ADD_INSN1(ret, nd_line(node), setspecial, INT2FIX(node->nd_cnt));
}
/* *flip == 1 */
@@ -4215,8 +4213,7 @@
COMPILE(ret, "flip2 end", node->nd_end);
ADD_INSNL(ret, nd_line(node), unless, ltrue);
ADD_INSN1(ret, nd_line(node), putobject, Qfalse);
- ADD_INSN2(ret, nd_line(node), setspecial, INT2FIX(node->nd_cnt),
- INT2FIX(0));
+ ADD_INSN1(ret, nd_line(node), setspecial, INT2FIX(node->nd_cnt));
ADD_LABEL(ret, ltrue);
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
Modified: trunk/eval_load.c
===================================================================
--- trunk/eval_load.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/eval_load.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -119,7 +119,6 @@
VALUE tmp;
int state;
volatile VALUE self = ruby_top_self;
- yarv_thread_t *th = GET_THREAD();
FilePathValue(fname);
fname = rb_str_new4(fname);
@@ -130,6 +129,7 @@
fname = tmp;
GET_THREAD()->errinfo = Qnil; /* ensure */
+
if (!wrap) {
rb_secure(4); /* should alter global state */
}
Modified: trunk/eval_proc.c
===================================================================
--- trunk/eval_proc.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/eval_proc.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -22,26 +22,10 @@
* MISSING: documentation
*/
-static VALUE
-proc_clone(self)
- VALUE self;
-{
- UNSUPPORTED(proc_clone);
- return Qnil;
-}
-
/*
* MISSING: documentation
*/
-static VALUE
-proc_dup(self)
- VALUE self;
-{
- UNSUPPORTED(proc_dup);
- return Qnil;
-}
-
/*
* call-seq:
* binding -> a_binding
@@ -89,10 +73,7 @@
*/
static VALUE
-bind_eval(argc, argv, bind)
- int argc;
- VALUE *argv;
- VALUE bind;
+bind_eval(int argc, VALUE *argv, VALUE bind)
{
UNSUPPORTED(bind_eval);
return Qnil;
@@ -161,7 +142,6 @@
proc_s_new(int argc, VALUE *argv, VALUE klass)
{
VALUE block = proc_alloc(klass, Qfalse);
-
rb_obj_call_init(block, argc, argv);
return block;
}
@@ -180,19 +160,19 @@
*/
VALUE
-rb_block_proc()
+rb_block_proc(void)
{
return proc_alloc(rb_cProc, Qfalse);
}
VALUE
-rb_block_lambda()
+rb_block_lambda(void)
{
return proc_alloc(rb_cProc, Qtrue);
}
VALUE
-rb_f_lambda()
+rb_f_lambda(void)
{
rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
return proc_alloc(rb_cProc, Qtrue);
@@ -207,7 +187,7 @@
*/
static VALUE
-proc_lambda()
+proc_lambda(void)
{
return proc_alloc(rb_cProc, Qtrue);
}
@@ -283,13 +263,6 @@
* Proc.new {|a,*b|}.arity #=> -2
*/
-static VALUE
-proc_arity(VALUE proc)
-{
- int arity = rb_proc_arity(proc);
- return INT2FIX(arity);
-}
-
/*
* call-seq:
* prc == other_proc => true or false
@@ -298,26 +271,6 @@
* <i>other_proc</i>, or if they are both procs with the same body.
*/
-static VALUE
-proc_eq(VALUE self, VALUE other)
-{
- if (self == other) {
- return Qtrue;
- }
- else {
- if (TYPE(other) != T_DATA &&
- RBASIC(other)->klass == cYarvProc &&
- CLASS_OF(self) == CLASS_OF(other)) {
- yarv_proc_t *p1, *p2;
- GetProcVal(self, p1);
- GetProcVal(other, p2);
- if (p1->block.iseq == p2->block.iseq && p1->envval == p2->envval) {
- return Qtrue;
- }
- }
- }
- return Qfalse;
-}
/*
* call-seq:
@@ -326,17 +279,6 @@
* Return hash value corresponding to proc body.
*/
-static VALUE
-proc_hash(VALUE self)
-{
- int hash;
- yarv_proc_t *proc;
- GetProcVal(self, proc);
- hash = (long)proc->block.iseq;
- hash ^= (long)proc->envval;
- hash ^= (long)proc->block.lfp >> 16;
- return INT2FIX(hash);
-}
/*
* call-seq:
@@ -346,29 +288,6 @@
* an indication of where the proc was defined.
*/
-static VALUE
-proc_to_s(VALUE self)
-{
- VALUE str = 0;
- yarv_proc_t *proc;
- char *cname = rb_obj_classname(self);
-
- GetProcVal(self, proc);
-
- if (proc->block.iseq) {
- str = rb_sprintf("#<%s:%p@%s:%d>", cname, proc->block.iseq,
- "test", -1);
- }
- else {
- str = rb_sprintf("#<%s:%p>", cname, proc->block.iseq);
- }
-
- if (OBJ_TAINTED(self)) {
- OBJ_TAINT(str);
- }
- return str;
-}
-
/*
* call-seq:
* prc.to_proc -> prc
@@ -378,12 +297,6 @@
* themselves.
*/
-static VALUE
-proc_to_self(VALUE self)
-{
- return self;
-}
-
/*
* call-seq:
* prc.binding => binding
@@ -1211,23 +1124,7 @@
sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
OBJ_TAINT(sysstack_error);
rb_global_variable(&sysstack_error);
-
- rb_cProc = rb_define_class("Proc", rb_cObject);
- rb_undef_alloc_func(rb_cProc);
- rb_define_singleton_method(rb_cProc, "new", proc_s_new, -1);
-
- rb_define_method(rb_cProc, "clone", proc_clone, 0);
- rb_define_method(rb_cProc, "dup", proc_dup, 0);
- rb_define_method(rb_cProc, "call", rb_proc_call, -2);
- rb_define_method(rb_cProc, "arity", proc_arity, 0);
- rb_define_method(rb_cProc, "[]", rb_proc_call, -2);
- rb_define_method(rb_cProc, "==", proc_eq, 1);
- rb_define_method(rb_cProc, "eql?", proc_eq, 1);
- rb_define_method(rb_cProc, "hash", proc_hash, 0);
- rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
- rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
- rb_define_method(rb_cProc, "binding", proc_binding, 0);
-
+
rb_define_global_function("proc", rb_block_proc, 0);
rb_define_global_function("lambda", proc_lambda, 0);
@@ -1306,7 +1203,7 @@
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
- rb_define_method(rb_cBinding, "clone", proc_clone, 0);
+ // rb_define_method(rb_cBinding, "clone", proc_clone, 0);
rb_define_method(rb_cBinding, "eval", bind_eval, -1);
rb_define_global_function("binding", rb_f_binding, 0);
}
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/insns.def 2006-02-16 16:13:06 UTC (rev 432)
@@ -119,7 +119,7 @@
*/
DEFINE_INSN
setspecial
-(num_t idx, num_t type)
+(num_t idx)
(VALUE obj)
()
{
@@ -694,6 +694,7 @@
(VALUE val)
()
{
+ val = val;
/* none */
}
@@ -988,6 +989,7 @@
/* TODO: trace instruction design */
if (GET_VM()->trace_flag & flag) {
/* */
+ args = Qnil;
}
}
@@ -1557,7 +1559,6 @@
(VALUE val)
{
IC ic = (IC) * (GET_PC() + dst + 1);
- debugs("PC: %04d\n", GET_PC() + dst);
ic->ic_value = val;
ic->ic_vmstat = GET_VM_STATE_VERSION();
Modified: trunk/sample/test.rb
===================================================================
--- trunk/sample/test.rb 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/sample/test.rb 2006-02-16 16:13:06 UTC (rev 432)
@@ -1,7 +1,5 @@
#! /usr/bin/env ruby
-Proc = YARVCore::VM::Proc
-
$KCODE = "none"
$testnum=0
$ntest=0
@@ -1052,6 +1050,8 @@
argument_test(true, get_block(&lambda{|a,|}),1)
argument_test(false, get_block(&lambda{|a,|}),1,2)
+# Proc#clone is not supported
+if false
blk = get_block{11}
test_ok(blk.class == Proc)
test_ok(blk.to_proc.class == Proc)
@@ -1063,6 +1063,7 @@
test_ok(lmd.to_proc.class == Proc)
test_ok(lmd.clone.call == 44)
test_ok(get_block(&lmd).class == Proc)
+end
test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
argument_test(true, Proc.new{|a,|}, 1,2)
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/test.rb 2006-02-16 16:13:06 UTC (rev 432)
@@ -1,4 +1,10 @@
+p proc{
+ # p 1
+}.to_s
+
+__END__
+
[[1, 2]].each{|a, b| p [a, b]}
__END__
Modified: trunk/version.c
===================================================================
--- trunk/version.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/version.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -26,12 +26,14 @@
VALUE v = rb_obj_freeze(rb_str_new2(ruby_version));
VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date));
VALUE p = rb_obj_freeze(rb_str_new2(ruby_platform));
- VALUE y = rb_obj_freeze(rb_str_new2(rev));
-
+ VALUE vv = rb_obj_freeze(rb_str_new2(rev));
+ VALUE vd = rb_obj_freeze(rb_str_new2(date));
+
rb_define_global_const("RUBY_VERSION", v);
rb_define_global_const("RUBY_RELEASE_DATE", d);
rb_define_global_const("RUBY_PLATFORM", p);
- rb_define_global_const("RUBY_VM_REV", y);
+ rb_define_global_const("RUBY_VM_REV", vv);
+ rb_define_global_const("RUBY_VM_DATE", vd);
}
void
Modified: trunk/vm.c
===================================================================
--- trunk/vm.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/vm.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -33,8 +33,6 @@
static NODE *lfp_get_special_cref(VALUE *lfp);
static NODE *lfp_set_special_cref(VALUE *lfp, NODE * cref);
-NORETURN(static void localjump_error(const char *, VALUE, int));
-
#if OPT_STACK_CACHING
static VALUE yarv_finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
#elif OPT_CALL_THREADED_CODE
@@ -682,7 +680,6 @@
VALUE val = Qundef;
int state;
NODE *stored_special_cref_stack = 0;
- yarv_control_frame_t *cfp = th->cfp;
if (proc->special_cref_stack) {
stored_special_cref_stack =
@@ -699,24 +696,23 @@
}
}
else {
- // TODO
+ if (state == TAG_BREAK) {
+ VALUE err = th->errinfo;
+ VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
+ VALUE *cdfp = proc->block.dfp;
+ if (escape_dfp == cdfp) {
+ state = 0;
+ th->errinfo = Qnil;
+ val = GET_THROWOBJ_VAL(err);
+ }
+ }
}
TH_POP_TAG();
+ /* restore cref */
if (stored_special_cref_stack) {
lfp_set_special_cref(proc->block.lfp, stored_special_cref_stack);
}
-
- if (state == TAG_BREAK) {
- VALUE err = th->errinfo;
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
- VALUE *cdfp = proc->block.dfp;
- if (escape_dfp == cdfp) {
- state = 0;
- th->errinfo = Qnil;
- val = GET_THROWOBJ_VAL(err);
- }
- }
if (state) {
JUMP_TAG(state);
@@ -1254,8 +1250,6 @@
mesg);
ID id;
- rb_iv_set(exc, "@reason", ID2SYM(id));
- rb_iv_set(exc, "@exit_value", value);
switch (reason) {
case TAG_BREAK:
id = rb_intern("break");
@@ -1276,6 +1270,7 @@
id = rb_intern("noreason");
break;
}
+ rb_iv_set(exc, "@exit_value", value);
rb_iv_set(exc, "@reason", ID2SYM(id));
return exc;
}
Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c 2006-02-16 14:03:36 UTC (rev 431)
+++ trunk/yarvcore.c 2006-02-16 16:13:06 UTC (rev 432)
@@ -875,13 +875,6 @@
return self;
}
-static VALUE
-proc_clone(VALUE self)
-{
- // TODO
- return self;
-}
-
VALUE
yarv_obj_is_proc(VALUE proc)
{
@@ -920,7 +913,84 @@
return FIX2INT(proc_arity(proc));
}
+static VALUE
+proc_eq(VALUE self, VALUE other)
+{
+ if (self == other) {
+ return Qtrue;
+ }
+ else {
+ if (TYPE(other) != T_DATA &&
+ RBASIC(other)->klass == cYarvProc &&
+ CLASS_OF(self) == CLASS_OF(other)) {
+ yarv_proc_t *p1, *p2;
+ GetProcVal(self, p1);
+ GetProcVal(other, p2);
+ if (p1->block.iseq == p2->block.iseq && p1->envval == p2->envval) {
+ return Qtrue;
+ }
+ }
+ }
+ return Qfalse;
+}
+static VALUE
+proc_hash(VALUE self)
+{
+ int hash;
+ yarv_proc_t *proc;
+ GetProcVal(self, proc);
+ hash = (long)proc->block.iseq;
+ hash ^= (long)proc->envval;
+ hash ^= (long)proc->block.lfp >> 16;
+ return INT2FIX(hash);
+}
+
+static VALUE
+proc_to_s(VALUE self)
+{
+ VALUE str = 0;
+ yarv_proc_t *proc;
+ char *cname = rb_obj_classname(self);
+ yarv_iseq_t *iseq;
+
+ GetProcVal(self, proc);
+ iseq = proc->block.iseq;
+
+ if (YARV_NORMAL_ISEQ_P(iseq)) {
+ int line_no = 0;
+
+ if (iseq->insn_info_tbl) {
+ line_no = iseq->insn_info_tbl[0].line_no;
+ }
+ str = rb_sprintf("#<%s:%p@%s:%d>", cname, self,
+ RSTRING(iseq->file_name)->ptr,
+ line_no);
+ }
+ else {
+ str = rb_sprintf("#<%s:%p>", cname, proc->block.iseq);
+ }
+
+ if (OBJ_TAINTED(self)) {
+ OBJ_TAINT(str);
+ }
+ return str;
+}
+
+static VALUE
+proc_clone(VALUE self)
+{
+ rb_bug("proc_clone is not supported.");
+ return Qnil;
+}
+
+static VALUE
+proc_dup(VALUE self)
+{
+ rb_bug("proc_dup is not supported.");
+ return Qnil;
+}
+
/***************/
/* YarvBinding */
/***************/
@@ -1088,13 +1158,21 @@
rb_define_alloc_func(cYarvEnv, env_alloc);
/* declare YARVCore::VM::Proc */
- cYarvProc = rb_define_class_under(cYarvVM, "Proc", rb_cObject);
+ rb_cProc = cYarvProc = rb_define_class_under(cYarvVM, "Proc", rb_cObject);
+ rb_const_set(rb_cObject, rb_intern("Proc"), cYarvProc);
+
rb_define_alloc_func(cYarvProc, proc_alloc);
rb_define_method(cYarvProc, "call", proc_call, -1);
rb_define_method(cYarvProc, "[]", proc_call, -1);
rb_define_method(cYarvProc, "to_proc", proc_to_proc, 0);
rb_define_method(cYarvProc, "clone", proc_clone, 0);
rb_define_method(cYarvProc, "arity", proc_arity, 0);
+ rb_define_method(cYarvProc, "clone", proc_clone, 0);
+ rb_define_method(cYarvProc, "duo", proc_dup, 0);
+ rb_define_method(cYarvProc, "==", proc_eq, 1);
+ rb_define_method(cYarvProc, "eql?", proc_eq, 1);
+ rb_define_method(cYarvProc, "hash", proc_hash, 0);
+ rb_define_method(cYarvProc, "to_s", proc_to_s, 0);
rb_define_singleton_method(cYarvProc, "new", rb_proc_s_new, -1);
/* declare YARVCore::VM::Binding */
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml