Mercurial > hg > CbC > old > CbC_scripts
changeset 22:c32994789739
allow to write context in arguments list at code segment declaration.
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 31 Oct 2015 03:03:09 +0900 |
parents | 6ec2d00b0957 |
children | e22a82d584c6 |
files | meta_connector/meta_connector.py |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/meta_connector/meta_connector.py Mon Oct 26 21:15:20 2015 +0900 +++ b/meta_connector/meta_connector.py Sat Oct 31 03:03:09 2015 +0900 @@ -55,6 +55,8 @@ file.write("/*-- generated by script */\n") file.write('// '+l) file.write('__code {0:s}(struct Context* context{1:s}) {{\n'.format(caller_name,get_args_from_line(l))) + else: + file.write(l) elif not isMetaOrStub and regexed_l is not None and re.search(r"^ *goto",l): callee_name = regexed_l.group(0).rstrip('(') if callee_name == 'start_code' or re.match('meta_|meta$',callee_name): @@ -62,7 +64,7 @@ else: file.write("/*-- connected by script */\n") file.write('// '+l) - meta_name = 'meta_'+caller_name if meta_search(lines, callee_name) else 'meta' + meta_name = 'meta_'+caller_name if cs_search(lines, 'meta_'+callee_name) else 'meta' file.write("goto {0:s}(context{1:s}, {2:s});\n".format(meta_name, get_args_from_line(l),\ callee_name.capitalize())) else: @@ -83,11 +85,17 @@ return args +def create_stub(file,name): + file.write('''__code {0:s}_stub(struct Context* context) {{ + goto {0:s}(context'''.format(name)) + + file.write(');\n}\n') + # search meta code segment. # Find it : __code meta_'name' -def meta_search(lines, name): +def cs_search(lines, name): for l in lines: - if re.search(r"^ *__code +meta_{0:s}\(".format(name),l) is not None: + if re.search(r"^ *__code {0:s}\(".format(name),l) is not None: return True return False @@ -103,8 +111,6 @@ output = open(args.output[0],'w') except IOError: print("cannot open file %s" % args.output) - lines = f.readlines() connect_list = parse_meta_syntax(lines, output) - main()