Beispiel #1
0
def is_syntactically_equal(expr1: ir.Expr, expr2: ir.Expr):
    if not expr1.is_same_expr_excluding_subexpressions(expr2):
        return False
    subexpressions1 = list(expr1.get_direct_subexpressions())
    subexpressions2 = list(expr2.get_direct_subexpressions())
    if len(subexpressions1) != len(subexpressions2):
        return False
    return all(
        is_syntactically_equal(expr1, expr2)
        for expr1, expr2 in zip(subexpressions1, subexpressions2))
Beispiel #2
0
 def _is_syntactically_equal(self, lhs: ir.Expr, rhs: ir.Expr):
     if not lhs.is_same_expr_excluding_subexpressions(rhs):
         return False
     lhs_exprs = list(lhs.get_direct_subexpressions())
     rhs_exprs = list(rhs.get_direct_subexpressions())
     if len(lhs_exprs) != len(rhs_exprs):
         return False
     return all(
         self._is_syntactically_equal(lhs_expr, rhs_expr)
         for lhs_expr, rhs_expr in zip(lhs_exprs, rhs_exprs))
Beispiel #3
0
 def is_same_term_excluding_args(self, term1: ir.Expr, term2: ir.Expr):
     return term1.is_same_expr_excluding_subexpressions(term2)
Beispiel #4
0
 def get_term_args(self, term: ir.Expr) -> List[Union[str, ir.Expr]]:
     return [
         _unpack_if_variable(expr, self.var_names,
                             self.literal_expr_by_unique_name)
         for expr in term.get_direct_subexpressions()
     ]