porffor 0.61.8 → 0.61.9
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/compiler/builtins/array.ts +4 -2
- package/compiler/builtins/function.ts +24 -0
- package/compiler/builtins_precompiled.js +471 -465
- package/compiler/codegen.js +37 -21
- package/compiler/parse.js +3 -0
- package/compiler/semantic.js +16 -14
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
|
@@ -448,7 +448,7 @@ export const __Array_prototype_with = (_this: any[], _index: any, value: any) =>
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
if (index
|
|
451
|
+
if (index >= len) {
|
|
452
452
|
throw new RangeError('Invalid index');
|
|
453
453
|
}
|
|
454
454
|
|
|
@@ -529,7 +529,7 @@ export const __Array_prototype_reverse = (_this: any[]) => {
|
|
|
529
529
|
let end: i32 = len - 1;
|
|
530
530
|
|
|
531
531
|
while (start < end) {
|
|
532
|
-
const tmp:
|
|
532
|
+
const tmp: any = _this[start];
|
|
533
533
|
_this[start++] = _this[end];
|
|
534
534
|
_this[end--] = tmp;
|
|
535
535
|
}
|
|
@@ -740,6 +740,8 @@ export const __Array_prototype_sort = (_this: any[], callbackFn: any) => {
|
|
|
740
740
|
};
|
|
741
741
|
}
|
|
742
742
|
|
|
743
|
+
if (Porffor.type(callbackFn) != Porffor.TYPES.function) throw new TypeError('Callback must be a function');
|
|
744
|
+
|
|
743
745
|
// insertion sort, i guess
|
|
744
746
|
const len: i32 = _this.length;
|
|
745
747
|
for (let i: i32 = 0; i < len; i++) {
|
|
@@ -27,4 +27,28 @@ export const __Function_prototype_apply = (_this: Function, thisArg: any, argsAr
|
|
|
27
27
|
export const __Function_prototype_bind = (_this: Function, thisArg: any, argsArray: any) => {
|
|
28
28
|
// todo: no good way to bind without dynamic functions or closure yet, just return function
|
|
29
29
|
return _this;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export const __Porffor_generateArgumentsObject = (argc: i32, hasRest: boolean, ...args: any[]) => {
|
|
34
|
+
let obj: object = {}, i: i32 = 0, limit: i32 = args.length;
|
|
35
|
+
if (hasRest) limit--;
|
|
36
|
+
limit = Math.min(argc, limit);
|
|
37
|
+
|
|
38
|
+
while (i < limit) {
|
|
39
|
+
obj[i] = args[i];
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (hasRest) {
|
|
44
|
+
const rest: any[] = args[limit];
|
|
45
|
+
const len: i32 = rest.length;
|
|
46
|
+
for (let j: i32 = 0; j < len; j++) {
|
|
47
|
+
obj[i] = rest[j];
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
obj.length = i;
|
|
53
|
+
return obj;
|
|
30
54
|
};
|