Changeset 2637


Ignore:
Timestamp:
Nov 15, 2012, 7:33:23 AM (7 years ago)
Author:
cameron
Message:

GenerateCarryElseFinalization?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2636 r2637  
    512512        ifIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
    513513        return ast.BoolOp(ast.Or(), [ifTest, mkCall(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryTest', ast.Load()), [ast.Num(ifIndex), ast.Num(carry_count)])])
     514    def GenerateCarryElseFinalization(self, block_no):
     515        carry_count = self.carryInfoSet.block_op_count[block_no]
     516        if carry_count == 0: return []
     517        ifIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
     518        return [mkCallStmt(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryDequeueEnqueue', ast.Load()), [ast.Num(ifIndex), ast.Num(carry_count)])]
    514519    def GenerateCarryWhileTest(self, whileIndex): pass
    515520    def EnterLocalWhileBlock(self, operation_offset): 
     
    522527        carry_count = self.carryInfoSet.countBlockCarrysWithAdv1(0)
    523528        if carry_count == 0: return []
    524         else: return [mkCallStmt('carryQ.CarryQ_Adjust', [ast.Num(carry_count)])]
     529        else: return [mkCallStmt(ast.Attribute(ast.Name(self.carryGroupVar, ast.Load()), 'CarryQ_Adjust', ast.Load()), [ast.Num(carry_count)])]
    525530
    526531def Strategic_CCGO_Factory(carryInfoSet):
     
    743748  def visit_If(self, ifNode):
    744749    self.block_no += 1
    745     new_test = self.ccgo.GenerateCarryIfTest(self.block_no, ifNode.test)
     750    this_block = self.block_no
    746751    carry_base = self.current_carry
    747752    carries = CarryCounter().count(ifNode)
     
    754759    carry_arglist = [ast.Num(carry_base), ast.Num(carries)]
    755760    #new_test = ast.BoolOp(ast.Or(), [ifNode.test, mkCall(ast.Attribute(self.carryvar, 'CarryTest', ast.Load()), carry_arglist)])
    756     new_else_part = ifNode.orelse + [mkCallStmt(ast.Attribute(self.carryvar, 'CarryDequeueEnqueue', ast.Load()), carry_arglist)]
     761    #new_else_part = ifNode.orelse + [mkCallStmt(ast.Attribute(self.carryvar, 'CarryDequeueEnqueue', ast.Load()), carry_arglist)]
     762    new_test = self.ccgo.GenerateCarryIfTest(this_block, ifNode.test)
     763    new_else_part = ifNode.orelse + self.ccgo.GenerateCarryElseFinalization(this_block)
    757764    newIf = ast.If(new_test, ifNode.body, new_else_part)
    758765    self.last_stmt = newIf
Note: See TracChangeset for help on using the changeset viewer.