use of org.develnext.jphp.core.opcode.ModuleOpcodePrinter in project jphp by jphp-compiler.
the class Launcher method run.
public void run(boolean mustBootstrap, boolean disableExtensions) throws Throwable {
readConfig();
if (!disableExtensions) {
initExtensions();
}
if (isDebug()) {
if (compileScope.getTickHandler() == null) {
throw new LaunchException("Cannot find a debugger, please add the jphp-debugger dependency");
}
}
if (Startup.isShowInitDelay()) {
long t = System.currentTimeMillis() - startTime;
Startup.trace("Startup time = " + t + "ms");
}
String file = config.getProperty("bootstrap.file", "JPHP-INF/.bootstrap.php");
String classLoader = config.getProperty("env.classLoader", ReflectionUtils.getClassName(WrapClassLoader.WrapLauncherClassLoader.class));
if (classLoader != null && !(classLoader.isEmpty())) {
ClassEntity classLoaderEntity = environment.fetchClass(classLoader);
if (classLoaderEntity == null) {
throw new LaunchException("Class loader class is not found: " + classLoader);
}
WrapClassLoader loader = classLoaderEntity.newObject(environment, TraceInfo.UNKNOWN, true);
environment.invokeMethod(loader, "register", Memory.TRUE);
}
if (file != null && !file.isEmpty()) {
try {
ModuleEntity bootstrap = loadFrom(file);
if (bootstrap == null) {
throw new IOException();
}
beforeIncludeBootstrap();
if (new StringMemory(config.getProperty("bootstrap.showBytecode", "")).toBoolean()) {
ModuleOpcodePrinter moduleOpcodePrinter = new ModuleOpcodePrinter(bootstrap);
System.out.println(moduleOpcodePrinter.toString());
}
initModule(bootstrap);
ArrayMemory argv = ArrayMemory.ofStrings(this.args);
argv.unshift(Memory.NULL);
environment.getGlobals().put("argv", argv);
environment.getGlobals().put("argc", LongMemory.valueOf(argv.size()));
environment.pushCall(new CallStackItem(new TraceInfo(bootstrap.getName(), -1, -1)));
try {
bootstrap.includeNoThrow(environment);
} finally {
afterIncludeBootstrap();
environment.popCall();
compileScope.triggerProgramShutdown(environment);
if (StringMemory.valueOf(config.getProperty("env.doFinal", "1")).toBoolean()) {
environment.doFinal();
}
}
} catch (IOException e) {
throw new LaunchException("Cannot find '" + file + "' resource for `bootstrap.file` option");
}
} else if (mustBootstrap)
throw new LaunchException("Please set value of the `bootstrap.file` option in the launcher.conf file");
}
Aggregations