diff options
author | bloodstalker <thabogre@gmail.com> | 2018-08-05 11:22:05 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2018-08-05 11:22:05 +0000 |
commit | 2a41a12e8063af2c7bd703957676123fb004fc97 (patch) | |
tree | c55d7ab62e27e55f730bb87a70764ca08fcfc2f4 /main.py | |
parent | update (diff) | |
download | faultreiber-2a41a12e8063af2c7bd703957676123fb004fc97.tar.gz faultreiber-2a41a12e8063af2c7bd703957676123fb004fc97.zip |
update
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -282,6 +282,7 @@ class CodeGen(object): if "isaggregate" in elem.attrib: dummy_string += ", " + elem.attrib["name"] + "*" + " dummy_" + elem.attrib["name"] read_source.write(static + inline + text.c_read_elem_sig.replace("YYY", elem.attrib["name"]).replace("XXX", elem.attrib["name"]+pointer)) + read_source.write("dummy = malloc(sizeof(" + elem.attrib["name"] + "));\n") count = get_elem_count(elem) if count == 1: for child in elem: @@ -305,6 +306,8 @@ class CodeGen(object): read_source.write(for_read) else: # child_count == -1 count_name_str = child.attrib["count"][6:] + read_source.write("if (" + "dummy->" + get_node_name(count_name_str, elem) + ")\n") + read_source.write("dummy->" + child.attrib["name"] + " = " + "malloc(sizeof(void*)*" + "dummy->" + get_node_name(count_name_str, elem) + ");\n") for_read = text.c_read_elem_sig_2.replace("XXX", ref_node_name).replace("YYY", "dummy->" + child.attrib["name"] + "[i]") + ";\n" read_source.write(text.simple_loop.replace("YYY", for_read).replace("XXX", "dummy->" + get_node_name(count_name_str, elem))) else: @@ -328,6 +331,8 @@ class CodeGen(object): read_source.write(text.simple_loop.replace("YYY", for_read).replace("XXX", str(child_count))) else: # child_count = -1 count_name_str = child.attrib["count"][6:] + read_source.write("dummy->" + child.attrib["name"] + " = " + "malloc(sizeof(" + type_resolver(child, self.def_elems + self.read_elems) + ")*" + "dummy->" + get_node_name(count_name_str, elem) + ");\n") + read_source.write("if (" + "dummy->" + get_node_name(count_name_str, elem) + ")\n") read_source.write(text.simple_loop.replace("YYY", for_read).replace("XXX", "dummy->" + get_node_name(count_name_str, elem))) else: pass |