file_out.close
end
+ # Serialize `model` to a file next to `file_name`
+ fun write_model_to_file
+ do
+ # Write the model to file next to the Nit module
+ var model_path = file_name.strip_extension + ".jwrapper.bin"
+ var model_stream = model_path.to_path.open_wo
+ var serializer = new BinarySerializer(model_stream)
+ serializer.serialize model
+ model_stream.close
+ end
+
# License for the header of the generated Nit module
var license = """
# This file is part of NIT (http://www.nitlanguage.org).
if opt_verbose.value > 0 then print "# Generating Nit code"
+# Generate the Nit module
var use_comment = opt_unknown.value == 0
var use_stub = opt_unknown.value == 1
var generator = new CodeGenerator(out_file, model, use_comment, use_stub)
generator.generate
sys.perfs["code generator"].add clock.lapse
+# Write the model to a file, for use by subsequent passes
+generator.write_model_to_file
+sys.perfs["writing model"].add clock.lapse
+
if opt_verbose.value > 1 then
print "# Performance Analysis:"
print sys.perfs