Compare commits
2 Commits
0.9.9-beta
...
0.9.11-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
5ba858545a
|
|||
|
446ecd8f2b
|
@@ -1,4 +1,4 @@
|
|||||||
project_group = me.topchetoeu
|
project_group = me.topchetoeu
|
||||||
project_name = jscript
|
project_name = jscript
|
||||||
project_version = 0.9.9-beta
|
project_version = 0.9.11-beta
|
||||||
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class AsyncFunctionLib extends FunctionValue {
|
|||||||
public void onReject(EngineException err) {
|
public void onReject(EngineException err) {
|
||||||
next(ctx, Values.NO_RETURN, err);
|
next(ctx, Values.NO_RETURN, err);
|
||||||
}
|
}
|
||||||
});
|
}.defer(ctx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class AsyncGeneratorLib {
|
|||||||
@Override public void onReject(EngineException err) {
|
@Override public void onReject(EngineException err) {
|
||||||
next(ctx, Values.NO_RETURN, Values.NO_RETURN, err);
|
next(ctx, Values.NO_RETURN, Values.NO_RETURN, err);
|
||||||
}
|
}
|
||||||
});
|
}.defer(ctx));
|
||||||
}
|
}
|
||||||
else if (state == 2) {
|
else if (state == 2) {
|
||||||
var obj = new ObjectValue();
|
var obj = new ObjectValue();
|
||||||
|
|||||||
@@ -53,26 +53,29 @@ public class PromiseLib {
|
|||||||
private Object val;
|
private Object val;
|
||||||
|
|
||||||
private void resolveSynchronized(Context ctx, Object val, int newState) {
|
private void resolveSynchronized(Context ctx, Object val, int newState) {
|
||||||
if (!ctx.hasNotNull(EventLoop.KEY)) throw EngineException.ofError("No event loop");
|
this.val = val;
|
||||||
|
this.state = newState;
|
||||||
ctx.get(EventLoop.KEY).pushMsg(() -> {
|
|
||||||
this.val = val;
|
for (var handle : handles) {
|
||||||
this.state = newState;
|
if (newState == STATE_FULFILLED) handle.onFulfil(val);
|
||||||
|
if (newState == STATE_REJECTED) {
|
||||||
for (var handle : handles) {
|
handle.onReject((EngineException)val);
|
||||||
if (newState == STATE_FULFILLED) handle.onFulfil(val);
|
handled = true;
|
||||||
if (newState == STATE_REJECTED) {
|
|
||||||
handle.onReject((EngineException)val);
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (state == STATE_REJECTED && !handled) {
|
if (state == STATE_REJECTED && !handled) {
|
||||||
Values.printError(((EngineException)val).setCtx(ctx), "(in promise)");
|
Values.printError(((EngineException)val).setCtx(ctx), "(in promise)");
|
||||||
}
|
}
|
||||||
|
|
||||||
handles = null;
|
handles = null;
|
||||||
}, true);
|
|
||||||
|
// ctx.get(EventLoop.KEY).pushMsg(() -> {
|
||||||
|
// if (!ctx.hasNotNull(EventLoop.KEY)) throw EngineException.ofError("No event loop");
|
||||||
|
|
||||||
|
|
||||||
|
// handles = null;
|
||||||
|
// }, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
private synchronized void resolve(Context ctx, Object val, int newState) {
|
private synchronized void resolve(Context ctx, Object val, int newState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user