Changeset 421


Ignore:
Timestamp:
Jul 2, 2010, 12:40:23 PM (9 years ago)
Author:
eamiri
Message:

input file can be in a different directory than the compiler

Location:
proto/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/bitstream_compiler.py

    r369 r421  
    2121
    2222    def read_template(self):
    23         f=open(self.templ_name)
     23        f=open(sys.path[0] + "/" + self.templ_name)
    2424        inp = ""
    2525        for line in f:
     
    3333        f.close()
    3434
    35     def generate_code(self, s):
     35    def generate_code(self, s, file_path):
    3636        # FRONT END
    3737        s = ast.parse(s)
    3838        livelist,s = py2bitexpr.get_lives(s)
    3939        livelist.append('error_mask')
    40         s = py2bitexpr.do_inlining(s)
     40        s = py2bitexpr.do_inlining(s, file_path)
    4141        s = py2bitexpr.translate_stmts(s)
    4242
     
    7070        #inp_file = open("parabix2.py")
    7171        inp_file = open(sys.argv[1])
     72        last_slash = sys.argv[1].rfind("/")
     73        file_path = sys.argv[1][:last_slash+1]
     74       
     75       
     76       
    7277        for line in inp_file:
    7378            mycode += line
     
    7782        if len(sys.argv) >= 3:
    7883            out_file = sys.argv[2]
    79         s = Program(out_file).generate_code(mycode)
     84        s = Program(out_file).generate_code(mycode, file_path)
  • proto/Compiler/py2bitexpr.py

    r408 r421  
    5454    pass
    5555
    56 def collect_functions(module):
     56def collect_functions(module, file_path):
    5757    imps = []
    5858    to_remove = []
     
    6767    for imp in imps:
    6868        for mod in imp.names:
    69             mod_file = open(mod.name + '.py')
     69            mod_file = open(file_path + mod.name + '.py')
    7070            mod_code = ""
    7171            for line in mod_file:
     
    344344    return [translate_var(advance), translate_var(scan_thru), translate_var(optimize)]
    345345
    346 def do_inlining(module):
    347     module = collect_functions(module)
     346def do_inlining(module, file_path):
     347    module = collect_functions(module, file_path)
    348348    func_dict = collect_names(module.body)
    349349    module = expand_list_init(module)
Note: See TracChangeset for help on using the changeset viewer.