本文整理了Java中php.runtime.Memory.toImmutable()
方法的一些代码示例,展示了Memory.toImmutable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.toImmutable()
方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:toImmutable
暂无
代码示例来源:origin: jphp-group/jphp
@Signature
private void makeFulfill(Environment env, Memory result) throws Exception {
if (this.state != State.PENDING) {
throw new IllegalStateException("This promise is already resolved, and you\'re not allowed to resolve a promise more than once");
}
this.state = State.FULFILLED;
this.value = result.toImmutable();
for (Subscriber subscriber : subscribers) {
this.invokeCallback(env, subscriber.subPromise, subscriber.onFulfilled);
}
}
代码示例来源:origin: jphp-group/jphp
public static ArrayMemory ofCollection(Collection<Memory> list) {
ArrayMemory result = new ArrayMemory();
for (Memory el : list) {
result.add(el.toImmutable());
}
return result;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public void __construct(ForeachIterator iterator) {
stack = new Stack<Memory>();
while (iterator.next()) {
stack.push(iterator.getValue().toImmutable());
}
}
代码示例来源:origin: jphp-group/jphp
@Override
public Memory toImmutable() {
switch (getValue().type){
case NULL:
case REFERENCE:
case ARRAY: return getValue().toImmutable();
default: return getValue();
}
}
代码示例来源: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 Memory toArray() {
ArrayMemory result = new ArrayMemory();
result.add(toImmutable());
return result.toConstant();
}
代码示例来源:origin: jphp-group/jphp
public Memory toObject(Environment env) {
StdClass stdClass = new StdClass(env);
stdClass.getProperties().refOfIndex("scalar").assign(toImmutable());
return new ObjectMemory(stdClass);
}
代码示例来源:origin: jphp-group/jphp
public static Memory array_shift(Environment env, TraceInfo trace, @Reference Memory input) {
if (!expectingReference(env, trace, input, "array_shift"))
return Memory.NULL;
if (!expecting(env, trace, 1, input, ARRAY))
return Memory.NULL;
Memory value = input.toValue(ArrayMemory.class).shift();
return value == null ? Memory.NULL : value.toImmutable();
}
代码示例来源:origin: jphp-group/jphp
public static Memory set_error_handler(Environment env, TraceInfo trace, @Reference Memory handler,
int flags) {
Invoker invoker = expectingCallback(env, trace, 1, handler);
if (invoker != null) {
ErrorHandler last = env.getErrorHandler();
env.setErrorHandler(new ErrorHandler(invoker, handler.toImmutable(), flags));
return last == null ? Memory.NULL : last.invokerMemory;
} else
return Memory.FALSE;
}
代码示例来源:origin: jphp-group/jphp
public static Memory set_exception_handler(Environment env, TraceInfo trace, @Reference Memory handler) {
Invoker invoker = expectingCallback(env, trace, 1, handler);
if (invoker != null) {
ExceptionHandler eh = env.getExceptionHandler();
env.setExceptionHandler(new ExceptionHandler(invoker, handler.toImmutable()));
return eh == null || eh.invoker == null ? Memory.NULL : eh.invokerMemory;
} else
return Memory.FALSE;
}
代码示例来源:origin: jphp-group/jphp
@FastMethod
@Signature({
@Arg(value = "collection", type = HintType.TRAVERSABLE)
})
public static Memory of(Environment env, Memory... args) {
return new ObjectMemory(new WrapFlow(env, args[0].toImmutable().getNewIterator(env)));
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg("name"), @Arg(value = "value", optional = @Optional("null"))
})
public Memory addSuperGlobal(Environment env, Memory... args) {
if (hasSuperGlobal(env, args[0]).toBoolean()) {
environment.exception("Super-global variable $%s already exists", args[0]);
}
environment.getScope().superGlobals.add(args[0].toString());
environment.getGlobals().putAsKeyString(args[0].toString(), args[1].toImmutable());
return Memory.UNDEFINED;
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testValueOf(){
Memory memory = ReferenceMemory.valueOf(Memory.TRUE);
Assert.assertTrue(memory instanceof ReferenceMemory);
Assert.assertFalse(memory.isImmutable());
Assert.assertNotNull(memory.toImmutable());
Assert.assertTrue(memory.toImmutable().isImmutable());
Assert.assertTrue(memory.toImmutable() instanceof TrueMemory);
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg(value = "collection", type = HintType.ARRAY)
})
public static Memory reverse(Environment env, Memory... args) {
ForeachIterator iterator = args[0].getNewIterator(env);
ArrayMemory result = new ArrayMemory();
while (iterator.next()) {
result.unshift(iterator.getValue().toImmutable());
}
return result.toConstant();
}
}
代码示例来源: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
@Signature
public Memory filters() {
ArrayMemory result = ArrayMemory.createListed(filters.getHandlers().length);
for (Handler handler : filters.getHandlers()) {
if (handler instanceof InvokeHandler) {
Invoker invoker = ((InvokeHandler) handler).getInvoker();
result.add(invoker.getMemory().toImmutable());
}
}
return result.toImmutable();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory handlers() {
ArrayMemory result = ArrayMemory.createListed(handlers.getHandlers().length);
for (Handler handler : handlers.getHandlers()) {
if (handler instanceof InvokeHandler) {
Invoker invoker = ((InvokeHandler) handler).getInvoker();
result.add(invoker.getMemory().toImmutable());
}
}
return result.toImmutable();
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory __debugInfo() {
ArrayMemory arr = ArrayMemory.createHashed();
arr.refOfIndex("*path").assign(path);
arr.refOfIndex("*methods").assign(ArrayMemory.ofStringCollection(methods));
arr.refOfIndex("*handler").assign(handler.toImmutable());
return arr;
}
代码示例来源:origin: jphp-group/jphp
public static Memory array_fill_keys(Environment env, TraceInfo trace, Memory keys, Memory value) {
if (expecting(env, trace, 1, keys, ARRAY)) {
ForeachIterator iterator = keys.getNewIterator(env);
ArrayMemory result = new ArrayMemory();
while (iterator.next()) {
result.refOfIndex(iterator.getValue()).assign(value.toImmutable());
}
return result.toConstant();
} else {
return new ArrayMemory().toConstant();
}
}
代码示例来源:origin: jphp-group/jphp
@Test
public void testTyped(){
Assert.assertTrue(Memory.TRUE.toBoolean());
Assert.assertEquals("1", Memory.TRUE.toString());
Assert.assertEquals(1.0, Memory.TRUE.toDouble(), 0.00001);
Assert.assertEquals(Memory.TRUE, Memory.TRUE.toImmutable());
}
内容来源于网络,如有侵权,请联系作者删除!