Make that generated files are path independent.
authorJean Privat <jean@pryen.org>
Thu, 25 Dec 2008 16:55:29 +0000 (11:55 -0500)
committerJean Privat <jean@pryen.org>
Thu, 25 Dec 2008 16:55:29 +0000 (11:55 -0500)
src/compiling/compiling.nit
src/compiling/compiling_global.nit
src/compiling/compiling_methods.nit

index f72eaea..59503a7 100644 (file)
@@ -109,8 +109,8 @@ redef class MMSrcModule
                compile_mod_to_c(v)
                var f = new OFStream.open("{tc.base_dir}/{name}.{tc.ext_prefix}_sep.h")
                f.write("/* This C header file is generated by NIT to compile modules and programs that requires {name}. */\n")
-               f.write("#ifndef {name}_{tc.ext_prefix}_sep\n")
-               f.write("#define {name}_{tc.ext_prefix}_sep\n")
+               f.write("#ifndef {name}_sep\n")
+               f.write("#define {name}_sep\n")
                for m in mhe.direct_greaters do f.write("#include \"{m.name}.{tc.ext_prefix}_sep.h\"\n")
                f.write(v.ctx.decls.join("\n"))
                f.write("\n#endif\n")
index b3fd43f..6eb0998 100644 (file)
@@ -492,7 +492,7 @@ redef class MMSrcModule
        # Compile sep files 
        meth compile_mod_to_c(v: CompilerVisitor)
        do
-               v.add_decl("#define LOCATE_{name} \"{filename}\"")
+               v.add_decl("extern const char *LOCATE_{name};")
                if not v.tc.global then
                        v.add_decl("extern const int SFT_{name}[];")
                end
@@ -526,6 +526,8 @@ redef class MMSrcModule
        # Compile module file for the current module
        meth compile_local_table_to_c(v: CompilerVisitor)
        do
+               v.add_instr("const char *LOCATE_{name} = \"{filename}\";")
+
                if v.tc.global or _local_table.is_empty then
                        return
                end
index f4af270..f055e0c 100644 (file)
@@ -327,8 +327,9 @@ redef class MMSrcMethod
                var ctx_old = v.ctx
                v.ctx = new CContext
 
-               v.add_decl("struct trace_t trace = \{NULL, LOCATE_{module.name}, {node.line_number}, LOCATE_{cname}};")
+               v.add_decl("struct trace_t trace = \{NULL, NULL, {node.line_number}, LOCATE_{cname}};")
                v.add_instr("trace.prev = tracehead; tracehead = &trace;")
+               v.add_instr("trace.file = LOCATE_{module.name};")
                var s = do_compile_inside(v, args)
                v.add_instr("tracehead = trace.prev;")
                if s == null then