@Signature({
@Arg("source"),
@Arg(value = "compiled", optional = @Optional("false")),
@Arg(value = "debugInformation", optional = @Optional("true"))
})
public Memory __construct(Environment env, Memory... args) throws Throwable {
InputStream is = Stream.getInputStream(env, args[0]);
try {
if (is != null) {
is = new BufferedInputStream(is);
}
Context context = new Context(is, Stream.getPath(args[0]), env.getDefaultCharset());
if (args[1].toBoolean()) {
ModuleDumper moduleDumper = new ModuleDumper(context, env, args[2].toBoolean());
module = moduleDumper.load(context.getInputStream(env.getDefaultCharset()));
} else {
AbstractCompiler compiler = env.scope.createCompiler(env, context);
module = compiler.compile(false);
}
register(env);
} finally {
Stream.closeStream(env, is);
}
return Memory.NULL;
}