Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions chb/api/BTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ def __str__(self) -> str:
return "index-size(" + str(self.bterm) + ")"


@apiregistry.register_tag("r", BTerm)
class BTermReturnValue(BTerm):
"""Return value

args[0]: index of bterm in interface dictionary
"""

def __init__(
self, ixd: "InterfaceDictionary", ixval: IndexedTableValue) -> None:
BTerm.__init__(self, ixd, ixval)

@property
def bterm(self) -> BTerm:
return self.id.bterm(self.args[0])

def __str__(self) -> str:
return "return-value(" + str(self.bterm) + ")"


@apiregistry.register_tag("c", BTerm)
class BTermNumConstant(BTerm):
"""Constant numerical term.
Expand All @@ -164,3 +183,22 @@ def constant(self) -> int:

def __str__(self) -> str:
return str(self.constant)


@apiregistry.register_tag("n", BTerm)
class BTermNamedConstant(BTerm):
"""String constant.

tags[1]: numerical value represented as a string
"""

def __init__(
self, ixd: "InterfaceDictionary", ixval: IndexedTableValue) -> None:
BTerm.__init__(self, ixd, ixval)

@property
def constant(self) -> str:
return self.bd.string(self.args[0])

def __str__(self) -> str:
return str(self.constant)
2 changes: 1 addition & 1 deletion chb/app/CHVersion.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chbversion: str = "0.3.0-20250723"
chbversion: str = "0.3.0-20250804"
10 changes: 8 additions & 2 deletions chb/app/Cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,14 @@ def ast(self,
cstr = rv.constant.string_reference()
straddr = hex(rv.constant.value)
astexpr = astree.mk_string_constant(astexpr, cstr, straddr)
rtnstmt = astree.mk_return_stmt(astexpr, instr.iaddr, instr.bytestring)
blockstmts[n] = [blocknode, rtnstmt]
rtnstmt = astree.mk_return_stmt(
astexpr, instr.iaddr, instr.bytestring)
astree.add_expr_reachingdefs(astexpr, instr.xdata.reachingdefs)
blockstmts[n] = [blocknode, rtnstmt]
else:
rtnstmt = astree.mk_return_stmt(
None, instr.iaddr, instr.bytestring)
blockstmts[n] = [blocknode, rtnstmt]
else:
blockstmts[n] = [blocknode]

Expand Down
Loading