Search in sources :

Example 6 with ReferenceMemory

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

the class ObjectInvokeHelper method GetAndDecProperty.

public static Memory GetAndDecProperty(Memory object, String property, Environment env, TraceInfo trace, PropertyCallCache callCache, int cacheIndex) throws Throwable {
    IObject iObject = fetchObject(object, property, env, trace);
    if (iObject == null)
        return Memory.NULL;
    ReferenceMemory ref = new ReferenceMemory();
    iObject.getReflection().minusProperty(env, trace, iObject, property, Memory.CONST_INT_1, ref);
    return ref.value;
}
Also used : ReferenceMemory(php.runtime.memory.ReferenceMemory) IObject(php.runtime.lang.IObject)

Example 7 with ReferenceMemory

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

the class ObjectInvokeHelper method GetAndIncProperty.

public static Memory GetAndIncProperty(Memory object, String property, Environment env, TraceInfo trace, PropertyCallCache callCache, int cacheIndex) throws Throwable {
    IObject iObject = fetchObject(object, property, env, trace);
    if (iObject == null)
        return Memory.NULL;
    ReferenceMemory ref = new ReferenceMemory();
    iObject.getReflection().plusProperty(env, trace, iObject, property, Memory.CONST_INT_1, ref);
    return ref.value;
}
Also used : ReferenceMemory(php.runtime.memory.ReferenceMemory) IObject(php.runtime.lang.IObject)

Example 8 with ReferenceMemory

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

the class Closure method getOrCreateStatic.

public Memory getOrCreateStatic(String name, Memory initValue) {
    if (statics == null)
        statics = new HashedMap<String, ReferenceMemory>();
    ReferenceMemory result = statics.get(name);
    if (result == null) {
        result = new ReferenceMemory(initValue);
        statics.put(name, result);
    }
    return result;
}
Also used : ReferenceMemory(php.runtime.memory.ReferenceMemory) HashedMap(php.runtime.common.collections.map.HashedMap)

Example 9 with ReferenceMemory

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

the class Generator method setCurrent.

protected Bucket setCurrent(Memory value) {
    boolean returnRef = (((GeneratorEntity) getReflection()).isReturnReference());
    Bucket current = iterator.getCurrentValue();
    if (value instanceof KeyValueMemory) {
        if (current != null) {
            current.setKey(((KeyValueMemory) value).key);
            current.setValue(returnRef ? new ReferenceMemory(value) : value.toValue());
        } else {
            current = new Bucket(((KeyValueMemory) value).key, returnRef ? new ReferenceMemory(value) : value.toValue());
        }
    } else {
        if (returnRef) {
            value = new ReferenceMemory(value);
        }
        if (current != null) {
            current.pushValue(value);
        } else {
            current = new Bucket(Memory.CONST_INT_0, value);
        }
    }
    return current;
}
Also used : ReferenceMemory(php.runtime.memory.ReferenceMemory) KeyValueMemory(php.runtime.memory.KeyValueMemory)

Example 10 with ReferenceMemory

use of php.runtime.memory.ReferenceMemory 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)

Aggregations

ReferenceMemory (php.runtime.memory.ReferenceMemory)11 Memory (php.runtime.Memory)4 ArrayMemory (php.runtime.memory.ArrayMemory)4 StringMemory (php.runtime.memory.StringMemory)3 IObject (php.runtime.lang.IObject)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1 HashedMap (php.runtime.common.collections.map.HashedMap)1 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)1 ForeachIterator (php.runtime.lang.ForeachIterator)1 KeyValueMemory (php.runtime.memory.KeyValueMemory)1 ObjectMemory (php.runtime.memory.ObjectMemory)1 VariadicMemory (php.runtime.memory.helper.VariadicMemory)1 ParameterEntity (php.runtime.reflection.ParameterEntity)1