porffor 0.14.0-f67c123a1 → 0.16.0-a2e115b05

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.
@@ -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: 1
49
+ },
50
+ {
51
+ name: '__Porffor_readFile',
52
+ import: 'q',
53
+ params: 2,
54
+ returns: 1
43
55
  }
44
56
  ];
45
57
 
@@ -138,7 +150,7 @@ export const BuiltinVars = function() {
138
150
  this.Math = number(1);
139
151
 
140
152
  // wintercg(tm)
141
- this.__navigator_userAgent = (scope, { makeString }) => makeString(scope, `Porffor/0.14.0`, false, '__navigator_userAgent');
153
+ this.__navigator_userAgent = (scope, { makeString }) => makeString(scope, `Porffor/0.16.0`, false, '__navigator_userAgent');
142
154
  this.__navigator_userAgent.type = Prefs.bytestring ? TYPES.bytestring : TYPES.string;
143
155
 
144
156
  for (const x in TYPES) {
@@ -155,6 +167,7 @@ export const BuiltinFuncs = function() {
155
167
  params: [ valtypeBinary, valtypeBinary ],
156
168
  locals: [],
157
169
  returns: [ valtypeBinary ],
170
+ returnType: TYPES.number,
158
171
  wasm: [ // x - truncf(x / y) * y
159
172
  [ Opcodes.local_get, 0 ], // x
160
173
 
@@ -177,6 +190,7 @@ export const BuiltinFuncs = function() {
177
190
  params: [ valtypeBinary, valtypeBinary ],
178
191
  locals: [],
179
192
  returns: [ valtypeBinary ],
193
+ returnType: TYPES.number,
180
194
  wasm: [
181
195
  [ Opcodes.local_get, 0 ],
182
196
  Opcodes.i32_to,
@@ -196,9 +210,11 @@ export const BuiltinFuncs = function() {
196
210
  params: [ valtypeBinary ],
197
211
  locals: [],
198
212
  returns: [ valtypeBinary ],
213
+ returnType: TYPES.number,
199
214
  wasm: [
200
215
  [ Opcodes.local_get, 0 ]
201
- ]
216
+ ],
217
+ constr: true
202
218
  };
203
219
 
204
220
  // just return given (default 0) for (new) Object() as we somewhat supports object just not constructor
@@ -210,7 +226,8 @@ export const BuiltinFuncs = function() {
210
226
  wasm: [
211
227
  // [ Opcodes.local_get, 0 ]
212
228
  ...number(1)
213
- ]
229
+ ],
230
+ constr: true
214
231
  };
215
232
 
216
233
 
@@ -219,7 +236,7 @@ export const BuiltinFuncs = function() {
219
236
  typedParams: true,
220
237
  locals: [ Valtype.i32, Valtype.i32 ],
221
238
  returns: [],
222
- wasm: (scope, { typeSwitch }) => [
239
+ wasm: (scope, { typeSwitch, builtin }) => [
223
240
  ...typeSwitch(scope, [ [ Opcodes.local_get, 1 ] ], {
224
241
  [TYPES.number]: [
225
242
  [ Opcodes.local_get, 0 ],
@@ -315,7 +332,7 @@ export const BuiltinFuncs = function() {
315
332
 
316
333
  // make end pointer
317
334
  [ Opcodes.i32_load, Math.log2(ValtypeSize.i32) - 1, 0 ],
318
- ...number(ValtypeSize[valtype], Valtype.i32),
335
+ ...number(ValtypeSize[valtype] + 1, Valtype.i32),
319
336
  [ Opcodes.i32_mul ],
320
337
 
321
338
  [ Opcodes.local_get, 2 ],
@@ -324,14 +341,18 @@ export const BuiltinFuncs = function() {
324
341
 
325
342
  [ Opcodes.loop, Blocktype.void ],
326
343
 
327
- // print current char
344
+ // print current array element
328
345
  [ Opcodes.local_get, 2 ],
329
- [ Opcodes.load, Math.log2(ValtypeSize.i16) - 1, ValtypeSize.i32 ],
330
- [ Opcodes.call, importedFuncs.print ],
346
+ [ Opcodes.load, 0, ValtypeSize.i32 ],
347
+
348
+ [ Opcodes.local_get, 2 ],
349
+ [ Opcodes.i32_load8_u, 0, ValtypeSize.i32 + ValtypeSize[valtype] ],
350
+
351
+ [ Opcodes.call, builtin('__Porffor_print') ],
331
352
 
332
353
  // increment pointer by sizeof valtype
333
354
  [ Opcodes.local_get, 2 ],
334
- ...number(ValtypeSize[valtype], Valtype.i32),
355
+ ...number(ValtypeSize[valtype] + 1, Valtype.i32),
335
356
  [ Opcodes.i32_add ],
336
357
  [ Opcodes.local_tee, 2 ],
337
358
 
@@ -451,6 +472,7 @@ export const BuiltinFuncs = function() {
451
472
  params: [ valtypeBinary ],
452
473
  locals: [],
453
474
  returns: [ valtypeBinary ],
475
+ returnType: TYPES.number,
454
476
  wasm: [
455
477
  [ Opcodes.local_get, 0 ],
456
478
  [ Opcodes.f64_sqrt ]
@@ -462,6 +484,7 @@ export const BuiltinFuncs = function() {
462
484
  params: [ valtypeBinary ],
463
485
  locals: [],
464
486
  returns: [ valtypeBinary ],
487
+ returnType: TYPES.number,
465
488
  wasm: [
466
489
  [ Opcodes.local_get, 0 ],
467
490
  [ Opcodes.f64_abs ]
@@ -473,6 +496,7 @@ export const BuiltinFuncs = function() {
473
496
  params: [ valtypeBinary ],
474
497
  locals: [],
475
498
  returns: [ valtypeBinary ],
499
+ returnType: TYPES.number,
476
500
  wasm: [
477
501
  ...number(1),
478
502
  [ Opcodes.local_get, 0 ],
@@ -485,6 +509,7 @@ export const BuiltinFuncs = function() {
485
509
  params: [ valtypeBinary ],
486
510
  locals: [],
487
511
  returns: [ valtypeBinary ],
512
+ returnType: TYPES.number,
488
513
  wasm: [
489
514
  [ Opcodes.local_get, 0 ],
490
515
  [ Opcodes.f64_floor ]
@@ -496,6 +521,7 @@ export const BuiltinFuncs = function() {
496
521
  params: [ valtypeBinary ],
497
522
  locals: [],
498
523
  returns: [ valtypeBinary ],
524
+ returnType: TYPES.number,
499
525
  wasm: [
500
526
  [ Opcodes.local_get, 0 ],
501
527
  [ Opcodes.f64_ceil ]
@@ -507,6 +533,7 @@ export const BuiltinFuncs = function() {
507
533
  params: [ valtypeBinary ],
508
534
  locals: [],
509
535
  returns: [ valtypeBinary ],
536
+ returnType: TYPES.number,
510
537
  wasm: [
511
538
  [ Opcodes.local_get, 0 ],
512
539
  [ Opcodes.f64_nearest ]
@@ -518,6 +545,7 @@ export const BuiltinFuncs = function() {
518
545
  params: [ valtypeBinary ],
519
546
  locals: [],
520
547
  returns: [ valtypeBinary ],
548
+ returnType: TYPES.number,
521
549
  wasm: [
522
550
  [ Opcodes.local_get, 0 ],
523
551
  [ Opcodes.f64_trunc ]
@@ -529,6 +557,7 @@ export const BuiltinFuncs = function() {
529
557
  params: [ valtypeBinary ],
530
558
  locals: [],
531
559
  returns: [ valtypeBinary ],
560
+ returnType: TYPES.number,
532
561
  wasm: [
533
562
  [ Opcodes.local_get, 0 ],
534
563
  Opcodes.i32_trunc_sat_f64_u,
@@ -542,6 +571,7 @@ export const BuiltinFuncs = function() {
542
571
  params: [ valtypeBinary ],
543
572
  locals: [],
544
573
  returns: [ valtypeBinary ],
574
+ returnType: TYPES.number,
545
575
  wasm: [
546
576
  [ Opcodes.local_get, 0 ],
547
577
  [ Opcodes.f32_demote_f64 ],
@@ -555,6 +585,7 @@ export const BuiltinFuncs = function() {
555
585
  params: [ valtypeBinary, valtypeBinary ],
556
586
  locals: [],
557
587
  returns: [ valtypeBinary ],
588
+ returnType: TYPES.number,
558
589
  wasm: [
559
590
  [ Opcodes.local_get, 0 ],
560
591
  Opcodes.i32_trunc_sat_f64_s,
@@ -869,6 +900,7 @@ export const BuiltinFuncs = function() {
869
900
  globalNames: [ 'state0', 'state1' ],
870
901
  globalInits: [ prngSeed0, prngSeed1 ],
871
902
  returns: [ Valtype.f64 ],
903
+ returnType: TYPES.number,
872
904
  wasm: [
873
905
  ...prng.wasm,
874
906
 
@@ -920,6 +952,7 @@ export const BuiltinFuncs = function() {
920
952
  globalNames: [ 'state0', 'state1' ],
921
953
  globalInits: [ prngSeed0, prngSeed1 ],
922
954
  returns: [ Valtype.i32 ],
955
+ returnType: TYPES.number,
923
956
  wasm: [
924
957
  ...prng.wasm,
925
958
 
@@ -941,6 +974,7 @@ export const BuiltinFuncs = function() {
941
974
  params: [ valtypeBinary ],
942
975
  locals: [],
943
976
  returns: [ valtypeBinary ],
977
+ returnType: TYPES.number,
944
978
  wasm: [
945
979
  [ Opcodes.local_get, 0 ],
946
980
  ...number(Math.PI / 180),
@@ -953,6 +987,7 @@ export const BuiltinFuncs = function() {
953
987
  params: [ valtypeBinary ],
954
988
  locals: [],
955
989
  returns: [ valtypeBinary ],
990
+ returnType: TYPES.number,
956
991
  wasm: [
957
992
  [ Opcodes.local_get, 0 ],
958
993
  ...number(180 / Math.PI),
@@ -966,6 +1001,7 @@ export const BuiltinFuncs = function() {
966
1001
  locals: [],
967
1002
  localNames: [ 'x', 'lower', 'upper' ],
968
1003
  returns: [ valtypeBinary ],
1004
+ returnType: TYPES.number,
969
1005
  wasm: [
970
1006
  [ Opcodes.local_get, 0 ],
971
1007
  [ Opcodes.local_get, 1 ],
@@ -981,9 +1017,9 @@ export const BuiltinFuncs = function() {
981
1017
  locals: [],
982
1018
  localNames: [ 'x', 'inLow', 'inHigh', 'outLow', 'outHigh' ],
983
1019
  returns: [ valtypeBinary ],
1020
+ returnType: TYPES.number,
984
1021
  wasm: [
985
1022
  // (x − inLow) * (outHigh − outLow) / (inHigh - inLow) + outLow
986
-
987
1023
  [ Opcodes.local_get, 0 ],
988
1024
  [ Opcodes.local_get, 1 ],
989
1025
  [ Opcodes.f64_sub ],
@@ -1025,6 +1061,7 @@ export const BuiltinFuncs = function() {
1025
1061
  params: [],
1026
1062
  locals: [],
1027
1063
  returns: [ valtypeBinary ],
1064
+ returnType: TYPES.number,
1028
1065
  wasm: [
1029
1066
  [ Opcodes.call, importedFuncs.time ]
1030
1067
  ]
@@ -1052,6 +1089,7 @@ export const BuiltinFuncs = function() {
1052
1089
  typedParams: true,
1053
1090
  locals: [],
1054
1091
  returns: [ valtypeBinary ],
1092
+ returnType: TYPES.number,
1055
1093
  wasm: [
1056
1094
  [ Opcodes.local_get, 1 ],
1057
1095
  Opcodes.i32_from_u