Skip to content

Commit ea04dce

Browse files
committed
[js] Add a bunch of missing async/await
1 parent 70eee4b commit ea04dce

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/vm/js/Operations.nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ class QAST::OperationsJS {
19321932
add_simple_op('isne_snfg', $T_INT, [$T_STR, $T_STR]);
19331933

19341934
add_simple_op('getjsattr', $T_OBJ, [$T_OBJ, $T_STR], :decont(0), :ctx);
1935-
add_simple_op('setjsattr', $T_OBJ, [$T_OBJ, $T_STR, $T_OBJ], :decont(0, 2), :ctx, :side_effects);
1935+
add_simple_op('setjsattr', $T_OBJ, [$T_OBJ, $T_STR, $T_OBJ], :decont(0, 2), :ctx, :side_effects, :await);
19361936

19371937
add_simple_op('writeint', $T_VOID, [$T_OBJ, $T_INT, $T_INT, $T_INT], :side_effects);
19381938
add_simple_op('writeuint', $T_VOID, [$T_OBJ, $T_INT, $T_UINT32, $T_INT], :side_effects);

src/vm/js/nqp-runtime/core.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,37 +681,37 @@ function fromJS(HLL, obj, isReturnValue, isArgument) {
681681
}
682682
}
683683

684-
function argToJSWithCtx(ctx, obj) {
684+
/*async*/ function argToJSWithCtx(ctx, obj) {
685685
if (obj instanceof NativeIntArg || obj instanceof NativeUIntArg) {
686686
return obj.value;
687687
} else if (obj instanceof NativeNumArg) {
688688
return obj.value;
689689
} else if (obj instanceof NativeStrArg) {
690690
return obj.value;
691691
} else {
692-
return toJSWithCtx(ctx, obj.$$decont(ctx));
692+
return /*await*/ toJSWithCtx(ctx, /*await*/ obj.$$decont(ctx));
693693
}
694694
}
695695

696-
function returnValueToJSWithCtx(ctx, obj) {
696+
/*async*/ function returnValueToJSWithCtx(ctx, obj) {
697697
if (obj instanceof NativeNumRet) {
698698
return obj.value;
699699
} else if (obj instanceof NativeNumArg) {
700700
return obj.value;
701701
} else if (typeof obj === 'string') {
702702
return obj;
703703
} else {
704-
return toJSWithCtx(ctx, obj.$$decont(obj));
704+
return /*await*/ toJSWithCtx(ctx, /*await*/ obj.$$decont(obj));
705705
}
706706
}
707707

708-
function toJSWithCtx(ctx, obj) {
708+
/*async*/ function toJSWithCtx(ctx, obj) {
709709
const HLL = ctx.$$getHLL();
710-
if (HLL.get('str_box') && obj.$$istype(ctx, HLL.get('str_box'))) {
710+
if (HLL.get('str_box') && /*await*/ obj.$$istype(ctx, HLL.get('str_box'))) {
711711
return obj.$$getStr();
712-
} else if (HLL.get('num_box') && obj.$$istype(ctx, HLL.get('num_box'))) {
712+
} else if (HLL.get('num_box') && /*await*/ obj.$$istype(ctx, HLL.get('num_box'))) {
713713
return obj.$$getNum();
714-
} else if (HLL.get('js_box') && obj.$$istype(ctx, HLL.get('js_box'))) {
714+
} else if (HLL.get('js_box') && /*await*/ obj.$$istype(ctx, HLL.get('js_box'))) {
715715
return obj.$$jsObject;
716716
} else if (obj === HLL.get('true_value')) {
717717
return true;
@@ -722,12 +722,12 @@ function toJSWithCtx(ctx, obj) {
722722
} else if (obj.$$getBignum) {
723723
return BigInt(obj.$$getBignum().toString());
724724
} else if (op.isinvokable(obj)) {
725-
return function() {
725+
return /*async*/ function() {
726726
const converted = [null, {}];
727727
for (let i = 0; i < arguments.length; i++) {
728728
converted.push(fromJSToArgument(arguments[i]));
729729
}
730-
return returnValueToJSWithCtx(ctx, obj.$$apply(converted));
730+
return /*await*/ returnValueToJSWithCtx(ctx, /*await*/ obj.$$apply(converted));
731731
};
732732
} else if (obj.$$STable === BOOT.StrArray.$$STable) {
733733
return obj.array;
@@ -2230,8 +2230,8 @@ op.isne_snfg = function(a, b) {
22302230
return (a.normalize('NFC') === b.normalize('NFC')) ? 0 : 1;
22312231
};
22322232

2233-
op.setjsattr = function(ctx, obj, attr, value) {
2234-
return obj.$$jsObject[attr] = toJSWithCtx(ctx, value);
2233+
op.setjsattr = /*async*/ function(ctx, obj, attr, value) {
2234+
return obj.$$jsObject[attr] = /*await*/ toJSWithCtx(ctx, value);
22352235
};
22362236

22372237
op.getjsattr = function(ctx, obj, attr) {

src/vm/js/nqp-runtime/reprs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ reprs.CStruct = CStruct;
25292529
/*async*/ function callJsMethod(obj, name, args) {
25302530
const converted = [];
25312531
for (let i = 3; i < args.length; i++) {
2532-
converted.push(/*await*/ core.toJSWithCtx(args[0], args[i].$$decont(args[0])));
2532+
converted.push(/*await*/ core.toJSWithCtx(args[0], /*await*/ args[i].$$decont(args[0])));
25332533
}
25342534

25352535
if (obj.$$jsObject[name]) {
@@ -2589,7 +2589,7 @@ class WrappedJSObject extends REPR {
25892589
/*async*/ $$apply(args) {
25902590
const converted = [];
25912591
for (let i = 2; i < args.length; i++) {
2592-
converted.push(/*await*/ core.toJSWithCtx(args[0], args[i].$$decont(args[0])));
2592+
converted.push(/*await*/ core.toJSWithCtx(args[0], /*await*/ args[i].$$decont(args[0])));
25932593
}
25942594
const ret = this.$$jsObject.apply(null, converted);
25952595
return core.fromJSToReturnValue(args[0], ret);
@@ -2620,7 +2620,7 @@ class WrappedJSObject extends REPR {
26202620

26212621
const converted = [];
26222622
for (let i = 0; i < args.length; i++) {
2623-
converted.push(/*await*/ core.toJSWithCtx(ctx, args[i].$$decont(ctx)));
2623+
converted.push(/*await*/ core.toJSWithCtx(ctx, /*await*/ args[i].$$decont(ctx)));
26242624
}
26252625
return core.fromJSToReturnValue(ctx, new this.$$jsObject(...converted));
26262626
}

0 commit comments

Comments
 (0)