porffor 0.30.13 → 0.30.14
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 +16 -16
- package/compiler/cyclone.js +3 -3
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/2c.js
CHANGED
@@ -231,20 +231,6 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
|
|
231
231
|
prependMain.set('argv', `_argc = argc; _argv = argv;`);
|
232
232
|
}
|
233
233
|
|
234
|
-
prepend.set('func decls', funcs.filter(x => x.name !== 'main').map(f => {
|
235
|
-
const returns = f.returns.length > 0;
|
236
|
-
const typedReturns = f.returnType == null;
|
237
|
-
|
238
|
-
const invLocals = inv(f.locals, x => x.idx);
|
239
|
-
for (const x in invLocals) {
|
240
|
-
invLocals[x] = sanitize(invLocals[x]);
|
241
|
-
}
|
242
|
-
|
243
|
-
const shouldInline = false;
|
244
|
-
|
245
|
-
return `${!typedReturns ? (returns ? CValtype[f.returns[0]] : 'void') : 'struct ReturnValue'} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')});`;
|
246
|
-
}).join('\n'));
|
247
|
-
|
248
234
|
if (out) out += '\n';
|
249
235
|
|
250
236
|
const line = (str, semi = true) => out += `${str}${semi ? ';' : ''}\n`;
|
@@ -438,7 +424,7 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
|
|
438
424
|
|
439
425
|
case Opcodes.f64_const: {
|
440
426
|
const val = i[1];
|
441
|
-
vals.push(val);
|
427
|
+
vals.push(val.toString());
|
442
428
|
break;
|
443
429
|
}
|
444
430
|
|
@@ -822,7 +808,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
|
|
822
808
|
break;
|
823
809
|
}
|
824
810
|
|
825
|
-
|
811
|
+
if (Prefs.d) log.warning('2c', `unimplemented op: ${invOpcodes[i[0]]} \x1b[90m(${f.name})`);
|
826
812
|
}
|
827
813
|
|
828
814
|
lastCond = false;
|
@@ -844,6 +830,20 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
|
|
844
830
|
|
845
831
|
cify(funcs.find(x => x.name === 'main'));
|
846
832
|
|
833
|
+
prepend.set('func decls', funcs.filter(x => x.name !== 'main' && cified.has(x.name)).map(f => {
|
834
|
+
const returns = f.returns.length > 0;
|
835
|
+
const typedReturns = f.returnType == null;
|
836
|
+
|
837
|
+
const invLocals = inv(f.locals, x => x.idx);
|
838
|
+
for (const x in invLocals) {
|
839
|
+
invLocals[x] = sanitize(invLocals[x]);
|
840
|
+
}
|
841
|
+
|
842
|
+
const shouldInline = false;
|
843
|
+
|
844
|
+
return `${!typedReturns ? (returns ? CValtype[f.returns[0]] : 'void') : 'struct ReturnValue'} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')});`;
|
845
|
+
}).join('\n'));
|
846
|
+
|
847
847
|
const makeIncludes = includes => [...includes.keys()].map(x => `#include <${x}>\n`).join('');
|
848
848
|
out = platformSpecific(makeIncludes(winIncludes), makeIncludes(unixIncludes), false) + '\n' + makeIncludes(includes) + '\n' + alwaysPreface + [...prepend.values()].join('\n') + '\n\n' + out;
|
849
849
|
|
package/compiler/cyclone.js
CHANGED
@@ -53,7 +53,7 @@ export default wasm => {
|
|
53
53
|
const replaceOp = newOp => {
|
54
54
|
op.splice(0, op.length, ...newOp);
|
55
55
|
};
|
56
|
-
const replaceVal = (val, valtype) => replaceOp(number(val, valtype));
|
56
|
+
const replaceVal = (val, valtype) => replaceOp(number(val, valtype)[0]);
|
57
57
|
|
58
58
|
const empty = () => {
|
59
59
|
stack = [];
|
@@ -511,7 +511,7 @@ export default wasm => {
|
|
511
511
|
|
512
512
|
// convert f64.const -> i32.const
|
513
513
|
const n = wasm[i - 1][1];
|
514
|
-
wasm.splice(i - 1, 1, number(n, Valtype.i32));
|
514
|
+
wasm.splice(i - 1, 1, number(n, Valtype.i32)[0]);
|
515
515
|
|
516
516
|
// convert math op from f64 to i32
|
517
517
|
wasm[i][0] = f64ToI32Op[wasm[i][0]];
|
@@ -551,7 +551,7 @@ export default wasm => {
|
|
551
551
|
|
552
552
|
// convert f64.const -> i32.const
|
553
553
|
const n = wasm[i - 2][1];
|
554
|
-
wasm.splice(i - 2, 1, number(n, Valtype.i32));
|
554
|
+
wasm.splice(i - 2, 1, number(n, Valtype.i32)[0]);
|
555
555
|
|
556
556
|
// convert math op from f64 to i32
|
557
557
|
wasm[i - 1][0] = f64ToI32Op[wasm[i - 1][0]];
|
package/package.json
CHANGED