use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.
the class ReflectionClass method getProperty.
@Signature(@Arg("name"))
public Memory getProperty(Environment env, Memory... args) {
String name = args[0].toString();
PropertyEntity e = entity.findProperty(name);
if (e == null)
e = entity.findStaticProperty(name);
if (e == null)
return Memory.NULL;
ClassEntity classEntity = env.fetchClass("ReflectionProperty");
ReflectionProperty prop = new ReflectionProperty(env, classEntity);
prop.setEntity(e);
return new ObjectMemory(prop);
}
use of php.runtime.memory.ObjectMemory 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.ObjectMemory 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.ObjectMemory in project jphp by jphp-compiler.
the class WrapTime method of.
@Signature({ @Arg(value = "args", type = HintType.ARRAY), @Arg(value = "timeZone", nativeType = WrapTimeZone.class, optional = @Optional("null")), @Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("null")) })
public static Memory of(Environment env, Memory... args) {
Locale aLocale = args[2].isNull() ? Locale.ENGLISH : args[2].toObject(WrapLocale.class).getLocale();
Calendar calendar = Calendar.getInstance(WrapTimeZone.getTimeZone(env, args[1]), aLocale);
Memory arg = args[0];
int year = arg.valueOfIndex("year").toInteger();
Memory m = arg.toValue(ArrayMemory.class).getByScalar("month");
int month = 1;
if (m != null)
month = m.toInteger();
int day = arg.valueOfIndex("day").toInteger();
if (day < 1)
day = 1;
int hour = arg.valueOfIndex("hour").toInteger();
int min = arg.valueOfIndex("min").toInteger();
int sec = arg.valueOfIndex("sec").toInteger();
calendar.set(year, month - 1, day, hour, min, sec);
calendar.set(Calendar.MILLISECOND, arg.valueOfIndex("millis").toInteger());
return new ObjectMemory(new WrapTime(env, calendar.getTime(), calendar.getTimeZone(), aLocale));
}
use of php.runtime.memory.ObjectMemory in project jphp by jphp-compiler.
the class WrapTime method add.
@Signature(@Arg(value = "args", type = HintType.ARRAY))
public Memory add(Environment env, Memory... args) {
ArrayMemory arg = args[0].toValue(ArrayMemory.class);
Memory year = arg.getByScalar("year");
Memory month = arg.getByScalar("month");
Memory day = arg.getByScalar("day");
Memory hour = arg.getByScalar("hour");
Memory min = arg.getByScalar("min");
Memory sec = arg.getByScalar("sec");
Memory millis = arg.getByScalar("millis");
Calendar calendar1 = (Calendar) calendar.clone();
if (year != null)
calendar1.add(Calendar.YEAR, year.toInteger());
if (month != null)
calendar1.add(Calendar.MONTH, month.toInteger());
if (day != null)
calendar1.add(Calendar.DAY_OF_MONTH, day.toInteger());
if (hour != null)
calendar1.add(Calendar.HOUR_OF_DAY, hour.toInteger());
if (min != null)
calendar1.add(Calendar.MINUTE, min.toInteger());
if (sec != null)
calendar1.add(Calendar.SECOND, sec.toInteger());
if (millis != null)
calendar1.add(Calendar.MILLISECOND, millis.toInteger());
return new ObjectMemory(new WrapTime(env, calendar1.getTime(), timeZone));
}
Aggregations