Search in sources :

Example 1 with ConcurrentEnvironment

use of php.runtime.env.ConcurrentEnvironment in project jphp by jphp-compiler.

the class ClassEntity method issetProperty.

public Memory issetProperty(Environment env, TraceInfo trace, IObject object, String property, PropertyCallCache callCache, int cacheIndex) throws Throwable {
    PropertyEntity entity = callCache == null || env instanceof ConcurrentEnvironment ? null : callCache.get(env, cacheIndex);
    if (entity == null) {
        ClassEntity contex = env.getLastClassOnStack();
        entity = isInstanceOf(contex) ? contex.properties.get(property) : properties.get(property);
        if (entity != null && callCache != null) {
            callCache.put(env, cacheIndex, entity);
        }
    }
    int accessFlag = entity == null ? 0 : entity.canAccess(env);
    ArrayMemory props = object.getProperties();
    Memory tmp = props == null || accessFlag != 0 ? null : props.getByScalar(entity == null ? property : entity.specificName);
    if (tmp != null)
        return tmp.isNull() ? tmp : Memory.TRUE;
    if (methodMagicIsset != null) {
        Memory result;
        ClassEntity contex = env.getLastClassOnStack();
        if (contex != null && contex.getId() == methodMagicIsset.getClazz().getId())
            if (env.peekCall(0).flags == FLAG_ISSET) {
                return object.getProperties().getByScalar(property) != null ? Memory.TRUE : Memory.NULL;
            }
        try {
            Memory[] args = new Memory[] { new StringMemory(property) };
            env.pushCall(trace, object, args, methodMagicIsset.getName(), methodMagicIsset.getClazz().getName(), name);
            env.peekCall(0).flags = FLAG_ISSET;
            InvokeArgumentHelper.checkType(env, trace, methodMagicIsset, new StringMemory(property));
            result = methodMagicIsset.invokeDynamic(object, env, new StringMemory(property)).toBoolean() ? Memory.TRUE : Memory.NULL;
        } finally {
            env.popCall();
        }
        return result;
    }
    return Memory.NULL;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ConcurrentEnvironment(php.runtime.env.ConcurrentEnvironment) ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ReferenceMemory(php.runtime.memory.ReferenceMemory) StringMemory(php.runtime.memory.StringMemory) StringMemory(php.runtime.memory.StringMemory)

Example 2 with ConcurrentEnvironment

use of php.runtime.env.ConcurrentEnvironment in project jphp by jphp-compiler.

the class ClassEntity method getRefProperty.

public Memory getRefProperty(Environment env, TraceInfo trace, IObject object, String property, PropertyCallCache callCache, int cacheIndex) throws Throwable {
    Memory value;
    PropertyEntity entity = callCache == null || env instanceof ConcurrentEnvironment ? null : callCache.get(env, cacheIndex);
    if (entity == null) {
        ClassEntity context = env.getLastClassOnStack();
        entity = isInstanceOf(context) ? context.properties.get(property) : properties.get(property);
        if (callCache != null) {
            callCache.put(env, cacheIndex, entity);
        }
    }
    if (entity == null) {
        PropertyEntity staticEntity = staticProperties.get(property);
        if (staticEntity != null) {
            invalidAccessToProperty(env, trace, staticEntity, staticEntity.canAccess(env));
            env.error(trace, ErrorType.E_STRICT, Messages.ERR_ACCESSING_STATIC_PROPERTY_AS_NON_STATIC, staticEntity.getClazz().getName(), staticEntity.getName());
        }
    }
    int accessFlag = entity == null ? 0 : entity.canAccess(env);
    ArrayMemory props = object.getProperties();
    value = props == null || accessFlag != 0 ? null : props.getByScalar(entity == null ? property : entity.specificName);
    if (accessFlag != 0)
        invalidAccessToProperty(env, trace, entity, accessFlag);
    if (value == null) {
        value = props == null ? new ReferenceMemory() : object.getProperties().refOfIndex(property);
        if (methodMagicGet != null || methodMagicSet != null) {
            env.error(trace, props == null ? ErrorType.E_ERROR : ErrorType.E_NOTICE, Messages.ERR_INDIRECT_MODIFICATION_OVERLOADED_PROPERTY, name, property);
        }
    }
    return value;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ReferenceMemory(php.runtime.memory.ReferenceMemory) ConcurrentEnvironment(php.runtime.env.ConcurrentEnvironment) ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ReferenceMemory(php.runtime.memory.ReferenceMemory) StringMemory(php.runtime.memory.StringMemory)

Example 3 with ConcurrentEnvironment

use of php.runtime.env.ConcurrentEnvironment in project jphp by jphp-compiler.

the class ClassEntity method getProperty.

public Memory getProperty(Environment env, TraceInfo trace, IObject object, String property, PropertyCallCache callCache, int cacheIndex) throws Throwable {
    Memory value;
    PropertyEntity entity = callCache == null || env instanceof ConcurrentEnvironment ? null : callCache.get(env, cacheIndex);
    if (entity == null) {
        ClassEntity context = env.getLastClassOnStack();
        entity = isInstanceOf(context) ? context.properties.get(property) : properties.get(property);
        if (callCache != null && entity != null) {
            callCache.put(env, cacheIndex, entity);
        }
    }
    if (entity == null) {
        PropertyEntity staticEntity = staticProperties.get(property);
        if (staticEntity != null) {
            invalidAccessToProperty(env, trace, staticEntity, staticEntity.canAccess(env));
            env.error(trace, ErrorType.E_STRICT, Messages.ERR_ACCESSING_STATIC_PROPERTY_AS_NON_STATIC, staticEntity.getClazz().getName(), staticEntity.getName());
        }
    }
    int accessFlag = entity == null ? 0 : entity.canAccess(env);
    if (entity != null && accessFlag != 0) {
        value = null;
    } else {
        if (entity != null) {
            value = entity.getValue(env, trace, object);
        } else {
            ArrayMemory props = object.getProperties();
            value = props == null ? null : props.getByScalar(property);
        }
    }
    if (value != null)
        return value;
    if (methodMagicGet != null) {
        Memory result;
        ClassEntity context = env.getLastClassOnStack();
        if (context != null && context.getId() == methodMagicGet.getClazz().getId()) {
            if (env.peekCall(0).flags == FLAG_GET) {
                env.error(trace, ErrorType.E_NOTICE, Messages.ERR_UNDEFINED_PROPERTY, name, property);
                return Memory.NULL;
            }
        }
        try {
            Memory[] args = new Memory[] { new StringMemory(property) };
            env.pushCall(trace, object, args, methodMagicGet.getName(), methodMagicGet.getClazz().getName(), name);
            env.peekCall(0).flags = FLAG_GET;
            InvokeArgumentHelper.checkType(env, trace, methodMagicGet, args);
            result = methodMagicGet.invokeDynamic(object, env, args);
        } finally {
            env.popCall();
        }
        return result;
    }
    if (accessFlag != 0)
        invalidAccessToProperty(env, trace, entity, accessFlag);
    env.error(trace, ErrorType.E_NOTICE, Messages.ERR_UNDEFINED_PROPERTY, name, property);
    return Memory.NULL;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ConcurrentEnvironment(php.runtime.env.ConcurrentEnvironment) ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ReferenceMemory(php.runtime.memory.ReferenceMemory) StringMemory(php.runtime.memory.StringMemory) StringMemory(php.runtime.memory.StringMemory)

Aggregations

Memory (php.runtime.Memory)3 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 ArrayMemory (php.runtime.memory.ArrayMemory)3 ReferenceMemory (php.runtime.memory.ReferenceMemory)3 StringMemory (php.runtime.memory.StringMemory)3