Skip to content

Commit

Permalink
fixing struc w/ struct
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Jul 18, 2022
1 parent 79a8d6b commit 8812bac
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions spliced/predict/smeagle/smeagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,17 @@ def unwrap_location(self, param):

return loc

def parse_empty_struct(self, libname, top_name, param, variable=False):
"""
Make up a fact for an empty struct
"""
loc = param.get("location")
if loc:
loc = self.unwrap_location(param)
self.gen.fact(
fn.abi_typelocation(libname, top_name, "Import", "Empty", loc or "none")
)

def parse_type(
self,
param,
Expand All @@ -498,8 +509,11 @@ def parse_type(
param = param["type"]

if param.get("class") in ["Struct", "Class"]:
for field in param.get("fields", []):
fields = param.get("fields", [])
for field in fields:
self.parse_type(field, libname, top_name, variable=variable)
if not fields:
self.parse_empty_struct(libname, top_name, original, variable=variable)
return

elif param.get("class") == "Function":
Expand All @@ -521,7 +535,8 @@ def parse_type(
# TODO need to handle array being parsed here...
if param_type.get("class") in ["Struct", "Class"]:
location = self.unwrap_location(param)
for field in param_type.get("fields", []):
fields = param_type.get("fields", [])
for field in fields:

offset = field.get("offset")
# If the struct needes to be unwrapped again
Expand All @@ -537,6 +552,12 @@ def parse_type(
if offset:
del field["offset"]
self.parse_type(field, libname, top_name, variable=variable)

# Empty structure, etc.
if not fields:
self.parse_empty_struct(
libname, top_name, original, variable=variable
)
return

# TODO need a location for pointer
Expand Down

0 comments on commit 8812bac

Please sign in to comment.