Skip to content

Commit

Permalink
Merge: fix_global_variable_dumping -> development
Browse files Browse the repository at this point in the history
fix: fix global data types dumping
  • Loading branch information
Sarapulov-Vas authored Aug 1, 2024
2 parents 0c81425 + 8f35445 commit 9197829
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/scripts/global_variables_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# pylint: disable = import-error
import re
import math
from java.lang import String


Expand Down Expand Up @@ -40,7 +41,10 @@ def read_structure(code_unit, program):
elif component.isPointer():
pointer_address = address_factory.getAddress(str(component.getValue()))
pointer = listing.getCodeUnitAt(pointer_address)
current_component_value = pointer.getLabel()
if pointer is not None:
current_component_value = pointer.getLabel()
else:
current_component_value = ""
else:
current_component_value = str(component.getValue())
struct += f"{current_component_value}, "
Expand Down Expand Up @@ -70,7 +74,9 @@ def get_array_declaration(code_unit):
variable_declaration_string = \
f'{array_type[:array_type.index("[")]} {str(code_unit.getLabel())}' + \
array_type[array_type.index("["):]
if string_array.count("0x0") == int(array_type[array_type.index("[") + 1:-1]):
if string_array is not None and\
string_array.count("0x0") ==\
math.prod(int(i) for i in re.findall(r'\[(\d*)\]', array_type)):
variable_declaration_string += " = {0}"
elif string_array is not None:
variable_declaration_string += " = " + string_array
Expand Down
6 changes: 6 additions & 0 deletions src/tests/user_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ def test_avl(clean):
def test_linpack(clean):
"""Recompiles AVL tree binary"""
assert compile_binary("linpack") == 0

def test_export_c_code():
"""Postprocessor test"""
for binary in os.listdir(INPUT_DIRECTORY):
export_c_code(f"{INPUT_DIRECTORY}{binary}", OUTPUT_PATH)
assert True

0 comments on commit 9197829

Please sign in to comment.