cvsuser     04/08/06 05:23:40

  Modified:    ast      node.c
               imcc     reg_alloc.c
  Log:
  ast 21 - some fixes, a bit better code
  
  Revision  Changes    Path
  1.23      +13 -8     parrot/ast/node.c
  
  Index: node.c
  ===================================================================
  RCS file: /cvs/public/parrot/ast/node.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -r1.22 -r1.23
  --- node.c    6 Aug 2004 09:35:33 -0000       1.22
  +++ node.c    6 Aug 2004 12:23:37 -0000       1.23
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: node.c,v 1.22 2004/08/06 09:35:33 leo Exp $
  +$Id: node.c,v 1.23 2004/08/06 12:23:37 leo Exp $
   
   =head1 NAME
   
  @@ -489,34 +489,39 @@
       SymReg *regs[IMCC_MAX_REGS], *lr, *rr;
       nodeType *var = CHILD(p);
       nodeType *rhs = var->next;
  -    int assigned = 0;
  +    int need_assign = 0, need_store = 0;
       char buf[128];
   
  -    lr = var->expand(interpreter, var);
       if (rhs->expand == exp_Binary) {
           /*
            * set the destination node, where the binary places
            * the result
            */
           rhs->dest = var;
  -        rr = rhs->expand(interpreter, rhs);
  -        assigned = 1;
  +        lr = rhs->expand(interpreter, rhs);
       }
       else if (rhs->expand == exp_Const) {
           const char *pmc;
           /* need a new value, because the name might be aliased by
            * a = b
            */
  -        rr = node_to_pmc(interpreter, rhs);
  +        lr = node_to_pmc(interpreter, rhs);
  +        ins = cur_unit->last_ins;
  +        need_store = 1;
       }
       else {
           rr = rhs->expand(interpreter, rhs);
  +        need_store = 1;
  +        need_assign = 1;
       }
  +    if (need_assign) {
  +        lr = var->expand(interpreter, var);
       ins = cur_unit->last_ins;
  -    if (!assigned) {
           regs[0] = lr;
           regs[1] = rr;
           ins = insINS(interpreter, cur_unit, ins, "set", regs, 2);
  +    }
  +    if (need_store) {
           regs[0] = get_const("-1", 'I');
           sprintf(buf, "\"%s\"", var->u.r->name);
           regs[1] = get_const(buf, 'S');
  
  
  
  1.16      +2 -0      parrot/imcc/reg_alloc.c
  
  Index: reg_alloc.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/reg_alloc.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -w -r1.15 -r1.16
  --- reg_alloc.c       5 Aug 2004 09:49:45 -0000       1.15
  +++ reg_alloc.c       6 Aug 2004 12:23:40 -0000       1.16
  @@ -80,6 +80,8 @@
   
       imcc_init_tables(interpreter);
       allocated = 0;
  +    if (!unit->instructions)
  +        return;
   
   #if IMC_TRACE
       fprintf(stderr, "reg_alloc.c: imc_reg_alloc\n");
  
  
  

Reply via email to