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.
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // dark wasm magic for dealing with memory, sorry.
2
4
  export const __Porffor_allocate = (): number => {
3
5
  Porffor.wasm`i32.const 1
@@ -1,4 +1,5 @@
1
1
  // @porf --valtype=i32
2
+ import type {} from './porffor.d.ts';
2
3
 
3
4
  export const __String_fromCharCode = (code: i32) => {
4
5
  // todo: support >1 arg
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  export const __Porffor_symbol_descStore = (op: boolean, value: any): any => {
2
4
  const ptr: bytestring = '';
3
5
 
@@ -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
- callsSelf: true,
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 char
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, -1 ],
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
  };