efront 4.0.19 → 4.0.22
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/queue.js +3 -2
- package/coms/basic/strings.js +21 -13
- package/coms/basic_/Symbol.js +2 -2
- package/coms/basic_/aster_.js +6 -6
- package/coms/basic_/asyncAster_.js +19 -13
- package/coms/basic_/exec_.js +21 -5
- package/coms/compile/Javascript.js +70 -30
- package/coms/compile/Program.js +27 -8
- package/coms/compile/common.js +78 -79
- package/coms/compile/downLevel.js +251 -100
- package/coms/compile/downLevel_test.js +55 -31
- package/coms/compile/run-test262.js +141 -0
- package/coms/compile/scanner2_test.js +7 -2
- package/coms/compile/unstruct.js +46 -42
- package/coms/compile/unstruct_test.js +10 -5
- package/coms/kugou/dance.js +1 -0
- package/coms/kugou/player.js +4 -27
- package/coms/reptile/colored_console.js +9 -9
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/compile/common.js
CHANGED
|
@@ -12,7 +12,8 @@ const [
|
|
|
12
12
|
/* 512 */LABEL,
|
|
13
13
|
/*1024 */PROPERTY,
|
|
14
14
|
] = new Array(20).fill(0).map((_, a) => 1 << a);
|
|
15
|
-
|
|
15
|
+
// --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
|
|
16
|
+
var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mn])?$/i;
|
|
16
17
|
var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
|
|
17
18
|
var skipAssignment = function (o, cx) {
|
|
18
19
|
var next = arguments.length === 1 ? function () {
|
|
@@ -361,7 +362,7 @@ var snapExpressFoot = function (o) {
|
|
|
361
362
|
n = o.next;
|
|
362
363
|
}
|
|
363
364
|
if (!n) break;
|
|
364
|
-
if (n.type === SCOPED && o.entry !== '{'
|
|
365
|
+
if (n.type === SCOPED && (o.entry !== '{' || o.isObject)
|
|
365
366
|
|| /\.$/.test(o.text) && !o.isdigit
|
|
366
367
|
|| n.type === EXPRESS && /^\??\.[^\.]/.test(n.text)
|
|
367
368
|
|| n.type === QUOTED && (n.length || /^\`/.test(n.text))
|
|
@@ -389,6 +390,7 @@ var mustBeYield = function (o) {
|
|
|
389
390
|
var createScoped = function (parsed, wash) {
|
|
390
391
|
var used = Object.create(null); var vars = Object.create(null), lets = vars;
|
|
391
392
|
var scoped = [], funcbody = scoped, argscope = scoped, thisscope = scoped;
|
|
393
|
+
funcbody.isroot = true;
|
|
392
394
|
scoped.body = parsed;
|
|
393
395
|
scoped.isfunc = true;
|
|
394
396
|
var run = function (o, id, body) {
|
|
@@ -439,25 +441,10 @@ var createScoped = function (parsed, wash) {
|
|
|
439
441
|
case VALUE:
|
|
440
442
|
if (o.isdigit) break;
|
|
441
443
|
case EXPRESS:
|
|
444
|
+
// if (o.text === 'readFileAsync') console.log(o)
|
|
442
445
|
if (o.prev && o.prev.type === EXPRESS) {
|
|
443
446
|
if (/\.$/.test(o.prev.text)) break;
|
|
444
447
|
}
|
|
445
|
-
if (o.text === 'await' && funcbody.async !== false) {
|
|
446
|
-
o.type = STRAP;
|
|
447
|
-
funcbody.async = true;
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
if (o.text === 'yield') {
|
|
451
|
-
if (funcbody.aster === true) {
|
|
452
|
-
o.type = STRAP;
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
if (mustBeYield(o)) {
|
|
456
|
-
o.type = STRAP;
|
|
457
|
-
funcbody.aster = true;
|
|
458
|
-
}
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
448
|
if (o.next && o.next.type === STAMP && o.next.text === "=>") {
|
|
462
449
|
isScope = true;
|
|
463
450
|
isArrow = true;
|
|
@@ -487,43 +474,29 @@ var createScoped = function (parsed, wash) {
|
|
|
487
474
|
|
|
488
475
|
case STRAP:
|
|
489
476
|
var s = o.text;
|
|
477
|
+
var m = null;
|
|
490
478
|
switch (s) {
|
|
491
479
|
case "return":
|
|
492
480
|
if (!funcbody.return) funcbody.return = [];
|
|
493
481
|
funcbody.return.push(o);
|
|
494
482
|
break;
|
|
495
483
|
case "await":
|
|
496
|
-
if (funcbody.async === false) {
|
|
497
|
-
o.type = EXPRESS;
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
funcbody.async = funcbody.await = true;
|
|
501
|
-
break;
|
|
502
|
-
case "yield":
|
|
503
|
-
if (!funcbody.aster) {
|
|
504
|
-
var mustyield = undefined;
|
|
505
|
-
var tmp = id;
|
|
506
|
-
if (body) while (body[++tmp] !== o.next) {
|
|
507
|
-
if (body[tmp].type === SPACE) {
|
|
508
|
-
mustyield = false;
|
|
509
|
-
break;
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
if (mustyield !== false) mustyield = mustBeYield(o);
|
|
513
|
-
if (mustyield) funcbody.aster = true;
|
|
514
|
-
continue;
|
|
515
|
-
}
|
|
516
|
-
funcbody.yield = true;
|
|
517
484
|
break;
|
|
518
485
|
case "as":
|
|
519
486
|
case "from":
|
|
520
487
|
break;
|
|
521
|
-
case "var":
|
|
522
|
-
case "import":
|
|
523
|
-
var m = vars;
|
|
524
488
|
case "let":
|
|
525
489
|
case "const":
|
|
526
|
-
m =
|
|
490
|
+
m = lets;
|
|
491
|
+
if (!o.next || o.next.type !== EXPRESS && (o.next.type !== SCOPED || o.next.entry === "(")) {
|
|
492
|
+
o.type = EXPRESS;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
case "import":
|
|
496
|
+
if (!o.next || o.next.type === QUOTED) break;
|
|
497
|
+
case "var":
|
|
498
|
+
m = m || vars;
|
|
499
|
+
if (s === 'var' && m !== vars) console.log(m === vars, m === lets, s);
|
|
527
500
|
var [declared, used0, o0, skiped] = getDeclared(o.next, s);
|
|
528
501
|
while (skiped.length) {
|
|
529
502
|
var o1 = run(skiped[0], 0);
|
|
@@ -566,8 +539,9 @@ var createScoped = function (parsed, wash) {
|
|
|
566
539
|
break;
|
|
567
540
|
case "for":
|
|
568
541
|
o = o.next;
|
|
569
|
-
if (o.type
|
|
570
|
-
|
|
542
|
+
if (o.type !== SCOPED && o.text === 'await') {
|
|
543
|
+
if (o.type === EXPRESS) o.type = STRAP;
|
|
544
|
+
funcbody.await = funcbody.async = true;
|
|
571
545
|
o = o.next;
|
|
572
546
|
}
|
|
573
547
|
isScope = true;
|
|
@@ -627,11 +601,11 @@ var createScoped = function (parsed, wash) {
|
|
|
627
601
|
lets = vars;
|
|
628
602
|
if (isFunction) {
|
|
629
603
|
vars.this = true, vars.arguments = true;
|
|
630
|
-
scoped.aster = isAster;
|
|
604
|
+
scoped.yield = scoped.aster = isAster;
|
|
631
605
|
thisscope = scoped;
|
|
632
606
|
argscope = scoped;
|
|
633
607
|
}
|
|
634
|
-
scoped.async = isAsync;
|
|
608
|
+
scoped.await = scoped.async = isAsync;
|
|
635
609
|
scoped.isfunc = true;
|
|
636
610
|
isFunction = true;
|
|
637
611
|
if (function_obj) function_obj.scoped = scoped;
|
|
@@ -743,7 +717,7 @@ var createScoped = function (parsed, wash) {
|
|
|
743
717
|
} while (o);
|
|
744
718
|
}
|
|
745
719
|
var map = isFunction ? vars : lets;
|
|
746
|
-
var keepscope = !!scoped.body || !!scoped.head;
|
|
720
|
+
var keepscope = !!scoped.body || !!scoped.head || isArrow;
|
|
747
721
|
if (!keepscope) for (var k in map) {
|
|
748
722
|
keepscope = true;
|
|
749
723
|
break;
|
|
@@ -772,7 +746,6 @@ var createScoped = function (parsed, wash) {
|
|
|
772
746
|
}
|
|
773
747
|
if (isClass) delete lets.super, delete lets.this, thisscope = _thisscope;
|
|
774
748
|
if (isFunction) {
|
|
775
|
-
if (used.yield) _scoped.yield = false;
|
|
776
749
|
funcbody = _funcbody;
|
|
777
750
|
if (!isArrow) {
|
|
778
751
|
delete vars.this;
|
|
@@ -801,11 +774,19 @@ var createScoped = function (parsed, wash) {
|
|
|
801
774
|
}
|
|
802
775
|
}
|
|
803
776
|
if (vars.yield) scoped.yield = false;
|
|
777
|
+
if (vars.await) scoped.await = false;
|
|
804
778
|
if (scoped.yield !== false && envs.yield) {
|
|
805
|
-
|
|
779
|
+
used.yield.forEach(o => o.type = STRAP);
|
|
780
|
+
scoped.yield = scoped.aster = true;
|
|
806
781
|
delete envs.yield;
|
|
807
782
|
delete used.yield;
|
|
808
783
|
}
|
|
784
|
+
if (scoped.await !== false && envs.await) {
|
|
785
|
+
used.await.forEach(o => o.type = STRAP);
|
|
786
|
+
scoped.await = scoped.async = true;
|
|
787
|
+
delete envs.await;
|
|
788
|
+
delete used.await;
|
|
789
|
+
}
|
|
809
790
|
delete envs.eval;
|
|
810
791
|
scoped.envs = envs;
|
|
811
792
|
return scoped;
|
|
@@ -835,6 +816,19 @@ var getDeclared = function (o, kind, queue) {
|
|
|
835
816
|
}
|
|
836
817
|
}
|
|
837
818
|
switch (o.type) {
|
|
819
|
+
case SCOPED:
|
|
820
|
+
if (snapExpressFoot(o) === o) {
|
|
821
|
+
var [d, u, _, s] = getDeclared(o.first, kind, o);
|
|
822
|
+
while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
|
|
823
|
+
mergeTo(used, u);
|
|
824
|
+
if (d.length || d.attributes.length) declared.push(d);
|
|
825
|
+
if (!prop) prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
826
|
+
d.entry = o.entry;
|
|
827
|
+
o.kind = kind;
|
|
828
|
+
attributes.push([prop, d]);
|
|
829
|
+
o = o.next;
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
838
832
|
case STAMP:
|
|
839
833
|
if (o.text === "*" && o.next) {
|
|
840
834
|
if (o.next.type === STRAP && o.next.text === 'as') {
|
|
@@ -854,10 +848,12 @@ var getDeclared = function (o, kind, queue) {
|
|
|
854
848
|
case EXPRESS:
|
|
855
849
|
case STRAP:
|
|
856
850
|
case VALUE:
|
|
857
|
-
var
|
|
858
|
-
|
|
859
|
-
var
|
|
860
|
-
if (
|
|
851
|
+
var isrest = /^\.\.\./.test(o.text);
|
|
852
|
+
var n = o;
|
|
853
|
+
var k = o.text;
|
|
854
|
+
if (isrest) declared.push(k = k.slice(3))
|
|
855
|
+
else if (o.text) declared.push(k);
|
|
856
|
+
if (!isrest && !prop) {
|
|
861
857
|
if (queue && queue.entry === '{') {
|
|
862
858
|
if (o.type & (EXPRESS | STRAP)) {
|
|
863
859
|
if (/^\[/.test(o.text)) prop = o.text;
|
|
@@ -870,22 +866,14 @@ var getDeclared = function (o, kind, queue) {
|
|
|
870
866
|
}
|
|
871
867
|
else prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
872
868
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
case SCOPED:
|
|
880
|
-
var [d, u, _, s] = getDeclared(o.first, kind, o);
|
|
881
|
-
while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
|
|
882
|
-
mergeTo(used, u);
|
|
883
|
-
declared.push(d);
|
|
884
|
-
if (!prop) prop = declared["..."] ? declared["..."][1] - index : `[${index}]`;
|
|
885
|
-
d.entry = o.entry;
|
|
869
|
+
var f = snapExpressFoot(o);
|
|
870
|
+
if (k) saveTo(used, k, o);
|
|
871
|
+
var s = [o];
|
|
872
|
+
while (o !== f) o = o.next, s.push(o);
|
|
873
|
+
if (isrest) declared["..."] = [s, index];
|
|
874
|
+
else attributes.push([prop, s]);
|
|
886
875
|
o.kind = kind;
|
|
887
|
-
|
|
888
|
-
o = o.next;
|
|
876
|
+
o = f.next;
|
|
889
877
|
break;
|
|
890
878
|
default:
|
|
891
879
|
console.log(o);
|
|
@@ -896,13 +884,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
896
884
|
case STRAP:
|
|
897
885
|
if (/^(in|of)$/.test(o.text)) {
|
|
898
886
|
o = o.next;
|
|
899
|
-
|
|
900
|
-
do {
|
|
901
|
-
skiped.push(o);
|
|
902
|
-
o = o.next;
|
|
903
|
-
} while (o !== o0);
|
|
904
|
-
o = o0;
|
|
905
|
-
break;
|
|
887
|
+
break loop;
|
|
906
888
|
}
|
|
907
889
|
break loop;
|
|
908
890
|
case STAMP:
|
|
@@ -910,6 +892,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
910
892
|
o.prev.equal = o;
|
|
911
893
|
o = o.next;
|
|
912
894
|
var o0 = skipAssignment(o);
|
|
895
|
+
if (isrest) throw "余集变量不能有默认值";
|
|
913
896
|
attributes[attributes.length - 1].push(queue, o, o0);
|
|
914
897
|
while (o !== o0) {
|
|
915
898
|
skiped.push(o);
|
|
@@ -940,7 +923,9 @@ var mapDeclared = function (map, declared) {
|
|
|
940
923
|
}
|
|
941
924
|
return map;
|
|
942
925
|
};
|
|
926
|
+
var { uncode } = require("../basic/strings");
|
|
943
927
|
var saveTo = function (used, k, o) {
|
|
928
|
+
k = uncode(k);
|
|
944
929
|
if (!(used[k] instanceof Array)) used[k] = [];
|
|
945
930
|
used[k].push(o);
|
|
946
931
|
};
|
|
@@ -1007,8 +992,11 @@ var relink = function (list) {
|
|
|
1007
992
|
return list;
|
|
1008
993
|
};
|
|
1009
994
|
var setqueue = function (list, queue = list) {
|
|
1010
|
-
|
|
1011
|
-
|
|
995
|
+
/**
|
|
996
|
+
* @type {PropertyDescriptor}
|
|
997
|
+
*/
|
|
998
|
+
var v = { value: queue, configurable: true, enumerable: false };
|
|
999
|
+
for (var o of list) delete o.queue, Object.defineProperty(o, 'queue', v);
|
|
1012
1000
|
};
|
|
1013
1001
|
|
|
1014
1002
|
var createString = function (parsed) {
|
|
@@ -1025,7 +1013,6 @@ var createString = function (parsed) {
|
|
|
1025
1013
|
) {
|
|
1026
1014
|
if (o.type !== EXPRESS || !/^(\.[^\.]|\[)/.test(o.text) && !prev.tag && !o.tag) {
|
|
1027
1015
|
result.push(" ");
|
|
1028
|
-
if (createString.debug && !o.text) console.log(o.type, o.text, o)
|
|
1029
1016
|
lasttype = SPACE
|
|
1030
1017
|
}
|
|
1031
1018
|
}
|
|
@@ -1246,6 +1233,17 @@ var replace = function (o, ...args) {
|
|
|
1246
1233
|
var i = queue.indexOf(o);
|
|
1247
1234
|
if (i >= 0) splice(queue, i, 1, ...args);
|
|
1248
1235
|
};
|
|
1236
|
+
var isEval = function (o) {
|
|
1237
|
+
if (o.entry === "[") {
|
|
1238
|
+
var h = snapExpressHead(o);
|
|
1239
|
+
return o !== h;
|
|
1240
|
+
}
|
|
1241
|
+
else if (o.entry === '(') {
|
|
1242
|
+
var h = snapExpressHead(o);
|
|
1243
|
+
return o === h;
|
|
1244
|
+
}
|
|
1245
|
+
return false;
|
|
1246
|
+
};
|
|
1249
1247
|
|
|
1250
1248
|
module.exports = {
|
|
1251
1249
|
/* 1 */COMMENT,
|
|
@@ -1272,6 +1270,7 @@ module.exports = {
|
|
|
1272
1270
|
skipSentenceQueue,
|
|
1273
1271
|
needBreakBetween,
|
|
1274
1272
|
saveTo,
|
|
1273
|
+
isEval,
|
|
1275
1274
|
rename,
|
|
1276
1275
|
relink,
|
|
1277
1276
|
setqueue,
|