use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ReflectionClass method getStaticProperties.
@Signature
public Memory getStaticProperties(Environment env, Memory... args) {
ArrayMemory result = new ArrayMemory();
ClassEntity classEntity = env.fetchClass("ReflectionProperty");
for (PropertyEntity e : entity.getStaticProperties()) {
ReflectionProperty prop = new ReflectionProperty(env, classEntity);
prop.setEntity(e);
result.add(new ObjectMemory(prop));
}
return result.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ReflectionClass method getInterfaces.
@Signature
public Memory getInterfaces(Environment env, Memory... args) {
ArrayMemory result = new ArrayMemory();
ClassEntity classEntity = env.fetchClass("ReflectionClass");
for (ClassEntity e : entity.getInterfaces().values()) {
ReflectionClass cls = new ReflectionClass(env, classEntity);
cls.setEntity(e);
result.add(new ObjectMemory(cls));
}
return result.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ItemsUtils method combine.
@Signature({ @Arg(value = "keys", type = HintType.TRAVERSABLE), @Arg(value = "values", type = HintType.TRAVERSABLE) })
public static Memory combine(Environment env, Memory... args) {
ForeachIterator keyIterator = args[0].getNewIterator(env);
ForeachIterator valueIterator = args[1].getNewIterator(env);
ArrayMemory r = new ArrayMemory();
while (keyIterator.next()) {
if (valueIterator.next()) {
r.refOfIndex(keyIterator.getValue()).assign(valueIterator.getValue().toImmutable());
} else {
return Memory.NULL;
}
}
return r.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ItemsUtils method map.
@Signature({ @Arg(value = "collection", type = HintType.TRAVERSABLE), @Arg(value = "callback", type = HintType.CALLABLE) })
public static Memory map(Environment env, Memory... args) throws Throwable {
ForeachIterator iterator = args[0].getNewIterator(env);
if (iterator == null) {
return Memory.NULL;
}
Invoker callback = Invoker.valueOf(env, null, args[1]);
if (callback == null) {
return Memory.NULL;
}
ArrayMemory r = new ArrayMemory();
while (iterator.next()) {
r.refOfIndex(iterator.getMemoryKey()).assign(callback.call(iterator.getValue()));
}
return r.toConstant();
}
use of php.runtime.memory.ArrayMemory in project jphp by jphp-compiler.
the class ItemsUtils method flatten.
@Signature({ @Arg(value = "collection", type = HintType.TRAVERSABLE), @Arg(value = "level", optional = @Optional("-1")) })
public static Memory flatten(Environment env, Memory... args) {
ArrayMemory r = new ArrayMemory();
int level = args[1].toInteger();
ForeachIterator iterator = args[0].getNewIterator(env);
if (iterator == null) {
return Memory.NULL;
}
Set<Integer> used = new HashSet<Integer>();
used.add(args[0].getPointer());
flatten(env, iterator, used, r, 0, level);
return r.toConstant();
}
Aggregations