def visit_Assign(self, node: gt_ir.Assign): target_name = node.target.name assert target_name in self.data.symbols inputs = self._merge_extents(self.visit(node.value)) result = StatementInfo(self.data.id_generator.new, node, inputs, {target_name}) return result
def visit_BlockStmt(self, node: gt_ir.BlockStmt): inputs = {} outputs = set() for stmt in node.stmts: stmt_info = self.visit(stmt) inputs = self._merge_extents(list(inputs.items()) + list(stmt_info.inputs.items())) outputs |= stmt_info.outputs result = StatementInfo(self.data.id_generator.new, node, inputs, outputs) return result
def visit_If(self, node: gt_ir.If): inputs = {} outputs = set() for stmt in [*node.main_body.stmts, *node.else_body.stmts]: stmt_info = self.visit(stmt) inputs = self._merge_extents(list(inputs.items()) + list(stmt_info.inputs.items())) outputs |= stmt_info.outputs cond_info = self.visit(node.condition) inputs = self._merge_extents(list(inputs.items()) + cond_info) result = StatementInfo(self.data.id_generator.new, node, inputs, outputs) return result
def visit_Decl(self, node: gt_ir.Decl): name = node.name assert node.is_api is False assert name in self.data.symbols return StatementInfo(self.data.id_generator.new, node)