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)
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