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