2007-02-02 18:21:41 +03:00
|
|
|
/* -*- c -*- */
|
|
|
|
/* do not use C++ style comment */
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
|
|
MACRO macro_eval_setup_send_arguments(num, blockptr, flag, blockiseq)
|
|
|
|
{
|
|
|
|
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_proc_t *po;
|
2007-02-02 18:21:41 +03:00
|
|
|
VALUE proc;
|
|
|
|
|
|
|
|
proc = TOPN(0);
|
|
|
|
if (proc != Qnil) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
if (!rb_obj_is_proc(proc)) {
|
2007-02-02 18:21:41 +03:00
|
|
|
proc = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
if (!rb_obj_is_proc(proc)) {
|
2007-02-02 18:21:41 +03:00
|
|
|
rb_raise(rb_eTypeError,
|
|
|
|
"wrong argument type %s (expected Proc)",
|
|
|
|
rb_obj_classname(proc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GetProcPtr(proc, po);
|
|
|
|
blockptr = &po->block;
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp)->proc = proc;
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
INC_SP(-1);
|
|
|
|
}
|
|
|
|
else if (blockiseq) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(reg_cfp);
|
2007-02-02 18:21:41 +03:00
|
|
|
blockptr->iseq = blockiseq;
|
|
|
|
blockptr->proc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* expand top of stack? */
|
|
|
|
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
|
|
|
VALUE ary = TOPN(0);
|
|
|
|
VALUE *ptr, *dst;
|
|
|
|
int i;
|
|
|
|
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_splat");
|
|
|
|
|
|
|
|
if (NIL_P(tmp)) {
|
|
|
|
tmp = rb_ary_new3(1, ary);
|
|
|
|
}
|
|
|
|
ary = tmp;
|
|
|
|
|
|
|
|
ptr = RARRAY_PTR(ary);
|
|
|
|
dst = GET_SP() - 1;
|
|
|
|
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
|
|
|
dst[i] = ptr[i];
|
|
|
|
}
|
|
|
|
num += i - 1;
|
|
|
|
INC_SP(i - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MACRO macro_eval_invoke_cfunc(num, id, recv, klass, mn, blockptr)
|
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_control_frame_t *cfp =
|
2007-02-02 18:21:41 +03:00
|
|
|
push_frame(th, 0, FRAME_MAGIC_CFUNC,
|
|
|
|
recv, (VALUE) blockptr, 0, GET_SP(), 0, 1);
|
|
|
|
cfp->callee_id = id; /* TODO */
|
|
|
|
cfp->method_id = id;
|
|
|
|
cfp->method_klass = klass;
|
|
|
|
|
|
|
|
reg_cfp->sp -= num + 1;
|
|
|
|
|
|
|
|
val = call_cfunc(mn->nd_cfnc, recv, mn->nd_argc, num, reg_cfp->sp + 1);
|
|
|
|
if (reg_cfp != th->cfp + 1) {
|
|
|
|
SDR2(reg_cfp);
|
|
|
|
SDR2(th->cfp-5);
|
|
|
|
rb_bug("cfp consistency error - send");
|
|
|
|
th->cfp = reg_cfp;
|
|
|
|
}
|
|
|
|
pop_frame(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num)
|
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *niseq;
|
2007-02-02 18:21:41 +03:00
|
|
|
VALUE *sp = GET_SP();
|
|
|
|
VALUE *rsp = sp - num - 1;
|
|
|
|
int opt_pc = 0, clear_local_size, i;
|
|
|
|
|
|
|
|
/* TODO: eliminate it */
|
|
|
|
GetISeqPtr(niseqval, niseq);
|
|
|
|
|
|
|
|
clear_local_size = niseq->local_size - num;
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
|
|
|
/* simple (only mandatory) arguments */
|
2007-02-02 18:21:41 +03:00
|
|
|
if (niseq->arg_simple) {
|
|
|
|
if (niseq->argc != num) {
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
rb_raise(rb_eArgError, "%d - wrong number of arguments (%lu for %d)",
|
|
|
|
0, (unsigned long)num, niseq->argc);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
/* optional arguments */
|
2007-02-02 18:21:41 +03:00
|
|
|
if (niseq->arg_opts) {
|
|
|
|
int iseq_argc = niseq->argc;
|
|
|
|
int opts = niseq->arg_opts - 1;
|
|
|
|
|
|
|
|
if (num < iseq_argc ||
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
(niseq->arg_rest == -1 && num > iseq_argc + opts)) {
|
2007-02-02 18:21:41 +03:00
|
|
|
if (0) {
|
|
|
|
printf("num: %lu, iseq_argc: %d, opts: %d\n",
|
|
|
|
(unsigned long)num, iseq_argc, opts);
|
|
|
|
}
|
|
|
|
rb_raise(rb_eArgError,
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
"%d - wrong number of arguments (%lu for %d)",
|
|
|
|
1, (unsigned long)num, iseq_argc);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
if (0) printf("num: %lu, opts: %d, iseq_argc: %d\n",
|
|
|
|
(unsigned long)num, opts, iseq_argc);
|
|
|
|
|
2007-02-02 18:21:41 +03:00
|
|
|
if (num - iseq_argc < opts) {
|
|
|
|
opt_pc = niseq->arg_opt_tbl[num - iseq_argc];
|
|
|
|
sp += opts - (num - iseq_argc);
|
|
|
|
num += opts - (num - iseq_argc);
|
|
|
|
clear_local_size = niseq->local_size - (iseq_argc + opts);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
opt_pc = niseq->arg_opt_tbl[opts];
|
|
|
|
}
|
|
|
|
}
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
|
|
|
/* rest argument */
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
if (niseq->arg_rest != -1) {
|
|
|
|
int rest = niseq->arg_rest - 1 /* spec val */;
|
2007-02-02 18:21:41 +03:00
|
|
|
int pack_size = num - rest;
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
2007-02-02 18:21:41 +03:00
|
|
|
if (0) {
|
|
|
|
printf("num: %lu, rest: %d, ps: %d\n",
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
(unsigned long)num, rest, pack_size);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
2007-02-02 18:21:41 +03:00
|
|
|
if (pack_size < 0) {
|
|
|
|
rb_raise(rb_eArgError,
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
"%d - wrong number of arguments (%lu for %d)",
|
|
|
|
2, (unsigned long)num, rest - niseq->arg_opts);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
* def m(x, y, z, *a) (rest: 3) =>
|
|
|
|
* x, y, z, a, b, c <SP> (num: 6, pack_size = 3)
|
|
|
|
* => x, y, z, [a,b,c] <SP> (num: 4)
|
2007-02-02 18:21:41 +03:00
|
|
|
*/
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
rsp[rest + 1] = rb_ary_new4(pack_size, &rsp[rest + 1]);
|
|
|
|
sp = &rsp[rest + 1 + 1];
|
2007-02-02 18:21:41 +03:00
|
|
|
num = rest + 1;
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
clear_local_size = niseq->local_size - (rest + 1);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* block argument */
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
if (niseq->arg_block != -1) {
|
2007-02-02 18:21:41 +03:00
|
|
|
VALUE arg_block_val = Qnil;
|
|
|
|
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
if (!((num == niseq->arg_rest) ||
|
|
|
|
(niseq->arg_opts && num == niseq->argc + niseq->arg_opts - 1)
|
2007-02-02 18:21:41 +03:00
|
|
|
|| num == niseq->argc)) {
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
|
|
|
if (0) printf("num: %d, rest: %d, opts: %d, argc: %d\n",
|
|
|
|
num, niseq->arg_rest, niseq->arg_opts, niseq->argc);
|
|
|
|
|
2007-02-02 18:21:41 +03:00
|
|
|
rb_raise(rb_eArgError,
|
* 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
2007-03-21 14:15:15 +03:00
|
|
|
"%d - wrong number of arguments (%lu for %d)",
|
|
|
|
3, (unsigned long)num, niseq->argc);
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (blockptr) {
|
|
|
|
/* make Proc object */
|
|
|
|
if (blockptr->proc == 0) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_proc_t *proc;
|
2007-02-02 18:21:41 +03:00
|
|
|
reg_cfp->sp = sp;
|
|
|
|
arg_block_val = th_make_proc(th, GET_CFP(), blockptr);
|
|
|
|
GetProcPtr(arg_block_val, proc);
|
|
|
|
blockptr = &proc->block;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
arg_block_val = blockptr->proc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rsp[1 + niseq->arg_block - 1] = arg_block_val;
|
|
|
|
sp++;
|
|
|
|
clear_local_size--;
|
|
|
|
}
|
|
|
|
}
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
|
2007-02-02 18:21:41 +03:00
|
|
|
/* stack overflow check */
|
|
|
|
if (CHECK_STACK_OVERFLOW(th, GET_CFP(), niseq->stack_max + 0x100)) {
|
|
|
|
rb_exc_raise(sysstack_error);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < clear_local_size; i++) {
|
|
|
|
*sp++ = Qnil;
|
|
|
|
}
|
|
|
|
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
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;
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
* 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
2007-02-24 05:07:05 +03:00
|
|
|
RESTORE_REGS();
|
2007-02-02 18:21:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr)
|
|
|
|
{
|
|
|
|
/* method missing */
|
|
|
|
if (mn == 0) {
|
|
|
|
/* temporarily */
|
|
|
|
if (id == idMethodMissing) {
|
|
|
|
rb_bug("method missing");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int stat = 0;
|
|
|
|
if (flag & VM_CALL_VCALL_BIT) {
|
|
|
|
stat |= NOEX_VCALL;
|
|
|
|
}
|
|
|
|
if (flag & VM_CALL_SUPER_BIT) {
|
|
|
|
stat |= NOEX_SUPER;
|
|
|
|
}
|
|
|
|
val = eval_method_missing(th, id, recv, num, blockptr, stat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!(flag & VM_CALL_FCALL_BIT) &&
|
|
|
|
(mn->nd_noex & NOEX_MASK) & NOEX_PRIVATE) {
|
|
|
|
int stat = NOEX_PRIVATE;
|
|
|
|
if (flag & VM_CALL_VCALL_BIT) {
|
|
|
|
stat |= NOEX_VCALL;
|
|
|
|
}
|
|
|
|
val = eval_method_missing(th, id, recv, num, blockptr, stat);
|
|
|
|
}
|
|
|
|
else if ((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED) {
|
|
|
|
VALUE defined_class = mn->nd_clss;
|
|
|
|
|
|
|
|
if (TYPE(defined_class) == T_ICLASS) {
|
|
|
|
defined_class = RBASIC(defined_class)->klass;
|
|
|
|
}
|
|
|
|
if (!rb_obj_is_kind_of(GET_SELF(), rb_class_real(defined_class))) {
|
|
|
|
val =
|
|
|
|
eval_method_missing(th, id, recv, num, blockptr,
|
|
|
|
NOEX_PROTECTED);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
goto INSN_LABEL(normal_method_dispatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NODE *node;
|
|
|
|
INSN_LABEL(normal_method_dispatch):
|
|
|
|
|
|
|
|
node = mn->nd_body;
|
|
|
|
switch (nd_type(node)) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
case RUBY_VM_METHOD_NODE:{
|
2007-02-02 18:21:41 +03:00
|
|
|
macro_eval_invoke_func(node->nd_body, recv, klass,
|
|
|
|
blockptr, num);
|
|
|
|
NEXT_INSN();
|
|
|
|
}
|
|
|
|
case NODE_CFUNC:{
|
|
|
|
macro_eval_invoke_cfunc(num, id, recv, klass, node, blockptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_ATTRSET:{
|
|
|
|
val = rb_ivar_set(recv, node->nd_vid, TOPN(0));
|
|
|
|
POPN(2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_IVAR:{
|
|
|
|
val = rb_ivar_get(recv, node->nd_vid);
|
|
|
|
POP();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_BMETHOD:{
|
|
|
|
VALUE *argv = GET_SP() - num;
|
|
|
|
val = th_invoke_bmethod(th, id, node->nd_cval,
|
|
|
|
recv, klass, num, argv);
|
|
|
|
INC_SP(-num-1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_ZSUPER:{
|
|
|
|
klass = RCLASS(mn->nd_clss)->super;
|
|
|
|
mn = rb_method_node(klass, id);
|
|
|
|
|
|
|
|
if (mn != 0) {
|
|
|
|
goto INSN_LABEL(normal_method_dispatch);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
goto LABEL_IS_SC(start_method_dispatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NODE_SCOPE:{
|
|
|
|
dpi(id);
|
|
|
|
SDR();
|
|
|
|
rb_bug("eval_invoke_method: NODE_SCOPE should not be appear");
|
|
|
|
/* unreachable */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-07 04:25:05 +03:00
|
|
|
printf("node: %s\n", ruby_node_name(nd_type(node)));
|
2007-02-02 18:21:41 +03:00
|
|
|
rb_bug("eval_invoke_method: unreachable");
|
|
|
|
/* unreachable */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|