porffor 0.2.0-4035760 → 0.2.0-4c545e7
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/codeGen.js +12 -9
- package/package.json +1 -1
- package/r.js +9 -45
package/compiler/codeGen.js
CHANGED
@@ -1286,8 +1286,8 @@ const getNodeType = (scope, node) => {
|
|
1286
1286
|
const generateLiteral = (scope, decl, global, name) => {
|
1287
1287
|
if (decl.value === null) return number(NULL);
|
1288
1288
|
|
1289
|
+
// hack: just return 1 for regex literals
|
1289
1290
|
if (decl.regex) {
|
1290
|
-
scope.regex[name] = decl.regex;
|
1291
1291
|
return number(1);
|
1292
1292
|
}
|
1293
1293
|
|
@@ -1473,8 +1473,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
1473
1473
|
// literal.func()
|
1474
1474
|
if (!name && decl.callee.type === 'MemberExpression') {
|
1475
1475
|
// megahack for /regex/.func()
|
1476
|
-
|
1477
|
-
|
1476
|
+
const funcName = decl.callee.property.name;
|
1477
|
+
if (decl.callee.object.regex && Object.hasOwn(Rhemyn, funcName)) {
|
1478
1478
|
const func = Rhemyn[funcName](decl.callee.object.regex.pattern, currentFuncIndex++);
|
1479
1479
|
|
1480
1480
|
funcIndex[func.name] = func.index;
|
@@ -1932,6 +1932,8 @@ const generateVar = (scope, decl) => {
|
|
1932
1932
|
for (const x of decl.declarations) {
|
1933
1933
|
const name = mapName(x.id.name);
|
1934
1934
|
|
1935
|
+
if (!name) return todo('destructuring is not supported yet');
|
1936
|
+
|
1935
1937
|
if (x.init && isFuncType(x.init.type)) {
|
1936
1938
|
// hack for let a = function () { ... }
|
1937
1939
|
x.init.id = { name };
|
@@ -2070,6 +2072,8 @@ const generateAssign = (scope, decl) => {
|
|
2070
2072
|
];
|
2071
2073
|
}
|
2072
2074
|
|
2075
|
+
if (!name) return todo('destructuring is not supported yet');
|
2076
|
+
|
2073
2077
|
const [ local, isGlobal ] = lookupName(scope, name);
|
2074
2078
|
|
2075
2079
|
if (local === undefined) {
|
@@ -2315,8 +2319,10 @@ const generateFor = (scope, decl) => {
|
|
2315
2319
|
out.push([ Opcodes.loop, Blocktype.void ]);
|
2316
2320
|
depth.push('for');
|
2317
2321
|
|
2318
|
-
out.push(...generate(scope, decl.test));
|
2319
|
-
|
2322
|
+
if (decl.test) out.push(...generate(scope, decl.test), Opcodes.i32_to);
|
2323
|
+
else out.push(...number(1, Valtype.i32));
|
2324
|
+
|
2325
|
+
out.push([ Opcodes.if, Blocktype.void ]);
|
2320
2326
|
depth.push('if');
|
2321
2327
|
|
2322
2328
|
out.push([ Opcodes.block, Blocktype.void ]);
|
@@ -2324,8 +2330,7 @@ const generateFor = (scope, decl) => {
|
|
2324
2330
|
out.push(...generate(scope, decl.body));
|
2325
2331
|
out.push([ Opcodes.end ]);
|
2326
2332
|
|
2327
|
-
out.push(...generate(scope, decl.update));
|
2328
|
-
depth.pop();
|
2333
|
+
if (decl.update) out.push(...generate(scope, decl.update));
|
2329
2334
|
|
2330
2335
|
out.push([ Opcodes.br, 1 ]);
|
2331
2336
|
out.push([ Opcodes.end ], [ Opcodes.end ]);
|
@@ -2766,8 +2771,6 @@ export const generateMember = (scope, decl, _global, _name) => {
|
|
2766
2771
|
const object = generate(scope, decl.object);
|
2767
2772
|
const property = generate(scope, decl.property);
|
2768
2773
|
|
2769
|
-
console.log(decl.property, property);
|
2770
|
-
|
2771
2774
|
// // todo: we should only do this for strings but we don't know at compile-time :(
|
2772
2775
|
// hack: this is naughty and will break things!
|
2773
2776
|
let newOut = number(0, valtypeBinary), newPointer = -1;
|
package/package.json
CHANGED
package/r.js
CHANGED
@@ -1,45 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
|
10
|
-
assert._isSameValue = function (a, b) {
|
11
|
-
if (a === b) {
|
12
|
-
// Handle +/-0 vs. -/+0
|
13
|
-
return a !== 0 || 1 / a === 1 / b;
|
14
|
-
}
|
15
|
-
|
16
|
-
// Handle NaN vs. NaN
|
17
|
-
return a !== a && b !== b;
|
18
|
-
|
19
|
-
// return a === b;
|
20
|
-
};
|
21
|
-
|
22
|
-
assert.sameValue = function (actual, expected) {
|
23
|
-
if (assert._isSameValue(actual, expected)) {
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
|
27
|
-
throw new Test262Error('assert.sameValue failed');
|
28
|
-
};
|
29
|
-
|
30
|
-
assert.notSameValue = function (actual, unexpected) {
|
31
|
-
if (!assert._isSameValue(actual, unexpected)) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
throw new Test262Error('assert.notSameValue failed');
|
36
|
-
};
|
37
|
-
function $DONOTEVALUATE() {
|
38
|
-
throw "Test262: This statement should not be evaluated.";
|
39
|
-
}
|
40
|
-
|
41
|
-
verifyProperty(this, "Infinity", {
|
42
|
-
enumerable: false,
|
43
|
-
writable: false,
|
44
|
-
configurable: false
|
45
|
-
});
|
1
|
+
var count = 0;
|
2
|
+
for (let x = 0; x < 10;) {
|
3
|
+
x++;
|
4
|
+
count++;
|
5
|
+
{
|
6
|
+
let x = "hello";
|
7
|
+
continue;
|
8
|
+
}
|
9
|
+
}
|