use of php.runtime.memory.UninitializedMemory 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;
} else if (memory instanceof UninitializedMemory) {
writeInt(-4);
writeUTF(((UninitializedMemory) memory).getArg());
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");
}
}
Aggregations