yarv-diff:340
From: ko1 atdot.net
Date: 4 Jul 2006 09:26:45 -0000
Subject: [yarv-diff:340] r506 - in trunk: . lib yarvtest
Author: ko1
Date: 2006-07-04 18:26:44 +0900 (Tue, 04 Jul 2006)
New Revision: 506
Modified:
trunk/
trunk/ChangeLog
trunk/disasm.c
trunk/eval.c
trunk/eval_error.h
trunk/eval_intern.h
trunk/eval_thread.c
trunk/lib/yasm.rb
trunk/vm.c
trunk/yarvcore.c
trunk/yarvcore.h
trunk/yarvtest/test_proc.rb
Log:
r786@lermite: ko1 | 2006-07-03 02:06:33 +0900
* eval_thread.c : add parameter "th" to thread_set_raised
* yarvcore.h : ditto
* eval_intern.h : ditto
* eval.c : ditto
* eval_error.h : declare with ANSI style
* disasm.c : rename iseq_iseq2simpledata() to iseq_data_to_ary
* lib/yasm.rb : rename Instruction#to_simpledata to
Instruction#to_a
* yarvcore.c : ditto
* vm.c : fix bug (Proc.new{|*args| p args}.call(1) #=> 1)
* yarvtest/test_proc.rb : add a tests for above
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:784
+ 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:786
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/ChangeLog 2006-07-04 09:26:44 UTC (rev 506)
@@ -3,7 +3,30 @@
# YARV ChangeLog
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-07-03(Mon) 01:54:23 +0900 Koichi Sasada <ko1 atdot.net>
+ * eval_thread.c : add parameter "th" to thread_set_raised
+
+ * yarvcore.h : ditto
+
+ * eval_intern.h : ditto
+
+ * eval.c : ditto
+
+ * eval_error.h : declare with ANSI style
+
+ * disasm.c : rename iseq_iseq2simpledata() to iseq_data_to_ary
+
+ * lib/yasm.rb : rename Instruction#to_simpledata to
+ Instruction#to_a
+
+ * yarvcore.c : ditto
+
+ * vm.c : fix bug (Proc.new{|*args| p args}.call(1) #=> 1)
+
+ * yarvtest/test_proc.rb : add a tests for above
+
+
2006-06-21(Wed) 09:19:06 +0900 Koichi Sasada <ko1 atdot.net>
* compile.c : remove yarv_iseq_t#catch_table_ary and
Modified: trunk/disasm.c
===================================================================
--- trunk/disasm.c 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/disasm.c 2006-07-04 09:26:44 UTC (rev 506)
@@ -604,7 +604,7 @@
}
VALUE
-iseq_iseq2simpledata(yarv_iseq_t *iseq)
+iseq_data_to_ary(yarv_iseq_t *iseq)
{
int i, j, pos, opt = 0;
VALUE *seq;
@@ -694,7 +694,7 @@
{
yarv_iseq_t *iseq = (yarv_iseq_t *)*seq;
if (iseq) {
- VALUE val = iseq_iseq2simpledata(iseq);
+ VALUE val = iseq_data_to_ary(iseq);
rb_ary_push(ary, val);
}
else {
@@ -732,7 +732,7 @@
if (entry->iseq) {
yarv_iseq_t *eiseq;
GetISeqVal(entry->iseq, eiseq);
- rb_ary_push(ary, iseq_iseq2simpledata(eiseq));
+ rb_ary_push(ary, iseq_data_to_ary(eiseq));
}
else {
rb_ary_push(ary, Qnil);
Modified: trunk/eval.c
===================================================================
--- trunk/eval.c 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/eval.c 2006-07-04 09:26:44 UTC (rev 506)
@@ -649,7 +649,7 @@
}
}
PUSH_TAG(PROT_NONE);
- raised = thread_reset_raised();
+ raised = thread_reset_raised(th);
if ((state = EXEC_TAG()) == 0) {
srcfile = rb_str_new2(ruby_sourcefile ? ruby_sourcefile : "(ruby)");
event_name = get_event_name(event);
@@ -661,7 +661,7 @@
klass ? klass : Qnil), Qundef, 0);
}
if (raised)
- thread_set_raised();
+ thread_set_raised(th);
POP_TAG();
tracing = 0;
@@ -909,7 +909,7 @@
//th->cfp++;
//}
- if (thread_set_raised()) {
+ if (thread_set_raised(th)) {
th->errinfo = exception_error;
JUMP_TAG(TAG_FATAL);
}
@@ -948,7 +948,7 @@
GET_THREAD()->errinfo = mesg;
}
else if (status) {
- thread_reset_raised();
+ thread_reset_raised(th);
JUMP_TAG(status);
}
}
@@ -957,7 +957,7 @@
if (tag != TAG_FATAL) {
// EXEC_EVENT_HOOK(RUBY_EVENT_RAISE ...)
}
- thread_reset_raised();
+ thread_reset_raised(th);
JUMP_TAG(tag);
}
Modified: trunk/eval_error.h
===================================================================
--- trunk/eval_error.h 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/eval_error.h 2006-07-04 09:26:44 UTC (rev 506)
@@ -5,7 +5,7 @@
#define SET_CURRENT_SOURCE() ((void)0)
void
-ruby_set_current_source()
+ruby_set_current_source(void)
{
if (ruby_current_node) {
ruby_sourcefile = ruby_current_node->nd_file;
@@ -14,13 +14,7 @@
}
static void
-#ifdef HAVE_STDARG_PROTOTYPES
warn_printf(const char *fmt, ...)
-#else
-warn_printf(fmt, va_alist)
- const char *fmt;
- va_dcl
-#endif
{
char buf[BUFSIZ];
va_list args;
@@ -35,7 +29,7 @@
#define warn_print2(x,l) rb_write_error2(x,l)
static void
-error_pos()
+error_pos(void)
{
ruby_set_current_source();
if (ruby_sourcefile) {
@@ -53,8 +47,7 @@
}
static VALUE
-get_backtrace(info)
- VALUE info;
+get_backtrace(VALUE info)
{
if (NIL_P(info))
return Qnil;
@@ -65,14 +58,13 @@
}
static void
-set_backtrace(info, bt)
- VALUE info, bt;
+set_backtrace(VALUE info, VALUE bt)
{
rb_funcall(info, rb_intern("set_backtrace"), 1, bt);
}
static void
-error_print()
+error_print(void)
{
VALUE errat = Qnil; /* OK */
volatile VALUE eclass, e;
@@ -208,8 +200,9 @@
error_handle(int ex)
{
int status = EXIT_FAILURE;
+ yarv_thread_t *th = GET_THREAD();
- if (thread_set_raised())
+ if (thread_set_raised(th))
return EXIT_FAILURE;
switch (ex & TAG_MASK) {
case 0:
@@ -254,6 +247,6 @@
rb_bug("Unknown longjmp status %d", ex);
break;
}
- thread_reset_raised();
+ thread_reset_raised(th);
return status;
}
Modified: trunk/eval_intern.h
===================================================================
--- trunk/eval_intern.h 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/eval_intern.h 2006-07-04 09:26:44 UTC (rev 506)
@@ -278,8 +278,8 @@
void rb_thread_cleanup _((void));
void rb_thread_wait_other_threads _((void));
-int thread_set_raised();
-int thread_reset_raised();
+int thread_set_raised(yarv_thread_t *th);
+int thread_reset_raised(yarv_thread_t *th);
VALUE rb_f_eval(int argc, VALUE *argv, VALUE self);
VALUE rb_make_exception _((int argc, VALUE *argv));
Modified: trunk/eval_thread.c
===================================================================
--- trunk/eval_thread.c 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/eval_thread.c 2006-07-04 09:26:44 UTC (rev 506)
@@ -336,26 +336,25 @@
0)
int
-thread_set_raised()
+thread_set_raised(yarv_thread_t *th)
{
- // TODO: fix me
+ if (th->raised_flag) {
+ return 1;
+ }
+ th->raised_flag = 1;
return 0;
}
int
-thread_reset_raised()
+thread_reset_raised(yarv_thread_t *th)
{
- // TODO: fix me
- return 0;
+ if (th->raised_flag == 0) {
+ return 0;
+ }
+ th->raised_flag = 0;
+ return 1;
}
-#define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
-#define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
-
-#define THREAD_SAVE_CONTEXT(th) \
- (rb_thread_save_context(th),\
- rb_thread_switch((FLUSH_REGISTER_WINDOWS, ruby_setjmp((th)->context))))
-
void
rb_thread_fd_close(fd)
int fd;
Modified: trunk/lib/yasm.rb
===================================================================
--- trunk/lib/yasm.rb 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/lib/yasm.rb 2006-07-04 09:26:44 UTC (rev 506)
@@ -32,7 +32,7 @@
[], vars, [nil], nil
)
sdb.instance_eval(&b)
- sdb.to_simpledata
+ sdb.to_a
end
def self.method name, args = [], vars = [], &b
@@ -41,7 +41,7 @@
args, vars, [nil], nil
)
sdb.instance_eval(&b)
- sdb.to_simpledata
+ sdb.to_a
end
def self.class name, vars = [], &b
@@ -50,7 +50,7 @@
args, vars, [nil], nil
)
sdb.instance_eval(&b)
- sdb.to_simpledata
+ sdb.to_a
end
def initialize type, name, filename, args, vars, lopt, parent
@@ -71,7 +71,7 @@
attr_reader :locals
attr_reader :local_sdb, :parent_sdb
- def to_simpledata
+ def to_a
# [magic, major_version, minor_version, format_type, misc,
# name, filename, line,
# type, args, vars, exception_table, body]
@@ -81,7 +81,7 @@
end
def method name, args=[], vars=[], &b
- YASM.method(name, args, vars, &b).to_simpledata
+ YASM.method(name, args, vars, &b).to_a
end
def block args=[], vars=[], &b
@@ -90,7 +90,7 @@
args, vars, [], self
)
sdb.instance_eval(&b)
- sdb.to_simpledata
+ sdb.to_a
end
# label
Modified: trunk/vm.c
===================================================================
--- trunk/vm.c 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/vm.c 2006-07-04 09:26:44 UTC (rev 506)
@@ -608,7 +608,7 @@
{
int i;
- if (0) { // for debug
+ if (0) { /* for debug */
int i;
GET_THREAD()->cfp->sp += argc;
for(i=0; i<argc; i++){
@@ -673,6 +673,7 @@
}
}
}
+
if (argc > iseq->argc) {
argc = iseq->argc;
}
@@ -686,6 +687,7 @@
yarv_control_frame_t *cfp = th->cfp;
yarv_block_t *block = GC_GUARDED_PTR_REF(cfp->lfp[0]);
VALUE val;
+
if (block == 0) {
th_localjump_error("no block given", Qnil, 0);
}
@@ -737,21 +739,25 @@
}
else {
yarv_iseq_t *iseq = proc->block.iseq;
+ yarv_control_frame_t *cfp;
int i;
+
th_set_finish_env(th);
+ cfp = th->cfp;
/* TODO: check overflow */
for (i=0; i<argc; i++) {
- th->cfp->sp[i] = argv[i];
+ cfp->sp[i] = argv[i];
}
argc = th_yield_setup_args(iseq, argc, cfp->sp);
- th->cfp->sp += argc;
-
+ cfp->sp += argc;
+
push_frame(th, iseq,
proc->is_lambda ? FRAME_MAGIC_LAMBDA : FRAME_MAGIC_PROC,
self, (VALUE)proc->block.dfp, iseq->iseq_encoded,
- th->cfp->sp, proc->block.lfp,
+ cfp->sp, proc->block.lfp,
iseq->local_size - argc);
+
val = th_eval_body(th);
}
}
Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/yarvcore.c 2006-07-04 09:26:44 UTC (rev 506)
@@ -559,14 +559,14 @@
return rb_str_new2(buff);
}
-VALUE iseq_iseq2simpledata(yarv_iseq_t *iseq);
+VALUE iseq_data_to_ary(yarv_iseq_t *iseq);
static VALUE
-iseq_to_simpledata(VALUE self)
+iseq_to_a(VALUE self)
{
yarv_iseq_t *iseq;
GetISeqVal(self, iseq);
- return iseq_iseq2simpledata(iseq);
+ return iseq_data_to_ary(iseq);
}
/******/
@@ -1216,7 +1216,7 @@
rb_define_method(cYarvISeq, "initialize", iseq_init, 6);
rb_define_method(cYarvISeq, "inspect", iseq_inspect, 0);
rb_define_method(cYarvISeq, "disasm", iseq_disasm, 0);
- rb_define_method(cYarvISeq, "to_simpledata", iseq_to_simpledata, 0);
+ rb_define_method(cYarvISeq, "to_a", iseq_to_a, 0);
rb_define_method(cYarvISeq, "eval", iseq_eval, 0);
rb_define_singleton_method(cYarvISeq, "load_simpledata",
iseq_m_load_simpledata, 1);
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/yarvcore.h 2006-07-04 09:26:44 UTC (rev 506)
@@ -385,7 +385,8 @@
unsigned long stack_size;
yarv_control_frame_t *cfp;
int safe_level;
-
+ int raised_flag;
+
/* passing state */
int state;
Modified: trunk/yarvtest/test_proc.rb
===================================================================
--- trunk/yarvtest/test_proc.rb 2006-06-21 04:22:13 UTC (rev 505)
+++ trunk/yarvtest/test_proc.rb 2006-07-04 09:26:44 UTC (rev 506)
@@ -40,6 +40,23 @@
a * 3
}.call(1, 2)
}
+
+ ae %q{
+ [
+ Proc.new{|*args| args}.call(),
+ Proc.new{|*args| args}.call(1),
+ Proc.new{|*args| args}.call(1, 2),
+ Proc.new{|*args| args}.call(1, 2, 3),
+ ]
+ }
+ ae %q{
+ [
+ Proc.new{|a, *b| [a, b]}.call(),
+ Proc.new{|a, *b| [a, b]}.call(1),
+ Proc.new{|a, *b| [a, b]}.call(1, 2),
+ Proc.new{|a, *b| [a, b]}.call(1, 2, 3),
+ ]
+ }
end
def test_closure
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml