efront 3.36.3 → 3.36.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- var { SPACE, COMMENT, EXPRESS, STRAP, STAMP, SCOPED, VALUE, LABEL, createString, skipAssignment } = require("./common");
1
+ var { SPACE, COMMENT, EXPRESS, STRAP, STAMP, SCOPED, VALUE, LABEL, createString, skipAssignment, relink } = require("./common");
2
2
  var scanner2 = require("./scanner2");
3
3
  var RE = { type: STRAP, text: "@re" };// if (_) return
4
4
  var RZ = { type: STRAP, text: "@rz" };// if (!_) return
5
+ var RD = { type: STRAP, text: "@rd" };// if (_) return
5
6
  var RETURN = { type: STRAP, text: "@ret" };// return;
6
7
  var NEXT = { type: STRAP, text: "@next" };// return;
7
- var relink = scanner2.Program.prototype.relink;
8
8
  var _break = function (body, cx, result) {
9
9
  var label;
10
10
  do {
@@ -39,6 +39,47 @@ var _break = function (body, cx, result) {
39
39
  }
40
40
  return bx;
41
41
  };
42
+ var _try = function (body, cx, unblock, result, getname) {
43
+ var o = body[cx];
44
+ o = o.next;
45
+ while (body[cx++] !== o);
46
+ var trystart = scanner2(`return [,7]`);
47
+ addresult(result, trystart);
48
+ var tryoffset = result.length;
49
+ unblock(o);
50
+ var final = scanner2(`return [0,9]`);
51
+
52
+ addresult(result, final);
53
+ o = o.next;
54
+ if (o.type !== STRAP || o.text !== 'catch') throw `缺少catch语句`;
55
+ o = o.next;
56
+ var arg = [];
57
+ var catchoffset = result.length;
58
+ if (o.type === SCOPED && o.entry === "(") {
59
+ var e = o.first;
60
+ if (e) {
61
+ arg = scanner2(`${e.text}=${ret_ || "@"}`);
62
+ addresult(result, arg);
63
+ }
64
+ o = o.next;
65
+ }
66
+ unblock(o);
67
+ o = o.next;
68
+ if (o && o.type === STRAP && o.text === 'finally') {
69
+ o = o.next;
70
+ var finishoffset = result.length;
71
+ unblock(o);
72
+ }
73
+ var tse = trystart[trystart.length - 1];
74
+ tse.unshift({
75
+ text: String(catchoffset - tryoffset << 16 | finishoffset - catchoffset),
76
+ type: VALUE,
77
+ });
78
+ relink(tse);
79
+
80
+ var finalend = scanner2(`return [1,9]`);
81
+ addresult(result, finalend);
82
+ };
42
83
  var evals = [];
43
84
 
44
85
  var _with = function (body, cx, unblock, result, getname) {
@@ -46,7 +87,6 @@ var _with = function (body, cx, unblock, result, getname) {
46
87
  var c = o.next;
47
88
  while (body[cx] !== c) cx++;
48
89
  unblock(c);
49
- addresult(result, []);
50
90
  evals.push(getname(0));
51
91
  var block = getblock(body, ++cx);
52
92
  cx += block.length;
@@ -87,18 +127,20 @@ var _switch = function (body, cx, unblock, result, getname) {
87
127
  };
88
128
  var q = _express(block, getnextname, true);
89
129
  for (var q of q) addresult(result, q);
90
- addresult(result, scanner2(`if(${getname(0)}===${getname(1)})return[]`));
130
+ var case_ = scanner2(`if(${getname(0)}===${getname(1)})return[]`)
131
+ addresult(result, case_);
91
132
  var by = cy;
92
133
  m = o[cy];
93
134
  while (m && (m.type !== STRAP || m.text !== 'case')) m = o[++cy];
94
- tmp.push(result.length - 1, o.slice(by, cy));
135
+ tmp.push(result.length - 1, case_, o.slice(by, cy));
95
136
  }
96
137
  while (tmp.length) {
97
138
  cy = tmp.shift();
139
+ case_ = tmp.shift();
98
140
  block = tmp.shift();
99
- var q = result[cy];
100
- q[q.length - 1].push({ type: VALUE, text: String(result.length - cy) });
101
- relink(q[q.length - 1]);
141
+ var q = case_[case_.length - 1];
142
+ q.push({ type: VALUE, text: String(result.length - cy) }, { type: STAMP, text: "," }, { type: VALUE, text: '0' });
143
+ relink(q);
102
144
  for (var cy = 0, dy = block.length; cy < dy; cy++) {
103
145
  var b = getblock(block, cy);
104
146
  cy += b.length;
@@ -107,7 +149,6 @@ var _switch = function (body, cx, unblock, result, getname) {
107
149
  result.push(r);
108
150
  }
109
151
  }
110
- addresult(result, []);
111
152
  }
112
153
  return cx;
113
154
  };
@@ -122,7 +163,7 @@ var _for = function (body, cx, unblock, result, tmpname) {
122
163
  while (o[cy] !== m) cy++;
123
164
  var block = getblock(o, cy);// init
124
165
  cy += block.length + 1;
125
- unblock(block, ...scanner2(`[1]`));
166
+ unblock(block, ...scanner2(`;return [1,0]`));
126
167
  var block1 = getblock(o, cy);// condition
127
168
  cy += block1.length + 1;
128
169
  var block2 = getblock(o, cy);// next
@@ -130,18 +171,15 @@ var _for = function (body, cx, unblock, result, tmpname) {
130
171
  var block_ = getblock(body, ++cx);// body
131
172
  cx += block_.length;
132
173
  unblock(block1);
133
- result[result.length - 1].pop();
134
- result[result.length - 1].pop();
135
174
  relink(result[result.length - 1]);
136
- var b = scanner2(`if(!${tmpname})return []`)
175
+ var b = scanner2(`;if(!${tmpname})return []`)
137
176
  result[result.length - 1].push(...b);
138
177
  relink(result[result.length - 1]);
139
178
  var i = result.length;
140
179
  unblock(block_);
141
180
  unblock(block2);
142
- result[result.length - 1].pop();
143
- result[result.length - 1].push(...scanner2(`[${i - result.length}]`));
144
- b[b.length - 1].push(result.length - i + 1);
181
+ result[result.length - 1].push(...scanner2(`;return [${i - result.length},0]`));
182
+ b[b.length - 1].push(...scanner2(`${result.length - i + 1},0`));
145
183
  relink(result[result.length - 1]);
146
184
  return cx;
147
185
  };
@@ -149,35 +187,92 @@ var _while = function (body, cx, unblock, result, tmpname) {
149
187
  var o = body[cx];
150
188
  o = o.next;
151
189
  while (body[cx] !== o) cx++;
152
- var b = scanner2(`if(!${tmpname})return []`)
190
+ var b = scanner2(`;if(!${tmpname})return []`)
153
191
  unblock(o);
154
- result[result.length - 1].pop();
155
- result[result.length - 1].pop();
156
192
  result[result.length - 1].push(...b);
157
193
  relink(result[result.length - 1]);
158
194
  var block = getblock(body, ++cx);
159
195
  var i = result.length;
160
196
  cx += block.length;
161
197
  unblock(block);
162
- result.push(scanner2(`return [${i - result.length - 1}]`));
163
- b[b.length - 1].push(result.length - i + 1);
198
+ result.push(scanner2(`return [${i - result.length - 1},0]`));
199
+ b[b.length - 1].push(...scanner2(`${result.length - i + 1},0`));
164
200
  return cx;
165
201
  };
166
- var addresult = function (result, next) {
202
+ var pushstep = function (result, step) {
203
+ if (!step.length) return;
167
204
  var q = result[result.length - 1];
168
- if (q && q._return) {
169
- q.pop(), q.pop();
170
- if (next.length) {
171
- q.push(...next);
172
- relink(q);
205
+ if (!q) {
206
+ result.push(step);
207
+ }
208
+ else if (q.await) {
209
+ if (!step.awaited) step.unshift(...scanner2(`${q.name}=${ret_};`));
210
+ step.awaited = true;
211
+ relink(step);
212
+ result.push(step);
213
+ }
214
+ else if (q.ifrt) {
215
+ result.push(step);
216
+ }
217
+ else {
218
+ q.push({ type: STAMP, text: ";" }, ...step);
219
+ step = q;
220
+ relink(q);
221
+ }
222
+ _return(step);
223
+ };
224
+ var patchstep = function (r, nextindex, h) {
225
+ var name = r.name;
226
+ var o, i, x, p, n;
227
+ if (evals.length) for (var i = r.length - 1; i >= h; i--) {
228
+ o = r[i];
229
+ if (o.set) {
230
+ var [m, _, b] = r.splice(i, 3);
231
+ r.splice(i, 0, ...scanner2(_withset(m.text, m.set, b.text)));
173
232
  }
174
- else {
175
- q.pop();
233
+ else if (o.get) {
234
+ r.splice(i, 1, ...scanner2(_withget(b.text)));
176
235
  }
177
- q._return = next._return;
178
236
  }
179
- else {
180
- if (next.length) result.push(next);
237
+ for (i = r.length - 1; i >= h; i--) {
238
+ o = r[i];
239
+ if (o === RZ) {
240
+ x = scanner2(`if(!${name})return [${nextindex},0]`);
241
+ }
242
+ else if (o === RE) {
243
+ x = scanner2(`if(${name})return [${nextindex},0]`);
244
+ }
245
+ else if (o === RD) {
246
+ x = scanner2(`if(${name}!==null&&${name}!== undefined)return [${nextindex},0]`);
247
+ }
248
+ else continue;
249
+ var p = o.prev;
250
+ if (!p || p.type === STAMP && p.text === ";");
251
+ else x.unshift({ type: STAMP, text: ";" });
252
+ var n = o.next;
253
+ if (!n || n.type === STAMP && n.text === ';');
254
+ else x.push({ type: STAMP, text: ';' });
255
+ r.splice(i, 1, ...x);
256
+ relink(r);
257
+ }
258
+ };
259
+ var addresult = function (result, step) {
260
+ if (!step.length) return;
261
+ var savedLength = result.length;
262
+ var prev = result[savedLength - 1];
263
+ if (prev) var patch = prev.length;
264
+ var cx, mx = 0, n;
265
+ var awaited = step.awaited;
266
+ do {
267
+ cx = step.indexOf(NEXT, mx);
268
+ n = step.slice(mx, mx = cx < 0 ? step.length : cx + 1);
269
+ if (awaited) n.awaited = awaited, awaited = false;
270
+ n.name = step.name;
271
+ pushstep(result, n);
272
+ } while (mx < step.length);
273
+ if (ret_) {
274
+ if (prev) patchstep(prev, result.length - savedLength - 1, patch || 0);
275
+ result.slice(savedLength).forEach((a, i) => patchstep(a, result.length - i - savedLength, 0));
181
276
  }
182
277
  };
183
278
  var _do = function (body, cx, unblock, result, tmpname) {
@@ -187,76 +282,37 @@ var _do = function (body, cx, unblock, result, tmpname) {
187
282
  unblock(o);
188
283
  o = o.next.next;
189
284
  unblock(o);
190
- var b = scanner2(`return [${tmpname}?${i - result.length}:${1}]`);
285
+ var b = scanner2(`return [${tmpname}?${i - result.length}:${1},0]`);
191
286
  addresult(result, b);
192
287
  while (body[cx] !== o) cx++;
193
288
  return cx;
194
289
  };
195
290
 
196
291
  var needbreak = function (o) {
197
- return o === RE || o === RZ || o === RETURN || o === NEXT;
292
+ return o === RE || o === RZ || o === RETURN || o === NEXT || o === RD;
198
293
  };
199
- var _return = function (q) {
200
- var result = [];
201
- var tmp = [];
202
- for (var q of q) {
203
- tmp.push(q);
204
- if (q.type === EXPRESS && q.next && q.next.type === STAMP && q.next.text === '=') {
205
- tmp.name = q.text;
206
- }
207
-
208
- if (needbreak(q)) {
209
- result.push(tmp);
210
- tmp = [];
211
- }
294
+ var _return = function (r, nextindex) {
295
+ var name = r.name;
296
+ var e = r[r.length - 1];
297
+ if (!needbreak(e)) return;
298
+ r.ifrt = true;
299
+ r.pop();
300
+ var semicolon = r[r.length - 1];
301
+ semicolon = semicolon && semicolon.type === STAMP && /^[,;]$/.test(semicolon.text);
302
+ var x;
303
+ if (e === RETURN) {
304
+ if (nextindex === 1) r._return = true;
305
+ x = scanner2(`return [${name},2]`);
212
306
  }
213
- if (tmp.length) result.push(tmp);
214
- result.forEach((r, i) => {
215
- var e = r[r.length - 1];
216
- if (!needbreak(e)) return;
217
- r.pop();
218
- var semicolon = r[r.length - 1];
219
- semicolon = semicolon && semicolon.type === STAMP && semicolon.text === ';';
220
- var x;
221
- if (e === RZ) {
222
- x = scanner2(`if(!${r.name})return [${result.length - i},]`);
223
- }
224
- else if (e === RE) {
225
- x = scanner2(`if(${r.name})return [${result.length - i},]`);
226
- }
227
- else if (e === RETURN) {
228
- if (result.length === 1) r._return = true;
229
- x = scanner2(`return [${result.length - i},]`);
230
- }
231
- else if (e === NEXT) {
232
- x = scanner2(`return [1,]`);
233
- }
234
- if (r.name) {
235
- if (!semicolon) r.push({ type: STAMP, text: ';' });
236
- x[x.length - 1].push({ type: EXPRESS, text: r.name });
237
- relink(x[x.length - 1]);
238
- r.push(...x);
239
- }
240
- else {
241
- x[x.length - 1].push(...r);
242
- r.splice(0, r.length, ...x);
243
- }
244
- relink(r);
245
- });
246
- return result;
307
+ else if (e === NEXT) {
308
+ x = scanner2(`return [${name},1]`);
309
+ r.await = true;
310
+ }
311
+ if (semicolon) r.pop();
312
+ r.push({ type: STAMP, text: ';' });
313
+ r.push(...x);
314
+ relink(r);
247
315
  };
248
- var power_map = {};
249
- [
250
- '=,+=,-=,*=,/=,%=,|=,&=,^=,**=,~='/* 1 */,
251
- '=>'/* 2 */, '?,:'/* 3 */, '&&,||'/* 4 */, '&,|,^'/* 5 */,
252
- 'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof'/* 6 */,
253
- '>>,>>>,<<'/* 7 */, '+,-'/* 8 */, '*,/,%'/* 9 */, '**'/* 10 */,
254
- 'typeof,await,yield,new,!,~'/* 11 */, '++,--'/* 12 */
255
- ].forEach((pp, i) => {
256
- pp.split(",").forEach(p => {
257
- power_map[p] = i + 1;
258
- })
259
- });
260
316
  var remove_end_comma = function (o) {
261
317
  if (!o.length || o.type !== SCOPED || o.entry === '[') return;
262
318
  for (var cx = o.length - 1; cx >= 0; cx--) {
@@ -277,18 +333,19 @@ var _invoke = function (t, getname) {
277
333
  var result = [];
278
334
  var cache = [];
279
335
  var queue = [];
336
+ queue.name = t.name;
280
337
  var bx = 0;
281
338
  for (var cx = 0; cx < t.length; cx++) {
282
339
  var o = t[cx];
283
340
  if (o.type === STAMP && /^[,;]$/.test(o.text)) {
284
- if (queue.length) queue.push({ type: STAMP, text: ';' });
341
+ if (queue.length) queue.push({ type: STAMP, text: ',' });
285
342
  queue.push(...t.splice(bx, cx + 1));
286
343
  cx += bx - cx - 1;
287
344
  queue.pop();
288
345
  bx = cx + 1;
289
346
  continue;
290
347
  }
291
- if (o.type === SCOPED && o.entry === '[' || o.entry === "(") {
348
+ if (o.type === SCOPED && (o.entry === '[' || o.entry === "(")) {
292
349
  var _nameindex = nameindex;
293
350
  remove_end_comma(o);
294
351
  var cy = 0;
@@ -304,33 +361,28 @@ var _invoke = function (t, getname) {
304
361
  o.splice(by, cy, { text: getdeepname(0), type: EXPRESS });
305
362
  cy -= cy - by - 1;
306
363
  nameindex++;
307
- q.forEach(q => {
308
- if (q._return) {
309
- q.splice(q.length - 3);
310
- }
311
- cache.push(q);
312
- });
364
+ cache.push(...q);
313
365
  }
314
366
  if (!cache.length) continue;
315
367
  nameindex = _nameindex;
316
- if (queue.length) result.push(queue), queue = [];
368
+ if (queue.length) addresult(result, queue), queue = [], queue.name = getdeepname(nameindex);
317
369
  result.push(...cache);
318
370
  cache = [];
319
371
  var m = t.splice(bx, cx + 1);
372
+ m.name = queue.name;
320
373
  cx -= m.length;
321
- if (bx + 1 < t.length && (t[bx].type === SCOPED || t[bx].type === EXPRESS)) t.splice(bx, 0, ...scanner2(`${getname(0)}=${getname(nameindex)}`));
374
+ if (bx + 1 < t.length && (t[bx].type & (SCOPED | EXPRESS))) t.splice(bx, 0, ...scanner2(`${getname(0)}=${getname(nameindex)}`)), t.name = getname(0);
322
375
  relink(m);
323
- result.push(m);
376
+ addresult(result, m);
324
377
  nameindex++;
325
378
  bx = cx + 1;
326
379
  }
327
380
  }
328
- if (t.length) {
329
- if (!queue.length && result.length) queue = result.pop();
330
- if (queue.length) queue.push({ type: STAMP, text: ';' });
331
- queue.push(...t);
381
+ if (queue.length) {
382
+ if (t.length) queue.push({ type: STAMP, text: ',' }, ...t), queue.name = t.name;
383
+ addresult(result, queue);
332
384
  }
333
- if (queue.length) result.push(..._return(queue, getname(0)));
385
+ else if (t.length) addresult(result, t);
334
386
  return result;
335
387
  };
336
388
 
@@ -359,14 +411,10 @@ var ternary = function (body, getname, ret) {
359
411
  if (!question.length) {
360
412
  var b = body.slice(0, bx);
361
413
  b = _express(b, getname, true);
362
- b[b.length - 1].pop();
363
- b[b.length - 1].pop();
364
414
  var c = ternary(body.slice(bx + 1, cx), getname, true);
365
415
  var d = ternary(body.slice(cx + 1), getname, true);
366
- b[b.length - 1].push(...scanner2(`return [${getname(0)}?1:${c.length + 1},${getname(0)}]${ret ? '' : ';'}`));
367
- c[c.length - 1].pop();
368
- c[c.length - 1].pop();
369
- c[c.length - 1].push(...scanner2(`return [${d.length + 1},${getname(0)}]${ret ? '' : ';'}`));
416
+ b[b.length - 1].push(...scanner2(`;return [${getname(0)}?1:${c.length + 1},0]`));
417
+ c[c.length - 1].push(...scanner2(`;return [${d.length + 1},0]`));
370
418
  res.push(...b);
371
419
  res.push(...c);
372
420
  res.push(...d);
@@ -374,7 +422,6 @@ var ternary = function (body, getname, ret) {
374
422
  }
375
423
  }
376
424
  if (!res.length) return _express(body, getname, ret);
377
- if (!ret) res = Array.prototype.concat.apply([], res), relink(res);
378
425
  return res;
379
426
  };
380
427
  var _express = function (body, getname, ret) {
@@ -393,17 +440,17 @@ var _express = function (body, getname, ret) {
393
440
  var exps = [];
394
441
  for (var cx = 0, dx = body.length; cx < dx; cx++) {
395
442
  var o = body[cx];
396
- if (o.type === COMMENT || o.type === SPACE) continue;
397
- if (o.type === STRAP || o.type === STAMP) {
443
+ if (o.type & (COMMENT | SPACE)) continue;
444
+ if (o.type & (STRAP | STAMP)) {
398
445
  var p = 0;
399
446
  if (o.text === '=') {
400
447
  ax = exps.length;
401
448
  bx = cx + 1;
402
449
  continue;
403
450
  }
404
- if (/[!~]|\+\-|\-\+/.test(o.text)) p = power_map["!"];
405
- if (!p && /[\+\-]/.test(o.text)) p = needpunc ? power_map["+"] : power_map["!"];
406
- if (!p) p = power_map[o.text];
451
+ if (/[!~]|\+\-|\-\+/.test(o.text)) p = powermap["!"];
452
+ if (!p && /[\+\-]/.test(o.text)) p = needpunc ? powermap["+"] : powermap["!"];
453
+ if (!p) p = powermap[o.text];
407
454
  needpunc = false;
408
455
  var b = body.slice(bx, cx + 1);
409
456
  bx = cx + 1;
@@ -412,7 +459,9 @@ var _express = function (body, getname, ret) {
412
459
  cache.push(b, p);
413
460
  continue;
414
461
  }
415
- var n = scanner2(`${getname(nameindex)}`);
462
+ var name = getname(nameindex);
463
+ var n = scanner2(name);
464
+ q.name = name;
416
465
  n.index = nameindex;
417
466
  nameindex = cache[cache.length - 2].index;
418
467
  n.push(b.pop());
@@ -421,20 +470,23 @@ var _express = function (body, getname, ret) {
421
470
  var p0 = cache.pop();
422
471
  var t = cache.pop();
423
472
  var isawait = _await(t);
424
- if (p0 > power_map["="]) q.push(...scanner2(`${getname(t.index)}=`));
473
+ if (p0 > powermap["="]) q.push(...scanner2(`${getname(t.index)}=`));
425
474
  q.push.apply(q, t);
426
475
  q.push.apply(q, b);
427
476
  if (isawait) q.push(NEXT);
428
477
  }
429
478
  nameindex++;
430
479
  if (maxindex < nameindex) maxindex = nameindex;
431
- if (p == power_map["||"]) {
480
+ if (p == powermap["||"]) {
432
481
  if (o.text === '||') {
433
482
  q.push(RE);
434
483
  }
435
484
  else if (o.text === '&&') {
436
485
  q.push(RZ);
437
486
  }
487
+ else if (o.text === '??') {
488
+ q.push(RD);
489
+ }
438
490
  nameindex = 0;
439
491
  } else {
440
492
  cache.push(n, p);
@@ -454,24 +506,14 @@ var _express = function (body, getname, ret) {
454
506
  nameindex = cache[cache.length - 1].index;
455
507
  var t = cache.pop();
456
508
  var isawait = _await(t, nameindex);
457
- if (p > power_map["="] && (ret || cache.length > 0)) q.push(...scanner2(`${getname(nameindex)}=`));
509
+ if (p > powermap["="] && (ret || cache.length > 0)) q.push(...scanner2(`${getname(nameindex)}=`));
458
510
  q.push.apply(q, t);
459
511
  q.push.apply(q, b);
460
512
  if (isawait) q.push(NEXT);
461
513
  b = [{ type: EXPRESS, text: getname(nameindex) }];
462
514
  }
463
- else {
464
- if (ax === 1) {
465
- if (evals.length) {
466
- q.push.apply(q, scanner2(_withset(exps[0].text, getname(nameindex), createString(b))));
467
- }
468
- else {
469
- q.push(exps[0], { type: STAMP, text: "=" });
470
- q.push(...b);
471
- }
472
- exps.shift();
473
- }
474
- else if (ret && b.length || ax > 1) {
515
+ else if (ax !== 1) {
516
+ if (ret && b.length || ax > 1) {
475
517
  q.push(...scanner2(`${getname(nameindex)}=`));
476
518
  q.push(...b);
477
519
  }
@@ -479,17 +521,22 @@ var _express = function (body, getname, ret) {
479
521
  q.push(...b);
480
522
  }
481
523
  }
524
+ q.name = getname(nameindex);
525
+ if (ax === 1) {
526
+ if (q.length) q.push({ type: STAMP, text: ';' });
527
+ q.push(exps[0], { type: STAMP, text: "=" });
528
+ q.push(...b);
529
+ q.name = exps[0].text;
530
+ exps[0].set = getname(nameindex);
531
+ exps.shift();
532
+ }
482
533
  if (ax > 1) {
483
534
  while (ax > 0) {
484
535
  q.push({ type: STAMP, text: ';' });
485
536
  var [e] = exps.splice(ax - 1, 1);
486
- if (evals.length) {
487
- _withset(e.text, getname(nameindex + 1), getname(nameindex));
488
- }
489
- else {
490
- q.push(e);
491
- q.push(...scanner2(`=${getname(nameindex)}`))
492
- }
537
+ e.set = getname(nameindex + 1);
538
+ q.push(e);
539
+ q.push(...scanner2(`=${getname(nameindex)}`))
493
540
  ax--;
494
541
  }
495
542
  }
@@ -498,16 +545,14 @@ var _express = function (body, getname, ret) {
498
545
  if (o.type !== EXPRESS) continue;
499
546
  if (o === exps[exps.length - 1]) {
500
547
  exps.pop();
501
- q.splice(cx, 1, ...scanner2(_withget(o.text)));
548
+ o.get = true;
502
549
  if (!exps.length) {
503
550
  break;
504
551
  }
505
552
  }
506
553
  }
507
554
  relink(q);
508
- if (ret && !needbreak(q[q.length - 1]) && q.length) q.push(RETURN);
509
- if (ret) result = _invoke(q, getdeepname);
510
- return ret ? result : q;
555
+ return _invoke(q, getdeepname);
511
556
  };
512
557
 
513
558
  var getblock = function (body, cx) {
@@ -525,14 +570,29 @@ var getblock = function (body, cx) {
525
570
  var labels = [];
526
571
 
527
572
  function toqueue(body, getname, ret = false) {
573
+ var retn = false;
574
+ var ifpatch = function () {
575
+ var re = scanner2(`return [1,0]`);
576
+ re.awaited = true;
577
+ addresult(result, re);
578
+ }
528
579
  var uniftop = function () {
529
- for (var cx = 0, dx = iftop.length - 1; cx < dx; cx++) {
580
+ for (var cx = 2, dx = iftop.length; cx < dx; cx += 2) {
581
+ var findex = iftop[cx];
582
+ var p = result[findex - 1];
583
+ p.pop();
584
+ p.push(...scanner2(`[${result.length + 1 - findex},0]`));
585
+ relink(p);
586
+ }
587
+ for (var cx = 0, dx = iftop.length - 1; cx < dx;) {
530
588
  var findex = iftop[cx++];
531
589
  var f = result[findex];
532
- var n = iftop[cx];
533
- var c = scanner2(`if(!${n})return [${iftop[cx + 1] - findex || 1}];`);
534
- if (f) f.unshift.apply(f, c), relink(f), f[f.length - 1][0].text = String(result.length - findex);
535
- else result.push(c);
590
+ var n = iftop[cx++];
591
+ if (f) {
592
+ var c = scanner2(`if(!${n})return [${iftop.length > cx ? iftop[cx] - findex : result.length - findex},0];`);
593
+ f.unshift.apply(f, c);
594
+ relink(f);
595
+ }
536
596
  };
537
597
  };
538
598
  var unblock = function (block, ...end) {
@@ -544,7 +604,6 @@ function toqueue(body, getname, ret = false) {
544
604
  });
545
605
  if (end.length) {
546
606
  var q = c[c.length - 1];
547
- q.pop();
548
607
  q.push(...end);
549
608
  relink(q);
550
609
  }
@@ -560,7 +619,8 @@ function toqueue(body, getname, ret = false) {
560
619
  var r = result[cx];
561
620
  if (r[r.length - 1] === end) { break }
562
621
  }
563
- end.push({ type: VALUE, text: result.length - cx });
622
+ end.push({ type: VALUE, text: result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
623
+ relink(end);
564
624
  }
565
625
  }
566
626
  };
@@ -591,6 +651,7 @@ function toqueue(body, getname, ret = false) {
591
651
  }
592
652
  if (o.type === SCOPED && o.entry === '{' && !o.isExpress) {
593
653
  var b = toqueue(o, getname, false);
654
+ // addresult(result, b);
594
655
  result.push.apply(result, b);
595
656
  cx++;
596
657
  bx = cx;
@@ -601,6 +662,7 @@ function toqueue(body, getname, ret = false) {
601
662
  break a;
602
663
  }
603
664
  if (o.text === 'return') {
665
+ retn = [RETURN];
604
666
  ret = true;
605
667
  bx = cx + 1;
606
668
  cx++;
@@ -616,6 +678,11 @@ function toqueue(body, getname, ret = false) {
616
678
  bx = cx + 1;
617
679
  continue;
618
680
  }
681
+ if (o.text === 'try') {
682
+ cx = _try(body, cx, unblock, result, getname);
683
+ bx = cx + 1;
684
+ continue;
685
+ }
619
686
  if (o.text === 'for') {
620
687
  labels.push(o);
621
688
  cx = _for(body, cx, unblock, result, getname(0));
@@ -646,6 +713,7 @@ function toqueue(body, getname, ret = false) {
646
713
  }
647
714
  var elseif = false;
648
715
  if (o.text === 'else') {
716
+ ifpatch();
649
717
  iftop.push(result.length);
650
718
  while (body[cx] !== o.next) cx++;
651
719
  o = o.next;
@@ -655,7 +723,7 @@ function toqueue(body, getname, ret = false) {
655
723
  while (body[cx] !== o.next) cx++;
656
724
  o = o.next;
657
725
  var n = '';
658
- if (o.first && o.first === o.lastUncomment) {
726
+ if (o.first && o.first === o.last) {
659
727
  if (o.first.type === EXPRESS) {
660
728
  n = o.first.text;
661
729
  }
@@ -671,10 +739,11 @@ function toqueue(body, getname, ret = false) {
671
739
  else {
672
740
  iftop.push(n);
673
741
  }
742
+ o = o.next;
674
743
  elseif = true;
675
744
  }
676
745
  if (elseif) {
677
- while (body[cx] !== o.next) cx++;
746
+ while (body[cx] !== o) cx++;
678
747
  var block = getblock(body, cx);
679
748
  cx += block.length;
680
749
  o = body[cx];
@@ -696,17 +765,28 @@ function toqueue(body, getname, ret = false) {
696
765
  cx++;
697
766
  bx = cx;
698
767
  b = ternary(b, getname, ret);
699
- if (ret) result.push.apply(result, b);
700
- else result.push(b);
768
+ result.push(...b);
769
+ if (retn) {
770
+ retn.name = b[b.length - 1].name;
771
+ addresult(result, retn);
772
+ }
773
+ retn = false;
701
774
  } while (cx < body.length);
702
775
  return result;
703
776
  }
777
+ var ret_ = '';
704
778
  module.exports = function (body, newname, ret) {
779
+ if (ret) ret = isString(ret) ? ret : newname();
780
+ var ret0 = ret_;
781
+ ret_ = ret;
705
782
  var tmpnames = [];
783
+ var p = 0;
706
784
  var getname = function (i) {
707
- i += evals.length;
785
+ i += evals.length + p;
708
786
  if (!tmpnames[i]) tmpnames[i] = newname();
709
787
  return tmpnames[i];
710
788
  };
711
- return toqueue(body, getname, ret);
789
+ var res = toqueue(body, getname, ret);
790
+ ret_ = ret0;
791
+ return res;
712
792
  };