Skip to content

Commit

Permalink
handle param unpacking in param parsing code, not being sub code
Browse files Browse the repository at this point in the history
  • Loading branch information
plobsing committed Feb 25, 2011
1 parent 412ce6c commit fbe0b62
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 342 deletions.
30 changes: 18 additions & 12 deletions compilers/imcc/cfg.c
Expand Up @@ -276,19 +276,25 @@ find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
ins->index = ++i;
ins->bbindex = unit->n_basic_blocks - 1;

if (!ins->op && (ins->type & ITPCCSUB)) {
if (first) {
if (ins->type & ITLABEL) {
expand_pcc_sub_ret(interp, unit, ins);
ins->type &= ~ITLABEL;
}
else {
/* if this is a sub call expand it */
expand_pcc_sub_call(interp, unit, ins);
}

ins->type &= ~ITPCCSUB;
if (!ins->op
&& (ins->type & ITPCCPARAM)
&& first) {
expand_pcc_sub(interp, unit, ins);
ins->type &= ~ITPCCPARAM;
}
else if (!ins->op
&& (ins->type & ITPCCSUB)
&& first) {
if (ins->type & ITLABEL) {
expand_pcc_sub_ret(interp, unit, ins);
ins->type &= ~ITLABEL;
}
else {
/* if this is a sub call expand it */
expand_pcc_sub_call(interp, unit, ins);
}

ins->type &= ~ITPCCSUB;
}
else if (ins->type & ITLABEL) {
/* set the labels address (ins) */
Expand Down
15 changes: 15 additions & 0 deletions compilers/imcc/imcc.y
Expand Up @@ -570,6 +570,7 @@ iSUBROUTINE(PARROT_INTERP, ARGMOD_NULLOK(IMC_Unit *unit), ARGMOD(SymReg *r))
{
ASSERT_ARGS(iSUBROUTINE)
Instruction * const i = iLABEL(interp, unit, r);
i->type |= ITPCCPARAM;

r->type = (r->type & VT_ENCODED) ? VT_PCC_SUB|VT_ENCODED : VT_PCC_SUB;
r->pcc_sub = mem_gc_allocate_zeroed_typed(interp, pcc_sub_t);
Expand Down Expand Up @@ -1336,6 +1337,20 @@ sub_param:
{ IMCC_INFO(interp)->is_def = 1; }
sub_param_type_def
{
if (/* IMCC_INFO(interp)->cur_unit->last_ins->op
|| */ !(IMCC_INFO(interp)->cur_unit->last_ins->type & ITPCCPARAM)) {
SymReg *r;
Instruction *i;
char name[128];
snprintf(name, sizeof (name), "%cpcc_params_%d",
IMCC_INTERNAL_CHAR, IMCC_INFO(interp)->cnr++);
r = mk_symreg(interp, name, 0);
r->type = VT_PCC_SUB;
r->pcc_sub = mem_gc_allocate_zeroed_typed(interp, pcc_sub_t);
i = iLABEL(interp, IMCC_INFO(interp)->cur_unit, r);
IMCC_INFO(interp)->cur_call = r;
i->type = ITPCCPARAM;
}
if (IMCC_INFO(interp)->adv_named_id) {
add_pcc_named_param(interp, IMCC_INFO(interp)->cur_call,
IMCC_INFO(interp)->adv_named_id, $3);
Expand Down

0 comments on commit fbe0b62

Please sign in to comment.