def add_to_set(e: Expr) -> Expr: """ Helper function to add variables to a set. Args: expr: Expression to add. Returns: Expression. """ if e.is_id(): l.add(e) return e
def _skip_subtree(expr: Expr) -> bool: """ Skips the subtree if an expression is a terminal expression. A terminal expression is a leaf in the abstract syntax tree, such as an ExprInt (register/variable), ExprMem (memory) or ExprLoc (location label) or ExprInt (integer). Args: expr: Expression to test. Returns: True if expr is terminal expression. """ return expr.is_id() or expr.is_int() or expr.is_loc() # type: ignore
def add_to_set(e: Expr) -> Expr: """ Helper function to add variables, memory and labels to a set. Args: expr: Expression to add. Returns: Expression. """ # memory if e.is_mem(): results.add(e) # registers if e.is_id(): results.add(e) # location IDs if e.is_loc(): results.add(e) return e
def get_vars(cond: Expr, vars=[]): if cond.is_id(): vars.append(cond) return cond