diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-24 02:07:05 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-24 02:07:05 +0000 |
commit | 0fe72040e4c278bfafe232dc44551de2dfac85e2 (patch) | |
tree | b94399addca7cc57efeb4ae755c408a09d99d115 /vm_macro.def | |
parent | c5148e038316b3351b4c831773b83e08c11c20fb (diff) | |
download | ruby-0fe72040e4c278bfafe232dc44551de2dfac85e2.tar.gz |
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_macro.def')
-rw-r--r-- | vm_macro.def | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/vm_macro.def b/vm_macro.def index 28f0ed7e4d..3d6c66402c 100644 --- a/vm_macro.def +++ b/vm_macro.def @@ -86,7 +86,8 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) GetISeqPtr(niseqval, niseq); clear_local_size = niseq->local_size - num; - /* set arguments */ + + /* simple (only mandatory) arguments */ if (niseq->arg_simple) { if (niseq->argc != num) { rb_raise(rb_eArgError, "wrong number of arguments (%lu for %d)", @@ -94,7 +95,7 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) } } else { - /* check optional arguments */ + /* optional arguments */ if (niseq->arg_opts) { int iseq_argc = niseq->argc; int opts = niseq->arg_opts - 1; @@ -110,10 +111,9 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) (unsigned long)num, iseq_argc); } - if (0) { - printf("num: %lu, opts: %d, iseq_argc: %d\n", - (unsigned long)num, opts, iseq_argc); - } + if (0) printf("num: %lu, opts: %d, iseq_argc: %d\n", + (unsigned long)num, opts, iseq_argc); + if (num - iseq_argc < opts) { opt_pc = niseq->arg_opt_tbl[num - iseq_argc]; sp += opts - (num - iseq_argc); @@ -124,23 +124,17 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) opt_pc = niseq->arg_opt_tbl[opts]; } } - /* check rest */ - if (niseq->arg_rest == -1) { - if (niseq->arg_opts) { - num = niseq->argc + niseq->arg_opts; - } - else { - num = niseq->argc; - } - sp = &rsp[1 + num + 1]; - } - else if (niseq->arg_rest != 0) { + + /* rest argument */ + if (niseq->arg_rest != 0) { int rest = niseq->arg_rest - 1; int pack_size = num - rest; + if (0) { printf("num: %lu, rest: %d, ps: %d\n", (unsigned long)num, niseq->arg_rest, pack_size); } + if (pack_size < 0) { rb_raise(rb_eArgError, "wrong number of arguments (%lu for %d)", @@ -165,6 +159,10 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) (niseq->arg_opts && num == niseq->argc + niseq->arg_opts - 1) || num == niseq->argc)) { + + if (0) printf("num: %d, rest: %d, opts: %d, argc: %d\n", + num, niseq->arg_rest, niseq->arg_opts, niseq->argc); + rb_raise(rb_eArgError, "wrong number of arguments (%lu for %d)", (unsigned long)num, niseq->argc); @@ -189,6 +187,7 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) clear_local_size--; } } + /* stack overflow check */ if (CHECK_STACK_OVERFLOW(th, GET_CFP(), niseq->stack_max + 0x100)) { rb_exc_raise(sysstack_error); @@ -198,32 +197,30 @@ MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num) *sp++ = Qnil; } - { - if (0 && (flag & VM_CALL_TAILCALL_BIT)) { - th->cfp++; - push_frame(th, niseq, FRAME_MAGIC_METHOD, - recv, (VALUE) blockptr, - niseq->iseq_encoded + opt_pc, sp, 0, 0); - } - else if (0 && - (flag & VM_CALL_TAILRECURSION_BIT) && niseq == GET_ISEQ()) { - /* do nothing */ - GET_CFP()->self = recv; - SET_LFP(sp); - SET_DFP(sp); - *sp++ = (VALUE) blockptr; - reg_cfp->sp = sp; - reg_cfp->bp = sp; - SET_PC(niseq->iseq_encoded + opt_pc); - } - else { - push_frame(th, niseq, - FRAME_MAGIC_METHOD, recv, (VALUE) blockptr, - niseq->iseq_encoded + opt_pc, sp, 0, 0); - reg_cfp->sp = rsp; - } - RESTORE_REGS(); + if (0 && (flag & VM_CALL_TAILCALL_BIT)) { + th->cfp++; + push_frame(th, niseq, FRAME_MAGIC_METHOD, + recv, (VALUE) blockptr, + niseq->iseq_encoded + opt_pc, sp, 0, 0); + } + else if (0 && + (flag & VM_CALL_TAILRECURSION_BIT) && niseq == GET_ISEQ()) { + /* do nothing */ + GET_CFP()->self = recv; + SET_LFP(sp); + SET_DFP(sp); + *sp++ = (VALUE) blockptr; + reg_cfp->sp = sp; + reg_cfp->bp = sp; + SET_PC(niseq->iseq_encoded + opt_pc); + } + else { + push_frame(th, niseq, + FRAME_MAGIC_METHOD, recv, (VALUE) blockptr, + niseq->iseq_encoded + opt_pc, sp, 0, 0); + reg_cfp->sp = rsp; } + RESTORE_REGS(); } MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr) |