Search in sources :

Example 6 with GeneratorEntity

use of php.runtime.reflection.helper.GeneratorEntity 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;
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) GeneratorEntity(php.runtime.reflection.helper.GeneratorEntity) DumpInputStream(php.runtime.loader.dump.io.DumpInputStream) FunctionEntity(php.runtime.reflection.FunctionEntity) ClosureEntity(php.runtime.reflection.helper.ClosureEntity) ModuleEntity(php.runtime.reflection.ModuleEntity) DumpException(php.runtime.loader.dump.io.DumpException) ConstantEntity(php.runtime.reflection.ConstantEntity)

Aggregations

GeneratorEntity (php.runtime.reflection.helper.GeneratorEntity)6 ClassEntity (php.runtime.reflection.ClassEntity)4 ClosureEntity (php.runtime.reflection.helper.ClosureEntity)4 DumpException (php.runtime.loader.dump.io.DumpException)3 FunctionEntity (php.runtime.reflection.FunctionEntity)3 DumpInputStream (php.runtime.loader.dump.io.DumpInputStream)2 ConstantEntity (php.runtime.reflection.ConstantEntity)2 Method (java.lang.reflect.Method)1 Memory (php.runtime.Memory)1 DumpOutputStream (php.runtime.loader.dump.io.DumpOutputStream)1 ArrayMemory (php.runtime.memory.ArrayMemory)1 ModuleEntity (php.runtime.reflection.ModuleEntity)1 ParameterEntity (php.runtime.reflection.ParameterEntity)1