コード例 #1
0
ファイル: constraints.py プロジェクト: fvutils/pyvsc
    def __init__(self, l, it=None, idx=None):
        self.stmt = None

        if it is None and idx is None:
            # Default: use it
            it = True
            idx = False
        else:
            # One or more are specified
            if idx is None:
                idx = False
            if it is None:
                it = False

        if not idx and not it:
            raise Exception("Neither it nor idx specified")

        # Form an expression to the array
        to_expr(l)
        e = pop_expr()

        self.arr_ref_e = e
        self.elem_t = Expr2FieldTypeVisitor().fieldtype(e)

        self.it = it
        self.idx = idx

        if not in_constraint_scope():
            raise Exception(
                "Attempting to use foreach constraint outside constraint scope"
            )

        self.stmt = ConstraintForeachModel(e)
        if in_srcinfo_mode():
            self.stmt.srcinfo = SourceInfo.mk()
コード例 #2
0
    def __init__(self, l, it=None, idx=None):
        self.stmt = None

        if it is None and idx is None:
            # Default: use it
            it = True
            idx = False
        else:
            # One or more are specified
            if idx is None:
                idx = False
            if it is None:
                it = False

        if not idx and not it:
            raise Exception("Neither it nor idx specified")

        self.it = it
        self.idx = idx
        self.arr = l
        self.arr_model = l._int_field_info.model
        if not in_constraint_scope():
            raise Exception(
                "Attempting to use foreach constraint outside constraint scope"
            )

        to_expr(l)
        e = pop_expr()
        self.stmt = ConstraintForeachModel(e)
コード例 #3
0
 def __init__(self, e):
     if not in_constraint_scope():
         raise Exception("Attempting to use if_then constraint outside constraint scope")
     
     to_expr(e)
     self.stmt = ConstraintIfElseModel(pop_expr())
     push_constraint_stmt(self.stmt)
コード例 #4
0
ファイル: constraints.py プロジェクト: fvutils/pyvsc
    def __init__(self, e):
        if not in_constraint_scope():
            raise Exception(
                "Attempting to use if_then constraint outside constraint scope"
            )

        to_expr(e)
        self.stmt = ConstraintImpliesModel(pop_expr())
        if in_srcinfo_mode():
            self.stmt.srcinfo = SourceInfo.mk()
コード例 #5
0
 def __enter__(self):
     if not in_constraint_scope():
         raise Exception("Attempting to use if_then constraint outside constraint scope")
     
     last_stmt = last_constraint_stmt()
     if last_stmt == None or not isinstance(last_stmt, ConstraintIfElseModel):
         raise Exception("Attempting to use else_then where it doesn't follow if_then/else_if")
     
     # Need to find where to think this in
     while last_stmt.false_c != None:
         last_stmt = last_stmt.false_c
         
     stmt = ConstraintScopeModel()
     last_stmt.false_c = stmt
     push_constraint_scope(stmt)
コード例 #6
0
 def __init__(self, e):
     self.stmt = None
     
     if not in_constraint_scope():
         raise Exception("Attempting to use if_then constraint outside constraint scope")
     
     last_stmt = last_constraint_stmt()
     if last_stmt == None or not isinstance(last_stmt, ConstraintIfElseModel):
         raise Exception("Attempting to use else_if where it doesn't follow if_then")
     
     to_expr(e)
     # Need to find where to think this in
     while last_stmt.false_c != None:
         last_stmt = last_stmt.false_c
         
     self.stmt = ConstraintIfElseModel(pop_expr())
     last_stmt.false_c = self.stmt