cvsuser     04/08/05 08:48:42

  Modified:    ast      node.c
               config/gen/makefiles root.in
               languages/python/t/basic 02_expr.t
  Log:
  ast 18 - store var by name; fixes
  
  Revision  Changes    Path
  1.20      +8 -19     parrot/ast/node.c
  
  Index: node.c
  ===================================================================
  RCS file: /cvs/public/parrot/ast/node.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -w -r1.19 -r1.20
  --- node.c    5 Aug 2004 13:54:28 -0000       1.19
  +++ node.c    5 Aug 2004 15:48:33 -0000       1.20
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
  -$Id: node.c,v 1.19 2004/08/05 13:54:28 leo Exp $
  +$Id: node.c,v 1.20 2004/08/05 15:48:33 leo Exp $
   
   =head1 NAME
   
  @@ -450,14 +450,13 @@
       SymReg *regs[IMCC_MAX_REGS], *r;
       nodeType *var = CHILD(p);
       nodeType *rhs = var->next;
  -    nodeType *dest;
  +    int assigned = 0;
   
       if (rhs->expand == exp_Binary) {
           ins = cur_unit->last_ins;
  -        dest = IMCC_new_temp_node(interpreter, 'P', &p->loc);
  -        rhs->dest = dest;
  -        dest->u.var.local_nr = var->u.var.local_nr;
  +        rhs->dest = var;
           rhs = rhs->expand(interpreter, rhs);
  +        assigned = 1;
       }
       else if (rhs->expand == exp_Const) {
           /* need a new value, because the name might be aliased by
  @@ -470,19 +469,11 @@
           rhs = rhs->expand(interpreter, rhs);
       }
       ins = cur_unit->last_ins;
  -    if (strcmp(var->u.var.r->name, rhs->u.var.r->name)) {
  +    if (!assigned) {
           regs[0] = var->u.var.r;
           regs[1] = rhs->u.var.r;
  -        /*
  -         * TODO If lhs is aliased to another name, this changes both vars.
  -         *      Assign is wrong too, as "a = b" implies "(a is b) == True"
  -         */
           insINS(interpreter, cur_unit, ins, "set", regs, 2);
       }
  -    /*
  -     * TODO store in lexicals if needed, i.e. if its not a leaf function
  -     * node
  -     */
       return var;
   }
   
  @@ -749,7 +740,7 @@
   {
       Instruction *ins;
       SymReg *regs[IMCC_MAX_REGS];
  -    char buf[16];
  +    char buf[128];
   
       if (var->u.var.r->type == VTADDRESS)
           ins = insert_find_global(interpreter, var);
  @@ -759,8 +750,8 @@
        * now create a scratchpad slot for this var
        */
       regs[0] = get_const("-1", 'I');
  -    sprintf(buf, "%d", cur_unit->local_count++);
  -    regs[1] = get_const(buf, 'I');
  +    sprintf(buf, "\"%s\"", var->u.var.r->name);
  +    regs[1] = get_const(buf, 'S');
       regs[2] = var->u.var.r;
       insINS(interpreter, cur_unit, ins, "store_lex", regs, 3);
       return NULL;
  @@ -1177,8 +1168,6 @@
               child = CHILD(p);
               IMCC_free_nodes(interpreter, child);
           }
  -        if (p->dest)
  -            mem_sys_free(p->dest);
           next = p->next;
           mem_sys_free(p);
           p = next;
  
  
  
  1.232     +2 -1      parrot/config/gen/makefiles/root.in
  
  Index: root.in
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/makefiles/root.in,v
  retrieving revision 1.231
  retrieving revision 1.232
  diff -u -w -r1.231 -r1.232
  --- root.in   1 Aug 2004 16:10:15 -0000       1.231
  +++ root.in   5 Aug 2004 15:48:36 -0000       1.232
  @@ -1,4 +1,4 @@
  -# $Id: root.in,v 1.231 2004/08/01 16:10:15 leo Exp $
  +# $Id: root.in,v 1.232 2004/08/05 15:48:36 leo Exp $
   
   ###############################################################################
   #
  @@ -190,6 +190,7 @@
       $(IMCC_DIR)/instructions.h \
       $(IMCC_DIR)/debug.h \
       $(IMCC_DIR)/sets.h \
  +    $(IMCC_DIR)/unit.h \
       $(IMCC_DIR)/symbol.h \
       $(IMCC_DIR)/symreg.h \
       $(IMCC_DIR)/pbc.h \
  
  
  
  1.13      +8 -2      parrot/languages/python/t/basic/02_expr.t
  
  Index: 02_expr.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/basic/02_expr.t,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -w -r1.12 -r1.13
  --- 02_expr.t 5 Aug 2004 06:57:22 -0000       1.12
  +++ 02_expr.t 5 Aug 2004 15:48:42 -0000       1.13
  @@ -1,9 +1,9 @@
  -# $Id: 02_expr.t,v 1.12 2004/08/05 06:57:22 leo Exp $
  +# $Id: 02_expr.t,v 1.13 2004/08/05 15:48:42 leo Exp $
   
   use strict;
   use lib '../../lib';
   
  -use Parrot::Test tests => 20;
  +use Parrot::Test tests => 21;
   
   sub test {
       language_output_is('python', $_[0], '', $_[1]);
  @@ -51,6 +51,12 @@
   print a, b
   CODE
   
  +test( <<'CODE', 'assign a,b - change one' );
  +a=b=41
  +b=2
  +print a,b
  +CODE
  +
   test( <<'CODE', 'sub I, P' );
   a = 1 + 2
   a = 4 - a
  
  
  

Reply via email to