@mirascript/mirascript 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AOINGBRS.js → chunk-MVHCSH3E.js} +154 -65
- package/dist/chunk-MVHCSH3E.js.map +6 -0
- package/dist/cli/index.js +3 -3
- package/dist/compiler/diagnostic.d.ts +12 -3
- package/dist/compiler/diagnostic.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/subtle.js +1 -1
- package/dist/vm/lib/_helpers.d.ts.map +1 -1
- package/dist/vm/lib/global/sequence/with.d.ts +2 -2
- package/dist/vm/lib/global/sequence/with.d.ts.map +1 -1
- package/dist/vm/operations.d.ts.map +1 -1
- package/dist/vm/types/boundary.d.ts.map +1 -1
- package/dist/vm/types/checker.d.ts +1 -1
- package/dist/vm/types/checker.d.ts.map +1 -1
- package/dist/vm/types/context.d.ts +14 -6
- package/dist/vm/types/context.d.ts.map +1 -1
- package/dist/vm/types/extern.d.ts +2 -0
- package/dist/vm/types/extern.d.ts.map +1 -1
- package/dist/vm/types/index.d.ts +6 -10
- package/dist/vm/types/index.d.ts.map +1 -1
- package/dist/vm/types/module.d.ts +2 -0
- package/dist/vm/types/module.d.ts.map +1 -1
- package/dist/vm/types/wrapper.d.ts +2 -0
- package/dist/vm/types/wrapper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/compiler/diagnostic.ts +14 -12
- package/src/vm/lib/_helpers.ts +2 -10
- package/src/vm/lib/global/sequence/with.ts +111 -17
- package/src/vm/operations.ts +23 -24
- package/src/vm/types/boundary.ts +4 -4
- package/src/vm/types/checker.ts +8 -15
- package/src/vm/types/context.ts +28 -16
- package/src/vm/types/extern.ts +11 -2
- package/src/vm/types/index.ts +7 -26
- package/src/vm/types/module.ts +7 -0
- package/src/vm/types/wrapper.ts +7 -0
- package/dist/chunk-AOINGBRS.js.map +0 -6
|
@@ -67,6 +67,11 @@ var VmWrapper = class {
|
|
|
67
67
|
return `<${this.type} ${this.describe}>`;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
+
var kVmWrapper = Symbol.for("mirascript.vm.wrapper");
|
|
71
|
+
Object.defineProperty(VmWrapper.prototype, kVmWrapper, { value: true });
|
|
72
|
+
function isVmWrapper(value) {
|
|
73
|
+
return value != null && typeof value == "object" && kVmWrapper in value;
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
// src/vm/helpers.ts
|
|
72
77
|
var helpers_exports = {};
|
|
@@ -143,8 +148,8 @@ var isSame = (a, b) => {
|
|
|
143
148
|
if (typeof a == "number" && typeof b == "number") return a === b || isNaN(a) && isNaN(b);
|
|
144
149
|
if (a === b) return true;
|
|
145
150
|
if (a == null || typeof a != "object" || b == null || typeof b != "object") return false;
|
|
146
|
-
if (a
|
|
147
|
-
if (b
|
|
151
|
+
if (isVmWrapper(a)) return a.same(b);
|
|
152
|
+
if (isVmWrapper(b)) return b.same(a);
|
|
148
153
|
if (isVmArray(a) && isVmArray(b)) {
|
|
149
154
|
const len2 = a.length;
|
|
150
155
|
if (len2 !== b.length) {
|
|
@@ -241,11 +246,6 @@ var $Eq = (a, b) => {
|
|
|
241
246
|
var $Neq = (a, b) => {
|
|
242
247
|
return !$Eq(a, b);
|
|
243
248
|
};
|
|
244
|
-
var stringComparer = new Intl.Collator("en", {
|
|
245
|
-
usage: "sort",
|
|
246
|
-
numeric: false,
|
|
247
|
-
sensitivity: "base"
|
|
248
|
-
});
|
|
249
249
|
var $Aeq = (a, b) => {
|
|
250
250
|
if (overloadNumberString(a, b)) {
|
|
251
251
|
const an = $ToNumber(a);
|
|
@@ -261,7 +261,12 @@ var $Aeq = (a, b) => {
|
|
|
261
261
|
const as = $ToString(a);
|
|
262
262
|
const bs = $ToString(b);
|
|
263
263
|
if (as === bs) return true;
|
|
264
|
-
|
|
264
|
+
const ai = as.toLowerCase();
|
|
265
|
+
const bi = bs.toLowerCase();
|
|
266
|
+
if (ai === bi) return true;
|
|
267
|
+
const an = ai.normalize("NFC");
|
|
268
|
+
const bn = bi.normalize("NFC");
|
|
269
|
+
return an === bn;
|
|
265
270
|
}
|
|
266
271
|
};
|
|
267
272
|
var $Naeq = (a, b) => {
|
|
@@ -290,7 +295,7 @@ var $In = (value, iterable) => {
|
|
|
290
295
|
value;
|
|
291
296
|
return iterable.some((item = null) => isSame(item, value));
|
|
292
297
|
}
|
|
293
|
-
if (iterable
|
|
298
|
+
if (isVmWrapper(iterable)) return iterable.has($ToString(value));
|
|
294
299
|
if (typeof iterable == "object") return hasOwnEnumerable(iterable, $ToString(value));
|
|
295
300
|
iterable;
|
|
296
301
|
return false;
|
|
@@ -311,7 +316,7 @@ var $Length = (value) => {
|
|
|
311
316
|
$AssertInit(value);
|
|
312
317
|
if (isVmArray(value)) return value.length;
|
|
313
318
|
if (isVmRecord(value)) return keys(value).length;
|
|
314
|
-
if (value
|
|
319
|
+
if (isVmWrapper(value)) {
|
|
315
320
|
return value.keys().length;
|
|
316
321
|
}
|
|
317
322
|
return Number.NaN;
|
|
@@ -376,7 +381,7 @@ var $Call = (func, args) => {
|
|
|
376
381
|
for (const a of args) {
|
|
377
382
|
$AssertInit(a);
|
|
378
383
|
}
|
|
379
|
-
if (func
|
|
384
|
+
if (isVmExtern(func)) {
|
|
380
385
|
return func.call(args) ?? null;
|
|
381
386
|
}
|
|
382
387
|
if (isVmFunction(func)) {
|
|
@@ -386,8 +391,8 @@ var $Call = (func, args) => {
|
|
|
386
391
|
};
|
|
387
392
|
var $Type = (value) => {
|
|
388
393
|
if (value === void 0 || value === null) return "nil";
|
|
389
|
-
if (value
|
|
390
|
-
if (value
|
|
394
|
+
if (isVmExtern(value)) return "extern";
|
|
395
|
+
if (isVmModule(value)) return "module";
|
|
391
396
|
if (isVmArray(value)) return "array";
|
|
392
397
|
if (typeof value == "object") return "record";
|
|
393
398
|
return typeof value;
|
|
@@ -404,7 +409,7 @@ function numberToString(value) {
|
|
|
404
409
|
}
|
|
405
410
|
function innerToString(value, useBraces) {
|
|
406
411
|
if (value == null) return "nil";
|
|
407
|
-
if (value
|
|
412
|
+
if (isVmWrapper(value)) return value.toString();
|
|
408
413
|
if (typeof value == "function") {
|
|
409
414
|
const name = getVmFunctionInfo(value)?.fullName;
|
|
410
415
|
return name ? `<function ${name}>` : `<function>`;
|
|
@@ -481,7 +486,7 @@ var $Has = (obj, key) => {
|
|
|
481
486
|
$AssertInit(obj);
|
|
482
487
|
const pk = $ToString(key);
|
|
483
488
|
if (obj == null || typeof obj != "object") return false;
|
|
484
|
-
if (obj
|
|
489
|
+
if (isVmWrapper(obj)) return obj.has(pk);
|
|
485
490
|
return hasOwnEnumerable(obj, pk);
|
|
486
491
|
};
|
|
487
492
|
var $Get = (obj, key) => {
|
|
@@ -493,7 +498,7 @@ var $Get = (obj, key) => {
|
|
|
493
498
|
}
|
|
494
499
|
const pk = $ToString(key);
|
|
495
500
|
if (obj == null || typeof obj != "object") return null;
|
|
496
|
-
if (obj
|
|
501
|
+
if (isVmWrapper(obj)) return obj.get(pk) ?? null;
|
|
497
502
|
if (!hasOwnEnumerable(obj, pk)) return null;
|
|
498
503
|
return obj[pk] ?? null;
|
|
499
504
|
};
|
|
@@ -507,7 +512,7 @@ var $Set = (obj, key, value) => {
|
|
|
507
512
|
};
|
|
508
513
|
var $Iterable = (value) => {
|
|
509
514
|
$AssertInit(value);
|
|
510
|
-
if (value
|
|
515
|
+
if (isVmWrapper(value)) return value.keys();
|
|
511
516
|
if (isVmArray(value)) return value;
|
|
512
517
|
if (value != null && typeof value == "object") return keys(value);
|
|
513
518
|
throw new VmError(`Value is not iterable`, isVmFunction(value) ? [] : [value]);
|
|
@@ -766,7 +771,7 @@ function wrapToVmValue(value, thisArg = null, assumeVmValue) {
|
|
|
766
771
|
return new VmExtern(value, thisArg);
|
|
767
772
|
}
|
|
768
773
|
case "object": {
|
|
769
|
-
if (value
|
|
774
|
+
if (isVmWrapper(value)) return value;
|
|
770
775
|
if (value instanceof Date) return value.valueOf();
|
|
771
776
|
if (assumeVmValue?.(value)) return value;
|
|
772
777
|
return new VmExtern(value);
|
|
@@ -788,7 +793,7 @@ function unwrapFromVmValue(value) {
|
|
|
788
793
|
return toVmFunctionProxy(value);
|
|
789
794
|
}
|
|
790
795
|
if (value == null || typeof value != "object") return value;
|
|
791
|
-
if (!(value
|
|
796
|
+
if (!isVmExtern(value)) return value;
|
|
792
797
|
if (value.thisArg == null || typeof value.value != "function") {
|
|
793
798
|
return value.value;
|
|
794
799
|
}
|
|
@@ -804,7 +809,8 @@ function unwrapFromVmValue(value) {
|
|
|
804
809
|
// src/vm/types/extern.ts
|
|
805
810
|
var ObjectPrototype = Object.prototype;
|
|
806
811
|
var ObjectToString = ObjectPrototype.toString;
|
|
807
|
-
var
|
|
812
|
+
var FunctionToString = Function.prototype.toString;
|
|
813
|
+
var VmExtern = class extends VmWrapper {
|
|
808
814
|
constructor(value, thisArg = null) {
|
|
809
815
|
super(value);
|
|
810
816
|
this.thisArg = thisArg;
|
|
@@ -871,13 +877,13 @@ var VmExtern = class _VmExtern extends VmWrapper {
|
|
|
871
877
|
}
|
|
872
878
|
/** @inheritdoc */
|
|
873
879
|
same(other) {
|
|
874
|
-
if (!(other
|
|
880
|
+
if (!isVmExtern(other)) return false;
|
|
875
881
|
return this.value === other.value && this.thisArg === other.thisArg;
|
|
876
882
|
}
|
|
877
883
|
/** @inheritdoc */
|
|
878
884
|
toString() {
|
|
879
885
|
const { toString } = this.value;
|
|
880
|
-
if (typeof toString != "function" || toString === ObjectToString) {
|
|
886
|
+
if (typeof toString != "function" || toString === ObjectToString || toString === FunctionToString) {
|
|
881
887
|
return super.toString();
|
|
882
888
|
}
|
|
883
889
|
try {
|
|
@@ -915,6 +921,11 @@ var VmExtern = class _VmExtern extends VmWrapper {
|
|
|
915
921
|
return tag;
|
|
916
922
|
}
|
|
917
923
|
};
|
|
924
|
+
var kVmExtern = Symbol.for("mirascript.vm.extern");
|
|
925
|
+
Object.defineProperty(VmExtern.prototype, kVmExtern, { value: true });
|
|
926
|
+
function isVmExtern(value) {
|
|
927
|
+
return value != null && typeof value == "object" && kVmExtern in value;
|
|
928
|
+
}
|
|
918
929
|
|
|
919
930
|
// src/vm/types/module.ts
|
|
920
931
|
var VmModule = class extends VmWrapper {
|
|
@@ -948,6 +959,11 @@ var VmModule = class extends VmWrapper {
|
|
|
948
959
|
return this.name;
|
|
949
960
|
}
|
|
950
961
|
};
|
|
962
|
+
var kVmModule = Symbol.for("mirascript.vm.module");
|
|
963
|
+
Object.defineProperty(VmModule.prototype, kVmModule, { value: true });
|
|
964
|
+
function isVmModule(value) {
|
|
965
|
+
return value != null && typeof value == "object" && kVmModule in value;
|
|
966
|
+
}
|
|
951
967
|
|
|
952
968
|
// src/vm/types/script.ts
|
|
953
969
|
var kVmScript = Symbol.for("mirascript.vm.script");
|
|
@@ -990,7 +1006,7 @@ function isVmConstInner(value, depth) {
|
|
|
990
1006
|
return true;
|
|
991
1007
|
case "object":
|
|
992
1008
|
if (value == null) return true;
|
|
993
|
-
if (value
|
|
1009
|
+
if (isVmWrapper(value)) return false;
|
|
994
1010
|
if (isArray(value)) {
|
|
995
1011
|
return isVmArrayDeep(value, depth);
|
|
996
1012
|
} else {
|
|
@@ -1011,7 +1027,7 @@ function isVmConst(value, checkDeep = false) {
|
|
|
1011
1027
|
return true;
|
|
1012
1028
|
case "object":
|
|
1013
1029
|
if (value == null) return true;
|
|
1014
|
-
if (value
|
|
1030
|
+
if (isVmWrapper(value)) return false;
|
|
1015
1031
|
if (!checkDeep) {
|
|
1016
1032
|
if (isArray(value)) {
|
|
1017
1033
|
return isVmArrayDeep(value, 0);
|
|
@@ -1030,7 +1046,7 @@ function isVmConst(value, checkDeep = false) {
|
|
|
1030
1046
|
}
|
|
1031
1047
|
}
|
|
1032
1048
|
function isVmImmutable(value, checkDeep = false) {
|
|
1033
|
-
return value
|
|
1049
|
+
return isVmModule(value) || isVmFunction(value) || isVmConst(value, checkDeep);
|
|
1034
1050
|
}
|
|
1035
1051
|
function isVmValue(value, checkDeep = false) {
|
|
1036
1052
|
if (value === void 0) return false;
|
|
@@ -1045,7 +1061,7 @@ function isVmAny(value, checkDeep) {
|
|
|
1045
1061
|
return true;
|
|
1046
1062
|
case "object":
|
|
1047
1063
|
if (value == null) return true;
|
|
1048
|
-
if (value
|
|
1064
|
+
if (isVmWrapper(value)) return true;
|
|
1049
1065
|
return isVmConst(value, checkDeep);
|
|
1050
1066
|
case "function":
|
|
1051
1067
|
return isVmFunction(value);
|
|
@@ -1064,7 +1080,7 @@ function isVmArray(value) {
|
|
|
1064
1080
|
}
|
|
1065
1081
|
function isVmRecord(value) {
|
|
1066
1082
|
if (value == null || typeof value !== "object") return false;
|
|
1067
|
-
if (value
|
|
1083
|
+
if (isVmWrapper(value)) return false;
|
|
1068
1084
|
if (isVmArray(value)) return false;
|
|
1069
1085
|
value;
|
|
1070
1086
|
return true;
|
|
@@ -1077,15 +1093,9 @@ function isVmPrimitive(value) {
|
|
|
1077
1093
|
}
|
|
1078
1094
|
return false;
|
|
1079
1095
|
}
|
|
1080
|
-
function isVmExtern(value) {
|
|
1081
|
-
return value instanceof VmExtern;
|
|
1082
|
-
}
|
|
1083
1096
|
function isVmCallable(value) {
|
|
1084
1097
|
return isVmFunction(value) || isVmExtern(value) && typeof value.value == "function";
|
|
1085
1098
|
}
|
|
1086
|
-
function isVmModule(value) {
|
|
1087
|
-
return value instanceof VmModule;
|
|
1088
|
-
}
|
|
1089
1099
|
var VM_ARRAY_MAX_LENGTH = 2 ** 31 - 1;
|
|
1090
1100
|
|
|
1091
1101
|
// src/vm/types/context.ts
|
|
@@ -1122,8 +1132,9 @@ var DefaultVmContext = Object.freeze({
|
|
|
1122
1132
|
var _a;
|
|
1123
1133
|
_a = kVmContext;
|
|
1124
1134
|
var ValueVmContext = class {
|
|
1125
|
-
constructor(env) {
|
|
1135
|
+
constructor(env, describe) {
|
|
1126
1136
|
this.env = env;
|
|
1137
|
+
this.describe = describe;
|
|
1127
1138
|
this[_a] = true;
|
|
1128
1139
|
this.cachedKeys = null;
|
|
1129
1140
|
}
|
|
@@ -1144,9 +1155,10 @@ var ValueVmContext = class {
|
|
|
1144
1155
|
var _a2;
|
|
1145
1156
|
_a2 = kVmContext;
|
|
1146
1157
|
var FactoryVmContext = class {
|
|
1147
|
-
constructor(getter, enumerator) {
|
|
1158
|
+
constructor(getter, enumerator, describe) {
|
|
1148
1159
|
this.getter = getter;
|
|
1149
1160
|
this.enumerator = enumerator;
|
|
1161
|
+
this.describe = describe;
|
|
1150
1162
|
this[_a2] = true;
|
|
1151
1163
|
}
|
|
1152
1164
|
/** @inheritdoc */
|
|
@@ -1170,9 +1182,10 @@ function createVmContext(...args) {
|
|
|
1170
1182
|
return { ...DefaultVmContext };
|
|
1171
1183
|
}
|
|
1172
1184
|
if (typeof args[0] == "function") {
|
|
1173
|
-
|
|
1185
|
+
const [getter, enumerator, describer2] = args;
|
|
1186
|
+
return new FactoryVmContext(getter, enumerator ?? void 0, describer2 ?? void 0);
|
|
1174
1187
|
}
|
|
1175
|
-
const [vmValues, externValues] = args;
|
|
1188
|
+
const [vmValues, externValues, describer] = args;
|
|
1176
1189
|
const env = create(VmSharedContext);
|
|
1177
1190
|
if (vmValues) {
|
|
1178
1191
|
for (const [key, value] of entries(vmValues)) {
|
|
@@ -1185,7 +1198,7 @@ function createVmContext(...args) {
|
|
|
1185
1198
|
env[key] = value == null ? null : wrapToVmValue(value, null);
|
|
1186
1199
|
}
|
|
1187
1200
|
}
|
|
1188
|
-
return new ValueVmContext(env);
|
|
1201
|
+
return new ValueVmContext(env, describer ?? void 0);
|
|
1189
1202
|
}
|
|
1190
1203
|
function isVmContext(context) {
|
|
1191
1204
|
if (context == null || typeof context != "object") return false;
|
|
@@ -1359,11 +1372,7 @@ function map(data, mapper) {
|
|
|
1359
1372
|
Cp();
|
|
1360
1373
|
const ret = mapper(data[i] ?? null, i, data);
|
|
1361
1374
|
if (ret === void 0) continue;
|
|
1362
|
-
|
|
1363
|
-
result.push(ret);
|
|
1364
|
-
} else {
|
|
1365
|
-
result.push(null);
|
|
1366
|
-
}
|
|
1375
|
+
result.push(ret);
|
|
1367
1376
|
}
|
|
1368
1377
|
return result;
|
|
1369
1378
|
} else {
|
|
@@ -1372,11 +1381,7 @@ function map(data, mapper) {
|
|
|
1372
1381
|
Cp();
|
|
1373
1382
|
const ret = mapper(value ?? null, key, data);
|
|
1374
1383
|
if (ret === void 0) continue;
|
|
1375
|
-
|
|
1376
|
-
e.push([key, ret]);
|
|
1377
|
-
} else {
|
|
1378
|
-
e.push([key, null]);
|
|
1379
|
-
}
|
|
1384
|
+
e.push([key, ret]);
|
|
1380
1385
|
}
|
|
1381
1386
|
return fromEntries(e);
|
|
1382
1387
|
}
|
|
@@ -1783,40 +1788,123 @@ var shr = VmLib(
|
|
|
1783
1788
|
);
|
|
1784
1789
|
|
|
1785
1790
|
// src/vm/lib/global/sequence/with.ts
|
|
1791
|
+
var arrIndex = (index) => {
|
|
1792
|
+
const idx = Math.trunc($ToNumber(index));
|
|
1793
|
+
if (!isSafeInteger(idx) || idx < 0 || idx >= VM_ARRAY_MAX_LENGTH) {
|
|
1794
|
+
return -1;
|
|
1795
|
+
}
|
|
1796
|
+
return idx;
|
|
1797
|
+
};
|
|
1798
|
+
var withInner = (obj, key, keyIndex, value) => {
|
|
1799
|
+
if (keyIndex >= key.length) {
|
|
1800
|
+
return value;
|
|
1801
|
+
}
|
|
1802
|
+
const k = key[keyIndex];
|
|
1803
|
+
let result;
|
|
1804
|
+
if (isVmArray(obj)) {
|
|
1805
|
+
result = [...obj];
|
|
1806
|
+
} else if (isVmRecord(obj)) {
|
|
1807
|
+
result = { ...obj };
|
|
1808
|
+
} else if (arrIndex(k) === k) {
|
|
1809
|
+
result = [];
|
|
1810
|
+
} else {
|
|
1811
|
+
result = {};
|
|
1812
|
+
}
|
|
1813
|
+
if (isArray(result)) {
|
|
1814
|
+
const index = arrIndex(k);
|
|
1815
|
+
while (index > result.length) {
|
|
1816
|
+
result.push(null);
|
|
1817
|
+
}
|
|
1818
|
+
result[index] = withInner(result[index], key, keyIndex + 1, value);
|
|
1819
|
+
} else {
|
|
1820
|
+
const prop = $ToString(k);
|
|
1821
|
+
result[prop] = withInner(result[prop], key, keyIndex + 1, value);
|
|
1822
|
+
}
|
|
1823
|
+
return result;
|
|
1824
|
+
};
|
|
1825
|
+
var normalizeEntries = (data, entries3) => {
|
|
1826
|
+
if (entries3.length % 2 !== 0) {
|
|
1827
|
+
throwError("Expected even number of entries", data);
|
|
1828
|
+
}
|
|
1829
|
+
const entryData = /* @__PURE__ */ new Map();
|
|
1830
|
+
for (let i = 0; i < entries3.length; i += 2) {
|
|
1831
|
+
let key = entries3[i];
|
|
1832
|
+
expectConst("key", key, data);
|
|
1833
|
+
if (key == null) {
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
if (isVmArray(key)) {
|
|
1837
|
+
if (key.length === 0 || key.includes(null) || key.includes(void 0)) {
|
|
1838
|
+
continue;
|
|
1839
|
+
} else if (key.length === 1) {
|
|
1840
|
+
key = key[0];
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
const value = entries3[i + 1];
|
|
1844
|
+
entryData.set(key, Element(value));
|
|
1845
|
+
}
|
|
1846
|
+
return entryData;
|
|
1847
|
+
};
|
|
1786
1848
|
var _with = VmLib(
|
|
1787
1849
|
(data, ...entries3) => {
|
|
1788
1850
|
expectArrayOrRecord("data", data, data);
|
|
1789
|
-
if (entries3.length
|
|
1790
|
-
|
|
1851
|
+
if (entries3.length === 0) {
|
|
1852
|
+
return data;
|
|
1791
1853
|
}
|
|
1854
|
+
const entryData = normalizeEntries(data, entries3);
|
|
1792
1855
|
if (isVmArray(data)) {
|
|
1793
1856
|
const result = [...data];
|
|
1794
|
-
for (
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1857
|
+
for (const [key, value] of entryData) {
|
|
1858
|
+
let index;
|
|
1859
|
+
let val;
|
|
1860
|
+
if (isVmArray(key)) {
|
|
1861
|
+
index = arrIndex(key[0]);
|
|
1862
|
+
if (index < 0) continue;
|
|
1863
|
+
val = withInner(result[index], key, 1, value);
|
|
1864
|
+
} else {
|
|
1865
|
+
index = arrIndex(key);
|
|
1866
|
+
if (index < 0) continue;
|
|
1867
|
+
val = value;
|
|
1868
|
+
}
|
|
1798
1869
|
while (index > result.length) {
|
|
1799
1870
|
result.push(null);
|
|
1800
1871
|
}
|
|
1801
|
-
result[index] =
|
|
1872
|
+
result[index] = val;
|
|
1802
1873
|
}
|
|
1803
1874
|
return result;
|
|
1804
1875
|
} else {
|
|
1805
1876
|
const result = { ...data };
|
|
1806
|
-
for (
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1877
|
+
for (const [key, value] of entryData) {
|
|
1878
|
+
let prop;
|
|
1879
|
+
let val;
|
|
1880
|
+
if (isVmArray(key)) {
|
|
1881
|
+
const firstKey = key[0];
|
|
1882
|
+
prop = $ToString(firstKey);
|
|
1883
|
+
val = withInner(result[prop], key, 1, value);
|
|
1884
|
+
} else {
|
|
1885
|
+
prop = $ToString(key);
|
|
1886
|
+
val = value;
|
|
1887
|
+
}
|
|
1888
|
+
result[prop] = val;
|
|
1810
1889
|
}
|
|
1811
1890
|
return result;
|
|
1812
1891
|
}
|
|
1813
1892
|
},
|
|
1814
1893
|
{
|
|
1815
1894
|
summary: "在数组或记录中设置多个键值对",
|
|
1816
|
-
params: {
|
|
1817
|
-
|
|
1895
|
+
params: {
|
|
1896
|
+
data: "要设置的数组或记录",
|
|
1897
|
+
"..entries": "要设置的键值对,成对出现"
|
|
1898
|
+
},
|
|
1899
|
+
paramsType: {
|
|
1900
|
+
data: "array | record",
|
|
1901
|
+
"..entries": `[..[string | number | (string | number)[], any][]]`
|
|
1902
|
+
},
|
|
1818
1903
|
returnsType: "type(data)",
|
|
1819
|
-
examples: [
|
|
1904
|
+
examples: [
|
|
1905
|
+
`with([10, 20], 2, 99, 3 ,100) // [10, 20, 99, 100]`,
|
|
1906
|
+
`(a: 1)::with(["b", 1], 2) // (a: 1, b: [nil, 2])`
|
|
1907
|
+
]
|
|
1820
1908
|
}
|
|
1821
1909
|
);
|
|
1822
1910
|
|
|
@@ -3596,6 +3684,7 @@ function compileSync(source, options = {}) {
|
|
|
3596
3684
|
|
|
3597
3685
|
export {
|
|
3598
3686
|
VmError,
|
|
3687
|
+
isVmWrapper,
|
|
3599
3688
|
operations_exports,
|
|
3600
3689
|
VmSharedContext,
|
|
3601
3690
|
defineVmContextValue,
|
|
@@ -3611,7 +3700,9 @@ export {
|
|
|
3611
3700
|
wrapToVmValue,
|
|
3612
3701
|
unwrapFromVmValue,
|
|
3613
3702
|
VmExtern,
|
|
3703
|
+
isVmExtern,
|
|
3614
3704
|
VmModule,
|
|
3705
|
+
isVmModule,
|
|
3615
3706
|
isVmScript,
|
|
3616
3707
|
isVmConst,
|
|
3617
3708
|
isVmImmutable,
|
|
@@ -3620,9 +3711,7 @@ export {
|
|
|
3620
3711
|
isVmArray,
|
|
3621
3712
|
isVmRecord,
|
|
3622
3713
|
isVmPrimitive,
|
|
3623
|
-
isVmExtern,
|
|
3624
3714
|
isVmCallable,
|
|
3625
|
-
isVmModule,
|
|
3626
3715
|
VM_ARRAY_MAX_LENGTH,
|
|
3627
3716
|
constants_exports,
|
|
3628
3717
|
DiagnosticCode,
|
|
@@ -3638,4 +3727,4 @@ export {
|
|
|
3638
3727
|
serializePropName,
|
|
3639
3728
|
serialize
|
|
3640
3729
|
};
|
|
3641
|
-
//# sourceMappingURL=chunk-
|
|
3730
|
+
//# sourceMappingURL=chunk-MVHCSH3E.js.map
|