efront 4.0.2 → 4.0.6
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 +32 -14
- package/coms/compile/downLevel.js +3 -3
- package/coms/compile/unstruct.js +56 -49
- package/coms/compile/unstruct_test.js +8 -2
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/typescript-helpers/__assign.js +0 -18
- package/coms/typescript-helpers/__asyncDelegator.js +0 -12
- package/coms/typescript-helpers/__asyncGenerator.js +0 -18
- package/coms/typescript-helpers/__asyncValues.js +0 -14
- package/coms/typescript-helpers/__await.js +0 -8
- package/coms/typescript-helpers/__awaiter.js +0 -16
- package/coms/typescript-helpers/__classPrivateFieldGet.js +0 -12
- package/coms/typescript-helpers/__classPrivateFieldIn.js +0 -11
- package/coms/typescript-helpers/__classPrivateFieldSet.js +0 -13
- package/coms/typescript-helpers/__createBinding.js +0 -18
- package/coms/typescript-helpers/__decorate.js +0 -13
- package/coms/typescript-helpers/__esDecorate.js +0 -34
- package/coms/typescript-helpers/__exportStar.js +0 -10
- package/coms/typescript-helpers/__extends.js +0 -22
- package/coms/typescript-helpers/__generator.js +0 -34
- package/coms/typescript-helpers/__importDefault.js +0 -10
- package/coms/typescript-helpers/__importStar.js +0 -14
- package/coms/typescript-helpers/__makeTemplateObject.js +0 -11
- package/coms/typescript-helpers/__metadata.js +0 -10
- package/coms/typescript-helpers/__param.js +0 -10
- package/coms/typescript-helpers/__propKey.js +0 -10
- package/coms/typescript-helpers/__read.js +0 -23
- package/coms/typescript-helpers/__rest.js +0 -18
- package/coms/typescript-helpers/__runInitializers.js +0 -14
- package/coms/typescript-helpers/__setFunctionName.js +0 -11
- package/coms/typescript-helpers/__setModuleDefault.js +0 -12
- package/coms/typescript-helpers/__spreadArray.js +0 -16
- package/coms/typescript-helpers/__values.js +0 -18
package/coms/compile/common.js
CHANGED
|
@@ -121,27 +121,42 @@ var skipAssignment = function (o, cx) {
|
|
|
121
121
|
break;
|
|
122
122
|
case STRAP:
|
|
123
123
|
if (needpunc) {
|
|
124
|
-
if (
|
|
125
|
-
next();
|
|
126
|
-
next();
|
|
127
|
-
needpunc = false;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
if (!/^(in|instanceof|of|else|as|finally)$/.test(o.text)) break loop;
|
|
124
|
+
if (!/^(in|instanceof|of|else|as)$/.test(o.text)) break loop;
|
|
131
125
|
if (o.text === 'else') {
|
|
132
126
|
if (!ifdeep) break loop;
|
|
133
127
|
ifdeep--;
|
|
128
|
+
needpunc = false;
|
|
134
129
|
}
|
|
135
|
-
|
|
136
130
|
next();
|
|
137
131
|
needpunc = false;
|
|
138
132
|
}
|
|
139
|
-
else if (/^(
|
|
133
|
+
else if (/^(try|catch|finally)$/.test(o.text)) {
|
|
134
|
+
next();
|
|
135
|
+
if (o.entry === "(") next();
|
|
136
|
+
next();
|
|
137
|
+
}
|
|
138
|
+
else if (o.text === 'else') {
|
|
139
|
+
ifdeep--;
|
|
140
|
+
needpunc = false;
|
|
141
|
+
next();
|
|
142
|
+
}
|
|
143
|
+
else if (/^(if|while|with|switch)$/.test(o.text)) {
|
|
140
144
|
if (o.text === 'if') ifdeep++;
|
|
141
145
|
next();
|
|
142
146
|
next();
|
|
143
147
|
break;
|
|
144
148
|
}
|
|
149
|
+
else if (o.text === 'do') {
|
|
150
|
+
next();
|
|
151
|
+
next();
|
|
152
|
+
next();
|
|
153
|
+
}
|
|
154
|
+
else if (o.text === 'for') {
|
|
155
|
+
next();
|
|
156
|
+
if (o.type === STRAP && o.text === 'await') next();
|
|
157
|
+
next();
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
145
160
|
else if (o.text === "class") {
|
|
146
161
|
next();
|
|
147
162
|
while (o && !o.isClass) next();
|
|
@@ -163,9 +178,12 @@ var skipAssignment = function (o, cx) {
|
|
|
163
178
|
needpunc = false;
|
|
164
179
|
break loop;
|
|
165
180
|
}
|
|
181
|
+
else if (o.isend && !ifdeep) {
|
|
182
|
+
next();
|
|
183
|
+
break loop;
|
|
184
|
+
}
|
|
166
185
|
else {
|
|
167
186
|
next();
|
|
168
|
-
needpunc = false;
|
|
169
187
|
}
|
|
170
188
|
break;
|
|
171
189
|
default:
|
|
@@ -191,7 +209,7 @@ function snapSentenceHead(o) {
|
|
|
191
209
|
p = o.prev;
|
|
192
210
|
if (!p) break;
|
|
193
211
|
}
|
|
194
|
-
var maybeprop = o.type === SCOPED && o.entry !== "{" || o.type === EXPRESS &&
|
|
212
|
+
var maybeprop = o.type === SCOPED && o.entry !== "{" || o.type === EXPRESS && /^[\.\[]/.test(o.text);
|
|
195
213
|
if (p.type === EXPRESS) {
|
|
196
214
|
if (maybeprop || /\.$/.test(p.text)) {
|
|
197
215
|
o = p;
|
|
@@ -472,7 +490,7 @@ var createScoped = function (parsed, wash) {
|
|
|
472
490
|
if (mustyield !== false && o.next) {
|
|
473
491
|
if (o.next.type === STRAP && !/^(?:instanceof|in|of|from|as)$/.test(o.next.text)
|
|
474
492
|
|| o.next.type === STAMP && /[!~]/.test(o.next.text)
|
|
475
|
-
|| o.next.type === EXPRESS &&
|
|
493
|
+
|| o.next.type === EXPRESS && !/^[\.\[]/.test(o.next.text)
|
|
476
494
|
|| o.next.type & (VALUE | QUOTED | SCOPED)
|
|
477
495
|
) {
|
|
478
496
|
mustyield = true;
|
|
@@ -704,7 +722,7 @@ var createScoped = function (parsed, wash) {
|
|
|
704
722
|
|| (VALUE | QUOTED | SCOPED) & o.type
|
|
705
723
|
|| EXPRESS === o.type && !/\.$/.test(o.text)) {
|
|
706
724
|
if ((VALUE | QUOTED | PROPERTY | LABEL) & next.type) break;
|
|
707
|
-
if (EXPRESS === next.type &&
|
|
725
|
+
if (EXPRESS === next.type && !/^[\.\[]/.test(next.text)) break;
|
|
708
726
|
if (next.type === SCOPED && next.entry === "{") break;
|
|
709
727
|
if (next.type === STRAP && !next.isExpress) break;
|
|
710
728
|
}
|
|
@@ -1079,7 +1097,7 @@ var createString = function (parsed) {
|
|
|
1079
1097
|
break;
|
|
1080
1098
|
default:
|
|
1081
1099
|
if (o instanceof Object) {
|
|
1082
|
-
if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (
|
|
1100
|
+
if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
|
|
1083
1101
|
else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE) & o.type) {
|
|
1084
1102
|
result.push(" ");
|
|
1085
1103
|
}
|
|
@@ -937,7 +937,7 @@ var unforin = function (o, getnewname_, killobj) {
|
|
|
937
937
|
);
|
|
938
938
|
insert1(o.queue, o.prev, ...s);
|
|
939
939
|
splice(o, 0, o.length, ...scanner2(`${kname}=0;${kname}<${tname}.length&&`));
|
|
940
|
-
var c = scanner2(`(${m.text}=${tname}[${kname}]);${kname}++`);
|
|
940
|
+
var c = scanner2(`(${m.text}=${tname}[${kname}],true);${kname}++`);
|
|
941
941
|
insert1(o, null, ...c);
|
|
942
942
|
};
|
|
943
943
|
|
|
@@ -1358,7 +1358,7 @@ var down = function (scoped) {
|
|
|
1358
1358
|
if (!hp) break a;
|
|
1359
1359
|
if (hp.text === 'for') {
|
|
1360
1360
|
unforof(hp.next, getdeepname, scoped.used);
|
|
1361
|
-
killed = unforin(scoped.head, getdeepname, _killobj.bind(null, _getlocal)) !== false;
|
|
1361
|
+
if (funcMark) killed = unforin(scoped.head, getdeepname, _killobj.bind(null, _getlocal)) !== false;
|
|
1362
1362
|
// unforcx(scoped.head, getdeepname);
|
|
1363
1363
|
}
|
|
1364
1364
|
else if (hp.text === 'catch') {
|
|
@@ -1383,8 +1383,8 @@ var down = function (scoped) {
|
|
|
1383
1383
|
if (funcMark) {
|
|
1384
1384
|
var argname = _letname("_");
|
|
1385
1385
|
unstruct.debug = downLevel.debug;
|
|
1386
|
-
var code = unawait(scoped.body, _getname, argname);
|
|
1387
1386
|
var body = scanner2(`return ${funcMark}()`);
|
|
1387
|
+
var code = unawait(scoped.body, _getname, argname);
|
|
1388
1388
|
code.forEach(function (c) {
|
|
1389
1389
|
var f = scanner2(`function(${c.awaited ? argname : ''}){\r\n}`);
|
|
1390
1390
|
if (!c.length) f[2].push(...scanner2('return [1,0]'));
|
package/coms/compile/unstruct.js
CHANGED
|
@@ -23,7 +23,7 @@ var _break = function (body, cx, result, iscontinue) {
|
|
|
23
23
|
if (b.type === LABEL && b.text === label) {
|
|
24
24
|
if (!b.breaks) b.breaks = [];
|
|
25
25
|
var _b = scanner2('return []');
|
|
26
|
-
_b.ret_ =
|
|
26
|
+
_b.ret_ = -1;
|
|
27
27
|
if (iscontinue) _b[1].continue = s, s.continue = true;
|
|
28
28
|
b.breaks.push(_b[1]);
|
|
29
29
|
pushstep(result, _b);
|
|
@@ -40,7 +40,7 @@ var _break = function (body, cx, result, iscontinue) {
|
|
|
40
40
|
if (b.type !== LABEL) {
|
|
41
41
|
if (!b.breaks) b.breaks = [];
|
|
42
42
|
var _b = scanner2("return []");
|
|
43
|
-
_b.ret_ =
|
|
43
|
+
_b.ret_ = -1;
|
|
44
44
|
if (iscontinue) _b[1].continue = b, b.continue = true;
|
|
45
45
|
b.breaks.push(_b[1]);
|
|
46
46
|
pushstep(result, _b);
|
|
@@ -146,7 +146,7 @@ var _switch = function (body, cx, unblock, result, getname) {
|
|
|
146
146
|
for (var q of q) if (q.length) pushstep(result, q);
|
|
147
147
|
var qe = q;
|
|
148
148
|
if (qe.name) var case_ = scanner2(`if(${qn}===${qe.name})return[]`);
|
|
149
|
-
else case_ = scanner2(`return[]`), case_.ret_ =
|
|
149
|
+
else case_ = scanner2(`return[]`), case_.ret_ = -1;
|
|
150
150
|
pushstep(result, case_);
|
|
151
151
|
var by = cy;
|
|
152
152
|
m = o[cy];
|
|
@@ -154,7 +154,7 @@ var _switch = function (body, cx, unblock, result, getname) {
|
|
|
154
154
|
tmp.push(result.length - 1, case_[case_.length - 1], o.slice(by, cy));
|
|
155
155
|
}
|
|
156
156
|
if (!result[result.length - 1].ret_) {
|
|
157
|
-
case_ = scanner2(`return[]`), case_.ret_ =
|
|
157
|
+
case_ = scanner2(`return[]`), case_.ret_ = -1;
|
|
158
158
|
pushstep(result, case_);
|
|
159
159
|
tmp.push(result.length - 1, case_[case_.length - 1], []);
|
|
160
160
|
}
|
|
@@ -284,7 +284,9 @@ var _while = function (body, cx, unblock, result) {
|
|
|
284
284
|
return cx;
|
|
285
285
|
};
|
|
286
286
|
var pushstep = function (result, step) {
|
|
287
|
-
if (
|
|
287
|
+
if (isempty(step, SPACE)) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
288
290
|
var q = result[result.length - 1];
|
|
289
291
|
if (!q) {
|
|
290
292
|
result.push(step);
|
|
@@ -302,6 +304,7 @@ var pushstep = function (result, step) {
|
|
|
302
304
|
if (needcomma(q)) q.push({ type: STAMP, text: ';' });
|
|
303
305
|
if (!ishalf(q)) {
|
|
304
306
|
q.ret_ = step.ret_;
|
|
307
|
+
q.ifbrk = step.ifbrk;
|
|
305
308
|
}
|
|
306
309
|
q.push(...step);
|
|
307
310
|
q.await_ = step.await_;
|
|
@@ -346,7 +349,7 @@ var patchstep = function (r, nextindex, h) {
|
|
|
346
349
|
relink(r);
|
|
347
350
|
}
|
|
348
351
|
};
|
|
349
|
-
var
|
|
352
|
+
var flushqueue = function (result, queue) {
|
|
350
353
|
var savedLength = result.length;
|
|
351
354
|
var savedIndex = savedLength - 1;
|
|
352
355
|
var prev = result[savedIndex];
|
|
@@ -359,21 +362,6 @@ var flusqueue = function (result, queue) {
|
|
|
359
362
|
}
|
|
360
363
|
};
|
|
361
364
|
|
|
362
|
-
var addresult = function (result, step) {
|
|
363
|
-
if (!step.length) return;
|
|
364
|
-
var cx, mx = 0, n;
|
|
365
|
-
var awaited = step.awaited;
|
|
366
|
-
var queue = [];
|
|
367
|
-
do {
|
|
368
|
-
while (step[mx] && step[mx].type === STAMP && /^[,;]$/.test(step[mx].text)) mx++;
|
|
369
|
-
cx = step.indexOf(NEXT, mx);
|
|
370
|
-
n = step.slice(mx, mx = cx < 0 ? step.length : cx + 1);
|
|
371
|
-
if (awaited) n.awaited = awaited, awaited = false;
|
|
372
|
-
n.name = step.name;
|
|
373
|
-
queue.push(n);
|
|
374
|
-
} while (mx < step.length);
|
|
375
|
-
flusqueue(result, queue);
|
|
376
|
-
};
|
|
377
365
|
var _do = function (body, cx, unblock, result) {
|
|
378
366
|
var o = body[cx];
|
|
379
367
|
var label = o;
|
|
@@ -391,7 +379,7 @@ var _do = function (body, cx, unblock, result) {
|
|
|
391
379
|
};
|
|
392
380
|
var stepReturn = function (value, type, q) {
|
|
393
381
|
var r = scanner2(`return [${value},${type}]`);
|
|
394
|
-
r.ret_ = true;
|
|
382
|
+
r.ret_ = type === 2 ? type : true;
|
|
395
383
|
if (q && q.length) r.name = q[q.length - 1].name;
|
|
396
384
|
return r;
|
|
397
385
|
}
|
|
@@ -422,7 +410,10 @@ var _return = function (r, nextindex) {
|
|
|
422
410
|
r.await_ = true;
|
|
423
411
|
}
|
|
424
412
|
if (needcomma(r)) r.push({ type: STAMP, text: ';' });
|
|
425
|
-
else if (r.length)
|
|
413
|
+
else if (r.length) {
|
|
414
|
+
var re = r[r.length - 1];
|
|
415
|
+
if (re.type === STAMP && re.text === ',') re.text = ';';
|
|
416
|
+
}
|
|
426
417
|
r.push(...x);
|
|
427
418
|
relink(r);
|
|
428
419
|
};
|
|
@@ -463,7 +454,6 @@ var _invoke = function (t, getname) {
|
|
|
463
454
|
for (var cx = 0; cx < t.length; cx++) {
|
|
464
455
|
var o = t[cx];
|
|
465
456
|
if (needbreak(o)) {
|
|
466
|
-
if (needcomma(queue)) queue.push({ type: STAMP, text: ',' });
|
|
467
457
|
var s = splice(t, bx, cx + 1 - bx);
|
|
468
458
|
if (cx > 0) s.name = s[0].text;
|
|
469
459
|
else s.name = qname;
|
|
@@ -484,7 +474,7 @@ var _invoke = function (t, getname) {
|
|
|
484
474
|
var ey = cy;
|
|
485
475
|
if (ay === ey || ay >= o.length) continue;
|
|
486
476
|
var m = o.slice(ay, ey);
|
|
487
|
-
if (m.length === 1 && (m[0].type === EXPRESS &&
|
|
477
|
+
if (m.length === 1 && (m[0].type === EXPRESS && !/[\.\[]/.test(m[0].text) || m[0].type === VALUE || m[0].type === QUOTED && !m[0].length)) {
|
|
488
478
|
continue;
|
|
489
479
|
}
|
|
490
480
|
var q = toqueue(m, getdeepname, true);
|
|
@@ -505,7 +495,7 @@ var _invoke = function (t, getname) {
|
|
|
505
495
|
}
|
|
506
496
|
nameindex = _nameindex;
|
|
507
497
|
if (!cache.length) continue;
|
|
508
|
-
if (queue.length)
|
|
498
|
+
if (queue.length) flushqueue(result, queue), queue = [];
|
|
509
499
|
for (var c of cache) pushstep(result, c);
|
|
510
500
|
cache = [];
|
|
511
501
|
var n = o.next;
|
|
@@ -524,15 +514,15 @@ var _invoke = function (t, getname) {
|
|
|
524
514
|
}
|
|
525
515
|
if (queue.length) {
|
|
526
516
|
queue.push(t);
|
|
527
|
-
|
|
517
|
+
flushqueue(result, queue);
|
|
528
518
|
}
|
|
529
519
|
else if (t.length) {
|
|
530
520
|
var t0 = t[0];
|
|
531
|
-
if (t0.type === EXPRESS &&
|
|
521
|
+
if (t0.type === EXPRESS && /^[\.\[]/.test(t0.text) || t0.type & (STAMP | STRAP) && powermap[t0.text] < powermap.new) {
|
|
532
522
|
t.unshift(...scanner2(`${qname}=${qname}`));
|
|
533
523
|
relink(t);
|
|
534
524
|
}
|
|
535
|
-
|
|
525
|
+
pushstep(result, t);
|
|
536
526
|
}
|
|
537
527
|
return result;
|
|
538
528
|
};
|
|
@@ -551,10 +541,18 @@ var ishalf = function (q) {
|
|
|
551
541
|
if (!e) return false;
|
|
552
542
|
return e.type === SCOPED && e.entry === '(' && e.prev && e.prev.type === STRAP && /^if$/.test(e.prev.text) || e.type === STRAP && /^else$/.test(e.text);
|
|
553
543
|
}
|
|
544
|
+
var isempty = function (q, ignore_types) {
|
|
545
|
+
for (var a of q) {
|
|
546
|
+
if (!(a.type & ignore_types || a.type === STAMP && /^[,;]$/.test(a.text))) return false;
|
|
547
|
+
}
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
554
550
|
var needcomma = function (q) {
|
|
555
|
-
if (
|
|
556
|
-
var e = q[q.length - 1];
|
|
551
|
+
if (isempty(q, COMMENT | SPACE)) return false;
|
|
557
552
|
if (ishalf(q)) return false;
|
|
553
|
+
var i = q.length - 1;
|
|
554
|
+
var e = q[i];
|
|
555
|
+
while (e.type & (SPACE | COMMENT)) e = q[--i];
|
|
558
556
|
return !needbreak(e);
|
|
559
557
|
};
|
|
560
558
|
var patchname = function (d, getname) {
|
|
@@ -595,9 +593,9 @@ var ternary = function (body, getname, ret) {
|
|
|
595
593
|
patchname(d, getname);
|
|
596
594
|
pushstep(d, stepReturn(1, 0, d));
|
|
597
595
|
pushstep(c, stepReturn(d.length + 1, 0, c));
|
|
598
|
-
|
|
596
|
+
pushstep(res, scanner2(`if(${getCondition(b, function (b) {
|
|
599
597
|
b = ternary(b, getname, true);
|
|
600
|
-
for (var b of b)
|
|
598
|
+
for (var b of b) pushstep(res, b);
|
|
601
599
|
return b;
|
|
602
600
|
}, true)})return [1,0]`));
|
|
603
601
|
var q = res[res.length - 1];
|
|
@@ -673,6 +671,7 @@ var ternary = function (body, getname, ret) {
|
|
|
673
671
|
eq.text = "=";
|
|
674
672
|
var q2 = explist2[explist2.length - 1];
|
|
675
673
|
an = q2.name;
|
|
674
|
+
asn = scanner2(an);
|
|
676
675
|
}
|
|
677
676
|
else an = n;
|
|
678
677
|
ass.push(equals[i], ...asn);
|
|
@@ -788,14 +787,9 @@ var _express = function (body, getname, ret) {
|
|
|
788
787
|
cache.push(b, p);
|
|
789
788
|
continue;
|
|
790
789
|
}
|
|
791
|
-
var
|
|
792
|
-
var n = scanner2(name);
|
|
793
|
-
q.name = name;
|
|
794
|
-
n.index = nameindex;
|
|
795
|
-
n.push(b.pop());
|
|
796
|
-
|
|
790
|
+
var pb = b.pop();
|
|
797
791
|
if (cache.length) nameindex = cache[cache.length - 2].index;
|
|
798
|
-
else if (isor)
|
|
792
|
+
else if (isor) q.push(...scanner2(`${getname(nameindex)}=`), ...b);
|
|
799
793
|
|
|
800
794
|
while (cache.length && cache[cache.length - 1] >= p) {
|
|
801
795
|
if (needcomma(q)) q.push({ type: STAMP, text: ',' });
|
|
@@ -805,10 +799,12 @@ var _express = function (body, getname, ret) {
|
|
|
805
799
|
if (p0 > powermap["="] || isawait) q.push(...scanner2(`${getname(t.index)}=`));
|
|
806
800
|
q.push.apply(q, t);
|
|
807
801
|
q.push.apply(q, b);
|
|
802
|
+
b = scanner2(`${getname(t.index)}`);
|
|
803
|
+
nameindex = t.index;
|
|
808
804
|
if (isawait) q.push(NEXT);
|
|
809
805
|
}
|
|
810
|
-
nameindex
|
|
811
|
-
|
|
806
|
+
var name = getname(nameindex);
|
|
807
|
+
q.name = name;
|
|
812
808
|
if (isor) {
|
|
813
809
|
if (o.text === '||') {
|
|
814
810
|
q.push(RE);
|
|
@@ -822,7 +818,12 @@ var _express = function (body, getname, ret) {
|
|
|
822
818
|
hasor = true;
|
|
823
819
|
nameindex = 0;
|
|
824
820
|
} else {
|
|
821
|
+
var n = scanner2(name);
|
|
822
|
+
n.index = nameindex;
|
|
823
|
+
n.push(pb);
|
|
824
|
+
nameindex++;
|
|
825
825
|
cache.push(n, p);
|
|
826
|
+
if (maxindex < nameindex) maxindex = nameindex;
|
|
826
827
|
}
|
|
827
828
|
}
|
|
828
829
|
else {
|
|
@@ -885,6 +886,7 @@ var getblock = function (body, cx) {
|
|
|
885
886
|
cx++;
|
|
886
887
|
}
|
|
887
888
|
var b = body.slice(ax, cx);
|
|
889
|
+
while (o && o.type & (SPACE | COMMENT)) o = body[++cx];
|
|
888
890
|
b.next = o;
|
|
889
891
|
return b;
|
|
890
892
|
};
|
|
@@ -900,9 +902,11 @@ var ifpatch = function (result, autoskip) {
|
|
|
900
902
|
if (!result.length) return;
|
|
901
903
|
if (autoskip !== false) {
|
|
902
904
|
var rs = result[result.length - 1];
|
|
903
|
-
if (rs.ret_ &&
|
|
905
|
+
if (rs.ret_ !== true && rs.ret_) return;
|
|
904
906
|
}
|
|
905
907
|
var re = stepReturn(1, 0);
|
|
908
|
+
re.ret_ = -2;
|
|
909
|
+
re.ifbrk = autoskip !== undefined;
|
|
906
910
|
pushstep(result, re);
|
|
907
911
|
};
|
|
908
912
|
function toqueue(body, getname, ret = false, result = []) {
|
|
@@ -913,9 +917,11 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
913
917
|
if (isbr) continue;
|
|
914
918
|
var findex = iftop[cx] - 1;
|
|
915
919
|
var p = result[findex];
|
|
916
|
-
p.
|
|
917
|
-
|
|
918
|
-
|
|
920
|
+
if (p.ifbrk) {
|
|
921
|
+
p.pop();
|
|
922
|
+
p.push(scanner2(`[${result.length - findex},0]`)[0]);
|
|
923
|
+
relink(p);
|
|
924
|
+
}
|
|
919
925
|
}
|
|
920
926
|
for (var cx = 1, dx = iftop.length - 2; cx < dx; cx++) {
|
|
921
927
|
var isbr = iftop[cx++];
|
|
@@ -943,6 +949,7 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
943
949
|
var r = result[cx];
|
|
944
950
|
if (r.indexOf(b) >= 0) { break }
|
|
945
951
|
}
|
|
952
|
+
if (cx < 0) throw console.log(result.map(r => createString(r)), e.text, createString([b.prev, b])), "break语句异常";
|
|
946
953
|
end.push({ type: VALUE, text: b.continue ? b.continue.contat - cx : result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
|
|
947
954
|
relink(end);
|
|
948
955
|
}
|
|
@@ -1044,7 +1051,7 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1044
1051
|
while (body[cx] !== o.next) cx++;
|
|
1045
1052
|
o = o.next;
|
|
1046
1053
|
isbr = isbreak(o);
|
|
1047
|
-
if (!isbr) ifpatch(result);
|
|
1054
|
+
if (!isbr) ifpatch(result, true);
|
|
1048
1055
|
iftop.push(result.length);
|
|
1049
1056
|
elseif = true;
|
|
1050
1057
|
}
|
|
@@ -1084,8 +1091,8 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1084
1091
|
var bn = body.next;
|
|
1085
1092
|
if (bn && bn.type === STAMP && bn.text === ';') bn = bn.next;
|
|
1086
1093
|
var inif = bn && bn.type === STRAP && bn.text === 'else';
|
|
1087
|
-
if (inif) ifpatch(result);
|
|
1088
|
-
else if (!isbr) ifpatch(result);
|
|
1094
|
+
if (inif) ifpatch(result, true);
|
|
1095
|
+
else if (!isbr) ifpatch(result, true);
|
|
1089
1096
|
uniftop();
|
|
1090
1097
|
if (inif) ifpatch(result, false);
|
|
1091
1098
|
iftop = null;
|
|
@@ -57,8 +57,10 @@ test("if(await a) await b", "_ = a; return [_, 1];\r\n if (!@) return [2, 0]; _
|
|
|
57
57
|
test("for(a in b)", "for (a in b)", true);
|
|
58
58
|
test("for(var a in b) a.push()", "for (var a in b) a.push()", true);
|
|
59
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())", "
|
|
61
|
-
test("for(a=0;a<1;a++)if(a==0)continue", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [
|
|
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())", "_ = Symbol.iterator; _ = os[_]; if (_) return [1, 0]; _ = Symbol.asyncIterator; _ = os[_]; if (_) return [1, 0]; _ = Symbol.iterator; _ = Array.prototype[_];\r\n a = _; _ = a.call(os); a = _; _ = a.next(); b = _; return [1, 0];\r\n _ = !b.done; if (!_) return [1, 0]; _ = b.value; o = _; _ = (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\r\n else a=1", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [3, 0]; _ = a == 0; if (_) return [2, 0]; return [1, 0];\r\n a = 1; return [1, 0];\r\n _ = a++; return [-2, 0]`, true);
|
|
62
|
+
test("for(a=0;a<1;a++)if(a==0){continue} else {a=1}", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [3, 0]; _ = a == 0; if (!_) return [1, 0]; return [2, 0];\r\n a = 1; return [1, 0];\r\n _ = a++; return [-2, 0]`, true);
|
|
63
|
+
test("for(a=0;a<1;a++){if(a==0){a=2;continue} else if(b) {a=1;continue} c=3}", `a = 0; return [1, 0];\r\n _ = a < 1; if (!_) return [4, 0]; _ = a == 0; if (!_) return [1, 0]; a = 2; return [3, 0];\r\n if (!b) return [1, 0]; a = 1; return [2, 0];\r\n c = 3; return [1, 0];\r\n _ = a++; return [-3, 0]`, true);
|
|
62
64
|
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
65
|
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
66
|
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);
|
|
@@ -73,6 +75,7 @@ test("switch(a){case 1:case 2:break;}", "if (a === 1) return [1, 0]; if (a === 2
|
|
|
73
75
|
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
76
|
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
77
|
test("with(a){ a = 1}", `if (_ = with_("a", [a])) _.a = 1; else a = 1;`, true);
|
|
78
|
+
test("try{a=2+1}catch(e){return;}", 'return [65537, 7];\r\n _ = 2 + 1; a = _; return [0, 9];\r\n e = @; return [undefined, 2];\r\n return [1, 9]', true);
|
|
76
79
|
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
80
|
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
81
|
test("(function(){})", '_ = function () {}; (_)', true);
|
|
@@ -85,6 +88,9 @@ test(`url += (/\\?/.test(url) ? "&" : "?") + datas;`, '_ = /\\?/.test(url); if (
|
|
|
85
88
|
test(`a = newname.querySelector("input,textarea").value = c.name.replace(/\\/$/, '')`, `_ = c.name.replace(/\\/$/, ''); newname.querySelector("input,textarea").value = _; a = _`, true);
|
|
86
89
|
test(`if (selected[f.url]) f.selected = true;`, `_ = f.url; _ = selected[_]; if (!_) return [1, 0]; f.selected = true; return [1, 0]`, true);
|
|
87
90
|
test(`location.protocol + parseURL(a.b).host `, `_ = a.b; _ = parseURL(_); location.protocol + _.host`, true);
|
|
91
|
+
test(`var base = location.protocol + "//" + parseURL(this.$scope.data.host).host + "/";`, `_ = location.protocol + "//", _0 = this.$scope.data.host; _0 = parseURL(_0); _ = _ + _0.host, _ = _ + "/"; base = _`, true);
|
|
92
|
+
test(`a=a+b*c+c*d`, `_ = b * c, _ = a + _, _0 = c * d, _ = _ + _0; a = _`, true);
|
|
93
|
+
test(`cc.name += "<f test></f>"`, `_ = cc.name + "<f test></f>"; cc.name = _`, true);
|
|
88
94
|
test("yield a", 'return [a, 3]', true);
|
|
89
95
|
test("throw a", 'throw a', true);
|
|
90
96
|
test("debugger", 'debugger', true);
|