diff options
author | bloodstalker <thabogre@gmail.com> | 2018-07-21 21:37:34 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2018-07-21 21:37:34 +0000 |
commit | 35862fbc6e7315b6c125bfb9708c9423f0c1423f (patch) | |
tree | 776a712fb96a921c5eede4a58fb7d55d2addfbee /main.py | |
parent | update (diff) | |
download | faultreiber-35862fbc6e7315b6c125bfb9708c9423f0c1423f.tar.gz faultreiber-35862fbc6e7315b6c125bfb9708c9423f0c1423f.zip |
update
Diffstat (limited to '')
-rwxr-xr-x | main.py | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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) |