use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class Environment method exception.
public void exception(TraceInfo trace, BaseException e, String message, Object... args) {
__clearSilent();
if (args == null || args.length == 0) {
e.__construct(this, new StringMemory(message));
} else {
e.__construct(this, new StringMemory(String.format(message, args)));
}
e.setTraceInfo(this, trace);
throw e;
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class ErrorHandler method onError.
public boolean onError(Environment env, SystemMessage message) {
if (ErrorType.check(errorHandlerFlags, message.getType())) {
TraceInfo trace = message.getTrace().trace;
int argCount = invoker.getArgumentCount();
if (argCount < 4)
argCount = 4;
else if (argCount > 5)
argCount = 5;
Memory[] args = new Memory[argCount];
args[0] = LongMemory.valueOf(message.getType().value);
args[1] = new StringMemory(message.getMessage());
args[2] = new StringMemory(trace.getFileName());
args[3] = LongMemory.valueOf(trace.getStartLine() + 1);
if (argCount > 4)
args[4] = new ArrayMemory(false, message.getTrace().args);
try {
invoker.setTrace(null);
return (invoker.call(args).toValue() != Memory.FALSE);
} catch (ErrorException e) {
throw e;
} catch (BaseException e) {
throw e;
} catch (DieException e) {
throw e;
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
return false;
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class InfoFunctions method print_r.
public static Memory print_r(Environment env, @Runtime.Reference Memory value, boolean returned) {
StringWriter writer = new StringWriter();
Printer printer = new PrintR(env, writer);
printer.print(value);
if (returned) {
return new StringMemory(writer.toString());
} else {
env.echo(writer.toString());
return Memory.TRUE;
}
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class InfoFunctions method set_include_path.
public static String set_include_path(Environment env, String value) {
String old = env.getConfigValue("include_path", Memory.CONST_EMPTY_STRING).toString();
env.setConfigValue("include_path", new StringMemory(value));
return old;
}
use of php.runtime.memory.StringMemory in project jphp by jphp-compiler.
the class ClassEntity method emptyProperty.
public Memory emptyProperty(Environment env, TraceInfo trace, IObject object, String property) throws Throwable {
ClassEntity contex = env.getLastClassOnStack();
PropertyEntity entity = isInstanceOf(contex) ? contex.properties.get(property) : properties.get(property);
int accessFlag = entity == null ? 0 : entity.canAccess(env);
ArrayMemory props = object.getProperties();
if (props != null && accessFlag == 0) {
Memory tmp = props.getByScalar(entity == null ? property : entity.specificName);
if (tmp != null) {
return tmp.toBoolean() ? Memory.TRUE : Memory.NULL;
} else
return Memory.NULL;
}
if (methodMagicIsset != null) {
Memory result;
if (contex != null && contex.getId() == methodMagicIsset.getClazz().getId()) {
if (env.peekCall(0).flags == FLAG_ISSET) {
return object.getProperties().getByScalar(property) != null ? Memory.TRUE : Memory.NULL;
}
}
try {
Memory[] args = new Memory[] { new StringMemory(property) };
env.pushCall(trace, object, args, methodMagicIsset.getName(), methodMagicIsset.getClazz().getName(), name);
env.peekCall(0).flags = FLAG_ISSET;
InvokeArgumentHelper.checkType(env, trace, methodMagicIsset, new StringMemory(property));
result = methodMagicIsset.invokeDynamic(object, env, new StringMemory(property)).toBoolean() ? Memory.TRUE : Memory.NULL;
} finally {
env.popCall();
}
return result;
}
return Memory.NULL;
}
Aggregations