Skip to content

Commit b44ae59

Browse files
committed
ASTI: allow for string return value
1 parent 5c6419d commit b44ae59

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

chb/app/Cfg.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,12 +685,14 @@ def ast(self,
685685
if astblock.has_return:
686686
instr = astblock.last_instruction
687687
rv = instr.return_value()
688+
astexpr: Optional[AST.ASTExpr] = None
688689
if rv is not None and not astree.returns_void():
689-
astexpr: Optional[AST.ASTExpr] = XU.xxpr_to_ast_def_expr(
690+
astexpr = XU.xxpr_to_ast_def_expr(
690691
rv, instr.xdata, instr.iaddr, astree)
691-
else:
692-
astexpr = None
693-
# astexpr = astexprs[0] if len(astexprs) == 1 else None
692+
if rv.is_string_reference:
693+
cstr = rv.constant.string_reference()
694+
straddr = hex(rv.constant.value)
695+
astexpr = astree.mk_string_constant(astexpr, cstr, straddr)
694696
rtnstmt = astree.mk_return_stmt(astexpr, instr.iaddr, instr.bytestring)
695697
blockstmts[n] = [blocknode, rtnstmt]
696698
else:

0 commit comments

Comments
 (0)