本文整理了Java中php.runtime.Memory.isObject()
方法的一些代码示例,展示了Memory.isObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.isObject()
方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:isObject
暂无
代码示例来源:origin: jphp-group/jphp
public static Memory issetProperty(Memory object, String property, Environment env, TraceInfo trace,
PropertyCallCache callCache, int cacheIndex)
throws Throwable {
object = object.toValue();
if (!object.isObject()) {
return Memory.NULL;
//env.error(trace, Messages.ERR_CANNOT_GET_PROPERTY_OF_NON_OBJECT.fetch(property));
}
IObject iObject = ((ObjectMemory) object).value;
return iObject.getReflection().issetProperty(env, trace, iObject, property, callCache, cacheIndex);
}
代码示例来源:origin: jphp-group/jphp
private static IObject fetchObject(Memory object, String property, Environment env, TraceInfo trace) {
object = object.toValue();
if (!object.isObject()) {
env.error(trace, Messages.ERR_CANNOT_SET_PROPERTY_OF_NON_OBJECT.fetch(property));
return null;
}
return ((ObjectMemory) object).value;
}
代码示例来源:origin: jphp-group/jphp
public static Memory get_resource_type(@Reference Memory memory) {
if (memory.isObject()) {
if (((ObjectMemory) memory).value instanceof Resource)
return new StringMemory(
((Resource) ((ObjectMemory) memory).value).getResourceType()
);
}
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
public boolean checkTypeHinting(Environment env, Memory value, String typeClass, boolean nullable) {
if (nullable && value.isNull())
return true;
if (!value.isObject()) {
return false;
}
return TypeChecker.of(typeClass).check(env, value, nullable, null);
}
代码示例来源:origin: jphp-group/jphp
@Signature
synchronized public void __clone(Environment env, TraceInfo trace) throws Throwable {
if (value == null) {
this.value = null;
} else if (value.isObject()) {
this.value = value.clone(env, trace);
} else {
this.value = value.toImmutable();
}
}
}
代码示例来源:origin: jphp-group/jphp
public static Memory emptyProperty(Memory object, String property, Environment env, TraceInfo trace,
PropertyCallCache callCache, int cacheIndex)
throws Throwable {
object = object.toValue();
if (!object.isObject()) {
return Memory.NULL;
//env.error(trace, Messages.ERR_CANNOT_GET_PROPERTY_OF_NON_OBJECT.fetch(property));
}
IObject iObject = ((ObjectMemory) object).value;
return iObject.getReflection().emptyProperty(env, trace, iObject, property);
}
代码示例来源:origin: jphp-group/jphp
@Override
public void manualUnset(Environment env){
if (this.getValue().isObject())
this.getValue().manualUnset(env);
this.unset();
}
代码示例来源:origin: jphp-group/jphp
public static boolean is_callable(Environment env, TraceInfo trace, @Reference Memory memory)
throws Throwable {
// optimize
if (memory.isObject() && memory.toValue(ObjectMemory.class).value instanceof Closure)
return true;
Invoker invoker = Invoker.valueOf(env, null, memory);
return invoker != null && invoker.canAccess(env) == 0;
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("object"))
public Memory isInstance(Environment env, Memory... args) {
if (args[0].isObject()) {
return args[0].toValue(ObjectMemory.class).getReflection().isInstanceOf(entity)
? Memory.TRUE : Memory.FALSE;
} else
return Memory.FALSE;
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean check(Environment env, Memory value, boolean nullable, String staticClassName) {
if (nullable && value.isNull())
return true;
if (!value.isObject())
return false;
ObjectMemory object = value.toValue(ObjectMemory.class);
ClassEntity oEntity = object.getReflection();
return oEntity.isInstanceOfLower(typeClassLower);
}
代码示例来源:origin: jphp-group/jphp
public static String getGivenName(Memory value) {
if (value.isObject())
return "an instance of " + value.toValue(ObjectMemory.class).getReflection().getName();
else
return value.getRealType().toString();
}
代码示例来源:origin: jphp-group/jphp
public static Memory get_parent_class(Memory object) {
if (object.isObject()) {
ClassEntity classEntity = object.toValue(ObjectMemory.class).getReflection().getParent();
if (classEntity == null)
return Memory.FALSE;
else
return new StringMemory(classEntity.getName());
} else {
return Memory.FALSE;
}
}
代码示例来源:origin: jphp-group/jphp
public static void unsetProperty(Memory object, String property, Environment env, TraceInfo trace,
PropertyCallCache callCache, int cacheIndex)
throws Throwable {
object = object.toValue();
if (!object.isObject()) {
env.error(trace, Messages.ERR_CANNOT_GET_PROPERTY_OF_NON_OBJECT.fetch(property));
}
IObject iObject = ((ObjectMemory) object).value;
iObject.getReflection().unsetProperty(env, trace, iObject, property, callCache, cacheIndex);
}
代码示例来源:origin: jphp-group/jphp
public static Memory getRefProperty(Memory object, String property, Environment env, TraceInfo trace,
PropertyCallCache callCache, int cacheIndex)
throws Throwable {
object = object.toValue();
if (!object.isObject()) {
env.error(trace,
Messages.ERR_CANNOT_GET_PROPERTY_OF_NON_OBJECT.fetch(property)
);
return Memory.NULL;
}
IObject iObject = ((ObjectMemory) object).value;
return iObject.getReflection().getRefProperty(env, trace, iObject, property, callCache, cacheIndex);
}
代码示例来源:origin: jphp-group/jphp
public static Memory makeValue(ParameterEntity param, Memory arg, Environment env, TraceInfo trace) {
if (param.isReference()) {
if (!arg.isReference() && !arg.isObject()) {
env.error(trace, ErrorType.E_ERROR, "Only variables can be passed by reference");
arg = new ReferenceMemory(arg);
}
} else {
arg = param.isMutable() ? arg.toImmutable() : arg.toValue();
}
return arg;
}
代码示例来源:origin: jphp-group/jphp
private static Memory makeNormalArg(Environment env, TraceInfo trace, ParameterEntity param, Memory arg) {
if (param.isReference()) {
if (!arg.isReference() && !arg.isObject()) {
env.error(trace, ErrorType.E_ERROR, "Only variables can be passed by reference");
return new ReferenceMemory(arg);
}
return arg;
} else {
return param.isMutable() ? arg.toImmutable() : arg.toValue();
}
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg("name"), @Arg("value"),
@Arg(value = "caseSensitive", optional = @Optional(value = "true", type = HintType.BOOLEAN))
})
public Memory defineConstant(Environment env, Memory... args){
Memory val = args[1].toValue();
if (val.isArray() || val.isObject())
env.exception("Argument 2 must be a scalar value");
if (!environment.defineConstant(args[0].toString(), val, args[2].toBoolean()))
env.exception("Constant '%s' already registered", args[0]);
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("argument"))
public Memory __construct(Environment env, Memory... args) {
Memory argument = args[0];
if (argument.isObject()) {
entity = argument.toValue(ObjectMemory.class).getReflection();
} else {
entity = env.fetchClass(argument.toString(), true);
if (entity == null)
exception(env, Messages.ERR_CLASS_NOT_FOUND.fetch(argument.toString()));
}
setEntity(entity);
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testDefine(){
Memory memory;
memory = runDynamic("class A { } return new A();", false);
Assert.assertTrue(memory.isObject());
IObject object = ((ObjectMemory)memory).value;
Assert.assertEquals("A", object.getReflection().getName());
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testProperties() throws Throwable {
Memory memory;
memory = runDynamic("class A { var $x = 11, $y = 30; } return new A();", false);
Assert.assertTrue(memory.isObject());
IObject object = ((ObjectMemory)memory).value;
Assert.assertEquals(11, object.getReflection().getProperty(environment, null, object, "x", null, 0).toLong());
Assert.assertEquals(30, object.getReflection().getProperty(environment, null, object, "y", null, 0).toLong());
memory = runDynamic("class A { public $arr = array(1, 2, 3); } return new A()->arr;", false);
Assert.assertTrue(memory.isArray());
}
内容来源于网络,如有侵权,请联系作者删除!