Search in sources :

Example 76 with ArrayMemory

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

the class WrapTimeZone method __construct.

@Signature({ @Arg("rawOffset"), @Arg("ID"), @Arg(value = "properties", type = HintType.ARRAY, optional = @Optional("null")) })
public Memory __construct(Environment env, Memory... args) {
    if (args[2].isNull()) {
        timeZone = new SimpleTimeZone(args[0].toInteger(), args[1].toString());
    } else {
        ArrayMemory props = args[2].toValue(ArrayMemory.class);
        int startMonth = props.valueOfIndex("start_month").toInteger();
        int startDay = props.valueOfIndex("start_day").toInteger();
        int startDayOfWeek = props.valueOfIndex("start_day_of_week").toInteger();
        int startTime = props.valueOfIndex("start_time").toInteger();
        int endMonth = props.valueOfIndex("end_month").toInteger();
        int endDay = props.valueOfIndex("end_day").toInteger();
        int endDayOfWeek = props.valueOfIndex("end_day_of_week").toInteger();
        int endTime = props.valueOfIndex("end_time").toInteger();
        timeZone = new SimpleTimeZone(args[0].toInteger(), args[1].toString(), startMonth, startDay, startDayOfWeek, startTime, endMonth, endDay, endDayOfWeek, endTime);
    }
    return Memory.NULL;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) SimpleTimeZone(java.util.SimpleTimeZone)

Example 77 with ArrayMemory

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

the class WrapConfiguration method getArray.

@Signature
public Memory getArray(String key, ArrayMemory def) {
    if (has(key)) {
        Memory memory = get(key);
        String[] split = StringUtils.split(memory.toString(), '|');
        ArrayMemory result = new ArrayMemory();
        for (String s : split) {
            result.add(s.trim());
        }
        return result.toConstant();
    } else {
        return def;
    }
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) TrueMemory(php.runtime.memory.TrueMemory) Memory(php.runtime.Memory) ArrayMemory(php.runtime.memory.ArrayMemory) LongMemory(php.runtime.memory.LongMemory) StringMemory(php.runtime.memory.StringMemory) Signature(php.runtime.annotation.Reflection.Signature)

Example 78 with ArrayMemory

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

the class WrapClassLoader method _getSplClassLoader.

protected synchronized SplClassLoader _getSplClassLoader(Environment env) {
    if (splClassLoader == null) {
        ArrayMemory callback = new ArrayMemory();
        callback.add(this);
        callback.add("loadClass");
        Invoker invoker = Invoker.valueOf(env, null, callback);
        splClassLoader = new SplClassLoader(invoker, callback);
    }
    return splClassLoader;
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory) SplClassLoader(php.runtime.env.SplClassLoader) Invoker(php.runtime.invoke.Invoker)

Example 79 with ArrayMemory

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

the class WrapEnvironment method getPackages.

@Signature
public Memory getPackages(Environment env, Memory... args) {
    PackageManager packageManager = this.environment.getPackageManager();
    ArrayMemory result = new ArrayMemory();
    for (String name : packageManager.names()) {
        result.add(new WrapPackage(env, packageManager.fetch(name)));
    }
    return result.toConstant();
}
Also used : ArrayMemory(php.runtime.memory.ArrayMemory)

Example 80 with ArrayMemory

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

ArrayMemory (php.runtime.memory.ArrayMemory)148 Memory (php.runtime.Memory)60 ForeachIterator (php.runtime.lang.ForeachIterator)41 ObjectMemory (php.runtime.memory.ObjectMemory)35 LongMemory (php.runtime.memory.LongMemory)31 StringMemory (php.runtime.memory.StringMemory)29 ReferenceMemory (php.runtime.memory.ReferenceMemory)25 KeyValueMemory (php.runtime.memory.KeyValueMemory)17 Invoker (php.runtime.invoke.Invoker)9 ClassEntity (php.runtime.reflection.ClassEntity)9 Signature (php.runtime.annotation.Reflection.Signature)6 IObject (php.runtime.lang.IObject)6 Map (java.util.Map)4 Test (org.junit.Test)4 DoubleMemory (php.runtime.memory.DoubleMemory)4 ConcurrentEnvironment (php.runtime.env.ConcurrentEnvironment)3 TraceInfo (php.runtime.env.TraceInfo)3 ModuleEntity (php.runtime.reflection.ModuleEntity)3 ParameterEntity (php.runtime.reflection.ParameterEntity)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2