efront 4.0.50 → 4.0.51

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.
@@ -1,7 +1,14 @@
1
- function decodeUTF16(buff, be = true) {
1
+ function decodeUTF16(buff, be) {
2
2
  var dist = [];
3
- var dec = be ? (a, b) => a << 8 | b : (a, b) => b << 8 | a;
4
- for (var cx = 0, dx = buff; cx < dx; cx += 2) {
3
+ var LE = (a, b) => b << 8 | a;
4
+ var BE = (a, b) => a << 8 | b;
5
+ if (buff[0] === 0xfe && buff[1] === 0xff) {
6
+ be = true;
7
+ }
8
+ else if (buff[0] === 0xff && buff[1] === 0xfe) be = true;
9
+ else if (isEmpty(be)) be = false;
10
+ var dec = be ? BE : LE;
11
+ for (var cx = 0, dx = buff.length; cx < dx; cx += 2) {
5
12
  var m = dec(buff[cx], buff[cx + 1]);
6
13
  var t;
7
14
  if (m > 0b1101111111111111 || m < 0b1101100000000000) {
@@ -25,7 +25,7 @@ function numberUTF16LE(t, dist = []) {
25
25
  return dist;
26
26
 
27
27
  }
28
- function encodeUTF16(strings, be = true) {
28
+ function encodeUTF16(strings, be = false) {
29
29
  var dist = [];
30
30
  var utf16 = be ? numberUTF16 : numberUTF16LE;
31
31
  for (var cx = 0, dx = strings.length; cx < dx; cx++) {
@@ -1,5 +1,5 @@
1
1
  function isEmpty(value) {
2
- if (value === '' || value === null || value === undefined || typeof value === 'number' && !isFinite(value)) return true;
2
+ if (value === '' || value === null || value === undefined || Number.isNaN(value)) return true;
3
3
  if (value instanceof Array && value.length === 0 || value.constructor === Object || !value.constructor) {
4
4
  for (var k in value) return false;
5
5
  return true;
@@ -133,13 +133,17 @@ function enumref(scoped) {
133
133
  for (var rk in rs) {
134
134
  var os = rs[rk];
135
135
  if (os.wcount !== 1 || os.length < 2) continue;
136
- var eq = null;
136
+ var eq = null, em = null;
137
137
  loop: for (var o of os) {
138
138
  if (o.equal) {
139
139
  if (o.equal.text !== '=') break;
140
140
  if (o.queue.kind) break;
141
141
  if (o.queue !== scoped.body) break;
142
142
  if (inCondition(o)) break;
143
+ if (o.enumref) {
144
+ em = o.enumref;
145
+ continue;
146
+ }
143
147
  o = o.equal.next;
144
148
  var n = skipAssignment(o);
145
149
  var exps = [];
@@ -154,6 +158,10 @@ function enumref(scoped) {
154
158
  }
155
159
  }
156
160
  else {
161
+ if (em) {
162
+ o.enumref = em;
163
+ continue;
164
+ }
157
165
  if (!eq) break;
158
166
  o.type = eq.type;
159
167
  o.isdigit = true;
@@ -172,7 +180,7 @@ function atuoenum(scoped) {
172
180
  enumref(scoped);
173
181
  }
174
182
  var exports = module.exports = function main(code) {
175
- atuoenum(code.scoped)
183
+ atuoenum(code.scoped);
176
184
  return code;
177
185
  }
178
186
  exports.createRefId = createRefId;
@@ -11,7 +11,9 @@ t("var a=1;console.log(a)", "var a = 1; console.log(1)");
11
11
  t("a.b = 2;console.log(a.b)", "a.b = 2; console.log(2)");
12
12
  t("a/*a*/.b = 2;console.log(a.b)", "a/*a*/.b = 2; console.log(2)");
13
13
  t("a.b = 2;console.log(a/*aaaa*/.b)", "a.b = 2; console.log(2)");
14
- t("a.b = 2;console.log(/*bbbb*/a.b)", "a.b = 2; console.log(/*bbbb*/2)");
14
+ t("a.b = 2;console.log(/*bbbb*/a.b)", "a.b = 2; console.log(/*bbbb*/ 2)");
15
15
  t("var {a=1};console.log(a)", "var { a = 1 }; console.log(a)");
16
16
  t("if(c) a=1;console.log(a)", "if (c) a = 1; console.log(a)");
17
+ t("console.log(a);a=1;", "console.log(a); a = 1;");
18
+ t("console.log(a);var a=1;", "console.log(a); var a = 1;");
17
19
  // t(fs.readFileSync(path.join(__dirname,"../zimoli/spacechar_test.js")).toString())
@@ -0,0 +1,23 @@
1
+ var { VALUE, QUOTED, EXPRESS, STRAP, relink } = require("./common");
2
+ var cloneNode = function (o) {
3
+ var c = o;
4
+ if (c instanceof Array && !c.text) {
5
+ c = c.map(cloneNode);
6
+ c.entry = o.entry;
7
+ c.leave = o.leave;
8
+ c.type = o.type;
9
+ c.isExpress = o.isExpress;
10
+ relink(c);
11
+ }
12
+ else if (typeof c === 'object' && c instanceof Object) {
13
+ c = Object.assign({}, c);
14
+ }
15
+ else switch (typeof c) {
16
+ case "number": case "bigint": c = { type: VALUE, isdigit: !Number.isNaN(c), text: String(c) }; break;
17
+ case "boolean": case "undefined": c = { type: VALUE, text: String(c) }; break;
18
+ case "regexp": c = { type: QUOTED, text: String(c) }; break;
19
+ case "string": c = scanner2(c); break;
20
+ default: if (c === null) c = { type: VALUE, text: String(c) };
21
+ }
22
+ return c;
23
+ };
@@ -1099,7 +1099,7 @@ var createString = function (parsed) {
1099
1099
  result.push(o.leave);
1100
1100
  break;
1101
1101
  default:
1102
- if (o instanceof Object) {
1102
+ if (o && typeof o === "object") {
1103
1103
  if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
1104
1104
  else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
1105
1105
  result.push(" ");
@@ -1229,6 +1229,11 @@ var splice = function (queue, index, size, ...args) {
1229
1229
  setqueue(args, queue);
1230
1230
  return res;
1231
1231
  };
1232
+ var remove = function (o) {
1233
+ var q = o.queue;
1234
+ var i = q.indexOf(o);
1235
+ if (i >= 0) splice(q, i, 1);
1236
+ };
1232
1237
  var replace = function (o, ...args) {
1233
1238
  var queue = o.queue;
1234
1239
  var i = queue.indexOf(o);
@@ -1280,6 +1285,7 @@ module.exports = {
1280
1285
  equal_reg,
1281
1286
  skipAssignment,
1282
1287
  getDeclared,
1288
+ remove,
1283
1289
  createString,
1284
1290
  createScoped,
1285
1291
  createExpressList,
@@ -0,0 +1,33 @@
1
+ var { SCOPED, EXPRESS, replace } = require("./common");
2
+
3
+ var patchObject = function (code, objs) {
4
+ var rest = [code];
5
+ var m = null;
6
+ while (rest.length) {
7
+ var code = rest.pop();
8
+ for (var c of code) {
9
+ if (c.type === SCOPED) {
10
+ rest.push(c);
11
+ continue;
12
+ }
13
+ if (c.type === EXPRESS) {
14
+ if (m = /^#\\(\d+)$/.exec(c.text)) {
15
+ var o = cloneNode(objs[+m[1]]);
16
+ if (o instanceof Array) replace(c, ...o);
17
+ else replace(c, o);
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ function rescan(strs, ...args) {
24
+ var dist = [];
25
+ var i = 0;
26
+ for (var s of strs) {
27
+ dist.push(s, '#\\' + i++);
28
+ }
29
+ if (i > args.length) dist.pop();
30
+ dist = scanner2(dist.join(' '));
31
+ patchObject(dist, args);
32
+ return dist;
33
+ }
@@ -0,0 +1,3 @@
1
+ var o = { name: 'o', text: 'replaced', abcd: 2023 };
2
+ var a = rescan`1${1}${2}${o}`;
3
+ console.log(a)
@@ -208,7 +208,7 @@ function scan(text, type = "js", lastIndex = 0) {
208
208
  program.Code = Code;
209
209
  program.lastIndex = lastIndex;
210
210
  var res = program.exec(text);
211
- res.program = program;
211
+ Object.defineProperty(res, "program", { value: program, enumerable: false })
212
212
  return res;
213
213
  }
214
214
 
@@ -1,12 +1,14 @@
1
1
  var { SPACE, COMMENT, EXPRESS, STRAP, QUOTED, STAMP, SCOPED, VALUE, LABEL, canbeTemp: _canbeTemp, isEval, createString, skipAssignment, skipSentenceQueue, isHalfSentence, splice, relink, createExpressList, snapExpressHead, snapExpressFoot } = require("./common");
2
2
  var scanner2 = require("./scanner2");
3
- var RE = { type: STRAP, text: "@re" };// if (_) return
4
- var RZ = { type: STRAP, text: "@rz" };// if (!_) return
5
- var RD = { type: STRAP, text: "@rd" };// if (_) return
6
- var RETURN = { type: STRAP, text: "@ret" };// return;
7
- var THROW = { type: STRAP, text: "@throw" };// return;
8
- var YIELD = { type: STRAP, text: "@yield" };// return;
9
- var NEXT = { type: STRAP, text: "@next" };// return;
3
+ var returnText = function () { return this.text };
4
+ var NodeNotClone = o => Object.assign(Object.create(null), o, { toString: returnText });
5
+ var RE = NodeNotClone({ type: STRAP, text: "@re" });// if (_) return
6
+ var RZ = NodeNotClone({ type: STRAP, text: "@rz" });// if (!_) return
7
+ var RD = NodeNotClone({ type: STRAP, text: "@rd" });// if (_) return
8
+ var RETURN = NodeNotClone({ type: STRAP, text: "@ret" });// return;
9
+ var THROW = NodeNotClone({ type: STRAP, text: "@throw" });// return;
10
+ var YIELD = NodeNotClone({ type: STRAP, text: "@yield" });// return;
11
+ var NEXT = NodeNotClone({ type: STRAP, text: "@next" });// return;
10
12
  var mount_break = function (body, cx, b1s, iscontinue) {
11
13
  var label;
12
14
  do {
@@ -77,7 +79,7 @@ var _try = function (body, cx, unblock, result, getname) {
77
79
  if (o.type === SCOPED && o.entry === "(") {
78
80
  var e = o.first;
79
81
  if (e) {
80
- arg = scanner2(`${e.text}=${ret_ || "@"};`);
82
+ arg = rescan`${e}=${ret_ || "@"};`;
81
83
  }
82
84
  o = o.next;
83
85
  }
@@ -117,18 +119,28 @@ var _with = function (body, cx, unblock, result, getname) {
117
119
  evals.pop();
118
120
  return cx;
119
121
  };
122
+ var _evals = function () {
123
+ var a = [];
124
+ if (evals.length) {
125
+ a.push(...evals[0]);
126
+ for (var cx = 1, dx = evals.length; cx < dx; cx++) {
127
+ a.push({ type: STAMP, text: ',' }, ...evals[cx]);
128
+ }
129
+ }
130
+ return a;
131
+ }
120
132
  var _withget = function (text) {
121
133
  var index = text.indexOf('.');
122
134
  if (index < 0) index = text.length;
123
135
  var name = text.slice(0, index);
124
136
  var prop = text.slice(index);
125
- return `withget_("${name}",[${evals.join(',')}],${name})${prop}`;
137
+ return rescan`withget_(${`"${name}"`},[${_evals()}],${name})${prop}`;
126
138
  };
127
139
  var _withset = function (text, tmpname, valname) {
128
140
  var index = text.indexOf(".");
129
141
  if (index < 0) index = text.length;
130
142
  var name = text.slice(0, index);
131
- return `if(${tmpname}=with_("${name}",[${evals.join(",")}]))${tmpname}.${text}=${valname};else ${text}=${valname};`;
143
+ return rescan`if(${tmpname}=with_(${`"${name}"`},[${_evals()}]))${tmpname}.${text}=${valname};else ${text}=${valname};`;
132
144
  };
133
145
  var _switch = function (body, cx, unblock, result, getname) {
134
146
  var o = body[cx];
@@ -159,7 +171,7 @@ var _switch = function (body, cx, unblock, result, getname) {
159
171
  var q = ternary(block, getnextname, true);
160
172
  for (var q of q) if (q.length) pushstep(result, q);
161
173
  var qe = q;
162
- if (qe.name) case_ = scanner2(`if(${qn}===${qe.name})return[]`), pushstep(result, case_);
174
+ if (qe.name) case_ = rescan`if(${qn}===${qe.name})return[]`, pushstep(result, case_);
163
175
  else default_ = case_ = scanner2(`return[]`), default_.ret_ = -2;
164
176
  var by = cy;
165
177
  m = o[cy];
@@ -248,7 +260,7 @@ var _for = function (body, cx, unblock, result) {
248
260
  var t = unblock(block1);
249
261
  if (t) {
250
262
  t = t && !t.await_ ? t.name : ret_;
251
- var b = scanner2(`if(!${t})return []`);
263
+ var b = rescan`if(!${t})return []`;
252
264
  var be = b[b.length - 1];
253
265
  pushstep(result, b);
254
266
  }
@@ -281,13 +293,13 @@ var getCondition = function (o, unblock, not_) {
281
293
  if (not_) not = !not;
282
294
  if (f && f === o.last) {
283
295
  if (f.type & (EXPRESS | VALUE)) {
284
- n = f.text;
296
+ n = cloneNode(f);
285
297
  }
286
298
  if (not && n) {
287
299
  if (f.type === VALUE) {
288
300
  n = String(eval("!" + f.text));
289
301
  }
290
- else n = "!" + n;
302
+ else n = rescan`!${n}`;
291
303
  }
292
304
  }
293
305
  if (!n) {
@@ -299,9 +311,9 @@ var getCondition = function (o, unblock, not_) {
299
311
  n = ret_;
300
312
  }
301
313
  else n = n.name;
302
- if (not) n = "!" + n;
314
+ if (not) n = rescan`!${n}`;
303
315
  }
304
- return n;
316
+ return cloneNode(n);
305
317
  }
306
318
  var _while = function (body, cx, unblock, result) {
307
319
  var o = body[cx];
@@ -310,7 +322,7 @@ var _while = function (body, cx, unblock, result) {
310
322
  o = o.next;
311
323
  while (body[cx] !== o) cx++;
312
324
  var i = result.length;
313
- var b = scanner2(`if(${getCondition(o, unblock, true)})return []`);
325
+ var b = rescan`if (${getCondition(o, unblock, true)}) return []`;
314
326
  var be = b[b.length - 1];
315
327
  pushstep(result, b);
316
328
  relink(result[result.length - 1]);
@@ -321,7 +333,7 @@ var _while = function (body, cx, unblock, result) {
321
333
  var we = wend[wend.length - 1];
322
334
  pushstep(result, wend);
323
335
  we[0].text = String(1 + i - result.length);
324
- be.push(...scanner2(`${result.length - i},0`));
336
+ be.push(...scanner2(`${result.length - i}, 0`));
325
337
  return cx;
326
338
  };
327
339
  var pushstep = function (result, step) {
@@ -334,7 +346,7 @@ var pushstep = function (result, step) {
334
346
  }
335
347
  else if (q.await_) {
336
348
  if (!step.awaited) {
337
- step.unshift(...scanner2(`${q.name}=${ret_};`)), relink(step);
349
+ step.unshift(...rescan`${q.name}=${ret_};`), relink(step);
338
350
  step.awaited = true;
339
351
  }
340
352
  result.push(step);
@@ -372,23 +384,23 @@ var patchstep = function (r, nextindex, h) {
372
384
  o = r[i];
373
385
  if (o.set) {
374
386
  var [m, _, b] = r.splice(i, 3);
375
- r.splice(i, 0, ...scanner2(_withset(m.text, m.set, b.text)));
387
+ r.splice(i, 0, ..._withset(m.text, m.set, b.text));
376
388
  }
377
389
  else if (o.get) {
378
- r.splice(i, 1, ...scanner2(_withget(b.text)));
390
+ r.splice(i, 1, ..._withget(b.text));
379
391
  }
380
392
  }
381
393
  var changed = false;
382
394
  for (i = r.length - 1; i >= h; i--) {
383
395
  o = r[i];
384
396
  if (o === RZ) {
385
- x = scanner2(`if(!${name})return [${nextindex},0]`);
397
+ x = rescan`if (!${name}) return [${nextindex}, 0]`;
386
398
  }
387
399
  else if (o === RE) {
388
- x = scanner2(`if(${name})return [${nextindex},0]`);
400
+ x = rescan`if (${name}) return [${nextindex}, 0]`;
389
401
  }
390
402
  else if (o === RD) {
391
- x = scanner2(`if(${name}!==null&&${name}!== undefined)return [${nextindex},0]`);
403
+ x = rescan`if (${name}!== null && ${name}!== undefined) return [${nextindex}, 0]`;
392
404
  }
393
405
  else continue;
394
406
  changed = true;
@@ -418,13 +430,13 @@ var _do = function (body, cx, unblock, result) {
418
430
  o = o.next.next;
419
431
 
420
432
  if (label.continue) ifpatch(result), label.contat = result.length;
421
- var b = scanner2(`if(${getCondition(o, unblock)})return [${i - result.length},0]`);
433
+ var b = rescan`if (${getCondition(o, unblock)}) return [${i - result.length}, 0]`;
422
434
  pushstep(result, b);
423
435
  while (body[cx] !== o) cx++;
424
436
  return cx + 1;
425
437
  };
426
438
  var stepReturn = function (value, type, q) {
427
- var r = scanner2(`return [${value},${type}]`);
439
+ var r = rescan`return [${value}, ${type}]`;
428
440
  r.ret_ = type === 2 ? type : true;
429
441
  if (q && q.length) r.name = q[q.length - 1].name;
430
442
  return r;
@@ -436,9 +448,9 @@ var isretn = function (o) {
436
448
  return o === RETURN || o === NEXT || o === YIELD || o === THROW;
437
449
  }
438
450
  var _return = function (r) {
439
- var name = r.name;
440
451
  var e = r[r.length - 1];
441
452
  if (!isretn(e)) return;
453
+ var name = r.name;
442
454
  r.pop();
443
455
  r.ret_ = !ishalf(r);
444
456
  var x;
@@ -446,7 +458,7 @@ var _return = function (r) {
446
458
  x = stepReturn(name, 2);
447
459
  }
448
460
  else if (e === THROW) {
449
- x = scanner2(`throw ${name}`);
461
+ x = rescan`throw ${name}`;
450
462
  }
451
463
  else if (e === YIELD) {
452
464
  x = stepReturn(name, 3);
@@ -511,7 +523,7 @@ var _invoke = function (t, getname) {
511
523
  }
512
524
  if (needbreak(o)) {
513
525
  var s = splice(t, bx, cx + 1 - bx);
514
- if (cx > 0) s.name = s[0].text;
526
+ if (cx > 0) s.name = [cloneNode(s[0])];
515
527
  else s.name = qname;
516
528
  queue.push(s);
517
529
  cx = bx - 1;
@@ -551,7 +563,7 @@ var _invoke = function (t, getname) {
551
563
  if (!iseval || m[m.length - 1] === o.last) {
552
564
  var q = toqueue(m, getdeepname, 1);
553
565
  var qe = q[q.length - 1];
554
- splice(o, by, ey - by, ...qe ? scanner2(qe.name) : []);
566
+ splice(o, by, ey - by, ...qe ? cloneNode(qe.name) : []);
555
567
  cy = by + 1;
556
568
  }
557
569
  else {
@@ -579,7 +591,7 @@ var _invoke = function (t, getname) {
579
591
  var fs = splice(t, hx, cx + 1 - hx, { type: EXPRESS, text: getname(nameindex) });
580
592
  fs.unshift(...scanner2(`${getname(nameindex)}=`));
581
593
  relink(fs);
582
- fs.name = getname(nameindex);
594
+ fs.name = [{ text: getname(nameindex), type: EXPRESS }];
583
595
  pushstep(result, fs);
584
596
  cx = hx - 1;
585
597
  }
@@ -638,12 +650,9 @@ var patchname = function (d, getname) {
638
650
  var de = d[d.length - 1];
639
651
  if (de && !de.name) {
640
652
  splice(de, 0, 0, { type: EXPRESS, text: getname(0) }, { type: STAMP, text: "=" });
641
- de.name = getname(0);
653
+ de.name = [{ text: getname(0), type: EXPRESS }];
642
654
  }
643
655
  };
644
- var clone = function (o) {
645
- return Object.assign(o instanceof Array ? [] : {}, o, { prev: null, next: null });
646
- };
647
656
  var popass = function (explist) {
648
657
  var asn = explist.pop();
649
658
  var n;
@@ -660,7 +669,7 @@ var popass = function (explist) {
660
669
  }
661
670
  else {
662
671
  n = asn && asn.name;
663
- asn = [{ type: EXPRESS, text: n }];
672
+ asn = n;
664
673
  }
665
674
  return [asn, n];
666
675
  }
@@ -683,7 +692,7 @@ var popexp = function (explist) {
683
692
  }
684
693
  else {
685
694
  n = asn.name;
686
- asn = scanner2(n);
695
+ asn = cloneNode(n);
687
696
  }
688
697
  return [asn, n];
689
698
  }
@@ -726,11 +735,12 @@ var ternary = function (body, getname, ret) {
726
735
  }
727
736
  pushstep(d, stepReturn(1, 0, d));
728
737
  pushstep(c, stepReturn(d.length + 1, 0, c));
729
- pushstep(explist, scanner2(`if(${getCondition(b, function (b) {
738
+ pushstep(explist, rescan`if (${getCondition(b, function (b) {
730
739
  b = ternary(b, getnextname, true);
731
740
  for (var b of b) pushstep(explist, b);
732
741
  return b;
733
- }, true)})return [1,0]`));
742
+ }, true)
743
+ }) return [1, 0]`);
734
744
  var q = explist[explist.length - 1];
735
745
  var qi = explist.length - 1;
736
746
  var qe = q[q.length - 1];
@@ -752,7 +762,7 @@ var ternary = function (body, getname, ret) {
752
762
  var ass = toqueue(body.slice(equalsend, cx), getnextname, false);
753
763
  var [ass1, n = ++eqused] = popass(ass);
754
764
  exphead.push(...ass);
755
- equals.push(...ass1, o);
765
+ equals.push(...cloneNode(ass1), o);
756
766
  if (!question.length) equalsend = cx + 1, equcount++;
757
767
  if (o.text.length > 1) hascalcequ = true;
758
768
  }
@@ -779,7 +789,7 @@ var ternary = function (body, getname, ret) {
779
789
  relink(equals);
780
790
  explist.unshift(...exphead);
781
791
  var q = explist[explist.length - 1];
782
- // if (!q) throw `语法错误: <red>${createString(body)}</red> \r\n行列位置: ${equals[0].row}:${equals[0].col}`
792
+ // if (!q) throw `语法错误: <red>${createString(body)}</red> \r\n行列位置: ${ equals[0].row }:${ equals[0].col }`
783
793
  var n = q.name;
784
794
  var i = equals.length - 1;
785
795
  var isSimpleAssign = true;
@@ -800,23 +810,23 @@ var ternary = function (body, getname, ret) {
800
810
  var eq = equals[i];
801
811
  if (isSimpleAssign) isSimpleAssign = ret !== 1 && canbeTemp(ass);
802
812
  if (isSimpleAssign && eq.text === '=') {
803
- [asn, n = createString(ass)] = popexp(explist);
813
+ [asn, n = cloneNode(ass)] = popexp(explist);
804
814
  }
805
- else if (n) var asn = scanner2(n);
815
+ else if (n && !isempty(n, SPACE | COMMENT)) var asn = n;
806
816
  else asn = explist.pop();
807
817
  var an = '';
808
818
  if (eq.text.length > 1) {
809
819
  var punc = eq.text.slice(0, eq.text.length - 1);
810
- var bdtmp = [...ass.map(clone), { type: STAMP, text: punc }, ...asn];
820
+ var bdtmp = [...ass.map(cloneNode), { type: STAMP, text: punc }, ...asn];
811
821
  relink(bdtmp);
812
822
  var explist2 = _express(bdtmp, getnextname, true);
813
823
  if (isSimpleAssign) {
814
- [asn, an = createString(ass)] = popexp(explist2);
824
+ [asn, an = cloneNode(ass)] = popexp(explist2);
815
825
  }
816
826
  else {
817
827
  var q2 = explist2[explist2.length - 1];
818
828
  an = q2.name;
819
- asn = scanner2(an);
829
+ asn = cloneNode(an);
820
830
  }
821
831
  for (var e of explist2) pushstep(explist, e);
822
832
  eq.text = "=";
@@ -825,7 +835,7 @@ var ternary = function (body, getname, ret) {
825
835
  ass.push(equals[i], ...asn);
826
836
  relink(ass);
827
837
  if (evals.length) ass[0].set = getnextname(0);
828
- ass.name = an;
838
+ if (an) ass.name = cloneNode(an);
829
839
  patchstep(ass, ass.length, 0);
830
840
  pushstep(explist, ass);
831
841
  isSimpleAssign = false;
@@ -916,7 +926,7 @@ var canbeOnce = function (body) {
916
926
  var _express = function (body, getname, ret) {
917
927
  if (canbeTemp(body)) {
918
928
  var q = [];
919
- q.name = createString(body);
929
+ q.name = cloneNode(body);
920
930
  return [q];
921
931
  }
922
932
  var result = [];
@@ -980,8 +990,8 @@ var _express = function (body, getname, ret) {
980
990
  else if (iw === 3) q.push(YIELD);
981
991
  }
982
992
  }
983
- var name = getname(nameindex);
984
- q.name = name;
993
+ var name = [{ text: getname(nameindex), type: EXPRESS }];
994
+ q.name = cloneNode(name);
985
995
  if (isor) {
986
996
  if (o.text === '||') {
987
997
  q.push(RE);
@@ -995,7 +1005,7 @@ var _express = function (body, getname, ret) {
995
1005
  hasor = true;
996
1006
  nameindex = 0;
997
1007
  } else {
998
- var n = scanner2(name);
1008
+ var n = cloneNode(name);
999
1009
  n.index = nameindex;
1000
1010
  n.push(pb);
1001
1011
  nameindex++;
@@ -1042,7 +1052,7 @@ var _express = function (body, getname, ret) {
1042
1052
  q.push(...b);
1043
1053
  }
1044
1054
  }
1045
- if (needname) q.name = getname(nameindex);
1055
+ if (needname) q.name = [{ text: getname(nameindex), type: EXPRESS }];
1046
1056
  relink(q);
1047
1057
  if (isFunctionOnly(q, 2)) {
1048
1058
  result = [q];
@@ -1118,7 +1128,7 @@ function toqueue(body, getname, ret = false, result = []) {
1118
1128
  var p = result[findex];
1119
1129
  if (p.ifbrk) {
1120
1130
  p.pop();
1121
- p.push(scanner2(`[${result.length - findex},0]`)[0]);
1131
+ p.push(scanner2(`[${result.length - findex}, 0]`)[0]);
1122
1132
  relink(p);
1123
1133
  }
1124
1134
  }
@@ -1266,10 +1276,10 @@ function toqueue(body, getname, ret = false, result = []) {
1266
1276
  var n = getCondition(o, unblock, !isbr);
1267
1277
  o = o.next;
1268
1278
  if (isbr) {
1269
- var c = scanner2(`if(${n})`);
1279
+ var c = rescan`if (${n})`;
1270
1280
  }
1271
1281
  else {
1272
- var c = scanner2(`if(${n})return [0,0]`);
1282
+ var c = rescan`if (${n}) return [0, 0]`;
1273
1283
  }
1274
1284
  var ce = c[3];
1275
1285
  pushstep(result, c);
@@ -1332,7 +1342,7 @@ function toqueue(body, getname, ret = false, result = []) {
1332
1342
  }
1333
1343
  else {
1334
1344
  var q = b[b.length - 1];
1335
- if (q && !q.length && q.name) pushstep(result, scanner2(q.name));
1345
+ if (q && !q.length && q.name) pushstep(result, cloneNode(q.name));
1336
1346
  }
1337
1347
  retn = false;
1338
1348
  } while (cx < body.length);
@@ -110,7 +110,7 @@ test("throw a", 'throw a', true);
110
110
  test("throw a,b", 'a; throw b', true);
111
111
  test("return a,b", 'a; return [b, 2]', true);
112
112
  test("return a\r\n", 'return [a, 2]', true);
113
- test("return a\r\n+b/*c*/;", '_ = a\r\n+ b; /*c*/ return [_, 2]', true);
113
+ test("return a\r\n+b/*c*/;", '_ = a\r\n+ b/*c*/; return [_, 2]', true);
114
114
  test("debugger", 'debugger', true);
115
115
  test("a(b,b+=1)", '_ = b; _0 = b + 1; b = _0; a(_, _0)', true);
116
116
  test("while(a){if(b){if(c);else d;continue;}}", 'if (!a) return [4, 0]; if (!b) return [3, 0]; if (!c) return [1, 0]; return [2, 0];\r\n d; return [1, 0];\r\n return [-2, 0];\r\n return [-3, 0]', true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.50",
3
+ "version": "4.0.51",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {