php.runtime.Memory.toValue()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中php.runtime.Memory.toValue()方法的一些代码示例,展示了Memory.toValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.toValue()方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:toValue

Memory.toValue介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Override
public ArrayMemory convert(Environment env, TraceInfo trace, Memory arg) throws Throwable {
  if (arg.isNull()) {
    return null;
  }
  return arg.toValue(ArrayMemory.class);
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "array", type = HintType.ARRAY, reference = true))
public static Memory pop(Environment env, Memory... args) throws Throwable {
  Memory array  = args[0];
  Memory pop = array.toValue(ArrayMemory.class).pop();
  return pop == null ? Memory.NULL : pop;
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "array", type = HintType.ARRAY))
public static Memory peak(Environment env, Memory... args) throws Throwable {
  Memory array  = args[0];
  Memory peek = array.toValue(ArrayMemory.class).peek();
  return peek == null ? Memory.NULL : peek;
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory plus(Memory memory) {
  switch (memory.type){
    case INT:
    case DOUBLE: return memory;
    case REFERENCE: return plus(memory.toValue());
    default: return memory.toNumeric();
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean smallerEq(Memory memory) {
  switch (memory.type) {
    case ARRAY:
      int r = compare((ArrayMemory) memory, false);
      return r == 0 || r == -1;
    case REFERENCE:
      return equal(memory.toValue());
    default:
      return false;
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean greater(Memory memory) {
  switch (memory.type) {
    case ARRAY:
      return compare((ArrayMemory) memory, false) == 1;
    case REFERENCE:
      return equal(memory.toValue());
    default:
      return false;
  }
}

代码示例来源:origin: jphp-group/jphp

@Signature({
    @Arg(value = "array", type = HintType.ARRAY, reference = true),
    @Arg(value = "values", type = HintType.VARARG)
})
public static Memory push(Environment env, Memory... args) throws Throwable {
  Memory array  = args[0];
  for (int i = 1; i < args.length; i++) {
    array.toValue(ArrayMemory.class).add(args[i].toImmutable());
  }
  return Memory.NULL;
}

代码示例来源: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

@Override
public boolean smaller(Memory memory) {
  switch (memory.type){
    case INT: return 0 < ((LongMemory)memory).value;
    case DOUBLE: return 0 < ((DoubleMemory)memory).value;
    case BOOL: return 0 < memory.toLong();
    case NULL: return false;
    case REFERENCE: return smaller(memory.toValue());
    default:
      return smaller(memory.toBoolean());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean smallerEq(Memory memory) {
  switch (memory.type){
    case INT: return 0 <= ((LongMemory)memory).value;
    case DOUBLE: return 0 <= ((DoubleMemory)memory).value;
    case BOOL: return 0 <= memory.toLong();
    case NULL: return true;
    case REFERENCE: return smallerEq(memory.toValue());
    default:
      return smallerEq(memory.toBoolean());
  }
}

代码示例来源:origin: jphp-group/jphp

public static int vprintf(Environment env, TraceInfo trace, String format, Memory array) {
  if (array.isArray()) {
    return printf(env, trace, format, array.toValue(ArrayMemory.class).values());
  } else
    return printf(env, trace, format, array);
}

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory getMessage(Environment env, Memory... args) {
  if (nativeMessage != null) {
    return StringMemory.valueOf(nativeMessage);
  }
  return clazz.refOfProperty(getProperties(), "message").toValue();
}

代码示例来源:origin: jphp-group/jphp

@Runtime.Immutable(ignoreRefs = true)
public static boolean array_key_exists(Environment env, TraceInfo trace, Memory key, @Reference Memory array) {
  if (expecting(env, trace, 2, array, ARRAY)) {
    ArrayMemory tmp = array.toValue(ArrayMemory.class);
    return tmp.get(key) != null;
  } else
    return false;
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory div(Memory memory) {
  switch (memory.type){
    case DOUBLE: return new DoubleMemory(1 / ((DoubleMemory)memory).value);
    case REFERENCE: return div(memory.toValue());
    default:
      return CONST_INT_1.div(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "names", type = HintType.ARRAY))
public Memory addFunctions(Environment env, Memory... args) {
  for (Memory one : args[0].toValue(ArrayMemory.class)) {
    pkg.addFunction(one.toString());
  }
  return Memory.NULL;
}

代码示例来源: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

public static Memory key(Environment env, TraceInfo trace, @Reference Memory array) {
  if (expectingReference(env, trace, array, "key")) {
    if (expecting(env, trace, 1, array, ARRAY)) {
      Memory value = array.toValue(ArrayMemory.class).getCurrentIterator().getMemoryKey();
      return value == null ? Memory.FALSE : value;
    }
  }
  return Memory.FALSE;
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "callback", type = HintType.CALLABLE))
public Memory each(Environment env, Memory... args) {
  ForeachIterator iterator = getSelfIterator(env);
  Invoker invoker = Invoker.valueOf(env, null, args[0]);
  int cnt = 0;
  while (iterator.next()) {
    cnt++;
    if (call(iterator, invoker).toValue() == Memory.FALSE)
      break;
  }
  return LongMemory.valueOf(cnt);
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory minus(Memory memory) {
  switch (memory.type){
    case INT: return LongMemory.valueOf(1 - ((LongMemory)memory).value);
    case DOUBLE: return new DoubleMemory(1 - ((DoubleMemory)memory).value);
    case REFERENCE: return minus(memory.toValue());
    case BOOL: return LongMemory.valueOf(1 - memory.toLong());
    default: return CONST_INT_1.minus(memory.toNumeric());
  }
}

相关文章