def visit_if(self, node: ast.If): cond = None iftrue = None iffalse = None for name, child in node.children(): if name == "cond": cond = child elif name == "iftrue": iftrue = child elif name == "iffalse": iffalse = child try: if self.visit(cond) == True: self.visit(iftrue) else: self.visit(iffalse) except: pass
def visit_if(self, node: ast.If): # print("visiting if") cond = None iftrue = None iffalse = None for name, child in node.children(): if name == "cond": cond = child elif name == "iftrue": iftrue = child elif name == "iffalse": iffalse = child try: cond = self.visit(cond) if isinstance(cond, ast.ID): cond = self.lookupSymTables(cond.getName()) if cond == True: return self.visit(iftrue) else: if iffalse: return self.visit(iffalse) except Exception as e: raise Exception(e)