aboutsummaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/main.py b/main.py
index e331e1c..c5ff396 100755
--- a/main.py
+++ b/main.py
@@ -100,6 +100,13 @@ def get_elem_size(elem, elems):
else:
return 0
+def get_encoding_read(encoding):
+ if encoding == "leb128u":
+ return text.c_read_leb_128_u
+ elif encoding == "leb128s":
+ return text.c_read_leb_128_s
+ else: pass
+
class Argparser(object):
def __init__(self):
parser = argparse.ArgumentParser()
@@ -156,6 +163,7 @@ class CodeGen(object):
print(elem.attrib)
def gen_reader_funcs(self):
+ temp_dec_list = []
read_source = open(self.argparser.args.outdir + "/read.c", "w")
read_source.write("\n// automatically generated by faultrieber\n")
read_source.write("// " + self.dnt + "\n")
@@ -213,9 +221,15 @@ class CodeGen(object):
if for_dummy_declare: dummy_list.append(for_dummy_declare)
for_read = str()
if "size" in child.attrib:
- for_read = text.c_read_gen_2.replace("XXX", pointer_remover(ref_node_name)+"_ins").replace("YYY", read_size_replacement)
+ if "encoding" in child.attrib:
+ for_read = get_encoding_read(child.attrib["encoding"])
+ else:
+ for_read = text.c_read_gen_2.replace("XXX", pointer_remover(ref_node_name)+"_ins").replace("YYY", read_size_replacement)
else:
- for_read = text.c_read_gen.replace("XXX", pointer_remover(ref_node_name)+"_ins").replace("YYY", pointer_remover(ref_node_name))
+ if "encoding" in child.attrib:
+ for_read = get_encoding_read(child.attrib["encoding"])
+ else:
+ for_read = text.c_read_gen.replace("XXX", pointer_remover(ref_node_name)+"_ins").replace("YYY", ref_node_name)
if child_count == 1:
for_dummy_assign = "dummy" + access + child.attrib["name"] + "=" +pointer_remover(ref_node_name)+"_ins" + ";\n"
read_source.write(for_dummy_declare+for_read+for_dummy_assign)