use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ClassEntity method unsetProperty.
public Memory unsetProperty(Environment env, TraceInfo trace, IObject object, String property, PropertyCallCache callCache, int index) throws Throwable {
ClassEntity context = env.getLastClassOnStack();
PropertyEntity entity = isInstanceOf(context) ? context.properties.get(property) : properties.get(property);
int accessFlag = entity == null ? 0 : entity.canAccess(env);
if (entity == null) {
PropertyEntity staticEntity = staticProperties.get(property);
if (staticEntity != null) {
invalidAccessToProperty(env, trace, staticEntity, staticEntity.canAccess(env));
}
}
ArrayMemory props = object.getProperties();
if (props == null || accessFlag != 0 || props.removeByScalar(entity == null ? property : entity.specificName) == null) {
if (methodMagicUnset != null) {
if (context != null && context.getId() == methodMagicUnset.getClazz().getId()) {
if (env.peekCall(0).flags == FLAG_UNSET) {
return Memory.NULL;
}
}
try {
Memory[] args = new Memory[] { new StringMemory(property) };
env.pushCall(trace, object, args, methodMagicUnset.getName(), methodMagicUnset.getClazz().getName(), name);
env.peekCall(0).flags = FLAG_UNSET;
InvokeArgumentHelper.checkType(env, trace, methodMagicUnset, args);
methodMagicUnset.invokeDynamic(object, env, args);
} finally {
env.popCall();
}
return Memory.NULL;
}
}
if (accessFlag != 0)
invalidAccessToProperty(env, trace, entity, accessFlag);
entity = staticProperties.get(property);
if (entity != null) {
env.error(trace, ErrorType.E_STRICT, Messages.ERR_ACCESSING_STATIC_PROPERTY_AS_NON_STATIC, entity.getClazz().getName(), entity.getName());
}
return Memory.NULL;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class DumpInputStream method readMemory.
public Memory readMemory() throws IOException {
int tmp = readInt();
if (tmp == -1)
return null;
if (tmp == -2)
return new ConstantMemory(readUTF());
if (tmp == -3)
return new ClassConstantMemory(readUTF(), readUTF());
if (tmp >= 0 && tmp < Memory.Type.values().length) {
Memory.Type type = Memory.Type.values()[tmp];
switch(type) {
case BOOL:
return readBoolean() ? Memory.TRUE : Memory.FALSE;
case INT:
return LongMemory.valueOf(readLong());
case DOUBLE:
return DoubleMemory.valueOf(readDouble());
case NULL:
return Memory.NULL;
case STRING:
return StringMemory.valueOf(readUTF());
case ARRAY:
ArrayMemory array = new ArrayMemory();
int size = readInt();
if (size < 0 || size > Short.MAX_VALUE)
throw new DumpException("Invalid array memory size");
for (int i = 0; i < size; i++) {
Memory key = readMemory();
Memory value = readMemory();
array.refOfIndex(key).assign(value);
}
return array;
case OBJECT:
default:
throw new DumpException("Cannot read " + type.toString() + " memory");
}
} else
throw new DumpException("Invalid ~Memory.Type value");
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class DumpOutputStream method writeMemory.
public void writeMemory(Memory memory) throws IOException {
if (memory == null) {
writeInt(-1);
return;
}
memory = memory.toValue();
if (memory instanceof ConstantMemory) {
writeInt(-2);
writeUTF(((ConstantMemory) memory).getName());
return;
} else if (memory instanceof ClassConstantMemory) {
writeInt(-3);
writeUTF(((ClassConstantMemory) memory).getClassName());
writeUTF(((ClassConstantMemory) memory).getName());
return;
}
Memory.Type type = memory.getRealType();
writeInt(type.ordinal());
switch(type) {
case NULL:
break;
case INT:
writeLong(memory.toLong());
break;
case STRING:
writeUTF(memory.toString());
break;
case DOUBLE:
writeDouble(memory.toDouble());
break;
case BOOL:
writeBoolean(memory.toBoolean());
break;
case ARRAY:
ArrayMemory array = memory.toValue(ArrayMemory.class);
if (array.size() > Short.MAX_VALUE)
throw new DumpException("Array is too big");
writeInt(array.size());
ForeachIterator foreachIterator = array.foreachIterator(false, false);
while (foreachIterator.next()) {
Memory key = foreachIterator.getMemoryKey();
Memory value = foreachIterator.getValue();
if (value.isShortcut())
throw new DumpException("Cannot dump references");
if (value.toValue() != Memory.UNDEFINED) {
writeMemory(key);
writeMemory(value.toValue());
}
}
break;
case OBJECT:
default:
throw new DumpException("Cannot dump " + type.toString() + " memory");
}
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class PropertyEntity method getValue.
public Memory getValue(Environment env, TraceInfo trace, Object object) throws Throwable {
if (getter != null && object instanceof IObject) {
return ObjectInvokeHelper.invokeMethod((IObject) object, getter, env, trace, null, false);
}
ArrayMemory props = ((IObject) object).getProperties();
Memory result = props.getByScalar(specificName);
if (result == null) {
result = props.getByScalar(name);
}
return result;
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class PSqlConnection method getCatalogs.
@Signature
public Memory getCatalogs(Environment env) throws SQLException {
ResultSet catalogs = metaData.getCatalogs();
ArrayMemory r = new ArrayMemory();
while (catalogs.next()) {
r.add(new PSqlResult(env, catalogs).toArray(env));
}
return r.toConstant();
}
Aggregations