use of php.runtime.reflection.ModuleEntity in project jphp by jphp-compiler.
the class ModuleDumper method load.
@Override
public ModuleEntity load(InputStream input) throws IOException {
DumpInputStream data = new DumpInputStream(input);
int STAMP = data.readInt();
if (STAMP != DUMP_STAMP)
throw new DumpException("Invalid file format");
int VERSION = data.readInt();
if (VERSION != DUMP_VERSION)
throw new DumpException("Invalid dump version - " + VERSION + ", only " + DUMP_VERSION);
// legacy
data.readLangMode();
ModuleEntity entity = new ModuleEntity(context);
entity.setName(data.readName());
entity.setInternalName(data.readName());
entity.setTrace(data.readTrace(context));
// constants
int count = data.readInt();
for (int i = 0; i < count; i++) {
ConstantEntity el = constantDumper.load(input);
el.setModule(entity);
entity.addConstant(el);
}
// closures
count = data.readInt();
for (int i = 0; i < count; i++) {
ClosureEntity el = closureDumper.load(input);
el.setModule(entity);
entity.addClosure(el);
}
count = data.readInt();
for (int i = 0; i < count; i++) {
GeneratorEntity el = generatorDumper.load(input);
el.setModule(entity);
entity.addGenerator(el);
}
// functions
count = data.readInt();
for (int i = 0; i < count; i++) {
FunctionEntity el = functionDumper.load(input);
el.setModule(entity);
entity.addFunction(el);
}
// classes
count = data.readInt();
ClassDumper classDumper = new ClassDumper(context, entity, env, debugInformation);
for (int i = 0; i < count; i++) {
ClassEntity el = classDumper.load(input);
el.setModule(entity);
entity.addClass(el);
}
// byte code
entity.setData(data.readRawData(Integer.MAX_VALUE));
data.readRawData(1024 * 1024 * 5);
return entity;
}
use of php.runtime.reflection.ModuleEntity in project jphp by jphp-compiler.
the class StandaloneLoader method run.
public void run(String bootstrapScriptName) {
loadExtensions();
try {
loadLibrary();
ModuleEntity bootstrap = fetchModule(bootstrapScriptName);
if (bootstrap != null) {
bootstrap.includeNoThrow(env);
} else {
System.out.println("(!) Cannot find bootstrap script.");
}
} catch (IOException e) {
throw new CriticalException(e);
}
}
Aggregations