efront 3.8.2 → 3.8.4
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/compile/common.js +3 -1
- package/coms/compile/scanner2.js +57 -16
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/compile/common.js
CHANGED
|
@@ -91,6 +91,7 @@ var skipAssignment = function (o) {
|
|
|
91
91
|
}
|
|
92
92
|
else if (o.text === "function") {
|
|
93
93
|
o = o.next;
|
|
94
|
+
if (o && o.type === STAMP) o = o.next;
|
|
94
95
|
if (o && o.type === EXPRESS) o = o.next;
|
|
95
96
|
if (o) o = o.next;
|
|
96
97
|
if (o) o = o.next;
|
|
@@ -185,6 +186,7 @@ var createScoped = function (parsed) {
|
|
|
185
186
|
continue loop;
|
|
186
187
|
case "function":
|
|
187
188
|
isFunction = true;
|
|
189
|
+
if (o.next.type === STAMP) o = o.next;
|
|
188
190
|
case "catch":
|
|
189
191
|
isCatch = true;
|
|
190
192
|
case "class":
|
|
@@ -377,7 +379,7 @@ var getDeclared = function (o, kind) {
|
|
|
377
379
|
}
|
|
378
380
|
case PROPERTY:
|
|
379
381
|
if (o.next) {
|
|
380
|
-
if (o.next.type === STAMP && o.next.text === ":") {
|
|
382
|
+
if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
|
|
381
383
|
o = o.next.next;
|
|
382
384
|
continue;
|
|
383
385
|
}
|
package/coms/compile/scanner2.js
CHANGED
|
@@ -26,6 +26,7 @@ var needBreak = function (prev, next) {
|
|
|
26
26
|
if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
|
|
27
27
|
if (next.type === EXPRESS && /^\./.test(next.text)) return;
|
|
28
28
|
if (next.type === PROPERTY) return ";";
|
|
29
|
+
if (next.type === STAMP && next.text === "*") return ";";
|
|
29
30
|
if (
|
|
30
31
|
[EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
|
|
31
32
|
|| prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
|
|
@@ -104,6 +105,7 @@ var insertAfter = function (o) {
|
|
|
104
105
|
for (var o of os) {
|
|
105
106
|
prev.next = o;
|
|
106
107
|
o.prev = prev;
|
|
108
|
+
Object.defineProperty(o, 'queue', { value: queue });
|
|
107
109
|
prev = o;
|
|
108
110
|
}
|
|
109
111
|
if (next) {
|
|
@@ -213,13 +215,13 @@ var detour = function (o, ie) {
|
|
|
213
215
|
}
|
|
214
216
|
if (!/^\[/.test(o.text) && o.queue.isClass) {
|
|
215
217
|
if (o.text === 'constructor') break;
|
|
216
|
-
if (o.text === 'get') console.log(o.text, o.type, o.next);
|
|
217
218
|
var text = strings.encode(strings.decode(o.text));
|
|
218
219
|
if (o.prev) {
|
|
219
220
|
var prev = o.prev;
|
|
220
221
|
if (prev && prev.type === PROPERTY && /^(get|set|static|async)$/.test(prev.text)) {
|
|
221
222
|
prev = prev.prev;
|
|
222
223
|
}
|
|
224
|
+
if (prev && prev.type === STAMP && prev.isprop) prev = prev.prev;
|
|
223
225
|
if (prev && (prev.type !== STAMP || prev.text !== ';')) insertAfter(prev, { text: ';', type: STAMP });
|
|
224
226
|
}
|
|
225
227
|
o.text = `[${text}]`;
|
|
@@ -315,7 +317,7 @@ class Program extends Array {
|
|
|
315
317
|
if (!o.prev || o.prev.text !== 'for') result.pop();
|
|
316
318
|
}
|
|
317
319
|
if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
|
|
318
|
-
result.push(" ");
|
|
320
|
+
if (!this.pressed) result.push(" ");
|
|
319
321
|
}
|
|
320
322
|
}
|
|
321
323
|
result.push(o.leave);
|
|
@@ -339,7 +341,7 @@ class Program extends Array {
|
|
|
339
341
|
) result.push(";");
|
|
340
342
|
}
|
|
341
343
|
else if (!/^(\+\+|\-\-)$/.test(o.text)) {
|
|
342
|
-
if (!this.pressed) result.push(" ");
|
|
344
|
+
if (!this.pressed && lasttype !== SPACE) result.push(" ");
|
|
343
345
|
}
|
|
344
346
|
}
|
|
345
347
|
result.push(o.text);
|
|
@@ -446,15 +448,20 @@ class Javascript {
|
|
|
446
448
|
var origin = queue;
|
|
447
449
|
var queue_push = function (scope) {
|
|
448
450
|
var last = queue.lastUncomment;
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
scope.
|
|
451
|
+
if (queue.isObject || queue.isClass) {
|
|
452
|
+
if (~[VALUE, QUOTED].indexOf(scope.type)) {
|
|
453
|
+
scope.isprop = isProperty();
|
|
454
|
+
}
|
|
455
|
+
else if (scope.type === SCOPED && scope.entry === '[') {
|
|
456
|
+
if (queue.isObject) scope.isprop = isProperty();
|
|
457
|
+
if (queue.isClass) scope.isprop = !last || last.isprop || last.type === STAMP && last.text === ';';
|
|
458
|
+
}
|
|
459
|
+
else if (scope.type === STAMP) {
|
|
460
|
+
scope.isprop = scope.text === "*" && isProperty();
|
|
461
|
+
}
|
|
462
|
+
else if (scope.type === PROPERTY) {
|
|
463
|
+
scope.isprop = true;
|
|
464
|
+
}
|
|
458
465
|
}
|
|
459
466
|
if (scope.type !== COMMENT && scope.type !== SPACE) {
|
|
460
467
|
Object.defineProperty(scope, 'queue', { value: queue });
|
|
@@ -655,10 +662,14 @@ class Javascript {
|
|
|
655
662
|
var prev = queue.lastUncomment;
|
|
656
663
|
if (queue.isObject) {
|
|
657
664
|
if (!prev || prev.type === STAMP && prev.text === ",") return true;
|
|
665
|
+
if (prev.type === STAMP && prev.isprop) return true;
|
|
658
666
|
}
|
|
659
667
|
if (queue.isClass) {
|
|
660
668
|
if (!prev) return true;
|
|
661
|
-
if (prev.type === STAMP)
|
|
669
|
+
if (prev.type === STAMP) {
|
|
670
|
+
if (prev.isprop) return true;
|
|
671
|
+
return /^(\+\+|\-\-|;)$/.test(prev.text);
|
|
672
|
+
}
|
|
662
673
|
if (prev.type === EXPRESS && !/\.$/.test(prev.text)) return true;
|
|
663
674
|
if (~[SCOPED, VALUE, QUOTED, PROPERTY].indexOf(prev.type)) return true;
|
|
664
675
|
}
|
|
@@ -770,7 +781,7 @@ class Javascript {
|
|
|
770
781
|
}
|
|
771
782
|
if (this.space_reg.test(m)) {
|
|
772
783
|
if (/[\r\n\u2028\u2029]/.test(m)) {
|
|
773
|
-
colstart = match.index +
|
|
784
|
+
colstart = match.index + 1;
|
|
774
785
|
m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
|
|
775
786
|
row += m.replace(/[^\r\n]+/, '').length >> 1;
|
|
776
787
|
save(SPACE);
|
|
@@ -790,7 +801,36 @@ class Javascript {
|
|
|
790
801
|
queue.inExpress = false;
|
|
791
802
|
}
|
|
792
803
|
}
|
|
793
|
-
|
|
804
|
+
if (m === 'yield') {
|
|
805
|
+
var temp = queue;
|
|
806
|
+
var type = STRAP;
|
|
807
|
+
while (temp) {
|
|
808
|
+
if (temp.entry != "{" || !temp.prev || temp.prev.type !== SCOPED || temp.prev.entry !== '(') {
|
|
809
|
+
temp = temp.queue;
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
var pp = temp.prev.prev;
|
|
813
|
+
var isprop = pp.isprop;
|
|
814
|
+
if (pp && pp.type === EXPRESS || pp.isprop) pp = pp.prev;
|
|
815
|
+
if (!pp || pp.type === STRAP && !/^function$/.test(pp.text)) {
|
|
816
|
+
temp = temp.queue;
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
if (pp.type === STAMP && pp.text === "*" && (pp.isprop || pp.prev && pp.prev.type === STRAP && pp.prev.text === "function")) {
|
|
820
|
+
type = STRAP;
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
if (isprop || pp.type === STRAP && pp.text === "function") {
|
|
824
|
+
type = EXPRESS;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
temp = temp.queue;
|
|
828
|
+
}
|
|
829
|
+
save(type);
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
save(STRAP);
|
|
833
|
+
}
|
|
794
834
|
continue;
|
|
795
835
|
}
|
|
796
836
|
if (this.value_reg.test(m) || this.number_reg.test(m)) {
|
|
@@ -828,7 +868,8 @@ class Javascript {
|
|
|
828
868
|
else scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(last.text);
|
|
829
869
|
}
|
|
830
870
|
else if (last.type === STRAP) {
|
|
831
|
-
if (queue[queue.length - 1].type === SPACE && /^(return|
|
|
871
|
+
if (queue[queue.length - 1].type === SPACE && /^(return|yield)$/.test(last.text));
|
|
872
|
+
else if (/^export$/.test(last.text));
|
|
832
873
|
else scope.isObject = queue.inExpress;
|
|
833
874
|
}
|
|
834
875
|
}
|