use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.
the class ClassConstantMemory method toImmutable.
@Override
public Memory toImmutable(Environment env, TraceInfo trace) {
ClassEntity classEntity = env.fetchClass(className, classLowerName, true);
if (classEntity == null) {
env.error(trace, ErrorType.E_ERROR, Messages.ERR_CLASS_NOT_FOUND, className);
return NULL;
}
ConstantEntity entity = classEntity.findConstant(name);
if (entity == null) {
env.error(trace, ErrorType.E_ERROR, Messages.ERR_UNDEFINED_CLASS_CONSTANT, className + "::" + name);
return NULL;
}
return entity.getValue();
}
use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.
the class PrintR method printClosure.
@Override
protected void printClosure(Closure closure, int level, Set<Integer> used) {
ClassEntity classEntity = closure.getReflection();
writeObjectHeader(Closure.class.getSimpleName());
if (used.contains(closure.getPointer())) {
printer.write(" *RECURSION*");
} else {
printer.write(StringUtils.repeat(' ', level));
writeOpen();
level += PRINT_INDENT;
used.add(closure.getPointer());
level -= PRINT_INDENT;
printer.write(StringUtils.repeat(' ', level));
writeClose();
used.remove(closure.getPointer());
}
}
use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.
the class VarDump method printClosure.
@Override
protected void printClosure(Closure closure, int level, Set<Integer> used) {
ClassEntity classEntity = closure.getReflection();
if (used.contains(closure.getPointer())) {
printer.write("*RECURSION*\n");
} else {
printer.write("object(");
printer.write(Closure.class.getSimpleName());
printer.write(")#" + closure.getPointer());
printer.write(" (" + closure.getUses().length + ") {\n");
level += PRINT_INDENT;
used.add(closure.getPointer());
level -= PRINT_INDENT;
printer.write(StringUtils.repeat(' ', level));
printer.write("}\n");
used.remove(closure.getPointer());
}
}
use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.
the class VarDump method printObject.
@Override
protected void printObject(ObjectMemory value, int level, Set<Integer> used) {
ClassEntity classEntity = value.getReflection();
if (used.contains(value.getPointer())) {
printer.write("*RECURSION*\n");
} else {
ArrayMemory arr;
if (classEntity.methodMagicDebugInfo != null) {
try {
Memory tmp = env.invokeMethod(value.value, classEntity.methodMagicDebugInfo.getName());
if (tmp.isArray()) {
arr = tmp.toValue(ArrayMemory.class);
} else {
arr = new ArrayMemory();
}
} catch (RuntimeException e) {
throw e;
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
} else
arr = value.getProperties();
printer.write("object(");
printer.write(classEntity.getName());
printer.write(")#" + value.getPointer());
printer.write(" (" + arr.size() + ") {\n");
level += 1;
used.add(value.getPointer());
if (classEntity.methodMagicDebugInfo == null) {
for (PropertyEntity entity : classEntity.getProperties()) {
if (entity.getGetter() != null && !entity.isHiddenInDebugInfo()) {
printer.write(StringUtils.repeat(' ', level * PRINT_INDENT));
printer.write("[\"");
printer.write(entity.getName());
printer.write('"');
printer.write(":getter]=>\n");
printer.write(StringUtils.repeat(' ', level * PRINT_INDENT));
try {
print(entity.getValue(env, TraceInfo.UNKNOWN, value.value), level, used);
} catch (RuntimeException e) {
throw e;
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
}
}
ForeachIterator iterator = arr.foreachIterator(false, false);
while (iterator.next()) {
printer.write(StringUtils.repeat(' ', level * PRINT_INDENT));
Memory key = iterator.getMemoryKey();
printer.write('[');
if (key.isString()) {
String realKey = key.toString();
int pos;
Modifier modifier = Modifier.PUBLIC;
String className = "";
if ((pos = realKey.lastIndexOf("\0")) > -1) {
if (realKey.startsWith("\0*\0")) {
modifier = Modifier.PROTECTED;
} else {
modifier = Modifier.PRIVATE;
className = realKey.substring(1, pos);
}
realKey = realKey.substring(pos + 1);
}
printer.write('"');
printer.write(realKey);
printer.write('"');
switch(modifier) {
case PRIVATE:
printer.write(":\"" + className + "\":private");
break;
case PROTECTED:
printer.write(":protected");
}
} else {
printer.write(key.toString());
}
printer.write("]=>\n");
printer.write(StringUtils.repeat(' ', level * PRINT_INDENT));
print(iterator.getValue(), level, used);
//printer.write('\n');
}
level -= 1;
printer.write(StringUtils.repeat(' ', level * PRINT_INDENT));
printer.write("}\n");
used.remove(value.getPointer());
}
}
use of php.runtime.reflection.ClassEntity in project jphp by jphp-compiler.
the class ObjectMemory method compare.
private boolean compare(Memory other, Comparator comparator) {
switch(other.type) {
case OBJECT:
ClassEntity otherReflection = ((ObjectMemory) other).getReflection();
if (otherReflection.getId() != getReflection().getId())
return false;
IObject otherObject = ((ObjectMemory) other).value;
return comparator.compare(value, otherObject);
case REFERENCE:
return compare(other.toValue(), comparator);
}
return false;
}
Aggregations