Search in sources :

Example 21 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class ReflectionFunction method getParameters.

@Override
@Signature
public Memory getParameters(Environment env, Memory... args) {
    if (cachedParameters != null)
        return cachedParameters;
    if (functionEntity instanceof CompileFunctionEntity)
        exception(env, "Cannot get parameters for internal function %s()", functionEntity.getName());
    ParameterEntity[] parameters = closureEntity == null ? functionEntity.getParameters() : closureEntity.parameters;
    ClassEntity entity = env.fetchClass("ReflectionParameter");
    ArrayMemory result = new ArrayMemory();
    int i = 0;
    for (ParameterEntity param : parameters) {
        ReflectionParameter e = new ReflectionParameter(env, entity);
        e.setEntity(param);
        e.setFunctionEntity(functionEntity);
        e.setPosition(i);
        i++;
        result.add(new ObjectMemory(e));
    }
    return cachedParameters = result;
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) ArrayMemory(php.runtime.memory.ArrayMemory) ParameterEntity(php.runtime.reflection.ParameterEntity) ObjectMemory(php.runtime.memory.ObjectMemory) CompileFunctionEntity(php.runtime.reflection.CompileFunctionEntity)

Example 22 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class ReflectionFunctionAbstract method getExtension.

@Signature
public Memory getExtension(Environment env, Memory... args) {
    if (getClosureEntity() != null)
        return Memory.NULL;
    Extension extension = getEntity().getExtension();
    if (extension == null)
        return Memory.NULL;
    else {
        ReflectionExtension ext = new ReflectionExtension(env, env.fetchClass("ReflectionExtension"));
        ext.setExtension(extension);
        return new ObjectMemory(ext);
    }
}
Also used : Extension(php.runtime.ext.support.Extension) ObjectMemory(php.runtime.memory.ObjectMemory) Signature(php.runtime.annotation.Reflection.Signature)

Example 23 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class ReflectionMethod method getPrototype.

@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);
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 24 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class ReflectionMethod method getParameters.

@Override
@Signature
public Memory getParameters(Environment env, Memory... args) {
    if (cachedParameters != null)
        return cachedParameters;
    ParameterEntity[] parameters = methodEntity.getParameters(Integer.MAX_VALUE);
    ClassEntity entity = env.fetchClass("ReflectionParameter");
    ArrayMemory result = new ArrayMemory();
    int i = 0;
    for (ParameterEntity param : parameters) {
        ReflectionParameter e = new ReflectionParameter(env, entity);
        e.setEntity(param);
        e.setFunctionEntity(methodEntity);
        e.setPosition(i);
        i++;
        result.add(new ObjectMemory(e));
    }
    return cachedParameters = result;
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) ArrayMemory(php.runtime.memory.ArrayMemory) ParameterEntity(php.runtime.reflection.ParameterEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Example 25 with ObjectMemory

use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.

the class ReflectionClass method getProperties.

@Signature(@Arg(value = "filter", optional = @Optional("NULL")))
public Memory getProperties(Environment env, Memory... args) {
    int mod = args[0].isNull() ? -1 : args[0].toInteger();
    ArrayMemory result = new ArrayMemory();
    ClassEntity classEntity = env.fetchClass("ReflectionProperty");
    if (mod == -1 || (mod & ReflectionProperty.IS_STATIC) == ReflectionProperty.IS_STATIC) {
        for (PropertyEntity e : entity.getStaticProperties()) {
            ReflectionProperty prop = new ReflectionProperty(env, classEntity);
            prop.setEntity(e);
            result.add(new ObjectMemory(prop));
        }
    }
    for (PropertyEntity e : entity.getProperties()) {
        if (checkModifiers(e, mod)) {
            ReflectionProperty prop = new ReflectionProperty(env, classEntity);
            prop.setEntity(e);
            result.add(new ObjectMemory(prop));
        }
    }
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ClassEntity(php.runtime.reflection.ClassEntity) PropertyEntity(php.runtime.reflection.PropertyEntity) ObjectMemory(php.runtime.memory.ObjectMemory)

Aggregations

ObjectMemory (php.runtime.memory.ObjectMemory)55 ArrayMemory (php.runtime.memory.ArrayMemory)24 Memory (php.runtime.Memory)19 ClassEntity (php.runtime.reflection.ClassEntity)17 StringMemory (php.runtime.memory.StringMemory)14 IObject (php.runtime.lang.IObject)11 Invoker (php.runtime.invoke.Invoker)6 LongMemory (php.runtime.memory.LongMemory)6 Environment (php.runtime.env.Environment)5 MethodEntity (php.runtime.reflection.MethodEntity)5 Calendar (java.util.Calendar)4 Closure (php.runtime.lang.Closure)4 Locale (java.util.Locale)3 Test (org.junit.Test)3 WrapLocale (php.runtime.ext.core.classes.util.WrapLocale)3 PropertyEntity (php.runtime.reflection.PropertyEntity)3 AbstractFunctionEntity (php.runtime.reflection.support.AbstractFunctionEntity)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Date (java.util.Date)2 TimeZone (java.util.TimeZone)2