Search in sources :

Example 1 with ArrayMemory

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

the class SPLFunctions method class_implements.

public static Memory class_implements(Environment env, TraceInfo trace, Memory object, boolean autoLoad) {
    ClassEntity entity;
    if (object.isObject()) {
        entity = object.toValue(ObjectMemory.class).getReflection();
    } else {
        entity = env.fetchClass(object.toString(), autoLoad);
    }
    if (entity == null) {
        env.warning(trace, "class_implements(): Class %s does not exist and could not be loaded", object.toString());
        return Memory.FALSE;
    }
    ArrayMemory result = new ArrayMemory();
    do {
        for (ClassEntity el : entity.getInterfaces().values()) {
            result.refOfIndex(el.getName()).assign(el.getName());
        }
        entity = entity.getParent();
        if (entity == null)
            break;
    } while (true);
    return result.toConstant();
}
Also used : ClassEntity(php.runtime.reflection.ClassEntity) ArrayMemory(php.runtime.memory.ArrayMemory)

Example 2 with ArrayMemory

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

the class ReflectionFunction method invokeArgs.

@Signature(@Arg(value = "args", type = HintType.ARRAY))
public Memory invokeArgs(Environment env, Memory... args) throws Throwable {
    ArrayMemory value = args[0].toValue(ArrayMemory.class);
    Memory[] passed = value.values();
    return invoke(env, passed);
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) ObjectMemory(php.runtime.memory.ObjectMemory) StringMemory(php.runtime.memory.StringMemory)

Example 3 with ArrayMemory

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

the class InvokeArgumentHelper method makeVariadic.

public static void makeVariadic(ForeachIterator iterator, ArrayMemory variadicArray, ParameterEntity param, Environment env, TraceInfo trace, int index, String originClassName, String originMethodName) {
    while (iterator.next()) {
        Memory arg = iterator.getValue();
        if (!param.checkTypeHinting(env, arg)) {
            invalidType(env, trace, param, index + 1, arg, originClassName, originMethodName);
        }
        variadicArray.add(makeValue(param, iterator.getValue(), env, trace));
    }
}
Also used : Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) ReferenceMemory(php.runtime.memory.ReferenceMemory) ObjectMemory(php.runtime.memory.ObjectMemory) VariadicMemory(php.runtime.memory.helper.VariadicMemory)

Example 4 with ArrayMemory

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

the class WrapLocale method __debugInfo.

@Signature
public Memory __debugInfo(Environment env, Memory... args) {
    ArrayMemory r = new ArrayMemory();
    r.refOfIndex("*language").assign(locale.getLanguage());
    r.refOfIndex("*country").assign(locale.getCountry());
    r.refOfIndex("*variant").assign(locale.getVariant());
    return r.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 5 with ArrayMemory

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

the class MultipleIterator method current.

@Override
@Signature
public Memory current(Environment env, Memory... args) {
    if (iterators.size() == 0) {
        return Memory.FALSE;
    }
    ArrayMemory result = new ArrayMemory();
    ForeachIterator iterator = iterators.getNewIterator(env);
    while (iterator.next()) {
        Iterator el = iterator.getValue().toObject(Iterator.class);
        if (env.invokeMethodNoThrow(el, "valid").toBoolean()) {
            Memory current = env.invokeMethodNoThrow(el, "current");
            if ((flags & MIT_KEYS_ASSOC) == MIT_KEYS_ASSOC) {
                result.put(iterator.getKey(), current);
            } else {
                result.add(current);
            }
        } else {
            if ((flags & MIT_NEED_ALL) == MIT_NEED_ALL) {
                env.exception(InvalidArgumentException.class, "One of iterators is not valid");
            }
        }
    }
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) ForeachIterator(php.runtime.lang.ForeachIterator) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) ObjectMemory(php.runtime.memory.ObjectMemory) ForeachIterator(php.runtime.lang.ForeachIterator)

Aggregations

ArrayMemory (php.runtime.memory.ArrayMemory)200 Memory (php.runtime.Memory)79 ForeachIterator (php.runtime.lang.ForeachIterator)46 ObjectMemory (php.runtime.memory.ObjectMemory)35 Signature (php.runtime.annotation.Reflection.Signature)33 LongMemory (php.runtime.memory.LongMemory)31 StringMemory (php.runtime.memory.StringMemory)30 ReferenceMemory (php.runtime.memory.ReferenceMemory)25 KeyValueMemory (php.runtime.memory.KeyValueMemory)17 Invoker (php.runtime.invoke.Invoker)9 ClassEntity (php.runtime.reflection.ClassEntity)9 IObject (php.runtime.lang.IObject)6 ArrayMapEntryMemory (php.runtime.memory.support.ArrayMapEntryMemory)6 Map (java.util.Map)5 Test (org.junit.Test)4 DoubleMemory (php.runtime.memory.DoubleMemory)4 ArrayList (java.util.ArrayList)3 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 TraceInfo (php.runtime.env.TraceInfo)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3