efront 4.0.41 → 4.0.48

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,6 +1,6 @@
1
1
  var fields = refilm`
2
- 路径/path html
3
- 访问量/count
2
+ 访问量/count money/10
3
+ 路径/path html/20
4
4
  `;
5
5
  function main() {
6
6
  var page = div();
@@ -56,6 +56,7 @@ class Table extends Array {
56
56
  var searchtext = this.searchText;
57
57
  var fields = this.searchFields ? this.searchFields : this.fields;
58
58
  var power = 0;
59
+ var s = o;
59
60
  if (isNode(o)) {
60
61
  o = extend({
61
62
  name: o.name,
@@ -68,6 +69,7 @@ class Table extends Array {
68
69
  }, o);
69
70
  }
70
71
  else o = isObject(o) ? Object.create(o) : new o.constructor(o);
72
+ o.$origin = s;
71
73
  for (var f of fields) {
72
74
  var name = seek(o, f.key);
73
75
  if (isEmpty(name) || !isString(name)) continue;
@@ -90,13 +92,24 @@ class Table extends Array {
90
92
  this.update();
91
93
  }
92
94
  async update() {
95
+ var origin = this.splice(0, this.length)
96
+ if (this.searched && this.source && this.searched !== this.source.length) {
97
+ origin = origin.map(o => o.$origin);
98
+ }
99
+ else {
100
+ origin = [];
101
+ }
93
102
  this.searched = 0;
94
- this.splice(0, this.length);
95
103
  var source = this.sorted ? this.sorted : this.source;
96
104
  if (!source) return;
97
105
  var searchid = ++this.searchid;
98
106
  this.complete = false;
99
107
  this.coverCount = 0;
108
+ if (origin.length) {
109
+ if (origin.length >= 160) origin = origin.slice(0, 80);
110
+ source = source.filter(a => origin.indexOf(a) < 0);
111
+ source = origin.concat(source);
112
+ }
100
113
  if (this.searchText) for (var o of source) {
101
114
  this.addItem(o);
102
115
  if (++this.searched % 600 === 0) {
@@ -1,5 +1,6 @@
1
1
  var require = window.require;
2
2
  var fs, path;
3
+ var document = window.document;
3
4
  function test(url) {
4
5
  var data = fs.readFileSync(url);
5
6
  data = String(data);
@@ -39,7 +40,7 @@ function analyse_test(text) {
39
40
  fs = require("fs");
40
41
  path = require("path");
41
42
  if (text) return analyse(text);
42
- testxml("/book/金山打字");
43
+ if (document) testxml("/book/金山打字");
43
44
  // testcode("/work/efront/coms/basic");
44
45
 
45
46
  testblog("炒面.txt");
@@ -0,0 +1,8 @@
1
+ function sliceEqual(a, b) {
2
+ if (a === b) return true;
3
+ if (a.length !== b.length) return false;
4
+ for (var cx = 0, dx = a.length; cx < dx; cx++) {
5
+ if (!isSame(a[cx], b[cx])) return false;
6
+ }
7
+ return true;
8
+ }
@@ -6,10 +6,8 @@ function concatTypedArray(buffs) {
6
6
  while (offset < total) {
7
7
  var b = buffs[inc++];
8
8
  if (b.buffer) b = new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
9
- for (var cx = 0, dx = b.length; cx < dx; cx++) {
10
- res[offset + cx] = b[cx];
11
- }
12
- offset += dx;
9
+ res.set(b, offset);
10
+ offset += b.length;
13
11
  }
14
12
  return res;
15
13
  }
@@ -53,23 +53,6 @@ var objectEqual = function (o1, o2, deep) {
53
53
  }
54
54
  return true;
55
55
  };
56
- function shallowEqual(o1, o2) {
57
- // 浅层比对,对内层对象不进行递归比对
58
- if (o1 === o2) return true;
59
- if (isObject(o1) && isObject(o2)) {
60
- var keys1 = Object.keys(o1), keys2 = Object.keys(o2);
61
- if (keys1.length !== keys2.length) return false;
62
- keys1.sort(), keys2.sort();
63
- for (var cx = 0, dx = keys1.length; cx < dx; cx++) {
64
- var key1 = keys1[cx];
65
- var key2 = keys2[cx];
66
- if (key1 !== key2) return false;
67
- if (!singleEqual(o1[key1], o2[key2])) return false;
68
- }
69
- return true;
70
- }
71
- return singleEqual(o1, o2);
72
- }
73
56
  function deepEqual(o1, o2) {
74
57
  if (o1 === o2) return true;
75
58
  if (isObject(o1) && isObject(o2)) {
@@ -1,3 +1,4 @@
1
+ var isNaN = Number.isNaN;
1
2
  function isSame(o1, o2) {
2
- return o1 === o2 || isNumber(o1) && isNumber(o2) && isNaN(o1) && isNaN(o2);
3
+ return o1 === o2 || isNaN(o1) && isNaN(o2);
3
4
  }
@@ -275,13 +275,13 @@ function parse(piece) {
275
275
  }
276
276
  };
277
277
  var is = function (a) {
278
- var reg = /^[\*\+\-\!\-\$&\?\~]|[\*\+\-\!\-\$&\?\~]$/;
278
+ var reg = /^[\*\+\-\!\-&\?\~]|^\$(?!\d)|[\*\+\-\!\-\$&\?\~]$/;
279
279
  if (!reg.test(a)) return a;
280
280
  required = test(/^\*|\*$/, a);
281
281
  if (test(/^[\+]|[\+]$/, a)) inlist = true;
282
282
  if (test(/^[\!]|[\!]$/, a)) inlist = false;
283
283
  hidden = test(/^\-|\-$/, a);
284
- readonly = test(/^[\$&]|[\$&]$/, a);
284
+ readonly = test(/^&|\$(?!\d)|[\$&]$/, a);
285
285
  delete_onempty = test(/^\?|\?$/, a);
286
286
  delete_onsubmit = test(/^\~|\~$/, a);
287
287
  return a.replace(reg, '');
@@ -331,6 +331,7 @@ function parse(piece) {
331
331
  type = d + 'bit/' + t;
332
332
  }
333
333
  var sizematch = /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
334
+ if (!sizematch[1] && /^\$\d/.test(sizematch[2])) sizematch = null;
334
335
  if (sizematch) {
335
336
  var [size_text, size = 1, unit, eq] = sizematch;
336
337
  if (unit && /^i?b?$/i.test(unit.slice(1))) {
@@ -0,0 +1,2 @@
1
+ var fields = refilm_decode(["启动时间/time $1"]);
2
+ console.log(fields);
@@ -0,0 +1,18 @@
1
+ var singleEqual = isSame;
2
+ function shallowEqual(o1, o2) {
3
+ // 浅层比对,对内层对象不进行递归比对
4
+ if (o1 === o2) return true;
5
+ if (isObject(o1) && isObject(o2)) {
6
+ var keys1 = Object.keys(o1), keys2 = Object.keys(o2);
7
+ if (keys1.length !== keys2.length) return false;
8
+ keys1.sort(), keys2.sort();
9
+ for (var cx = 0, dx = keys1.length; cx < dx; cx++) {
10
+ var key1 = keys1[cx];
11
+ var key2 = keys2[cx];
12
+ if (key1 !== key2) return false;
13
+ if (!singleEqual(o1[key1], o2[key2])) return false;
14
+ }
15
+ return true;
16
+ }
17
+ return singleEqual(o1, o2);
18
+ }
@@ -0,0 +1,5 @@
1
+ var spliter = /\s*[,;\|]\s*/
2
+ module.exports = function (names) {
3
+ if (typeof names === 'string') names = names.split(spliter);
4
+ return names;
5
+ }
@@ -312,6 +312,7 @@ var scan = function (data) {
312
312
  var detourTemplate = function (raw, params) {
313
313
  var spliter = { text: ",", type: STAMP };
314
314
  var template = scan(`extend([],{["raw"]:[]})`);
315
+ rootenvs.extend = true;
315
316
  var str0 = template[1].first;
316
317
  var str1 = template[1][2][2];
317
318
  for (var r of raw) {
@@ -364,19 +365,27 @@ var removeQuote = function (o, c, i) {
364
365
  if (c.next) c.next.prev = cf;
365
366
  }
366
367
 
367
- Javascript.prototype.detour = function detour(o, ie) {
368
- var avoidMap = this.avoidMap;
368
+ Javascript.prototype.detour = function (o, ie) {
369
+ context = this;
370
+ var envs = rootenvs = Object.create(null);
371
+ detour(o, ie);
372
+ rootenvs = null;
373
+ context = null;
374
+ return envs;
375
+ }
376
+ var context = null, rootenvs = null;
377
+ function detour(o, ie) {
369
378
  while (o) {
370
379
  switch (o.type) {
371
380
  case SCOPED:
372
- this.detour(o.first, ie);
381
+ detour(o.first, ie);
373
382
  break;
374
383
  case EXPRESS:
375
384
  var text = o.text.replace(/^\.\.\./, '');
376
385
  var hasdot = o.text.length !== text.length;
377
- if (avoidMap) {
386
+ if (context.avoidMap) {
378
387
  var m = /^[^\.\[\]]+/.exec(o.text);
379
- if (m) { avoidMap[m[0]] = true; }
388
+ if (m) { context.avoidMap[m[0]] = true; }
380
389
  }
381
390
  if (/\?\./.test(text)) {
382
391
  text = renderExpress(text);
@@ -384,7 +393,7 @@ Javascript.prototype.detour = function detour(o, ie) {
384
393
  o = replace(o, ...scan(text));
385
394
  continue;
386
395
  }
387
- text = text.replace(/\.([^\.\[\!\=\:]+)/g, (_, a) => ie === undefined || this.strap_reg.test(a) || /#/.test(a) ? `[${strings.recode(a)}]` : _);
396
+ text = text.replace(/\.([^\.\[\!\=\:]+)/g, (_, a) => ie === undefined || context.strap_reg.test(a) || /#/.test(a) ? `[${strings.recode(a)}]` : _);
388
397
  if (hasdot) text = "..." + text;
389
398
  o.text = text;
390
399
  break;
@@ -404,7 +413,7 @@ Javascript.prototype.detour = function detour(o, ie) {
404
413
  else {
405
414
  c.entry = "(";
406
415
  c.leave = ")";
407
- this.detour(c.first, ie);
416
+ detour(c.first, ie);
408
417
  splice(o, cx + 1, 0, { type: STAMP, text: ',' });
409
418
  removeQuote(o, c);
410
419
  }
@@ -424,7 +433,7 @@ Javascript.prototype.detour = function detour(o, ie) {
424
433
  } else {
425
434
  c.entry = '(';
426
435
  c.leave = ")";
427
- this.detour(c.first, ie);
436
+ detour(c.first, ie);
428
437
  params.push(c);
429
438
  }
430
439
  }
@@ -460,7 +469,7 @@ Javascript.prototype.detour = function detour(o, ie) {
460
469
  if (/^\[/.test(o.text)) break;
461
470
  if (o.queue.isObject) {
462
471
  var text = strings.recode(o.text);
463
- if (ie === undefined || o.prev && (o.prev.type !== STAMP || o.prev.text !== ",") || this.strap_reg.test(o.text)) {
472
+ if (ie === undefined || o.prev && (o.prev.type !== STAMP || o.prev.text !== ",") || context.strap_reg.test(o.text)) {
464
473
  text = `[${text}]`;
465
474
  }
466
475
  else if (ie !== false) {
@@ -612,6 +621,7 @@ var removeExport = function (c, i, code) {
612
621
  o = n && n.next;
613
622
  var exp = scan(`\r\nexports.${prop}=`);
614
623
  exp.push(name);
624
+ name.isExpress = true;
615
625
  allexports.push(exp);
616
626
  }
617
627
  var ni = skipAssignment(code, i);
@@ -627,6 +637,7 @@ var removeExport = function (c, i, code) {
627
637
  n.type = STAMP;
628
638
  c.text = `exports.default`;
629
639
  code.exportDefault = true;
640
+ n.next.isExpress = true;
630
641
  c.type = EXPRESS;
631
642
  return;
632
643
  }
@@ -638,6 +649,7 @@ var removeExport = function (c, i, code) {
638
649
  }
639
650
  c.text = `exports.${dec[0]}`;
640
651
  c.type = EXPRESS;
652
+ n.isExpress = true;
641
653
  code.splice(i + 1, 0, ...scan(`=`));
642
654
  var nn = n.next;
643
655
  var d = nn.text;
@@ -153,6 +153,7 @@ class Program {
153
153
  extends_reg = /^(extends)$/;
154
154
  spaces = spaceDefined;
155
155
  nocase = false
156
+ keepspace = false;
156
157
  lastIndex = 0
157
158
  compile(s) {
158
159
  return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\-\*\?\$\^\|\\\/ ]/g, function (m) {
@@ -192,7 +193,7 @@ class Program {
192
193
  var last = queue.last;
193
194
  Object.defineProperty(scope, 'queue', { value: queue, enumerable: false, configurable: true });
194
195
  scope.prev = last;
195
- if (scope.type !== COMMENT && scope.type !== SPACE) {
196
+ if (!(scope.type & (COMMENT | SPACE))) {
196
197
  var keeplast = program.setType(scope) === false;
197
198
  if (keeplast) {
198
199
  if (queue.last !== last) last = queue.last;
@@ -237,12 +238,7 @@ class Program {
237
238
  }
238
239
  }
239
240
  var last = queue.last;
240
- if (type === SPACE) {
241
- if (last && last.isend === false) {
242
- last.isend = true;
243
- queue.inExpress = false;
244
- }
245
- }
241
+ if (type === SPACE);
246
242
  else if (type !== STAMP);
247
243
  else if (m === ";") {
248
244
  if (last && last.isend === false) last.isend = true;
@@ -526,8 +522,16 @@ class Program {
526
522
  m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
527
523
  row += m.replace(/[^\r\n]+/g, '').length >> 1;
528
524
  colstart = match.index + m.replace(/[^\r\n]+$/, '').length - 1;
525
+ var last = queue.last;
526
+ if (last && last.isend === false) {
527
+ last.isend = true;
528
+ queue.inExpress = false;
529
+ }
529
530
  save(SPACE);
530
531
  }
532
+ else {
533
+ if (this.keepspace) save(SPACE);
534
+ }
531
535
  lasttype = SPACE;
532
536
  continue;
533
537
  }
@@ -13,7 +13,7 @@ const [
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
+ var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mniul]|ll)?$/i;
17
17
  var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
18
18
  var skipAssignment = function (o, cx) {
19
19
  var next = arguments.length === 1 ? function () {
@@ -132,6 +132,7 @@ var skipAssignment = function (o, cx) {
132
132
  next();
133
133
  }
134
134
  else if (o.text === 'else') {
135
+ if (ifdeep <= 0) break loop;
135
136
  ifdeep--;
136
137
  needpunc = false;
137
138
  next();
@@ -140,7 +141,6 @@ var skipAssignment = function (o, cx) {
140
141
  if (o.text === 'if') ifdeep++;
141
142
  next();
142
143
  next();
143
- break;
144
144
  }
145
145
  else if (o.text === 'do') {
146
146
  next();
@@ -151,14 +151,12 @@ var skipAssignment = function (o, cx) {
151
151
  next();
152
152
  if (o.type === STRAP && o.text === 'await') next();
153
153
  next();
154
- break;
155
154
  }
156
155
  else if (o.text === "class") {
157
156
  next();
158
157
  while (o && !o.isClass) next();
159
158
  while (o && o.isClass) next();
160
159
  needpunc = true;
161
- break;
162
160
  }
163
161
  else if (o.text === "function") {
164
162
  next();
@@ -167,7 +165,6 @@ var skipAssignment = function (o, cx) {
167
165
  if (o) next();
168
166
  if (o) next();
169
167
  needpunc = true;
170
- break;
171
168
  }
172
169
  else if (o.text === 'debugger') {
173
170
  next();
@@ -1005,6 +1002,7 @@ var createString = function (parsed) {
1005
1002
  var keepspace = parsed.keepspace !== false;
1006
1003
  var helpcode = parsed.helpcode;
1007
1004
  var lasttype = SPACE;
1005
+ var uncomment = parsed.comment === false;
1008
1006
  var result = [], cacheresult, finalresult = result;
1009
1007
  var helpcolor = parsed.keepcolor === false;
1010
1008
  var run = (o, i, a) => {
@@ -1022,8 +1020,9 @@ var createString = function (parsed) {
1022
1020
  switch (o.type) {
1023
1021
  case COMMENT:
1024
1022
  // 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
1023
+ if (uncomment) break;
1025
1024
  var tmp = o.text, opentmp = false;
1026
- if (!keepspace || helpcode) {
1025
+ if (helpcode) {
1027
1026
  if (/^\/[\/\*]\s*\<\!--/.test(tmp)) {
1028
1027
  opentmp = true;
1029
1028
  if (/^\/\*/.test(tmp)) opentmp = 2;
@@ -1102,7 +1101,7 @@ var createString = function (parsed) {
1102
1101
  default:
1103
1102
  if (o instanceof Object) {
1104
1103
  if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
1105
- else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE) & o.type) {
1104
+ else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
1106
1105
  result.push(" ");
1107
1106
  }
1108
1107
  else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
@@ -733,13 +733,13 @@ var killspr = function (body, i, _getobjname, killobj) {
733
733
  var index = 0;
734
734
  var spr = function () {
735
735
  var s = m;
736
- s.text = s.text.replace(/^\.\.\./, '');
737
736
  m = skipAssignment(m);
738
- var q = scanner2(`slice_["call"]()`);
739
- rootenvs.slice_ = true;
737
+ s.text = s.text.replace(/^\.\.\./, '');
740
738
  var v = splice2(o, s, m);
741
739
  if (m) splice2(o, m, m = m.next);
742
740
  killobj(v);
741
+ var q = scanner2(`slice_["call"]()`);
742
+ rootenvs.slice_ = true;
743
743
  insert1(q[q.length - 1], null, ...v);
744
744
  return q;
745
745
  };
@@ -760,6 +760,23 @@ var killspr = function (body, i, _getobjname, killobj) {
760
760
  var next = o.next;
761
761
  if (o.entry === '(') {
762
762
  var r = snapExpressHead(o);
763
+ if (r.type === STRAP && r.text === "new") {
764
+ var qt = scanner2(`()`)[0];
765
+ r = r.next;
766
+ var b = body.lastIndexOf(r, i);
767
+ var ct = splice(body, b, i - b + 1, qt);
768
+ var qq = ct[ct.length - 1];
769
+ var qb = scanner2("[null,]")[0];
770
+ qb.push(...splice(qq, 0, qq.length, qb));
771
+ ct[ct.length - 1].unshift({ type: STAMP, text: ',' });
772
+ ct[ct.length - 1].unshift(...ct.slice(0, ct.length - 1).map(a => extend({}, a)));
773
+ ct.splice(ct.length - 1, 0, ...scanner2("['bind']['apply']"));
774
+ qt.push(...ct);
775
+ relink(qq)
776
+ relink(qb)
777
+ relink(qt)
778
+ return b;
779
+ }
763
780
  var rt = r.type === EXPRESS && r.text.replace(/^\.\.\./, '');
764
781
  var p = o.prev;
765
782
  if (r === o);
@@ -19,7 +19,7 @@ assert(downLevel(`a(c**=d)`), 'a(c = power_(c, d))', true);
19
19
  assert(downLevel(`a(c.b.d**=d)`), 'a((_ = c.b, _.d = power_(_.d, d)))\r\nvar _', true);
20
20
  assert(downLevel(`a(c.b[a.b]**=d)`), 'a((_ = c.b, _[_0 = a.b] = power_(_[_0], d)))\r\nvar _, _0', true);
21
21
  assert(downLevel(`c.b[a.b]**=d`), '_ = c.b, _[_0 = a.b] = power_(_[_0], d)\r\nvar _, _0', true);
22
- // 声明及解构
22
+ i++// 声明及解构
23
23
  assert(downLevel(`var [data, args, strs] = breakcode(data, occurs), strs = []`), 'var _ = breakcode(data, occurs), data = _[0], args = _[1], strs = _[2], strs = []\r\nvar _');
24
24
  assert(downLevel(`var [name, type, options] = piece, key, repeat;`), 'var name = piece[0], type = piece[1], options = piece[2], key, repeat;');
25
25
  assert(downLevel(`var [] = piece, key,[]= repeat;`), 'var key;');
@@ -80,6 +80,7 @@ assert(downLevel(`function (a=b,[c],d,e=f){}`), "function (a, arg1, d, e) { if (
80
80
  assert(downLevel(`function (arg1=b,[c],d,e=f){}`), "function (arg1, arg2, d, e) { if (arg1 === undefined) arg1 = b; var c = arg2[0]; if (e === undefined) e = f; }")
81
81
  i++// class降级
82
82
  assert(downLevel(`class a {}`), "function a() {}")
83
+ var tmp = scanner2('export class a{a(){}}'); tmp.fix(); assert(downLevel.code(tmp).toString(), `exports.a = function (a) { a["prototype"].a = function () {}\r\nreturn a }(function a() {})`);
83
84
  assert(downLevel(`class a { static{ a.a=1}}`), "function a() {}; (function () { a.a = 1 }())")
84
85
  assert(downLevel(`if(a) a = 1; class a {}`), "if (a) a = 1; function a() {}")
85
86
  assert(downLevel(`async function(){if(a) a = 1; class a {}}`), `function () { return async_(
@@ -192,6 +193,8 @@ assert(downLevel(`=[a,b,...c,d,e,f]`), `var slice_ = Array["prototype"]["slice"]
192
193
  assert(downLevel(`=[a,b,...c,d,e,f,...g]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d, e, f], slice_["call"](g))`)
193
194
  assert(downLevel(`=[a,b,...c,d,...e]`), `var slice_ = Array["prototype"]["slice"];\r\n= [a, b]["concat"](slice_["call"](c), [d], slice_["call"](e))`)
194
195
  assert(downLevel(`a(...b)`), `a["apply"](null, b)`)
196
+ assert(downLevel(`a(..."b,c".split(","))`), `a["apply"](null, "b,c".split(","))`)
197
+ assert(downLevel(`new a(...args)`), `var slice_ = Array["prototype"]["slice"];\r\nnew (a['bind']['apply'](a, [null]["concat"](slice_["call"](args))))`)
195
198
  assert(downLevel(`a(c,d,e,...b(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"](b["apply"](null, c))))`)
196
199
  assert(downLevel(`a(c,d,e,...b.a(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"](b.a["apply"](b, c))))`)
197
200
  assert(downLevel(`a(c,d,e,...b.a.c(...c))`), `var slice_ = Array["prototype"]["slice"];\r\na["apply"](null, [c, d, e]["concat"](slice_["call"]((_ = b.a).c["apply"](_, c))))\r\nvar _`)
@@ -226,7 +229,7 @@ function () {
226
229
  return [8, 8]
227
230
  },
228
231
  function () {
229
- _2 = Symbol["asyncIterator"]; _2 = os[_2]; if (_2) return [1, 0]; _2 = Symbol["iterator"]; _2 = os[_2]; if (_2) return [1, 0]; _2 = Symbol["iterator"]; _2 = Array["prototype"][_2]
232
+ _2 = Symbol["asyncIterator"]; _2 = os[_2]; if (_2) return [1, 0]; _2 = Symbol["iterator"]; _2 = os[_2]; if (_2) return [1, 0]; _2 = Array["prototype"]; _3 = Symbol["iterator"]; _2 = _2[_3]
230
233
  },
231
234
  function () {
232
235
  _0 = _2; _0 = _0["call"](os); _2 = _0["next"](); return [_2, 1]
@@ -258,13 +261,13 @@ if (!_2) return [1, 0]; _2 = _0["return"](); return [1, 0]
258
261
  function () {
259
262
  return [1, 9]
260
263
  })
261
- var _, _0, _2`)
264
+ var _, _0, _2, _3`)
262
265
  assert(downLevel(`for await(var [o,s] of os) noSymbol`), `return async_(
263
266
  function () {
264
267
  return [11, 8]
265
268
  },
266
269
  function () {
267
- o; s; _5 = Symbol["asyncIterator"]; _5 = os[_5]; if (_5) return [1, 0]; _5 = Symbol["iterator"]; _5 = os[_5]; if (_5) return [1, 0]; _5 = Symbol["iterator"]; _5 = Array["prototype"][_5]
270
+ o; s; _5 = Symbol["asyncIterator"]; _5 = os[_5]; if (_5) return [1, 0]; _5 = Symbol["iterator"]; _5 = os[_5]; if (_5) return [1, 0]; _5 = Array["prototype"]; _6 = Symbol["iterator"]; _5 = _5[_6]
268
271
  },
269
272
  function () {
270
273
  _0 = _5; _0 = _0["call"](os); _5 = _0["next"](); return [_5, 1]
@@ -276,16 +279,16 @@ function () {
276
279
  _5 = !_["done"]; if (!_5) return [5, 0]; _5 = _["value"]; return [_5, 1]
277
280
  },
278
281
  function (_4) {
279
- _5 = _4; _1 = _5; _6 = Symbol["iterator"]; _6 = _1[_6]; if (_6) return [1, 0]; _6 = Symbol["iterator"]; _6 = Array["prototype"][_6]
282
+ _5 = _4; _1 = _5; _6 = Symbol["iterator"]; _6 = _1[_6]; if (_6) return [1, 0]; _6 = Array["prototype"]; _7 = Symbol["iterator"]; _6 = _6[_7]
280
283
  },
281
284
  function () {
282
- _6 = (_6); _2 = _6["call"](_1); _3 = undefined; _3 = _2["next"](); o = _3["value"]; _3 = _2["next"](); s = _3["value"]; _9 = !_3; if (_9) return [1, 0]; _9 = !_3["done"]
285
+ _6 = (_6); _2 = _6["call"](_1); _3 = undefined; _3 = _2["next"](); o = _3["value"]; _3 = _2["next"](); s = _3["value"]; _10 = !_3; if (_10) return [1, 0]; _10 = !_3["done"]
283
286
  },
284
287
  function () {
285
- _9 = (_9); if (!_9) return [1, 0]; _9 = _2["return"]; _9 = isFunction(_9); if (!_9) return [1, 0]; _9 = _2["return"]()
288
+ _10 = (_10); if (!_10) return [1, 0]; _10 = _2["return"]; _10 = isFunction(_10); if (!_10) return [1, 0]; _10 = _2["return"]()
286
289
  },
287
290
  function () {
288
- _3 = _9; _5 = (true)
291
+ _3 = _10; _5 = (true)
289
292
  },
290
293
  function () {
291
294
  if (!_5) return [2, 0]; noSymbol; _5 = _0["next"](); return [_5, 1]
@@ -305,7 +308,7 @@ if (!_5) return [1, 0]; _5 = _0["return"](); return [1, 0]
305
308
  function () {
306
309
  return [1, 9]
307
310
  })
308
- var o, s, _, _0, _1, _2, _3, _5, _6, _7, _8, _9`);
311
+ var o, s, _, _0, _1, _2, _3, _5, _6, _7, _8, _9, _10`);
309
312
  assert(downLevel(`for(o of os) noSymbol`), `for (_ = 0; _ < os["length"] && (o = os[_], true); _++) noSymbol\r\nvar _, _0`)
310
313
  assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }\r\nvar _, _0`)
311
314
  assert(downLevel(`for(var o of os) Symbol`), `try { for (var o, _0 = os[Symbol["iterator"]] || Array["prototype"][Symbol["iterator"]], _0 = _0["call"](os), _ = _0["next"](); !_["done"] && (o = _["value"], true); _ = _0["next"]()) Symbol } finally { if (_ && !_["done"] && isFunction(_0["return"])) _0["return"]() }\r\nvar _, _0`)
@@ -324,9 +327,9 @@ assert(downLevel("if(a){}[r, g, b] = rgb4s(r, g, b, s)"), "if (a) {} _ = rgb4s(r
324
327
  assert(downLevel(`{c,[c]:b,...a}=a`), `c = a.c, b = a[c], a = rest_(a, ["c", c])`)
325
328
  assert(downLevel(`async()=>name = require("./$split")(name)["join"]("/");`), `function () { return async_(
326
329
  function () {
327
- _0 = require("./$split"); _1 = _0(name); name = _1["join"]("/"); return [name, 2]
330
+ _0 = require("./$split"); _0 = _0(name); name = _0["join"]("/"); return [name, 2]
328
331
  })
329
- var _0, _1 };`);
332
+ var _0 };`);
330
333
  i++//异步或步进函数
331
334
  assert(downLevel(`function *(){yield *a}`), `function () { return aster_(
332
335
  function () {
@@ -348,7 +351,7 @@ function () {
348
351
  return [5, 8]
349
352
  },
350
353
  function () {
351
- a; _2 = Symbol["iterator"]; _2 = b[_2]; if (_2) return [1, 0]; _2 = Symbol["iterator"]; _2 = Array["prototype"][_2]
354
+ a; _2 = Symbol["iterator"]; _2 = b[_2]; if (_2) return [1, 0]; _2 = Array["prototype"]; _3 = Symbol["iterator"]; _2 = _2[_3]
352
355
  },
353
356
  function () {
354
357
  _0 = _2; _0 = _0["call"](b); _ = _0["next"](); return [1, 0]
@@ -371,7 +374,7 @@ if (!_2) return [1, 0]; _2 = _0["return"](); return [1, 0]
371
374
  function () {
372
375
  return [1, 9]
373
376
  })
374
- var a, _, _0, _2 }`)
377
+ var a, _, _0, _2, _3 }`)
375
378
  assert(downLevel(`a={async a(){var b =c;return 1}}`), `a = (_ = {},
376
379
  _.a = function () { return async_(\r\nfunction () {\r\nb = c; return [1, 2]\r\n})\r\nvar b }, _)\r\nvar _`)
377
380
  assert(downLevel(`async function(){return 1}`), `function () { return async_(\r\nfunction () {\r\nreturn [1, 2]\r\n}) }`)
@@ -14,7 +14,7 @@ function format(code, step) {
14
14
  var lowspace = rest.pop();
15
15
  var cp = code.prev;
16
16
  var cpp = cp && cp.prev;
17
- if(cpp && cpp.type === STRAP && cpp.text==="switch"){
17
+ if (cpp && cpp.type === STRAP && cpp.text === "switch") {
18
18
  lowspace += step;
19
19
  }
20
20
  var space = lowspace + step;
@@ -37,10 +37,15 @@ function format(code, step) {
37
37
  code.push({ type: SPACE, text: lowspace });
38
38
  }
39
39
  }
40
+ if (breakline && e.type === STAMP) {
41
+ if (e.text === ':' && !e.inExpress) {
42
+ if (code[code.length - 1].type === SPACE) code.pop();
43
+ }
44
+ }
40
45
  code.push(e);
41
46
  if (e.type === SCOPED) rest.push(space, e);
42
47
  }
43
- if (breakline && (e.type === STAMP && /^[,;]$/.test(e.text) || !code.isClass && !code.isObject)) hasCommaBefore = !code.isObject && e.text === ',', code.push({ type: SPACE, text: hasCommaBefore ? deepspace: space });
48
+ if (breakline && (e.type === STAMP && /^[,;]$/.test(e.text) || !code.isClass && !code.isObject)) hasCommaBefore = !code.isObject && e.text === ',', code.push({ type: SPACE, text: hasCommaBefore ? deepspace : space });
44
49
  }
45
50
  if (breakline) {
46
51
  var hasspaceend = code[code.length - 1].type === SPACE;
@@ -154,13 +154,15 @@ class Code extends Array {
154
154
  // 提前处理属性
155
155
  break() {
156
156
  this.program.avoidMap = avoidMap;
157
- this.program.detour(this.first);
157
+ var envs = this.program.detour(this.first);
158
+ if (this._scoped) extend(this.envs, envs);
158
159
  return this;
159
160
  }
160
161
  // 绕开低版本ie的异常属性
161
162
  detour(ie) {
162
163
  this.program.avoidMap = avoidMap;
163
- this.program.detour(this.first, ie !== false);
164
+ var envs = this.program.detour(this.first, ie !== false);
165
+ if (this._scoped) extend(this.envs, envs);
164
166
  return this;
165
167
  }
166
168
  // 压缩
@@ -111,6 +111,16 @@ function testUnicode() {
111
111
  var m = scanner(`\\u{0042}\\u0042=1`);
112
112
  console.log(m.toString())
113
113
  }
114
+ function testComment() {
115
+ var m = scanner(`SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */`);
116
+ console.log(m[m.length - 1].type === common.COMMENT);
117
+ m.comment = false;
118
+ console.log(common.createString(m));
119
+ }
120
+ function testQuote() {
121
+ var m = scanner(`(sizeof(("table")) / sizeof(("table")[0]))`);
122
+ console.log(m.toString());
123
+ }
114
124
  Program.debug = true;
115
125
  // testSpeed();
116
126
  // testVariables();
@@ -124,6 +134,8 @@ Program.debug = true;
124
134
  // testJsxOnlyHtml();
125
135
  // testSpaceLess();
126
136
  // testArrow();
127
- testUnicode();
137
+ // testUnicode();
138
+ // testComment();
139
+ testQuote();
128
140
  // var typescript = require("../typescript/index");
129
141
  // typescript.transpile(data.toString(), { noEmitHelpers: true });