On Thursday 22 May 2008 18:26:30 Will Coleda via RT wrote: > Here's a simple patch that implements this: > > $ svn diff compilers/ > Index: compilers/imcc/pcc.c > ========================================================= > ========== > --- compilers/imcc/pcc.c (revision 27756) > +++ compilers/imcc/pcc.c (working copy) > @@ -319,16 +319,10 @@ > unshift_self(sub, self); > } > > - /* Don't generate any parameter checking code if there > - * are no named arguments. > - */ > nargs = sub->pcc_sub->nargs; > + ins = pcc_get_args(interp, unit, ins, "get_params", nargs, > + sub->pcc_sub->args, sub->pcc_sub->arg_flags); > > - if (nargs) { > - ins = pcc_get_args(interp, unit, ins, "get_params", nargs, > - sub->pcc_sub->args, sub->pcc_sub->arg_flags); > - } > - > /* > * check if there is a return > */ > > The problem with this is that it also applies to subs marked :main, and I > don't think we wish to enforce it for :main - the args passed in may not > match at all. If someone can tweak this slightly to avoid inserting the > get_params opcode in that one case, that should be sufficient to close out > this case. Added a test case to t/op/calling.t; Thanks to mdiep for the > pointer to the fix. (I had been staring at src/inter_call.c for some time > to no avail)
In theory, this should do it. In practice, I'm not sure we know if we have the main sub yet. Plenty of tests fail (and so does much of the build). Do you have better luck than I do? -- c
=== compilers/imcc/pcc.c ================================================================== --- compilers/imcc/pcc.c (revision 27794) +++ compilers/imcc/pcc.c (local) @@ -303,7 +303,6 @@ void expand_pcc_sub(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGIN(Instruction *ins)) { - int nargs; SymReg *sub = ins->symregs[0]; SymReg *regs[2]; @@ -319,16 +318,10 @@ unshift_self(sub, self); } - /* Don't generate any parameter checking code if there - * are no named arguments. - */ - nargs = sub->pcc_sub->nargs; + if (!(sub->pcc_sub->pragma & P_MAIN)) + ins = pcc_get_args(interp, unit, ins, "get_params", sub->pcc_sub->nargs, + sub->pcc_sub->args, sub->pcc_sub->arg_flags); - if (nargs) { - ins = pcc_get_args(interp, unit, ins, "get_params", nargs, - sub->pcc_sub->args, sub->pcc_sub->arg_flags); - } - /* * check if there is a return */