efront 3.37.0 → 3.38.1
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/coms/basic/#loader.js +3 -2
- package/coms/basic/assert.js +21 -9
- package/coms/basic_/Array2.js +2 -1
- package/coms/basic_/JSON.js +5 -5
- package/coms/basic_/Symbol.js +4 -1
- package/coms/basic_/exec_.js +21 -10
- package/coms/basic_/extends_.js +1 -0
- package/coms/compile/Javascript.js +36 -12
- package/coms/compile/Program.js +11 -4
- package/coms/compile/common.js +170 -51
- package/coms/compile/downLevel.js +727 -275
- package/coms/compile/downLevel_test.js +195 -53
- package/coms/compile/powermap.js +2 -2
- package/coms/compile/scanner2.js +5 -2
- package/coms/compile/translate.js +45 -19
- package/coms/compile/unstruct.js +506 -280
- package/coms/compile/unstruct_test.js +66 -40
- package/coms/reptile/colored_console.js +2 -2
- package/coms/zimoli/appendChild.js +1 -1
- package/coms/zimoli/css.js +1 -0
- package/coms/zimoli/zimoli.js +1 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
var unstruct = require('./unstruct');
|
|
2
2
|
var scanner2 = require("./scanner2");
|
|
3
3
|
var { createString } = require("./common");
|
|
4
|
+
var r = 10;
|
|
4
5
|
function test(codetext, expect, ret = false) {
|
|
5
|
-
var code = scanner2(codetext);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
assert(code.map(createString).join("; "), expect);
|
|
6
|
+
var code = scanner2(codetext), i = -2;
|
|
7
|
+
try { code = unstruct(code, () => ++i >= 0 ? "_" + i : '_', ret && "@"); } catch (e) { console.log(r); throw e }
|
|
8
|
+
assert(code.map(createString).join(";\r\n "), expect, r++);
|
|
9
9
|
}
|
|
10
10
|
test('a+b', "a + b");
|
|
11
|
+
test('var a = b', "a = b");
|
|
11
12
|
test('a + !c', "_ = !c, a + _");
|
|
12
13
|
test('a + b * c', "_ = b * c, a + _");
|
|
13
14
|
test('a + b * !c', "_ = !c, _ = b * _, a + _");
|
|
@@ -16,49 +17,74 @@ test('a * a + b * c', "_ = a * a, _0 = b * c, _ + _0");
|
|
|
16
17
|
test('a * a + b * c * c ** d', "_ = a * a, _0 = b * c, _1 = c ** d, _0 = _0 * _1, _ + _0");
|
|
17
18
|
test('a * a || b * c * c ** d', "_ = a * a @re _ = b * c, _0 = c ** d, _ * _0");
|
|
18
19
|
test('a * a || b * c || c * d', "_ = a * a @re _ = b * c @re c * d");
|
|
19
|
-
test('a
|
|
20
|
+
test('a || b || c', "_ = a; if (_) return [1, 0]; _ = b; if (_) return [1, 0]; c", true);
|
|
21
|
+
test('a?b:c', "if (!a) return [1, 0]; _ = b; return [2, 0];\r\n _ = c; return [1, 0]");
|
|
20
22
|
test('a * a && b * c * c ** d', "_ = a * a @rz _ = b * c, _0 = c ** d, _ * _0");
|
|
21
|
-
test('a = 1 + 2', "_ = 1 + 2
|
|
23
|
+
test('a = 1 + 2', "_ = 1 + 2; a = _", true);
|
|
22
24
|
test('a = b', "a = b", true);
|
|
23
|
-
test('a = b
|
|
24
|
-
test('
|
|
25
|
-
test('a = b = c
|
|
26
|
-
test('
|
|
25
|
+
test('a.a = b', "a.a = b", true);
|
|
26
|
+
test('loaded[f.name] = a', "_ = f.name; loaded[_] = a", true);
|
|
27
|
+
test('a = b = c', "b = c; a = c", true);
|
|
28
|
+
test('a = b = c + d', "_ = c + d; b = _; a = _", true);
|
|
29
|
+
test('a = b = c + d * 1', "_ = d * 1, _ = c + _; b = _; a = _", true);
|
|
30
|
+
test('return a = b', "a = b; return [b, 2]", true);
|
|
27
31
|
test('a*a', "a * a", true);
|
|
28
32
|
test('a * a && b * c * c ** d', "_ = a * a; if (!_) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
29
33
|
test('a * a || b * c * c ** d', "_ = a * a; if (_) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
30
34
|
test('a * a ?? b * c * c ** d', "_ = a * a; if (_ !== null && _ !== undefined) return [1, 0]; _ = b * c, _0 = c ** d, _ * _0", true);
|
|
31
|
-
test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_, 1]
|
|
32
|
-
|
|
35
|
+
test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; _ * c", true);
|
|
33
36
|
test("await a", "_ = a; return [_, 1]", true);
|
|
34
|
-
test("yield a", "
|
|
37
|
+
test("yield a", "return [a, 3]", true);
|
|
35
38
|
test("await a()", "_ = a(); return [_, 1]", true);
|
|
36
39
|
test("yield a()", "_ = a(); return [_, 3]", true);
|
|
37
40
|
test("(1+ +1)", "_ = +1, _ = 1 + _; (_)", true);
|
|
38
|
-
test("await a(await b)", "_ = b; return [_, 1]
|
|
39
|
-
test("await a(await b).s(await c)", "_ = b; return [_, 1]
|
|
40
|
-
test("a*a + await a(await b).s(await c)", "_ = a * a
|
|
41
|
-
test("a*a + await a(await b(await c)).s(await c)", "_ = a * a
|
|
42
|
-
test("await a, await b", "_ = a; return [_, 1]
|
|
43
|
-
test("await a * b, await b", "_ = a; return [_, 1]
|
|
44
|
-
test("if(a);", "", true);
|
|
45
|
-
test("if(a)
|
|
46
|
-
test("if(a)
|
|
47
|
-
test("if(a)
|
|
48
|
-
test("if(a) await b
|
|
49
|
-
test("if(a) await b; else
|
|
50
|
-
test("if(
|
|
51
|
-
test("
|
|
52
|
-
test("
|
|
53
|
-
test("
|
|
54
|
-
test("
|
|
55
|
-
test("
|
|
56
|
-
test("
|
|
57
|
-
test("
|
|
58
|
-
test("
|
|
59
|
-
test("
|
|
60
|
-
test("
|
|
61
|
-
test("
|
|
62
|
-
test("
|
|
63
|
-
test("
|
|
64
|
-
test("
|
|
41
|
+
test("await a(await b)", "_ = b; return [_, 1];\r\n _ = @; _ = a(_); return [_, 1]", true);
|
|
42
|
+
test("await a(await b).s(await c)", "_ = b; return [_, 1];\r\n _ = @; _ = a(_); _0 = c; return [_0, 1];\r\n _0 = @; _ = _.s(_0); return [_, 1]", true);
|
|
43
|
+
test("a*a + await a(await b).s(await c)", "_ = a * a, _0 = b; return [_0, 1];\r\n _0 = @; _0 = a(_0); _1 = c; return [_1, 1];\r\n _1 = @; _0 = _0.s(_1); return [_0, 1];\r\n _0 = @; _ + _0", true);
|
|
44
|
+
test("a*a + await a(await b(await c)).s(await c)", "_ = a * a, _0 = c; return [_0, 1];\r\n _0 = @; _0 = b(_0); return [_0, 1];\r\n _0 = @; _0 = a(_0); _1 = c; return [_1, 1];\r\n _1 = @; _0 = _0.s(_1); return [_0, 1];\r\n _0 = @; _ + _0", true);
|
|
45
|
+
test("await a, await b", "_ = a; return [_, 1];\r\n _ = @; _ = b; return [_, 1]", true);
|
|
46
|
+
test("await a * b, await b", "_ = a; return [_, 1];\r\n _ = @; _ * b; _ = b; return [_, 1]", true);
|
|
47
|
+
test("if(a);", "if (!a) return [1, 0]; return [1, 0]", true);
|
|
48
|
+
test("if(a) return a;", "if (a) return [a, 2]", true);
|
|
49
|
+
test("if(a) { if(b) return a;} else return d", "if (!a) return [2, 0]; if (b) return [a, 2]; return [1, 0];\r\n return [2, 0];\r\n return [d, 2]", true);
|
|
50
|
+
test("if(a) return a; else return b", "if (a) return [a, 2]; return [b, 2]", true);
|
|
51
|
+
test("if(a) await b", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
52
|
+
test("if(a) await b; else await c", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [3, 0];\r\n _ = c; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
53
|
+
test("if(a) b; else await c", "if (!a) return [1, 0]; b; return [3, 0];\r\n _ = c; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
54
|
+
test("if(a) await b; else if(e) await c", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [3, 0];\r\n if (!e) return [2, 0]; _ = c; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
55
|
+
test("if(a) await b; else if(e) await c else await d", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [5, 0];\r\n if (!e) return [2, 0]; _ = c; return [_, 1];\r\n _ = @; return [3, 0];\r\n _ = d; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
56
|
+
test("if(await a) await b", "_ = a; return [_, 1];\r\n if (!@) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [1, 0]", true);
|
|
57
|
+
test("for(a in b)", "for (a in b)", true);
|
|
58
|
+
test("for(var a in b) a.push()", "for (var a in b) a.push()", true);
|
|
59
|
+
test("for(;;)", "return [0, 0]", true);
|
|
60
|
+
test("for(a = os[Symbol.iterator] || os[Symbol.asyncIterator] || Array.prototype[Symbol.iterator], a = a.call(os), b = a.next(); !b.done && (o = b.value, true); b = a.next())", "_0 = Symbol.iterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.asyncIterator; _ = os[_0]; if (_) return [1, 0]; _0 = Symbol.iterator; _ = Array.prototype[_0];\r\n a = _; _ = a.call(os); a = _; _ = a.next(); b = _; return [1, 0];\r\n _ = !b.done; if (!_) return [1, 0]; _0 = b.value; o = _0; _ = (_0, true);\r\n if (!_) return [1, 0]; _ = a.next(); b = _; return [-1, 0]", true);
|
|
61
|
+
test("for(a=0;a<1;a++)if(a==0)continue", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [2, 0]; _ = a == 0; if (_) return [1, 0]; return [1, 0];\r\n _ = a++; return [-1, 0]`, true);
|
|
62
|
+
test("for(a=0;a<10;a++) await a", "a = 0; return [1, 0];\r\n _ = a < 10; if (!_) return [2, 0]; _ = a; return [_, 1];\r\n _ = @; _ = a++; return [-1, 0]", true);
|
|
63
|
+
test("for(a=0;a<10;a++) await a, await b", "a = 0; return [1, 0];\r\n _ = a < 10; if (!_) return [3, 0]; _ = a; return [_, 1];\r\n _ = @; _ = b; return [_, 1];\r\n _ = @; _ = a++; return [-2, 0]", true);
|
|
64
|
+
test("for(a=0;b=2,a<10;a++) await a, await b", "a = 0; return [1, 0];\r\n b = 2; _ = a < 10; if (!_) return [3, 0]; _ = a; return [_, 1];\r\n _ = @; _ = b; return [_, 1];\r\n _ = @; _ = a++; return [-2, 0]", true);
|
|
65
|
+
test("while(a) await b", "if (!a) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; return [-1, 0]", true);
|
|
66
|
+
test("do{await b}while(a)", "_ = b; return [_, 1];\r\n _ = @; if (a) return [-1, 0]", true);
|
|
67
|
+
test("switch(a){case 1:}", "if (a === 1) return [1, 0]; return [1, 0]", true);
|
|
68
|
+
test("switch(a){case 1: default:}", "if (a === 1) return [1, 0]; return [1, 0]", true);
|
|
69
|
+
test("switch(a.a){case 1:}", "_ = a.a; if (_ === 1) return [1, 0]; return [1, 0]", true);
|
|
70
|
+
test("switch(a){case 1:break;}", "if (a === 1) return [1, 0]; return [1, 0]", true);
|
|
71
|
+
test("switch(a){case 1:break;case 2:break;}", "if (a === 1) return [1, 0]; if (a === 2) return [1, 0]; return [1, 0]", true);
|
|
72
|
+
test("switch(a){case 1:case 2:break;}", "if (a === 1) return [1, 0]; if (a === 2) return [1, 0]; return [1, 0]", true);
|
|
73
|
+
test("switch(a){case 1:case 2:x=1;}", "if (a === 1) return [1, 0]; if (a === 2) return [1, 0]; return [2, 0];\r\n x = 1; return [1, 0]", true);
|
|
74
|
+
test("switch(a){case 1:case 2:x=1;}", "if (a === 1) return [1, 0]; if (a === 2) return [1, 0]; return [2, 0];\r\n x = 1; return [1, 0]", true);
|
|
75
|
+
test("with(a){ a = 1}", `if (_ = with_("a", [a])) _.a = 1; else a = 1;`, true);
|
|
76
|
+
test("try{a=2+1}catch(e){}", 'return [1, 7];\r\n _ = 2 + 1; a = _; return [0, 9];\r\n return [1, 9]', true);
|
|
77
|
+
test("try{a=2+1}catch(e){a=3}", 'return [65537, 7];\r\n _ = 2 + 1; a = _; return [0, 9];\r\n e = @; a = 3; return [0, 9];\r\n return [1, 9]', true);
|
|
78
|
+
test("(function(){})", '_ = function () {}; (_)', true);
|
|
79
|
+
test("(1+2*function(){}())", '_ = 2 * function () {}(), _ = 1 + _; (_)', true);
|
|
80
|
+
test("function a(){}", 'function a() {}', true);
|
|
81
|
+
test("await new Promise(function(){})", '_ = function () {}; _ = new Promise(_); return [_, 1]', true);
|
|
82
|
+
test(`onerror({ status: xhr.status, response: "Cookie解析异常!", toString: toResponse })`, '_ = { status: xhr.status, response: "Cookie解析异常!", toString: toResponse }; onerror(_)', true);
|
|
83
|
+
test(`if (!/^https\\:\\/\\/|^s\\/\\//.test(url)) console.warn("请使用https访问如下路径:" + url)`, '_ = /^https\\:\\/\\/|^s\\/\\//.test(url); if (_) return [1, 0]; _ = "请使用https访问如下路径:" + url; _ = console.warn(_); return [1, 0]', true);
|
|
84
|
+
test(`url += (/\\?/.test(url) ? "&" : "?") + datas;`, '_ = /\\?/.test(url); if (!_) return [1, 0]; _ = "&"; return [2, 0];\r\n _ = "?"; return [1, 0];\r\n _ = (_); _ = _ + datas; _ = url + _; url = _', true);
|
|
85
|
+
test(`a = newname.querySelector("input,textarea").value = c.name.replace(/\\/$/, '')`, `_ = c.name.replace(/\\/$/, ''); newname.querySelector("input,textarea").value = _; a = _`, true);
|
|
86
|
+
test(`if (selected[f.url]) f.selected = true;`, `_ = f.url; _ = selected[_]; if (!_) return [1, 0]; f.selected = true; return [1, 0]`, true);
|
|
87
|
+
test(`location.protocol + parseURL(a.b).host `, `_ = a.b; _ = parseURL(_); location.protocol + _.host`, true);
|
|
88
|
+
test("yield a", 'return [a, 3]', true);
|
|
89
|
+
test("throw a", 'throw a', true);
|
|
90
|
+
test("debugger", 'debugger', true);
|
|
@@ -156,14 +156,14 @@ var formatRows = function (arg, rows, deep, entry, leave) {
|
|
|
156
156
|
if (isArray) {
|
|
157
157
|
for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
|
|
158
158
|
res.push(rows.slice(cx, cx + itemcount).map((r, i) => {
|
|
159
|
-
return Array(maxLength[i] - lens[cx + i]).join(" ") + r;
|
|
159
|
+
return Array(maxLength[i] - lens[cx + i] + 1).join(" ") + r;
|
|
160
160
|
}).join(', '));
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
|
|
165
165
|
res.push([rows[cx], ...rows.slice(cx + 1, cx + itemcount).map((r, i) => {
|
|
166
|
-
return Array(maxLength[i] - lens[cx + i]).join(" ") + r;
|
|
166
|
+
return Array(maxLength[i] - lens[cx + i] + 1).join(" ") + r;
|
|
167
167
|
})].join(', '));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -10,8 +10,8 @@ function hasEnterStyle(e) {
|
|
|
10
10
|
|
|
11
11
|
function _onappend(node, append = createEvent("append"), mount = createEvent("mounted")) {
|
|
12
12
|
if (node.isMounted) return;
|
|
13
|
-
node.isMounted = true;
|
|
14
13
|
if (node.nodeType !== 1 && node.nodeType !== 8) return;
|
|
14
|
+
node.isMounted = true;
|
|
15
15
|
dispatch(node, append);
|
|
16
16
|
var children = Array.apply(null, node.childNodes);
|
|
17
17
|
for (var c of children) {
|
package/coms/zimoli/css.js
CHANGED
|
@@ -156,6 +156,7 @@ var cssTargetSelector = function (targetSelector, oStyle, oValue) {
|
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
function cssTargetStyleSheet(stylesheet, innerCss) {
|
|
159
|
+
if (isObject(innerCss)) innerCss = serialize(innerCss, ';', ':');
|
|
159
160
|
var styleSheet = stylesheet.styleSheet;
|
|
160
161
|
if (styleSheet) {
|
|
161
162
|
//IE
|
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -687,6 +687,7 @@ zimoli.clearHistory = function () {
|
|
|
687
687
|
history = {};
|
|
688
688
|
};
|
|
689
689
|
zimoli.getCurrentHistory = function () {
|
|
690
|
+
if (!history[current_history]) history[current_history] = [];
|
|
690
691
|
return history[current_history];
|
|
691
692
|
};
|
|
692
693
|
zimoli.inithash = locationInitHash;
|