Changeset 2264 for proto/Compiler


Ignore:
Timestamp:
Aug 5, 2012, 3:34:31 PM (7 years ago)
Author:
cameron
Message:

Record the last stmt processed during CarryIntro?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2263 r2264  
    334334    self.current_carry = 0
    335335    self.current_adv_n = 0
     336    self.last_stmt = None
    336337    carry_count = CarryCounter().count(node)
    337338    adv_n_count = adv_nCounter().count(node)
     
    468469      return c
    469470    else: return exprnode
     471  def visit_Assign(self, assignode):
     472      self.generic_visit(assignode)
     473      self.last_stmt = assignode
     474      return assignode
     475
    470476  def visit_If(self, ifNode):
    471477    carry_base = self.current_carry
     
    473479    assert adv_nCounter().count(ifNode) == 0, "Advance(x,n) within if: illegal\n"
    474480    self.generic_visit(ifNode)
    475     if carries == 0 or self.carryin == "": return ifNode
     481    if carries == 0 or self.carryin == "":
     482      self.last_stmt = ifNode
     483      return ifNode
    476484    #CARRYSET
    477485    carry_arglist = [ast.Num(carry_base), ast.Num(carries)]
    478486    new_test = ast.BoolOp(ast.Or(), [ifNode.test, mkCall(ast.Attribute(self.carryvar, 'CarryTest', ast.Load()), carry_arglist)])
    479487    new_else_part = ifNode.orelse + [mkCallStmt(ast.Attribute(self.carryvar, 'CarryDequeueEnqueue', ast.Load()), carry_arglist)]
    480     return ast.If(new_test, ifNode.body, new_else_part)
     488    newIf = ast.If(new_test, ifNode.body, new_else_part)
     489    self.last_stmt = newIf
     490    return newIf
     491
    481492  def visit_While(self, whileNode):
    482493    if self.carryout == '':
     
    499510    else: new_test = ast.BoolOp(ast.Or(), [whileNode.test, mkCall(ast.Attribute(self.carryvar, 'CarryTest', ast.Load()), carry_arglist)])
    500511    else_part = [mkCallStmt(ast.Attribute(self.carryvar, 'CarryDequeueEnqueue', ast.Load()), carry_arglist)]   
    501     return ast.If(new_test, whileNode.body + [inner_while], else_part)
     512    newIf = ast.If(new_test, whileNode.body + [inner_while], else_part)
     513    self.last_stmt = newIf
     514    return newIf
    502515
    503516class StreamStructGen(ast.NodeVisitor):
Note: See TracChangeset for help on using the changeset viewer.