Search in sources :

Example 16 with CriticalException

use of php.runtime.exceptions.CriticalException in project jphp by jphp-compiler.

the class ByteArrayInputStreamMemoryOperation method unconvert.

@Override
public Memory unconvert(Environment env, TraceInfo trace, ByteArrayInputStream arg) throws Throwable {
    byte[] buffer = new byte[4096];
    try {
        ByteBuffer result = ByteBuffer.allocate(20);
        int len;
        while ((len = arg.read(buffer)) > 0) {
            // nop
            result.put(buffer, 0, len);
        }
        return new BinaryMemory(result.array());
    } catch (IOException e) {
        throw new CriticalException(e);
    }
}
Also used : BinaryMemory(php.runtime.memory.BinaryMemory) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) CriticalException(php.runtime.exceptions.CriticalException)

Example 17 with CriticalException

use of php.runtime.exceptions.CriticalException in project jphp by jphp-compiler.

the class Invoker method forEnvironment.

public Invoker forEnvironment(Environment env) {
    try {
        Invoker clone = clone();
        clone.env = env;
        return clone;
    } catch (CloneNotSupportedException e) {
        throw new CriticalException(e);
    }
}
Also used : WrapInvoker(php.runtime.ext.core.classes.WrapInvoker) CriticalException(php.runtime.exceptions.CriticalException)

Example 18 with CriticalException

use of php.runtime.exceptions.CriticalException in project jphp by jphp-compiler.

the class Invoker method callAny.

public final Memory callAny(Object... args) {
    if (args != null && args.length > 0) {
        Memory[] passed = new Memory[args.length];
        for (int i = 0; i < passed.length; i++) {
            if (args[i] == null) {
                passed[i] = Memory.NULL;
                continue;
            }
            MemoryOperation operation = MemoryOperation.get(args[i].getClass(), args[i].getClass().getGenericSuperclass());
            if (operation == null) {
                throw new CriticalException("Unsupported bind type - " + args[i].getClass().toString());
            }
            passed[i] = operation.unconvertNoThow(env, trace, args[i]);
        }
        return callNoThrow(passed);
    } else {
        return callNoThrow();
    }
}
Also used : Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) MemoryOperation(php.runtime.memory.support.MemoryOperation) CriticalException(php.runtime.exceptions.CriticalException)

Example 19 with CriticalException

use of php.runtime.exceptions.CriticalException 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

CriticalException (php.runtime.exceptions.CriticalException)19 Memory (php.runtime.Memory)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IObject (php.runtime.lang.IObject)5 ObjectMemory (php.runtime.memory.ObjectMemory)4 ClassEntity (php.runtime.reflection.ClassEntity)4 IOException (java.io.IOException)3 ValueExprToken (org.develnext.jphp.core.tokenizer.token.expr.ValueExprToken)3 BaseWrapper (php.runtime.lang.BaseWrapper)3 StringMemory (php.runtime.memory.StringMemory)3 Field (java.lang.reflect.Field)2 OpenEchoTagToken (org.develnext.jphp.core.tokenizer.token.OpenEchoTagToken)2 Token (org.develnext.jphp.core.tokenizer.token.Token)2 ClassExprToken (org.develnext.jphp.core.tokenizer.token.expr.ClassExprToken)2 OperatorExprToken (org.develnext.jphp.core.tokenizer.token.expr.OperatorExprToken)2 Reflection (php.runtime.annotation.Reflection)2 Environment (php.runtime.env.Environment)2 ArrayMemory (php.runtime.memory.ArrayMemory)2 ReferenceMemory (php.runtime.memory.ReferenceMemory)2 Constructor (java.lang.reflect.Constructor)1