Ignore:
Timestamp:
Aug 5, 2014, 12:38:42 PM (5 years ago)
Author:
cameron
Message:

Eliminating some common subexpressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/charsetcompiler/CC_compiler.py

    r3959 r3960  
    2020        predeclared = [self.bit_var(i) for i in range(0, self.mEncoding.bits)]
    2121        for sym in predeclared: self.common_expression_map[sym] = sym
     22
     23    def add_symbol_to_map(self, sym):
     24        self.common_expression_map[sym] = sym
     25
     26    def add_common_expressions(self, enclosing_cgo):
     27        for sym in enclosing_cgo.common_expression_map.keys():
     28            self.common_expression_map[sym] = enclosing_cgo.common_expression_map[sym]
    2229
    2330    def bit_var(self, n):
     
    231238            if isinstance(expr, TrueLiteral): return '-1'
    232239            elif isinstance(expr, FalseLiteral): return '0'
    233             elif isinstance(expr, Var): return expr.varname
     240            elif isinstance(expr, Var):
     241               # This is a hack.
     242               self.common_expression_map[expr.varname] = expr.varname
     243               return expr.varname
    234244            elif isinstance(expr, Not):
    235245               e = self.expr_string_to_variable(self.expr2py(expr.operand))
Note: See TracChangeset for help on using the changeset viewer.