porffor 0.14.0-b481bfc5f → 0.14.0-b880d42f1
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/CONTRIBUTING.md +4 -2
- package/compiler/2c.js +65 -2
- package/compiler/assemble.js +14 -0
- package/compiler/builtins/annexb_string.ts +1 -0
- package/compiler/builtins/array.ts +78 -0
- package/compiler/builtins/base64.ts +1 -0
- package/compiler/builtins/boolean.ts +2 -0
- package/compiler/builtins/crypto.ts +1 -0
- package/compiler/builtins/date.ts +2 -0
- package/compiler/builtins/escape.ts +1 -2
- package/compiler/builtins/function.ts +2 -0
- package/compiler/builtins/int.ts +2 -0
- package/compiler/builtins/math.ts +410 -0
- package/compiler/builtins/number.ts +2 -0
- package/compiler/builtins/object.ts +2 -0
- package/compiler/builtins/set.ts +2 -0
- package/compiler/builtins/string.ts +1 -0
- package/compiler/builtins/symbol.ts +2 -0
- package/compiler/builtins.js +26 -4
- package/compiler/codegen.js +241 -154
- package/compiler/generated_builtins.js +318 -31
- package/compiler/index.js +1 -1
- package/compiler/parse.js +1 -1
- package/compiler/precompile.js +5 -4
- package/package.json +1 -1
- package/runner/index.js +4 -3
package/compiler/builtins/set.ts
CHANGED
package/compiler/builtins.js
CHANGED
@@ -40,6 +40,18 @@ export const importedFuncs = [
|
|
40
40
|
import: 'z',
|
41
41
|
params: 1,
|
42
42
|
returns: 0
|
43
|
+
},
|
44
|
+
{
|
45
|
+
name: '__Porffor_readArgv',
|
46
|
+
import: 'w',
|
47
|
+
params: 2,
|
48
|
+
returns: 0
|
49
|
+
},
|
50
|
+
{
|
51
|
+
name: '__Porffor_readFile',
|
52
|
+
import: 'q',
|
53
|
+
params: 2,
|
54
|
+
returns: 0
|
43
55
|
}
|
44
56
|
];
|
45
57
|
|
@@ -221,8 +233,7 @@ export const BuiltinFuncs = function() {
|
|
221
233
|
typedParams: true,
|
222
234
|
locals: [ Valtype.i32, Valtype.i32 ],
|
223
235
|
returns: [],
|
224
|
-
|
225
|
-
wasm: (scope, { typeSwitch }) => [
|
236
|
+
wasm: (scope, { typeSwitch, builtin }) => [
|
226
237
|
...typeSwitch(scope, [ [ Opcodes.local_get, 1 ] ], {
|
227
238
|
[TYPES.number]: [
|
228
239
|
[ Opcodes.local_get, 0 ],
|
@@ -327,14 +338,14 @@ export const BuiltinFuncs = function() {
|
|
327
338
|
|
328
339
|
[ Opcodes.loop, Blocktype.void ],
|
329
340
|
|
330
|
-
// print current
|
341
|
+
// print current array element
|
331
342
|
[ Opcodes.local_get, 2 ],
|
332
343
|
[ Opcodes.load, 0, ValtypeSize.i32 ],
|
333
344
|
|
334
345
|
[ Opcodes.local_get, 2 ],
|
335
346
|
[ Opcodes.i32_load8_u, 0, ValtypeSize.i32 + ValtypeSize[valtype] ],
|
336
347
|
|
337
|
-
[ Opcodes.call,
|
348
|
+
[ Opcodes.call, builtin('__Porffor_print') ],
|
338
349
|
|
339
350
|
// increment pointer by sizeof valtype
|
340
351
|
[ Opcodes.local_get, 2 ],
|
@@ -1084,5 +1095,16 @@ export const BuiltinFuncs = function() {
|
|
1084
1095
|
]
|
1085
1096
|
};
|
1086
1097
|
|
1098
|
+
|
1099
|
+
this.__fs_readFileSync = {
|
1100
|
+
params: [ valtypeBinary, valtypeBinary ],
|
1101
|
+
locals: [],
|
1102
|
+
returns: [ valtypeBinary ],
|
1103
|
+
returnType: TYPES.bytestring,
|
1104
|
+
wasm: [
|
1105
|
+
[ Opcodes.call, importedFuncs.__Porffor_readFile ],
|
1106
|
+
]
|
1107
|
+
};
|
1108
|
+
|
1087
1109
|
GeneratedBuiltins.BuiltinFuncs.call(this);
|
1088
1110
|
};
|