Search in sources :

Example 11 with ModuleEntity

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;
}
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)

Example 12 with ModuleEntity

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);
    }
}
Also used : ModuleEntity(php.runtime.reflection.ModuleEntity) IOException(java.io.IOException) CriticalException(php.runtime.exceptions.CriticalException)

Aggregations

ModuleEntity (php.runtime.reflection.ModuleEntity)12 File (java.io.File)3 Context (php.runtime.env.Context)3 ArrayMemory (php.runtime.memory.ArrayMemory)3 ClassEntity (php.runtime.reflection.ClassEntity)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Memory (php.runtime.Memory)2 ErrorException (php.runtime.exceptions.support.ErrorException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 JvmCompiler (org.develnext.jphp.core.compiler.jvm.JvmCompiler)1 ModuleOpcodePrinter (org.develnext.jphp.core.opcode.ModuleOpcodePrinter)1 SyntaxAnalyzer (org.develnext.jphp.core.syntax.SyntaxAnalyzer)1 Test (org.develnext.jphp.core.tester.Test)1 Tokenizer (org.develnext.jphp.core.tokenizer.Tokenizer)1 ReaderInputStream (org.develnext.jphp.scripting.util.ReaderInputStream)1 AbstractCompiler (php.runtime.common.AbstractCompiler)1 Environment (php.runtime.env.Environment)1 CriticalException (php.runtime.exceptions.CriticalException)1 CustomErrorException (php.runtime.exceptions.CustomErrorException)1