def expand(self, e: ExprModel) -> ExprModel: if ForeachRefExpander.EN_DEBUG > 0: print("--> ForeachRefExpander::expand") self._field = None self._expr = None # Tracks whether a foreach index is used anywhere in the expression self._refs_index_var = False e.accept(self) if self._refs_index_var: if self._expr is not None: ret = self._expr elif self._field is not None: ret = ExprFieldRefModel(self._field) else: raise Exception( "references index vars, but failed to resolve field") else: ret = None if ForeachRefExpander.EN_DEBUG > 0: print("<-- ForeachRefExpander::expand ret=%s" % str(ret)) return ret
def field(self, e: ExprModel, fail_on_failure=True): e.accept(self) if self.fm is None and fail_on_failure: from vsc.visitors.model_pretty_printer import ModelPrettyPrinter raise Exception("Failed to obtain field from expression %s" % (ModelPrettyPrinter.print(e))) return self.fm
def build(self, btor: Boolector): ret = None if self.op == UnaryExprType.Not: ret = btor.Not(self.expr.build(btor)) return ret ExprModel.build(self, btor)
def build(self, btor): from vsc.visitors.model_pretty_printer import ModelPrettyPrinter cond = ExprModel.toBool(btor, self.cond.build(btor)) true_c = self.true_c.build(btor) if self.false_c == None: ret = btor.Implies(cond, true_c) else: false_c = self.false_c.build(btor) ret = btor.Cond(cond, true_c, false_c) return ret
def build(self, btor): return ExprModel.toBool(btor, self.e.build(btor))
def build(self, btor): cond = ExprModel.toBool(btor, self.cond.build(btor)) body = super().build(btor) return btor.Implies(cond, body)
def build(self, btor): raise Exception("") ExprModel.build(self, btor)
def val(self): # TODO: return min or max value of the propagator ExprModel.val(self)