efront 3.36.6 → 3.36.9

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.
@@ -219,7 +219,8 @@ function parseValue(map) {
219
219
  case "nil":
220
220
  return null;
221
221
  }
222
- return parseNumber(map);
222
+ if (/^[\d\.]/.test(map)) return parseNumber(map);
223
+ return map;
223
224
  }
224
225
 
225
226
  var last_type = '';
@@ -228,7 +229,7 @@ var getComment = function (piece) {
228
229
  for (var cx = 0, dx = piece.length; cx < dx; cx++) {
229
230
  var p = piece[cx];
230
231
  if (!isString(p)) continue;
231
- var a = /^\/\//.exec(p);
232
+ var a = /^(\/\/|;)/.exec(p);
232
233
  if (a) {
233
234
  return piece.splice(cx, piece.length - cx).join(' ').slice(2);
234
235
  }
@@ -329,11 +330,11 @@ function parse(piece) {
329
330
  let [_, t, d] = /^(\w*?)\/?(\d+)$/.exec(type);
330
331
  type = d + 'bit/' + t;
331
332
  }
332
- var sizematch = /^(\-?\d+|\-?\d*\.\d+)([YZEPTGMK]i?b?|bytes?|bits?|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
333
+ var sizematch = /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
333
334
  if (sizematch) {
334
- var [size_text, size, unit] = sizematch;
335
- if (unit) {
336
- var ratio = KMGT.indexOf(unit.toUpperCase().charAt(0));
335
+ var [size_text, size = 1, unit, eq] = sizematch;
336
+ if (unit && /^i?b?$/i.test(unit.slice(1))) {
337
+ let ratio = KMGT.indexOf(unit.toUpperCase().charAt(0));
337
338
  size *= Math.pow(1024, ratio + 1);
338
339
  if (ratio >= 0) {
339
340
  unit = unit.slice(1).replace(/^i/, '');
@@ -345,12 +346,19 @@ function parse(piece) {
345
346
  var ratio;
346
347
  switch (unit) {
347
348
  case "long":
349
+ case "qword":
350
+ case "real8":
348
351
  case "double":
349
- if (!size) size = 8;
352
+ ratio = 8;
353
+ break;
354
+ case "dword":
355
+ case "real":
356
+ case "real4":
350
357
  case "float":
351
358
  case "uint":
352
359
  case "int":
353
- if (!size) size = 4;
360
+ ratio = 4;
361
+ break;
354
362
  case "bit":
355
363
  case "utf":
356
364
  case "bool":
@@ -368,12 +376,17 @@ function parse(piece) {
368
376
  ratio = 1;
369
377
  }
370
378
  type = type.slice(size_text.length);
371
- if (/\=/.test(type)) {
372
- var value = type.slice(1, (size * ratio) + 1);
373
- type = type.slice(value.length + 1) || 'flag';
379
+ if (eq === '=') {
380
+ // 只读
381
+ var value = parseValue(type);
382
+ type = "flag";
383
+ }
384
+ else if (/=/.test(type)) {
385
+ [type, value] = type.split("=");
386
+ value = parseValue(value);
374
387
  }
375
388
  if (!type) {
376
- type = size + unit;
389
+ type = (!sizematch[1] ? '' : size) + unit;
377
390
  } else {
378
391
  type = type.replace(/^[\|\:\-\,\/]/, '');
379
392
  }
@@ -387,7 +400,6 @@ function parse(piece) {
387
400
  type = type.slice(1);
388
401
  }
389
402
  if (typeof options === "string" && !/^[\$#]+\d+$/.test(options)) {
390
- console.log(options)
391
403
  options = is(options);
392
404
  var needUnfold = /^\[|\]$/.test(options);
393
405
  options = options.replace(/^\[|\]$/g, '');
@@ -17,5 +17,16 @@ var Symbol = this.Symbol || function () {
17
17
  };
18
18
 
19
19
  Symbol.prototype = prototype;
20
+ Symbol.iterator = Symbol('iterator');
21
+ Symbol.asyncIterator = Symbol('asyncIterator');
22
+ Array.prototype[Symbol.iterator] = function () {
23
+ var arr = this, cx = 0, dx = arr.length;
24
+ return {
25
+ next() {
26
+ if (cx < dx) return { value: arr[cx++], done: false };
27
+ return { value: undefined, done: true };
28
+ }
29
+ }
30
+ };
20
31
  return Symbol;
21
32
  }();
@@ -0,0 +1,35 @@
1
+ class Generator {
2
+ constructor(f) {
3
+ this.state = "suspended";
4
+ this.exec = f;
5
+ };
6
+ throw(e) {
7
+ delete this.exec;
8
+ this.state = "closed";
9
+ throw e;
10
+ }
11
+ return(value) {
12
+ delete this.exec;
13
+ this.state = "closed";
14
+ return { value: undefined, done: true };
15
+ }
16
+ next() {
17
+ if (this.exec) {
18
+ var exec = this.exec;
19
+ delete this.exec;
20
+ delete this.value;
21
+ exec(this.return, this.throw, (value, exec) => {
22
+ this.value = value;
23
+ this.exec = exec;
24
+ });
25
+ }
26
+ return { value: this.value, done: !this.exec };
27
+ }
28
+ }
29
+ Generator.prototype[Symbol.iterator] = function () {
30
+ return this;
31
+ };
32
+
33
+ function aster_() {
34
+ return new Generator(exec_.bind(this, arguments));
35
+ }
@@ -0,0 +1,50 @@
1
+ class AsyncGenerator {
2
+ constructor(f) {
3
+ this.state = "suspended";
4
+ this.exec = f;
5
+ };
6
+ throw(e) {
7
+ delete this.exec;
8
+ this.state = "closed";
9
+ return Promise.reject(e);
10
+ }
11
+ return(value) {
12
+ delete this.exec;
13
+ this.state = "closed";
14
+ return Promise.resolve({ value: undefined, done: true });
15
+ }
16
+ next() {
17
+ if (this.exec) {
18
+ var exec = this.exec;
19
+ delete this.exec;
20
+ delete this.value;
21
+ return this.promise = new Promise(function (ok, oh) {
22
+ exec(function (result) {
23
+ delete this.promise;
24
+ ok(result);
25
+ this.return(result);
26
+ }, function (error) {
27
+ delete this.promise;
28
+ oh(error);
29
+ this.throw(error);
30
+ }, (value, exec) => {
31
+ delete this.promise;
32
+ ok({ value: value, done: !this.exec })
33
+ this.value = value;
34
+ this.exec = exec;
35
+ });
36
+ })
37
+ }
38
+ else if (this.promise) {
39
+ return this.promise.then(this.next, this.next);
40
+ }
41
+ return Promise.resolve({ value: undefined, done: true });
42
+ }
43
+
44
+ }
45
+ Generator.prototype[Symbol.asyncIterator] = function () {
46
+ return this;
47
+ }
48
+ function asyncAster_() {
49
+ return new AsyncGenerator(exec_.bind(this, arguments));
50
+ }
@@ -1,62 +1,4 @@
1
- var exec = function (args, ok, oh) {
2
- var p = null, index = 0, r, finished = false;
3
- var next = function (arg) {
4
- p = arg;
5
- run();
6
- };
7
- var catches = [];
8
- var thro = function (err) {
9
- if (catches.length) {
10
- [index, p] = catches[catches.length - 1]
11
- index += p >>> 16;
12
- p = err;
13
- next();
14
- }
15
- else {
16
- oh(err);
17
- }
18
- };
19
- var retn = function (p) {
20
- r = p;
21
- finished = true;
22
- if (catches.length) fina();
23
- else ok(r);
24
- };
25
- var fina = function () {
26
- // 仅在try或catch未结束时使用
27
- [index, p] = catches[catches.length - 1];
28
- index += (p >>> 16) + (p & 0xffff);
29
- next();
30
- };
31
- var fine = function () {
32
- catches.pop();
33
- next();
34
- }
35
- var run = function () {
36
- var args_length = args.length, i;
37
- if (finished && !catches.length || index > args_length) return ok(r);
38
- loop: while (index < args_length) {
39
- try {
40
- [p, i] = args[index](p) || [1, 0];
41
- } catch (e) {
42
- p = null;
43
- thro(e);
44
- break;
45
- }
46
- switch (i) {
47
- case 0: index += p; break; // reflow
48
- case 1: index += 1; break loop; // await p;
49
- case 2: return finished = true, retn(p); // return p;
50
- case 7: index++; catches.push([index, p]); break; // try start
51
- case 9: return p ? fine() : fina(); // finally
52
- default: throw "代码异常!";
53
- }
54
- }
55
- if (p && isFunction(p.then)) p.then(next, thro);
56
- else next(p);
57
- };
58
- next();
59
- };
1
+
60
2
  function async_() {
61
- return new Promise(exec.bind(null, arguments));
3
+ return new Promise(exec_.bind(this, arguments));
62
4
  }
@@ -0,0 +1,62 @@
1
+ var exec = function (args, ok, oh, int) {
2
+ var p = null, index = 0, r, finished = false, t = this;
3
+ var next = function (arg) {
4
+ p = arg;
5
+ run();
6
+ };
7
+ var catches = [];
8
+ var thro = function (err) {
9
+ if (catches.length) {
10
+ [index, p] = catches[catches.length - 1]
11
+ index += p >>> 16;
12
+ p = err;
13
+ next();
14
+ }
15
+ else {
16
+ oh(err);
17
+ }
18
+ };
19
+ var retn = function (p) {
20
+ r = p;
21
+ finished = true;
22
+ if (catches.length) fina();
23
+ else ok(r);
24
+ };
25
+ var fina = function () {
26
+ // 仅在try或catch未结束时使用
27
+ [index, p] = catches[catches.length - 1];
28
+ index += (p >>> 16) + (p & 0xffff);
29
+ next();
30
+ };
31
+ var fine = function () {
32
+ catches.pop();
33
+ next();
34
+ }
35
+ var run = function () {
36
+ var args_length = args.length, i;
37
+ if (finished && !catches.length || index > args_length) return ok(r);
38
+ while (index < args_length) {
39
+ try {
40
+ [p, i] = args[index].call(t, p) || [1, 0];
41
+ } catch (e) {
42
+ p = null;
43
+ thro(e);
44
+ break;
45
+ }
46
+ switch (i) {
47
+ case 0: index += p; break; // reflow
48
+ case 1:
49
+ index++; // await p;
50
+ if (p && isFunction(p.then)) return p.then(next, thro);
51
+ else return next(p);
52
+ case 2: return finished = true, retn(p); // return p;
53
+ case 3: return index++, int(p, next); // yield p;
54
+ case 7: index++; catches.push([index, p]); break; // try start
55
+ case 9: return p ? fine() : fina(); // finally
56
+ default: throw "代码异常!";
57
+ }
58
+ }
59
+ retn();
60
+ };
61
+ next();
62
+ };
@@ -33,7 +33,7 @@ function,continue,debugger
33
33
  instanceof`.trim().split(/[,\s]+/);
34
34
  class Javascript extends Program {
35
35
  straps = straps;
36
- value_reg = /^(false|true|null|Infinity|NaN|undefined|arguments|this|eval|super)$/
36
+ value_reg = /^(false|true|null|Infinity|NaN|undefined)$/
37
37
  transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|export|default|instanceof|throw|extends|import|from)$/
38
38
  strapexp_reg = /^(new|void|typeof|delete|class|function|await)/;
39
39
  forceend_reg = /^(return|yield|break|continue|debugger)$/;
@@ -439,7 +439,7 @@ Javascript.prototype.detour = function detour(o, ie) {
439
439
  };
440
440
 
441
441
  var removeImport = function (c, i, code) {
442
- var { used, envs } = code;
442
+ var { used, envs, vars } = code;
443
443
  var [dec, map, o] = getDeclared(c.next);
444
444
  if (dec.length !== 1 || !o) throw new Error("代码结构异常!");
445
445
  if (o.type !== STRAP || o.text !== 'from') throw new Error("缺少from语句");
@@ -484,8 +484,8 @@ var removeImport = function (c, i, code) {
484
484
  used[name].push(u);
485
485
  });
486
486
  delete used[dn];
487
+ delete vars[dn];
487
488
  });
488
-
489
489
  }
490
490
  var u = { type: EXPRESS, text: name };
491
491
  code.splice(i + 1, oi - i - 1, u);
@@ -101,8 +101,11 @@ var skipAssignment = function (o, cx) {
101
101
  next();
102
102
  break;
103
103
  }
104
- case VALUE:
105
104
  case QUOTED:
105
+ if (needpunc && /^`/.test(o.text || o.entry)) {
106
+ needpunc = false;
107
+ }
108
+ case VALUE:
106
109
  if (needpunc) break loop;
107
110
  needpunc = true;
108
111
  next();
@@ -279,6 +282,7 @@ var createScoped = function (parsed, wash) {
279
282
  var isClass = false;
280
283
  var isAsync = false;
281
284
  var isAster = false;
285
+ var function_obj = null;
282
286
  if (o.type === STAMP && equal_reg.test(o.text)) {
283
287
  var p = snapExpressHead(o.prev);
284
288
  if (!p) {
@@ -421,6 +425,7 @@ var createScoped = function (parsed, wash) {
421
425
  if (o.prev && o.prev.text === 'async') {
422
426
  isAsync = true;
423
427
  }
428
+ function_obj = o;
424
429
  if (o.next.type === STAMP) {
425
430
  isAster = true;
426
431
  o = o.next;
@@ -505,6 +510,7 @@ var createScoped = function (parsed, wash) {
505
510
  scoped.async = isAsync;
506
511
  scoped.isfunc = true;
507
512
  isFunction = true;
513
+ if (function_obj) function_obj.scoped = scoped;
508
514
  funcbody = scoped;
509
515
  } else {
510
516
  vars = _vars;
@@ -16,4 +16,5 @@ test('try{}catch{}finally{} if(m)c=d+a;else aa debugger\r\n a')
16
16
  test('try{}catch{}\r\nfinally{}\r\n if(m)c=d+a;else aa debugger\r\n a')
17
17
  test('var a')
18
18
  test('var a,b,c=1;')
19
- test('a:')
19
+ test('a:')
20
+ test('a`b`,a`aa{s}`,c;')
@@ -664,12 +664,8 @@ var killobj = function (body, getobjname, getname_, setsolid, deep = 0) {
664
664
  o = o.next;
665
665
  }
666
666
  };
667
- var import_ = function () { };
668
- var export_ = function () { };
669
667
 
670
668
  // 字面量 false|true|null|Infinity|NaN|undefined|arguments|this|eval|super
671
- var unfalse = function () { };
672
- var unyield = function () { };
673
669
  var power_map = {};
674
670
  [
675
671
  '=,+=,-=,*=,/=,%=,|=,&=,^=,**=,~=',
@@ -691,11 +687,11 @@ var getsync = function (m) {
691
687
  if (m.type === SCOPED && m.await) return null;
692
688
  var n = skipAssignment(m);
693
689
  while (m !== n) {
694
- if (m.await || m.type === STRAP && m.text === 'await') return null;
690
+ if (m.await || m.type === STRAP && /^(yield|await)$/.test(m.text)) return null;
695
691
  m = m.next;
696
692
  }
697
693
  };
698
- var isawait = function (o) {
694
+ var ises3 = function (o) {
699
695
  if (o && o.type === SCOPED && o.entry === "{") {
700
696
  if (!o.await) return false;
701
697
  }
@@ -710,9 +706,9 @@ var isawait = function (o) {
710
706
  return false;
711
707
  }
712
708
  var unforin = function (o, body, getnewname_) {
713
- // 仅处理有 await 的代码
709
+ // 仅处理有 await 或 yield 的代码
714
710
  if (!o.await) {
715
- if (!isawait(o.next)) return;
711
+ if (!ises3(o.next)) return;
716
712
  }
717
713
  var m = o.first;
718
714
  var hasdeclare = false;
@@ -743,6 +739,11 @@ var unforin = function (o, body, getnewname_) {
743
739
  };
744
740
 
745
741
  var unforof = function (o, getnewname, used) {
742
+ var hasawait = false;
743
+ if (o.type === STRAP && o.text === 'await') {
744
+ hasawait = true;
745
+ o = o.next;
746
+ }
746
747
  var m = o.first;
747
748
  var hasdeclare = false;
748
749
  if (m.type === STRAP) {
@@ -761,7 +762,7 @@ var unforof = function (o, getnewname, used) {
761
762
  insert1(o, m, ...scanner2(d.map(a => a.text).join(",")));
762
763
  }
763
764
  var iname = getnewname();
764
- insert1(o, m, ...scanner2(`${iname}=0`));
765
+ var gname = getnewname();
765
766
  var oname;
766
767
  if (!f.next && f.type === EXPRESS && !/\./.test(f.text) && used[f.text].length === 1) {
767
768
  splice1(o, m);
@@ -774,12 +775,7 @@ var unforof = function (o, getnewname, used) {
774
775
  insert1(o, null, ...scanner2(`,${oname}=`));
775
776
  insert1(o, null, ...mo);
776
777
  }
777
- insert1(o, null, ...scanner2(`;${iname}<${oname}.length&&`));
778
- var q = scanner2(`(=${oname}[${iname}],true)`)[0];
779
- insert1(q, q[0], p);
780
- insert1(o, null, q);
781
- insert1(o, null, ...scanner2(`;${iname}++`));
782
-
778
+ insert1(o, null, ...scanner2(`${gname}=${hasawait ? `${oname}[Symbol.asyncGenerator]||${oname}[Symbol.generator]` : `${oname}[Symbol.generator]||${oname}[Symbol.asyncGenerator]`}||Array.prototype[Symbol.asyncGenerator].bind(${oname}),${gname}=${gname}(),${iname}=${hasawait ? "await " : ''}${gname}.next();${p.text}=${iname}.value,!${iname}.done;${iname}=${gname}.next();`));
783
779
  };
784
780
  var unarrow = function (body, o, killobj, getname_) {
785
781
  var p = o.prev;
@@ -961,10 +957,10 @@ var down = function (scoped) {
961
957
  if (argcodes.length) precode(argcodes.join(";") + ";");
962
958
  if (scoped.body) scoped.body.keeplet = false, killobj(scoped.body, gettmpname, _getname, setsolid);
963
959
  scoped.forEach(kill);
964
- if (scoped.async) {
960
+ if (scoped.async || scoped.yield) {
965
961
  var argname = _getname("_");
966
962
  var code = unawait(scoped.body, _getname, argname);
967
- var body = scanner2(`return async_()`);
963
+ var body = scanner2(`return ${[, "aster_", "async_", "asyncAster_"][scoped.async << 1 | scoped.yield]}()`);
968
964
  code.forEach(function (c) {
969
965
  var f = scanner2(`function(${body[2].length ? argname : ''}){}`);
970
966
  if (!c.length) insert1(f[2], null, ...scanner2('return []'));