From 35862fbc6e7315b6c125bfb9708c9423f0c1423f Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sun, 22 Jul 2018 02:07:34 +0430 Subject: update --- main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'main.py') 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) -- cgit v1.2.3