def lhs_ast(self, astree: AbstractSyntaxTree, iaddr: str, xdata: InstrXData) -> Tuple[ASTLval, List[ASTInstruction]]: def indirect_lhs( rtype: Optional[BCTyp] ) -> Tuple[ASTLval, List[ASTInstruction]]: tmplval = astree.mk_returnval_variable_lval(iaddr, rtype) tmprhs = astree.mk_lval_expr(tmplval) reglval = astree.mk_register_variable_lval("R0") return (tmplval, [astree.mk_assign(reglval, tmprhs)]) calltarget = xdata.call_target(self.ixd) tgtname = calltarget.name models = ModelsAccess() if astree.has_symbol(tgtname) and astree.symbol(tgtname).vtype: fnsymbol = astree.symbol(tgtname) if fnsymbol.returns_void: return (astree.mk_ignored_lval(), []) else: return indirect_lhs(fnsymbol.vtype) elif models.has_so_function_summary(tgtname): summary = models.so_function_summary(tgtname) returntype = summary.signature.returntype if returntype.is_named_type: returntype = cast(MNamedType, returntype) typename = returntype.typename if typename == "void" or typename == "VOID": return (astree.mk_ignored_lval(), []) else: return indirect_lhs(None) else: return indirect_lhs(None) else: return indirect_lhs(None)
def vfunctionreturn_value_to_ast_lval( vconstvar: "VFunctionReturnValue", astree: AbstractSyntaxTree) -> AST.ASTLval: vtype = None if vconstvar.has_call_target(): calltarget = str(vconstvar.call_target()) if astree.has_symbol(calltarget): vinfo = astree.symbol(calltarget) vtype = vinfo.vtype return astree.mk_returnval_variable_lval(vconstvar.callsite, vtype)