aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-08-10 14:48:52 +0000
committerbloodstalker <thabogre@gmail.com>2018-08-10 14:48:52 +0000
commita1cd8204343a4e4c173691dc646c85f883d76bad (patch)
tree41dafb4a93502d5ec0faf19387560e059b837ba1 /main.py
parentupdate (diff)
downloadfaultreiber-a1cd8204343a4e4c173691dc646c85f883d76bad.tar.gz
faultreiber-a1cd8204343a4e4c173691dc646c85f883d76bad.zip
update
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/main.py b/main.py
index 9d43c59..335935f 100755
--- a/main.py
+++ b/main.py
@@ -329,12 +329,20 @@ class CodeGen(object):
if "encoding" in cond.attrib:
for_read = "dummy->" + cond.attrib["name"] + array_subscript + "=" + get_encoding_read(cond.attrib["encoding"])
else:
- for_read = text.c_read_gen_2.replace("XXX", "dummy" + "->"+ cond.attrib["name"] + array_subscript).replace("YYY", ref_size)
+ if cond.attrib["name"] == "string":
+ for_read = "dummy->" + cond.attrib["name"] + " = " + "malloc(" + ref_size + "+1);\n"
+ for_read += "dummy->" + cond.attrib["name"] + "["+ref_size+"]=" + "0;\n"
+ for_read = text.c_read_gen_2_no.replace("XXX", "dummy" + "->"+ cond.attrib["name"] + array_subscript).replace("YYY", ref_size)
+ else:
+ for_read = text.c_read_gen_2.replace("XXX", "dummy" + "->"+ cond.attrib["name"] + array_subscript).replace("YYY", ref_size)
else:
if "encoding" in cond.attrib:
for_read = "dummy->" + cond.attrib["name"] + array_subscript + " = " + get_encoding_read(cond.attrib["encoding"])
else:
- for_read = text.c_read_gen.replace("XXX", "dummy" + "->" + cond.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
+ if cond.attrib["type"] == "string":
+ for_read = text.c_read_gen_no.replace("XXX", "dummy" + "->" + cond.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
+ else:
+ for_read = text.c_read_gen.replace("XXX", "dummy" + "->" + cond.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
if child_count == 1:
read_source.write(for_read)
elif child_count > 1:
@@ -345,6 +353,7 @@ class CodeGen(object):
read_source.write("if (" + "dummy->" + get_node_name(count_name_str, child) + ")\n")
read_source.write(text.simple_loop.replace("YYY", for_read).replace("XXX", "dummy->" + get_node_name(count_name_str, elem)))
read_source.write("}\n")
+ continue
if ref_node:
ref_node_name = pointer_remover(ref_node.attrib["name"])
if child_count == 1:
@@ -368,12 +377,20 @@ class CodeGen(object):
if "encoding" in child.attrib:
for_read = "dummy->" + child.attrib["name"] + array_subscript + "=" + get_encoding_read(child.attrib["encoding"])
else:
- for_read = text.c_read_gen_2.replace("XXX", "dummy" + "->"+ child.attrib["name"] + array_subscript).replace("YYY", ref_size)
+ if child.attrib["type"] == "string":
+ for_read = "dummy->" + child.attrib["name"] + " = " + "malloc(" + ref_size + "+1);\n"
+ for_read += "dummy->" + child.attrib["name"] + "["+ref_size+"]=" + "0;\n"
+ for_read += text.c_read_gen_2_no.replace("XXX", "dummy" + "->"+ child.attrib["name"] + array_subscript).replace("YYY", ref_size)
+ else:
+ for_read = text.c_read_gen_2.replace("XXX", "dummy" + "->"+ child.attrib["name"] + array_subscript).replace("YYY", ref_size)
else:
if "encoding" in child.attrib:
for_read = "dummy->" + child.attrib["name"] + array_subscript + " = " + get_encoding_read(child.attrib["encoding"])
else:
- for_read = text.c_read_gen.replace("XXX", "dummy" + "->" + child.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
+ if child.attrib["type"] == "string":
+ for_read = text.c_read_gen_no.replace("XXX", "dummy" + "->" + child.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
+ else:
+ for_read = text.c_read_gen.replace("XXX", "dummy" + "->" + child.attrib["name"] + array_subscript).replace("YYY", ref_node_name)
if child_count == 1:
read_source.write(for_read)
elif child_count > 1: