compile: add module compiling_writer to replace CContext
[nit.git] / src / compiling / compiling.nit
index f052c04..4f58fbf 100644 (file)
@@ -120,7 +120,8 @@ redef class Program
                for m in module.mhe.greaters_and_self do
                        f.write("#include \"{m.name}.{get_file_ending}.h\"\n")
                end
-               f.write(v.to_s)
+               v.header_writer.write_to_stream(f)
+               v.writer.write_to_stream(f)
                f.close
        end
 end
@@ -142,18 +143,14 @@ redef class MMModule
                f.write("#ifndef {name}{program.get_file_ending}\n")
                f.write("#define {name}{program.get_file_ending}\n")
                for m in mhe.direct_greaters do f.write("#include \"{m.name}.{program.get_file_ending}.h\"\n")
-               for s in v.ctx.decls do
-                       f.write(s)
-               end
+               v.header_writer.write_to_stream(f)
                f.write("#endif\n")
                f.close
 
                f = new OFStream.open("{tc.compdir.as(not null)}/{name}.{program.get_file_ending}.c")
                f.write("/* This C file is generated by NIT to compile module {name}. */\n")
                f.write("#include \"{name}.{program.get_file_ending}.h\"\n")
-               for s in v.ctx.instrs do
-                       f.write(s)
-               end
+               v.top_writer.write_to_stream(f)
                f.close
        end
 end