efront 4.0.48 → 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.
@@ -438,3 +438,4 @@ function olinde(v, vector) {
438
438
  }
439
439
  return v;
440
440
  }
441
+ Matrix.norm = norm;
@@ -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,6 +1,7 @@
1
1
  var d = 0b10000000, s = 0b00111111;
2
+ var keep0 = true;
2
3
  function numberUTF8(t, dist = []) {
3
- if (t < 128) {//0b0xxxxxxx - 0b10xxxxxx
4
+ if (t < 128 && (keep0 || t > 0)) {//0b0xxxxxxx - 0b10xxxxxx
4
5
  dist.push(0b00000000 | t)
5
6
  }
6
7
  else if (t < 2048) {// 0b110xxxxx 10xxxxxx
@@ -43,11 +44,11 @@ function numberUTF8(t, dist = []) {
43
44
  }
44
45
  return dist;
45
46
  }
46
- function encodeUTF8(string) {
47
+ function encodeUTF8(string, encode0) {
48
+ keep0 = !encode0;
47
49
  var dist = [], t;
48
50
  for (var cx = 0, dx = string.length; cx < dx; cx++) {
49
- t = string.codePointAt(cx);
50
- if (t > 0xffff) cx++;
51
+ t = string.charCodeAt(cx);
51
52
  numberUTF8(t, dist);
52
53
  }
53
54
  return dist;
@@ -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;
@@ -507,7 +507,21 @@ function detour(o, ie) {
507
507
  if (o) o = o.next;
508
508
  }
509
509
  };
510
-
510
+ var _splice_keepspace = function (a, i) {
511
+ var res = splice.apply(null, arguments);
512
+ if (res.length) {
513
+ var start = res[0].prev;
514
+ var end = res[res.length - 1].next;
515
+ if (!start) start = 0;
516
+ else start = start.row;
517
+ if (end) end = end.row;
518
+ var delta = end - start;
519
+ if (delta > 0) {
520
+ splice(a, i, 0, { type: SPACE, text: Array(delta + 1).join('\r\n') });
521
+ }
522
+ }
523
+ return res;
524
+ }
511
525
  var removeImport = function (c, i, code) {
512
526
  var next = c.next;
513
527
  var { used, envs, vars } = code;
@@ -591,7 +605,7 @@ var removeImport = function (c, i, code) {
591
605
  });
592
606
  });
593
607
  var u = { type: EXPRESS, text: name };
594
- code.splice(i + 1, oi - i - 1, u);
608
+ _splice_keepspace(code, i + 1, oi - i - 1, u);
595
609
  used[name].push(u);
596
610
  return u;
597
611
  };
@@ -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);
@@ -343,6 +355,10 @@ var pushstep = function (result, step) {
343
355
  if (q.await__) step.awaited = true;
344
356
  result.push(step);
345
357
  }
358
+ else if (isempty(step, COMMENT)) {
359
+ q.push(...step);
360
+ step = q;
361
+ }
346
362
  else {
347
363
  if (needcomma(q)) q.push({ type: STAMP, text: ';' });
348
364
  if (!ishalf(q)) {
@@ -368,23 +384,23 @@ var patchstep = function (r, nextindex, h) {
368
384
  o = r[i];
369
385
  if (o.set) {
370
386
  var [m, _, b] = r.splice(i, 3);
371
- r.splice(i, 0, ...scanner2(_withset(m.text, m.set, b.text)));
387
+ r.splice(i, 0, ..._withset(m.text, m.set, b.text));
372
388
  }
373
389
  else if (o.get) {
374
- r.splice(i, 1, ...scanner2(_withget(b.text)));
390
+ r.splice(i, 1, ..._withget(b.text));
375
391
  }
376
392
  }
377
393
  var changed = false;
378
394
  for (i = r.length - 1; i >= h; i--) {
379
395
  o = r[i];
380
396
  if (o === RZ) {
381
- x = scanner2(`if(!${name})return [${nextindex},0]`);
397
+ x = rescan`if (!${name}) return [${nextindex}, 0]`;
382
398
  }
383
399
  else if (o === RE) {
384
- x = scanner2(`if(${name})return [${nextindex},0]`);
400
+ x = rescan`if (${name}) return [${nextindex}, 0]`;
385
401
  }
386
402
  else if (o === RD) {
387
- x = scanner2(`if(${name}!==null&&${name}!== undefined)return [${nextindex},0]`);
403
+ x = rescan`if (${name}!== null && ${name}!== undefined) return [${nextindex}, 0]`;
388
404
  }
389
405
  else continue;
390
406
  changed = true;
@@ -414,13 +430,13 @@ var _do = function (body, cx, unblock, result) {
414
430
  o = o.next.next;
415
431
 
416
432
  if (label.continue) ifpatch(result), label.contat = result.length;
417
- 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]`;
418
434
  pushstep(result, b);
419
435
  while (body[cx] !== o) cx++;
420
436
  return cx + 1;
421
437
  };
422
438
  var stepReturn = function (value, type, q) {
423
- var r = scanner2(`return [${value},${type}]`);
439
+ var r = rescan`return [${value}, ${type}]`;
424
440
  r.ret_ = type === 2 ? type : true;
425
441
  if (q && q.length) r.name = q[q.length - 1].name;
426
442
  return r;
@@ -432,9 +448,9 @@ var isretn = function (o) {
432
448
  return o === RETURN || o === NEXT || o === YIELD || o === THROW;
433
449
  }
434
450
  var _return = function (r) {
435
- var name = r.name;
436
451
  var e = r[r.length - 1];
437
452
  if (!isretn(e)) return;
453
+ var name = r.name;
438
454
  r.pop();
439
455
  r.ret_ = !ishalf(r);
440
456
  var x;
@@ -442,7 +458,7 @@ var _return = function (r) {
442
458
  x = stepReturn(name, 2);
443
459
  }
444
460
  else if (e === THROW) {
445
- x = scanner2(`throw ${name}`);
461
+ x = rescan`throw ${name}`;
446
462
  }
447
463
  else if (e === YIELD) {
448
464
  x = stepReturn(name, 3);
@@ -507,7 +523,7 @@ var _invoke = function (t, getname) {
507
523
  }
508
524
  if (needbreak(o)) {
509
525
  var s = splice(t, bx, cx + 1 - bx);
510
- if (cx > 0) s.name = s[0].text;
526
+ if (cx > 0) s.name = [cloneNode(s[0])];
511
527
  else s.name = qname;
512
528
  queue.push(s);
513
529
  cx = bx - 1;
@@ -547,7 +563,7 @@ var _invoke = function (t, getname) {
547
563
  if (!iseval || m[m.length - 1] === o.last) {
548
564
  var q = toqueue(m, getdeepname, 1);
549
565
  var qe = q[q.length - 1];
550
- splice(o, by, ey - by, ...qe ? scanner2(qe.name) : []);
566
+ splice(o, by, ey - by, ...qe ? cloneNode(qe.name) : []);
551
567
  cy = by + 1;
552
568
  }
553
569
  else {
@@ -575,7 +591,7 @@ var _invoke = function (t, getname) {
575
591
  var fs = splice(t, hx, cx + 1 - hx, { type: EXPRESS, text: getname(nameindex) });
576
592
  fs.unshift(...scanner2(`${getname(nameindex)}=`));
577
593
  relink(fs);
578
- fs.name = getname(nameindex);
594
+ fs.name = [{ text: getname(nameindex), type: EXPRESS }];
579
595
  pushstep(result, fs);
580
596
  cx = hx - 1;
581
597
  }
@@ -634,12 +650,9 @@ var patchname = function (d, getname) {
634
650
  var de = d[d.length - 1];
635
651
  if (de && !de.name) {
636
652
  splice(de, 0, 0, { type: EXPRESS, text: getname(0) }, { type: STAMP, text: "=" });
637
- de.name = getname(0);
653
+ de.name = [{ text: getname(0), type: EXPRESS }];
638
654
  }
639
655
  };
640
- var clone = function (o) {
641
- return Object.assign(o instanceof Array ? [] : {}, o, { prev: null, next: null });
642
- };
643
656
  var popass = function (explist) {
644
657
  var asn = explist.pop();
645
658
  var n;
@@ -656,7 +669,7 @@ var popass = function (explist) {
656
669
  }
657
670
  else {
658
671
  n = asn && asn.name;
659
- asn = [{ type: EXPRESS, text: n }];
672
+ asn = n;
660
673
  }
661
674
  return [asn, n];
662
675
  }
@@ -679,7 +692,7 @@ var popexp = function (explist) {
679
692
  }
680
693
  else {
681
694
  n = asn.name;
682
- asn = scanner2(n);
695
+ asn = cloneNode(n);
683
696
  }
684
697
  return [asn, n];
685
698
  }
@@ -722,11 +735,12 @@ var ternary = function (body, getname, ret) {
722
735
  }
723
736
  pushstep(d, stepReturn(1, 0, d));
724
737
  pushstep(c, stepReturn(d.length + 1, 0, c));
725
- pushstep(explist, scanner2(`if(${getCondition(b, function (b) {
738
+ pushstep(explist, rescan`if (${getCondition(b, function (b) {
726
739
  b = ternary(b, getnextname, true);
727
740
  for (var b of b) pushstep(explist, b);
728
741
  return b;
729
- }, true)})return [1,0]`));
742
+ }, true)
743
+ }) return [1, 0]`);
730
744
  var q = explist[explist.length - 1];
731
745
  var qi = explist.length - 1;
732
746
  var qe = q[q.length - 1];
@@ -748,7 +762,7 @@ var ternary = function (body, getname, ret) {
748
762
  var ass = toqueue(body.slice(equalsend, cx), getnextname, false);
749
763
  var [ass1, n = ++eqused] = popass(ass);
750
764
  exphead.push(...ass);
751
- equals.push(...ass1, o);
765
+ equals.push(...cloneNode(ass1), o);
752
766
  if (!question.length) equalsend = cx + 1, equcount++;
753
767
  if (o.text.length > 1) hascalcequ = true;
754
768
  }
@@ -775,7 +789,7 @@ var ternary = function (body, getname, ret) {
775
789
  relink(equals);
776
790
  explist.unshift(...exphead);
777
791
  var q = explist[explist.length - 1];
778
- // 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 }`
779
793
  var n = q.name;
780
794
  var i = equals.length - 1;
781
795
  var isSimpleAssign = true;
@@ -796,23 +810,23 @@ var ternary = function (body, getname, ret) {
796
810
  var eq = equals[i];
797
811
  if (isSimpleAssign) isSimpleAssign = ret !== 1 && canbeTemp(ass);
798
812
  if (isSimpleAssign && eq.text === '=') {
799
- [asn, n = createString(ass)] = popexp(explist);
813
+ [asn, n = cloneNode(ass)] = popexp(explist);
800
814
  }
801
- else if (n) var asn = scanner2(n);
815
+ else if (n && !isempty(n, SPACE | COMMENT)) var asn = n;
802
816
  else asn = explist.pop();
803
817
  var an = '';
804
818
  if (eq.text.length > 1) {
805
819
  var punc = eq.text.slice(0, eq.text.length - 1);
806
- var bdtmp = [...ass.map(clone), { type: STAMP, text: punc }, ...asn];
820
+ var bdtmp = [...ass.map(cloneNode), { type: STAMP, text: punc }, ...asn];
807
821
  relink(bdtmp);
808
822
  var explist2 = _express(bdtmp, getnextname, true);
809
823
  if (isSimpleAssign) {
810
- [asn, an = createString(ass)] = popexp(explist2);
824
+ [asn, an = cloneNode(ass)] = popexp(explist2);
811
825
  }
812
826
  else {
813
827
  var q2 = explist2[explist2.length - 1];
814
828
  an = q2.name;
815
- asn = scanner2(an);
829
+ asn = cloneNode(an);
816
830
  }
817
831
  for (var e of explist2) pushstep(explist, e);
818
832
  eq.text = "=";
@@ -821,7 +835,7 @@ var ternary = function (body, getname, ret) {
821
835
  ass.push(equals[i], ...asn);
822
836
  relink(ass);
823
837
  if (evals.length) ass[0].set = getnextname(0);
824
- ass.name = an;
838
+ if (an) ass.name = cloneNode(an);
825
839
  patchstep(ass, ass.length, 0);
826
840
  pushstep(explist, ass);
827
841
  isSimpleAssign = false;
@@ -912,7 +926,7 @@ var canbeOnce = function (body) {
912
926
  var _express = function (body, getname, ret) {
913
927
  if (canbeTemp(body)) {
914
928
  var q = [];
915
- q.name = createString(body);
929
+ q.name = cloneNode(body);
916
930
  return [q];
917
931
  }
918
932
  var result = [];
@@ -976,8 +990,8 @@ var _express = function (body, getname, ret) {
976
990
  else if (iw === 3) q.push(YIELD);
977
991
  }
978
992
  }
979
- var name = getname(nameindex);
980
- q.name = name;
993
+ var name = [{ text: getname(nameindex), type: EXPRESS }];
994
+ q.name = cloneNode(name);
981
995
  if (isor) {
982
996
  if (o.text === '||') {
983
997
  q.push(RE);
@@ -991,7 +1005,7 @@ var _express = function (body, getname, ret) {
991
1005
  hasor = true;
992
1006
  nameindex = 0;
993
1007
  } else {
994
- var n = scanner2(name);
1008
+ var n = cloneNode(name);
995
1009
  n.index = nameindex;
996
1010
  n.push(pb);
997
1011
  nameindex++;
@@ -1038,7 +1052,7 @@ var _express = function (body, getname, ret) {
1038
1052
  q.push(...b);
1039
1053
  }
1040
1054
  }
1041
- if (needname) q.name = getname(nameindex);
1055
+ if (needname) q.name = [{ text: getname(nameindex), type: EXPRESS }];
1042
1056
  relink(q);
1043
1057
  if (isFunctionOnly(q, 2)) {
1044
1058
  result = [q];
@@ -1114,7 +1128,7 @@ function toqueue(body, getname, ret = false, result = []) {
1114
1128
  var p = result[findex];
1115
1129
  if (p.ifbrk) {
1116
1130
  p.pop();
1117
- p.push(scanner2(`[${result.length - findex},0]`)[0]);
1131
+ p.push(scanner2(`[${result.length - findex}, 0]`)[0]);
1118
1132
  relink(p);
1119
1133
  }
1120
1134
  }
@@ -1262,10 +1276,10 @@ function toqueue(body, getname, ret = false, result = []) {
1262
1276
  var n = getCondition(o, unblock, !isbr);
1263
1277
  o = o.next;
1264
1278
  if (isbr) {
1265
- var c = scanner2(`if(${n})`);
1279
+ var c = rescan`if (${n})`;
1266
1280
  }
1267
1281
  else {
1268
- var c = scanner2(`if(${n})return [0,0]`);
1282
+ var c = rescan`if (${n}) return [0, 0]`;
1269
1283
  }
1270
1284
  var ce = c[3];
1271
1285
  pushstep(result, c);
@@ -1328,7 +1342,7 @@ function toqueue(body, getname, ret = false, result = []) {
1328
1342
  }
1329
1343
  else {
1330
1344
  var q = b[b.length - 1];
1331
- if (q && !q.length && q.name) pushstep(result, scanner2(q.name));
1345
+ if (q && !q.length && q.name) pushstep(result, cloneNode(q.name));
1332
1346
  }
1333
1347
  retn = false;
1334
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);