Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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)
Esempio n. 4
0
    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
Esempio n. 5
0
 def build(self, btor):
     return ExprModel.toBool(btor, self.e.build(btor))
Esempio n. 6
0
    def build(self, btor):
        cond = ExprModel.toBool(btor, self.cond.build(btor))
        body = super().build(btor)

        return btor.Implies(cond, body)
Esempio n. 7
0
 def build(self, btor):
     raise Exception("")
     ExprModel.build(self, btor)
Esempio n. 8
0
 def val(self):
     # TODO: return min or max value of the propagator
     ExprModel.val(self)