public ClassEntity fetchClass(Class<?> clazz) { ClassEntity result = fetchClass(ReflectionUtils.getClassName(clazz), false); if (result == null) throw new CriticalException("Native class is not registered - " + clazz.getName()); return result; }
public static Memory getStaticProperty(String className, String lowerClassName, String property, Environment env, TraceInfo trace, PropertyCallCache callCache, int cacheIndex, boolean lateStaticCall) throws Throwable { ClassEntity entity = env.fetchClass(className, lowerClassName, true); if (entity == null) { env.error(trace, Messages.ERR_CLASS_NOT_FOUND.fetch(className)); return Memory.NULL; } return entity.getStaticProperty( env, trace, property, true, true, entity, callCache, cacheIndex, lateStaticCall ); }
@Signature(@Arg("interface")) public Memory implementsInterface(Environment env, Memory... args) { String name = args[0].toString(); ClassEntity e = env.fetchClass(name, true); if (!e.isInterface()) exception(env, "Interface %s is a Class", name); if (!entity.isInstanceOf(e)) return Memory.FALSE; return env.fetchClass(name).isInterface() ? Memory.TRUE : Memory.FALSE; }
protected void exception(Environment env, String message, Object... args){ WrapIOException exception = new WrapIOException(env, env.fetchClass("php\\io\\IOException")); exception.__construct(env, new StringMemory(String.format(message, args))); env.__throwException(exception); }
@Signature(@Arg(value = "mode", optional = @Optional("r"))) public Memory open(Environment env, Memory... args) throws Throwable { ClassEntity classEntity = env.fetchClass(FileStream.class); return classEntity.newObject(env, env.trace(), true, StringMemory.valueOf(file.getPath()), args[0]); }
public static Memory issetStaticProperty(String className, String lowerClassName, String property, Environment env, TraceInfo trace, PropertyCallCache callCache, int cacheIndex, boolean lateStaticCall) throws Throwable { ClassEntity entity = env.fetchClass(className, lowerClassName, true); if (entity == null) { env.error(trace, Messages.ERR_CLASS_NOT_FOUND.fetch(className)); return Memory.NULL; } return entity.getStaticProperty(env, trace, property, false, true, entity, callCache, cacheIndex, lateStaticCall); }
public void exception(TraceInfo trace, Class<? extends BaseBaseException> e, String message, Object... args) { ClassEntity entity = fetchClass(e); IObject object = entity.newObjectWithoutConstruct(this); if (object instanceof BaseException) { exception(trace, (BaseException) object, message, args); } else if (object instanceof BaseError) { exception(trace, (BaseError) object, message, args); } else { throw new CriticalException("Unable to create extension object from class " + e.getName()); } }
protected ClassEntity fetchClass(String name) { ClassEntity result = compiler.getModule().findClass(name); if (result == null) result = getCompiler().getEnvironment().fetchClass(name, true); return result; }
@Signature(@Arg("className")) public Memory importClass(Environment env, Memory... args) throws Throwable { ClassEntity classEntity = env.fetchClass(args[0].toString()); if (classEntity == null) { env.exception(Messages.ERR_CLASS_NOT_FOUND.fetch(args[0])); return Memory.NULL; } environment.registerClass(classEntity); return Memory.NULL; }
@Signature public Memory getDeclaringClass(Environment env, Memory... args){ ClassEntity entity = env.fetchClass("ReflectionClass"); ReflectionClass r = new ReflectionClass(env, entity); r.setEntity(methodEntity.getClazz()); return new ObjectMemory(r); }
public Memory __throwCatch(BaseBaseException e, String className, String lowerClassName) { ClassEntity origin = e.getReflection(); ClassEntity cause = fetchClass(className, lowerClassName, false); if (cause != null && origin.isInstanceOf(cause)) return new ObjectMemory(e); if (origin.isInstanceOfLower(lowerClassName)) return new ObjectMemory(e); else return Memory.NULL; }
@Signature public Memory getDeclaringClass(Environment env, Memory... args) { if (functionEntity == null) return Memory.NULL; if (functionEntity instanceof FunctionEntity) return Memory.NULL; MethodEntity method = (MethodEntity) functionEntity; ClassEntity classEntity = env.fetchClass("ReflectionClass"); ReflectionClass r = new ReflectionClass(env, classEntity); r.setEntity(method.getClazz()); return new ObjectMemory(r); }
@Signature(@Arg("className")) public Memory exportClass(final Environment env, Memory... args) throws Throwable { ClassEntity classEntity = environment.fetchClass(args[0].toString()); if (classEntity == null) { env.exception(Messages.ERR_CLASS_NOT_FOUND.fetch(args[0])); return Memory.NULL; } env.registerClass(classEntity); return Memory.NULL; }
@Signature public Memory getDeclaringClass(Environment env, Memory... args){ ReflectionClass clazz = new ReflectionClass(env, env.fetchClass("ReflectionClass")); clazz.setEntity(entity.getClazz()); return new ObjectMemory(clazz); }
public String __getParent(TraceInfo trace, String className) { ClassEntity o = fetchClass(className, true); if (o == null) { error(trace, ErrorType.E_ERROR, Messages.ERR_CLASS_NOT_FOUND, className); return null; } if (o.getParent() == null) { error(trace, "Cannot access parent:: when current class scope has no parent"); return null; } return o.getParent().getName(); }
@Signature public Memory getInterfaces(Environment env, Memory... args) { ArrayMemory result = new ArrayMemory(); ClassEntity classEntity = env.fetchClass("ReflectionClass"); for (ClassEntity e : entity.getInterfaces().values()) { ReflectionClass cls = new ReflectionClass(env, classEntity); cls.setEntity(e); result.add(new ObjectMemory(cls)); } return result.toConstant(); }
@Signature public Memory getParentClass(Environment env, Memory... args) { if (entity.getParent() == null) return Memory.NULL; ClassEntity classEntity = env.fetchClass("ReflectionClass"); ReflectionClass result = new ReflectionClass(env, classEntity); result.setEntity(entity.getParent()); return new ObjectMemory(result); }
@Signature public Memory getPrototype(Environment env, Memory... args){ if (methodEntity.getPrototype() == null) return Memory.NULL; ClassEntity classEntity = env.fetchClass("ReflectionMethod"); ReflectionMethod r = new ReflectionMethod(env, classEntity); r.setEntity(methodEntity.getPrototype()); return new ObjectMemory(r); }
@FastMethod @Signature({ @Arg("typeName") }) public static Memory typeModule(Environment env, Memory... args) { ClassEntity classEntity = env.fetchClass(args[0].toString(), true); if (classEntity != null && classEntity.getModule() != null) { return ObjectMemory.valueOf(new WrapModule(env, classEntity.getModule())); } return Memory.NULL; }
@Signature public Memory getStaticProperties(Environment env, Memory... args) { ArrayMemory result = new ArrayMemory(); ClassEntity classEntity = env.fetchClass("ReflectionProperty"); for (PropertyEntity e : entity.getStaticProperties()) { ReflectionProperty prop = new ReflectionProperty(env, classEntity); prop.setEntity(e); result.add(new ObjectMemory(prop)); } return result.toConstant(); }