porffor 0.55.35 → 0.56.0
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/bigint.ts +4 -4
- package/compiler/builtins/object.ts +1 -1
- package/compiler/builtins.js +0 -55
- package/compiler/builtins_precompiled.js +112 -112
- package/compiler/codegen.js +41 -37
- package/compiler/expression.js +55 -3
- package/package.json +1 -1
- package/r.cjs +102 -3
- package/runner/index.js +1 -1
@@ -77,10 +77,10 @@ export const __Porffor_bigint_fromString = (n: string|bytestring): bigint => {
|
|
77
77
|
|
78
78
|
let negative: boolean = false;
|
79
79
|
let offset: i32 = 0;
|
80
|
-
if (n[0]
|
80
|
+
if (n[0] == '-') {
|
81
81
|
negative = true;
|
82
82
|
offset = 1;
|
83
|
-
} else if (n[0]
|
83
|
+
} else if (n[0] == '+') {
|
84
84
|
offset = 1;
|
85
85
|
}
|
86
86
|
|
@@ -120,8 +120,8 @@ export const __Porffor_bigint_fromString = (n: string|bytestring): bigint => {
|
|
120
120
|
digits[j] = quotient;
|
121
121
|
}
|
122
122
|
|
123
|
-
while (digits.length > 0 && digits[0]
|
124
|
-
if (carry
|
123
|
+
while (digits.length > 0 && digits[0] == 0) digits.shift();
|
124
|
+
if (carry != 0 || digits.length > 0) result.unshift(carry);
|
125
125
|
}
|
126
126
|
|
127
127
|
return __Porffor_bigint_fromDigits(negative, result);
|
@@ -524,7 +524,7 @@ export const __Object_defineProperty = (target: any, prop: any, desc: any): any
|
|
524
524
|
if (!Porffor.object.isObject(desc)) throw new TypeError('Descriptor is a non-object');
|
525
525
|
|
526
526
|
if (Porffor.type(target) == Porffor.TYPES.array) {
|
527
|
-
if (prop
|
527
|
+
if (prop == 'length' && __Object_hasOwn(desc, 'value')) {
|
528
528
|
const v: any = desc.value;
|
529
529
|
const n: number = ecma262.ToNumber(v);
|
530
530
|
if (Porffor.fastOr(
|
package/compiler/builtins.js
CHANGED
@@ -100,61 +100,6 @@ export const BuiltinVars = function(ctx) {
|
|
100
100
|
};
|
101
101
|
|
102
102
|
export const BuiltinFuncs = function() {
|
103
|
-
this['f64_%'] = {
|
104
|
-
params: [ valtypeBinary, valtypeBinary ],
|
105
|
-
locals: [],
|
106
|
-
returns: [ valtypeBinary ],
|
107
|
-
returnType: TYPES.number,
|
108
|
-
wasm: [ // x - truncf(x / y) * y
|
109
|
-
[ Opcodes.local_get, 0 ], // x
|
110
|
-
|
111
|
-
[ Opcodes.local_get, 0 ], // x
|
112
|
-
[ Opcodes.local_get, 1 ], // y
|
113
|
-
|
114
|
-
[ Opcodes.f64_div ],
|
115
|
-
[ Opcodes.f64_trunc ],
|
116
|
-
|
117
|
-
[ Opcodes.local_get, 1 ], // y
|
118
|
-
[ Opcodes.f64_mul ],
|
119
|
-
|
120
|
-
[ Opcodes.f64_sub ]
|
121
|
-
]
|
122
|
-
};
|
123
|
-
|
124
|
-
this['f64_**'] = this['i32_**'] = {
|
125
|
-
params: [ valtypeBinary, valtypeBinary ],
|
126
|
-
locals: [],
|
127
|
-
returns: [ valtypeBinary ],
|
128
|
-
returnType: TYPES.number,
|
129
|
-
wasm: (scope, { builtin }) => [
|
130
|
-
[ Opcodes.local_get, 0 ],
|
131
|
-
number(TYPES.number, Valtype.i32),
|
132
|
-
[ Opcodes.local_get, 1 ],
|
133
|
-
number(TYPES.number, Valtype.i32),
|
134
|
-
[ Opcodes.call, builtin('__Math_pow') ]
|
135
|
-
]
|
136
|
-
};
|
137
|
-
|
138
|
-
// add bitwise ops by converting operands to i32 first
|
139
|
-
for (const [ char, op ] of [ ['&', Opcodes.i32_and], ['|', Opcodes.i32_or], ['^', Opcodes.i32_xor], ['<<', Opcodes.i32_shl], ['>>', Opcodes.i32_shr_s], ['>>>', Opcodes.i32_shr_u] ]) {
|
140
|
-
this[`f64_${char}`] = {
|
141
|
-
params: [ Valtype.f64, Valtype.f64 ],
|
142
|
-
locals: [],
|
143
|
-
returns: [ Valtype.f64 ],
|
144
|
-
returnType: TYPES.number,
|
145
|
-
wasm: [
|
146
|
-
[ Opcodes.local_get, 0 ],
|
147
|
-
Opcodes.i32_trunc_sat_f64_s,
|
148
|
-
|
149
|
-
[ Opcodes.local_get, 1 ],
|
150
|
-
Opcodes.i32_trunc_sat_f64_s,
|
151
|
-
|
152
|
-
[ op ],
|
153
|
-
[ Opcodes.f64_convert_i32_s ]
|
154
|
-
]
|
155
|
-
};
|
156
|
-
}
|
157
|
-
|
158
103
|
this.isNaN = {
|
159
104
|
floatOnly: true,
|
160
105
|
params: [ valtypeBinary ],
|