porffor 0.2.0-964b4c2 → 0.2.0-9ca9aed

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/2c.js CHANGED
@@ -124,7 +124,7 @@ export default ({ funcs, globals, tags, exceptions, pages }) => {
124
124
  const returns = f.returns.length > 0;
125
125
 
126
126
  const shouldInline = f.internal;
127
- out += `${f.name === 'main' ? 'int' : (f.internal ? 'double' : 'struct ReturnValue')} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')}) {\n`;
127
+ out += `${f.name === 'main' ? 'int' : (f.internal ? (returns ? 'double' : 'void') : 'struct ReturnValue')} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')}) {\n`;
128
128
 
129
129
  const localKeys = Object.keys(f.locals).sort((a, b) => f.locals[a].idx - f.locals[b].idx).slice(f.params.length).sort((a, b) => f.locals[a].idx - f.locals[b].idx);
130
130
  for (const x of localKeys) {
@@ -367,6 +367,11 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
367
367
  line(`return ${vals.pop()}`);
368
368
  }
369
369
 
370
+ if (f.name === 'main') {
371
+ out += '\n';
372
+ line(`return 0`);
373
+ }
374
+
370
375
  out += '}\n\n';
371
376
  }
372
377
 
@@ -1013,7 +1013,18 @@ const TYPES = {
1013
1013
 
1014
1014
  // these are not "typeof" types but tracked internally
1015
1015
  _array: 0x10,
1016
- _regexp: 0x11
1016
+ _regexp: 0x11,
1017
+
1018
+ // typed arrays
1019
+ _int8array: 0x20,
1020
+ _uint8array: 0x21,
1021
+ _uint8clampedarray: 0x22,
1022
+ _int16array: 0x23,
1023
+ _uint16array: 0x24,
1024
+ _int32array: 0x25,
1025
+ _uint32array: 0x26,
1026
+ _float32array: 0x27,
1027
+ _float64array: 0x28,
1017
1028
  };
1018
1029
 
1019
1030
  const TYPE_NAMES = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.2.0-964b4c2",
4
+ "version": "0.2.0-9ca9aed",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "dependencies": {
package/tmp.c CHANGED
@@ -65,5 +65,7 @@ int main() {
65
65
  counter = counter + 1e+0;
66
66
  }
67
67
  __console_log(sum);
68
+
69
+ return 0;
68
70
  }
69
71