use of php.runtime.common.Callback in project jphp by jphp-compiler.
the class WrapPromise method resolve.
@Signature
public static WrapPromise resolve(Environment env, Memory result) {
if (result.instanceOf(WrapPromise.class)) {
WrapPromise promise = new WrapPromise(env);
promise.__construct(env, new RunnableInvoker(env, new Callback<Memory, Memory[]>() {
@Override
public Memory call(Memory[] args) {
try {
return ObjectMemory.valueOf(promise.then(env, Invoker.create(env, args[0]), Invoker.create(env, args[1])));
} catch (Exception e) {
env.forwardThrow(e);
return Memory.NULL;
}
}
}));
return promise;
} else {
return new WrapPromise(env, new Callback<Memory, Memory[]>() {
@Override
public Memory call(Memory[] args) {
// resolve.
return Invoker.create(env, args[0]).callAny(result);
}
});
}
}
Aggregations