本文整理了Java中php.runtime.Memory.getRealType()
方法的一些代码示例,展示了Memory.getRealType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.getRealType()
方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:getRealType
暂无
代码示例来源:origin: jphp-group/jphp
public static boolean isset(Memory[] values){
for (Memory value : values)
if (value.getRealType() == Memory.Type.NULL)
return false;
return true;
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean identical(Memory memory) {
return memory.getRealType() == Type.NULL;
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory valueOfIndex(TraceInfo trace, Memory index) {
switch (index.getRealType()) {
case OBJECT:
case ARRAY:
return UNDEFINED; // TODO ADD WARNING
}
Memory e = get(index);
return e == null ? UNDEFINED : e;
}
代码示例来源:origin: jphp-group/jphp
@Immutable
public static boolean is_scalar(Memory memory) {
switch (memory.getRealType()) {
case BOOL:
case NULL:
case INT:
case DOUBLE:
case STRING:
return true;
}
return false;
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean identical(Memory memory) {
return memory.getRealType() == Type.INT && memory.toValue(LongMemory.class).value == value;
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean identical(Memory memory) {
return memory.getRealType() == Type.DOUBLE && (memory.toValue(DoubleMemory.class)).value == value;
}
代码示例来源:origin: jphp-group/jphp
private static String escapeValue(Memory value) {
switch (value.getRealType()) {
case BOOL:
return value.toBoolean() ? "1" : "0";
default:
return value
.toString()
.replace("\r", "\\r")
.replace("\t", "\\t")
.replace("\n", "\\n");
}
}
代码示例来源:origin: jphp-group/jphp
protected static boolean expecting(Environment env, TraceInfo trace, int index, Memory memory, Memory.Type type) {
if (memory.getRealType() != type) {
env.warning(trace, "expects parameter " + index + " to be " + type.toString() +
", " + memory.getRealType().toString() + " given");
return false;
}
return true;
}
代码示例来源:origin: jphp-group/jphp
@Override
public boolean identical(Memory memory) {
return memory.getRealType() == Type.STRING && toString().equals(memory.toString());
}
代码示例来源:origin: jphp-group/jphp
public static Memory range(Environment env, TraceInfo trace, Memory low, Memory high, Memory step) {
if (low.getRealType() == Memory.Type.DOUBLE || high.getRealType() == Memory.Type.DOUBLE || step.getRealType() == Memory.Type.DOUBLE) {
return _range_double(env, trace, low.toDouble(), high.toDouble(), step.toDouble());
} else {
return _range_long(env, trace, low.toLong(), high.toLong(), step.toLong());
}
}
代码示例来源:origin: jphp-group/jphp
public static void ob_implicit_flush(Environment env, TraceInfo trace, Memory value){
OutputBuffer root = env.getDefaultBuffer();
switch (value.getRealType()){
case ARRAY:
case STRING:
case OBJECT:
env.warning(trace,
"ob_implicit_flush() expects parameter 1 to be long, " + value.getRealType().toString() + " given"
);
return;
}
if (root != null)
root.setImplicitFlush(value.toBoolean());
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory refOfIndexAsShortcut(TraceInfo trace, Memory index) {
switch (index.getRealType()) {
case OBJECT:
case ARRAY:
return new ReferenceMemory(); // TODO ADD WARNING
}
checkCopied();
return getOrCreateAsShortcut(index);
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory refOfIndex(TraceInfo trace, Memory index) {
switch (index.getRealType()) {
case OBJECT:
case ARRAY:
return new ReferenceMemory(); // TODO ADD WARNING
}
checkCopied();
return getOrCreate(index);
}
代码示例来源:origin: jphp-group/jphp
@Override
public Type getRealType() {
if (getValue().type == Type.REFERENCE)
return getValue().getRealType();
return getValue().type;
}
代码示例来源:origin: jphp-group/jphp
protected static boolean expectingImplement(Environment env, TraceInfo trace,
int index, Memory memory, Class<?> clazz) {
if (!memory.isObject() || !memory.toValue(ObjectMemory.class).getClass().isAssignableFrom(clazz)) {
String given = memory.getRealType().toString();
if (memory.isObject())
given = memory.toValue(ObjectMemory.class).getReflection().getName();
env.warning(trace, "expects parameter " + index + " must implement "
+ (clazz.isInterface() ? "interface " : "") + clazz.getSimpleName() +
", " + given + " given");
return false;
}
return true;
}
代码示例来源:origin: jphp-group/jphp
@Override
public Number convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
switch (arg.getRealType()) {
case DOUBLE: return arg.toDouble();
case INT: return arg.toInteger();
default:
return convert(env, trace, arg.toNumeric());
}
}
代码示例来源: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
@Signature({@Arg("string")})
public static Memory format(Environment env, Memory... args) {
String s = args[0].toString();
Object[] _args = new Object[args.length - 1];
for (int i = 1; i < args.length; i++) {
Memory arg = args[i];
Object _arg = arg;
switch (arg.getRealType()) {
case INT:
_arg = arg.toLong();
break;
case DOUBLE:
_arg = arg.toDouble();
break;
case BOOL:
_arg = arg.toBoolean();
break;
}
_args[i - 1] = _arg;
}
return StringMemory.valueOf(String.format(s, _args));
}
代码示例来源:origin: jphp-group/jphp
public static Memory get_class_methods(Environment env, TraceInfo trace, Memory value) {
ClassEntity entity;
if (value.isString()) {
entity = env.fetchClass(value.toString(), true);
} else if (value.isObject()) {
entity = value.toValue(ObjectMemory.class).getReflection();
} else {
env.warning(
trace, "get_class_methods(): Argument 1 must be string or object, %s given",
value.getRealType().toString()
);
return Memory.NULL;
}
if (entity == null)
return Memory.NULL;
ClassEntity context = env.getLastClassOnStack();
ArrayMemory result = new ArrayMemory();
for (MethodEntity el : entity.getMethods().values()) {
if (el.canAccess(env, context) == 0)
result.refOfPush().assign(el.getName());
}
return result.toConstant();
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("object"))
public Memory getClosure(final Environment env, Memory... args) throws Throwable {
IObject object;
if (args[0].isNull()){
object = null;
} else if (args[0].isObject()) {
object = args[0].toValue(ObjectMemory.class).value;
} else {
exception(env, "Argument 1 must be NULL or object, %s given", args[0].getRealType().toString());
return Memory.NULL;
}
if (object == null && !methodEntity.isStatic()){
exception(env, "Cannot use method as static");
return Memory.NULL;
} else if (object != null && methodEntity.isStatic()){
exception(env, "Cannot use method as non static");
return Memory.NULL;
}
return new ObjectMemory(methodEntity.getClosure(env, object));
}
}
内容来源于网络,如有侵权,请联系作者删除!