Coverage Report

Created: 2025-10-28 07:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/moddable/xs/sources/xsCode.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2016-2025  Moddable Tech, Inc.
3
 *
4
 *   This file is part of the Moddable SDK Runtime.
5
 * 
6
 *   The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
 *   it under the terms of the GNU Lesser General Public License as published by
8
 *   the Free Software Foundation, either version 3 of the License, or
9
 *   (at your option) any later version.
10
 * 
11
 *   The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *   GNU Lesser General Public License for more details.
15
 * 
16
 *   You should have received a copy of the GNU Lesser General Public License
17
 *   along with the Moddable SDK Runtime.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 * This file incorporates work covered by the following copyright and  
20
 * permission notice:  
21
 *
22
 *       Copyright (C) 2010-2016 Marvell International Ltd.
23
 *       Copyright (C) 2002-2010 Kinoma, Inc.
24
 *
25
 *       Licensed under the Apache License, Version 2.0 (the "License");
26
 *       you may not use this file except in compliance with the License.
27
 *       You may obtain a copy of the License at
28
 *
29
 *        http://www.apache.org/licenses/LICENSE-2.0
30
 *
31
 *       Unless required by applicable law or agreed to in writing, software
32
 *       distributed under the License is distributed on an "AS IS" BASIS,
33
 *       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
 *       See the License for the specific language governing permissions and
35
 *       limitations under the License.
36
 */
37
38
#include "xsScript.h"
39
40
//#define mxCodePrint 1
41
42
#define mxByteCodePart\
43
  txByteCode* nextCode;\
44
  txInteger id;\
45
  txInteger stackLevel
46
  
47
struct sxByteCode {
48
  mxByteCodePart;
49
};
50
  
51
struct sxBigIntCode {
52
  mxByteCodePart;
53
  txBigInt bigint;
54
};
55
  
56
struct sxBranchCode {
57
  mxByteCodePart;
58
  txTargetCode* target;
59
};
60
  
61
struct sxIndexCode {
62
  mxByteCodePart;
63
  txInteger index;
64
};
65
  
66
struct sxIntegerCode {
67
  mxByteCodePart;
68
  txInteger integer;
69
};
70
  
71
struct sxNumberCode {
72
  mxByteCodePart;
73
  txNumber number;
74
};
75
  
76
struct sxStringCode {
77
  mxByteCodePart;
78
  txInteger length;
79
  txString string;
80
};
81
  
82
struct sxSymbolCode {
83
  mxByteCodePart;
84
  txSymbol* symbol;
85
};
86
87
struct sxTargetCode {
88
  mxByteCodePart;
89
  txInteger index;
90
  txLabelNode* label;
91
  txTargetCode* nextTarget;
92
  txInteger environmentLevel;
93
  txInteger scopeLevel;
94
  txInteger offset;
95
  txTargetCode* original;
96
  txBoolean used;
97
};
98
  
99
struct sxVariableCode {
100
  mxByteCodePart;
101
  txSymbol* symbol;
102
  txInteger index;
103
};
104
105
struct sxCoder {
106
  txParser* parser;
107
  txByteCode* firstCode;
108
  txByteCode* lastCode;
109
  txTargetCode* firstBreakTarget;
110
  txTargetCode* firstContinueTarget;
111
  txTargetCode* returnTarget;
112
  txInteger environmentLevel;
113
  txInteger scopeLevel;
114
  txInteger stackLevel;
115
  txInteger targetIndex;
116
  txSymbol* path;
117
  txInteger line;
118
  txBoolean programFlag;
119
  txBoolean evalFlag;
120
  txBoolean importFlag;
121
  txBoolean importMetaFlag;
122
  txClassNode* classNode;
123
  txTargetCode* chainTarget;
124
};
125
126
typedef struct {
127
  txInteger exception;
128
  txInteger selector;
129
  txTargetCode* catchTarget;
130
} txUsingContext;
131
132
typedef void (*txCompound)(void* it, void* param, txByte step);
133
134
static void fxCoderAdd(txCoder* self, txInteger delta, void* it);
135
static void fxCoderAddBigInt(txCoder* self, txInteger delta, txInteger id, txBigInt* bigint);
136
static void fxCoderAddBranch(txCoder* self, txInteger delta, txInteger id, txTargetCode* target);
137
static void fxCoderAddByte(txCoder* self, txInteger delta, txInteger id);
138
static void fxCoderAddIndex(txCoder* self, txInteger delta, txInteger id, txInteger index);
139
static void fxCoderAddInteger(txCoder* self, txInteger delta, txInteger id, txInteger integer);
140
static void fxCoderAddLine(txCoder* self, txInteger delta, txInteger id, txNode* node);
141
static void fxCoderAddNumber(txCoder* self, txInteger delta, txInteger id, txNumber number);
142
static void fxCoderAddString(txCoder* self, txInteger delta, txInteger id, txInteger length, txString string);
143
static void fxCoderAddSymbol(txCoder* self, txInteger delta, txInteger id, txSymbol* symbol);
144
static void fxCoderAddVariable(txCoder* self, txInteger delta, txInteger id, txSymbol* symbol, txInteger index);
145
static void fxCoderAdjustEnvironment(txCoder* self, txTargetCode* target);
146
static void fxCoderAdjustScope(txCoder* self, txTargetCode* target);
147
static txTargetCode* fxCoderAliasTargets(txCoder* self, txTargetCode* target);
148
static txInteger fxCoderCountParameters(txCoder* self, txNode* it);
149
static txTargetCode* fxCoderCreateTarget(txCoder* self);
150
static txTargetCode* fxCoderFinalizeTargets(txCoder* self, txTargetCode* alias, txInteger selector, txInteger* address, txTargetCode* finallyTarget);
151
static void fxCoderJumpTargets(txCoder* self, txTargetCode* target, txInteger selector, txInteger* address);
152
static void fxCoderOptimize(txCoder* self);
153
static txInteger fxCoderUseTemporaryVariable(txCoder* self);
154
static void fxCoderUnuseTemporaryVariables(txCoder* self, txInteger count);
155
156
static void fxScopeCoded(txScope* self, txCoder* coder);
157
static void fxScopeCodedBody(txScope* self, txCoder* coder);
158
static void fxScopeCodingBlock(txScope* self, txCoder* coder);
159
static void fxScopeCodingBody(txScope* self, txCoder* coder);
160
static void fxScopeCodingParams(txScope* self, txCoder* coder);
161
static void fxScopeCodingProgram(txScope* self, txCoder* coder);
162
static void fxScopeCodeDefineNodes(txScope* self, txCoder* coder);
163
static void fxScopeCodeRefresh(txScope* self, txCoder* coder);
164
static void fxScopeCodeReset(txScope* self, txCoder* coder);
165
static void fxScopeCodeRetrieve(txScope* self, txCoder* coder);
166
static void fxScopeCodeStore(txScope* self, txCoder* coder);
167
static void fxScopeCodeStoreAll(txScope* self, txCoder* coder);
168
static void fxScopeCodeUsed(txScope* self, txCoder* coder, txUsingContext* context);
169
static void fxScopeCodeUsedReverse(txScope* self, txCoder* coder, txDeclareNode* node, txInteger exception, txInteger selector);
170
static void fxScopeCodeUsing(txScope* self, txCoder* coder, txUsingContext* context);
171
static void fxScopeCodeUsingStatement(txScope* self, txCoder* coder, txNode* statement);
172
173
static void fxNodeDispatchCode(void* it, void* param);
174
static void fxNodeDispatchCodeAssign(void* it, void* param, txFlag flag);
175
static void fxNodeDispatchCodeDelete(void* it, void* param);
176
static void fxNodeDispatchCodeReference(void* it, void* param, txFlag flag);
177
static txFlag fxNodeDispatchCodeThis(void* it, void* param, txFlag flag);
178
179
static txFlag fxNodeCodeName(txNode* value);
180
static void fxCompoundExpressionNodeCodeName(void* it, void* param);
181
static void fxSpreadNodeCode(void* it, void* param, txInteger counter);
182
183
txScript* fxParserCode(txParser* parser)
184
339k
{
185
339k
  txCoder coder;
186
339k
  txByteCode* code;
187
339k
  txScript* script;
188
339k
  txSize size, delta, offset;
189
339k
  txSymbol* symbol;
190
339k
  txSymbol** address;
191
339k
  txSize c, i;
192
339k
  txID id, count;
193
339k
  txSize total;
194
339k
  txByte* p;
195
339k
  txHostNode* node;
196
339k
#ifdef mxMetering
197
339k
  txUnsigned meterIndex = 0;
198
339k
#endif
199
200
339k
    c_memset(&coder, 0, sizeof(txCoder));
201
339k
  coder.parser = parser;
202
339k
  if (parser->errorCount == 0) {
203
116k
    mxTryParser(parser) {
204
116k
      txNode* self = parser->root;
205
116k
      (*self->description->dispatch->code)(parser->root, &coder);
206
116k
    }
207
116k
    mxCatchParser(parser) {
208
3.91k
    }
209
116k
  }
210
339k
  if (parser->errorCount) {
211
227k
    if (parser->console) {
212
227k
      coder.firstCode = NULL;
213
227k
      coder.lastCode = NULL;
214
227k
      fxCoderAddByte(&coder, 1, XS_CODE_GLOBAL);
215
227k
      fxCoderAddSymbol(&coder, 0, XS_CODE_GET_VARIABLE, parser->errorSymbol);
216
227k
      fxCoderAddByte(&coder, 2, XS_CODE_NEW);
217
227k
      fxCoderAddString(&coder, 1, XS_CODE_STRING_1, mxStringLength(parser->errorMessage), parser->errorMessage);
218
227k
      fxCoderAddInteger(&coder, -3, XS_CODE_RUN_1, 1);
219
227k
      fxCoderAddByte(&coder, -1, XS_CODE_THROW);
220
227k
    }
221
0
    else
222
0
      return C_NULL;
223
227k
  }
224
  
225
339k
  fxCoderOptimize(&coder);
226
  
227
339k
  script = c_malloc(sizeof(txScript));
228
339k
  if (!script) goto bail;
229
339k
  c_memset(script, 0, sizeof(txScript));
230
  
231
339k
  code = coder.firstCode;
232
339k
  size = 0;
233
339k
  delta = 0;
234
17.0M
  while (code) {
235
16.7M
    txInteger value;
236
16.7M
    switch (code->id) {
237
665k
    case XS_NO_CODE:
238
665k
      ((txTargetCode*)code)->offset = size;
239
665k
      break;
240
40.6k
    case XS_CODE_BRANCH_1:
241
56.5k
    case XS_CODE_BRANCH_CHAIN_1:
242
273k
    case XS_CODE_BRANCH_COALESCE_1:
243
293k
    case XS_CODE_BRANCH_ELSE_1:
244
377k
    case XS_CODE_BRANCH_IF_1:
245
378k
    case XS_CODE_BRANCH_STATUS_1:
246
411k
    case XS_CODE_CATCH_1:
247
461k
    case XS_CODE_CODE_1:
248
461k
      size += 2;
249
461k
      delta += 3;
250
461k
      break;
251
      
252
12.3k
    case XS_CODE_ARGUMENT:
253
12.7k
    case XS_CODE_ARGUMENTS:
254
13.6k
    case XS_CODE_ARGUMENTS_SLOPPY:
255
13.6k
    case XS_CODE_ARGUMENTS_STRICT:
256
170k
    case XS_CODE_BEGIN_SLOPPY:
257
172k
    case XS_CODE_BEGIN_STRICT:
258
173k
    case XS_CODE_BEGIN_STRICT_BASE:
259
174k
    case XS_CODE_BEGIN_STRICT_DERIVED:
260
175k
    case XS_CODE_BEGIN_STRICT_FIELD:
261
175k
    case XS_CODE_MODULE:
262
175k
      size += 2;
263
175k
      break;
264
265
507k
    case XS_CODE_LINE:
266
507k
      size += 3;
267
507k
      break;
268
546
    case XS_CODE_ASYNC_FUNCTION:
269
682
    case XS_CODE_ASYNC_GENERATOR_FUNCTION:
270
36.9k
    case XS_CODE_CONSTRUCTOR_FUNCTION:
271
40.0k
    case XS_CODE_DELETE_PROPERTY:
272
40.0k
    case XS_CODE_DELETE_SUPER:
273
201k
    case XS_CODE_FILE:
274
213k
    case XS_CODE_FUNCTION:
275
213k
    case XS_CODE_GENERATOR_FUNCTION:
276
599k
    case XS_CODE_GET_PROPERTY:
277
599k
    case XS_CODE_GET_SUPER:
278
622k
    case XS_CODE_GET_THIS_VARIABLE:
279
1.08M
    case XS_CODE_GET_VARIABLE:
280
1.08M
    case XS_CODE_EVAL_PRIVATE:
281
1.13M
    case XS_CODE_EVAL_REFERENCE:
282
1.14M
    case XS_CODE_NAME:
283
1.16M
    case XS_CODE_NEW_CLOSURE:
284
1.22M
    case XS_CODE_NEW_LOCAL:
285
1.29M
    case XS_CODE_NEW_PROPERTY:
286
1.54M
    case XS_CODE_PROGRAM_REFERENCE:
287
2.43M
    case XS_CODE_SET_PROPERTY:
288
2.43M
    case XS_CODE_SET_SUPER:
289
2.48M
    case XS_CODE_SET_VARIABLE:
290
2.48M
    case XS_CODE_SYMBOL:
291
2.53M
    case XS_CODE_PROFILE:
292
2.53M
      size += 1 + sizeof(txID);
293
2.53M
      break;
294
      
295
797k
    case XS_CODE_STRING_1:
296
797k
      size += ((txStringCode*)code)->length;
297
      // continue
298
859k
    case XS_CODE_RESERVE_1:
299
868k
    case XS_CODE_RETRIEVE_1:
300
1.15M
    case XS_CODE_UNWIND_1:
301
1.15M
      value = ((txIndexCode*)code)->index;
302
1.15M
      if (value > 65535) {
303
0
        code->id += 2;
304
0
        size += 5;
305
0
      }
306
1.15M
      else if (value > 255) {
307
8.01k
        code->id += 1;
308
8.01k
        size += 3;
309
8.01k
      }
310
1.15M
      else
311
1.15M
        size += 2;
312
1.15M
      break;
313
12.8k
    case XS_CODE_BIGINT_1:
314
12.8k
      value = fxBigIntMeasure(&((txBigIntCode*)code)->bigint);
315
12.8k
      if (value > 255) {
316
0
        code->id += 1;
317
0
        size += 3;
318
0
      }
319
12.8k
      else
320
12.8k
        size += 2;
321
12.8k
      size += value;
322
12.8k
      break;
323
      
324
10.8k
    case XS_CODE_CONST_CLOSURE_1:
325
33.3k
    case XS_CODE_CONST_LOCAL_1:
326
51.9k
    case XS_CODE_GET_CLOSURE_1:
327
1.54M
    case XS_CODE_GET_LOCAL_1:
328
1.54M
    case XS_CODE_GET_PRIVATE_1:
329
1.54M
    case XS_CODE_HAS_PRIVATE_1:
330
1.54M
    case XS_CODE_LET_CLOSURE_1:
331
1.55M
    case XS_CODE_LET_LOCAL_1:
332
1.55M
    case XS_CODE_NEW_PRIVATE_1:
333
1.55M
    case XS_CODE_PULL_CLOSURE_1:
334
1.68M
    case XS_CODE_PULL_LOCAL_1:
335
1.68M
    case XS_CODE_REFRESH_CLOSURE_1:
336
1.68M
    case XS_CODE_REFRESH_LOCAL_1:
337
1.68M
    case XS_CODE_RESET_CLOSURE_1:
338
1.68M
    case XS_CODE_RESET_LOCAL_1:
339
1.68M
    case XS_CODE_SET_CLOSURE_1:
340
2.22M
    case XS_CODE_SET_LOCAL_1:
341
2.22M
    case XS_CODE_SET_PRIVATE_1:
342
2.45M
    case XS_CODE_STORE_1:
343
2.45M
    case XS_CODE_USED_1:
344
2.46M
    case XS_CODE_VAR_CLOSURE_1:
345
2.49M
    case XS_CODE_VAR_LOCAL_1:
346
2.49M
      value = ((txIndexCode*)code)->index + 1;
347
2.49M
      if (value > 65535) {
348
0
        code->id += 2;
349
0
        size += 5;
350
0
      }
351
2.49M
      else if (value > 255) {
352
1.31M
        code->id += 1;
353
1.31M
        size += 3;
354
1.31M
      }
355
1.18M
      else
356
1.18M
        size += 2;
357
2.49M
      break;
358
      
359
1.88M
    case XS_CODE_INTEGER_1: 
360
2.48M
    case XS_CODE_RUN_1: 
361
2.48M
    case XS_CODE_RUN_TAIL_1: 
362
2.48M
      value = ((txIntegerCode*)code)->integer;
363
2.48M
      if ((value < -32768) || (value > 32767)) {
364
15.4k
        code->id += 2;
365
15.4k
        size += 5;
366
15.4k
      }
367
2.46M
      else if ((value < -128) || (value > 127)) {
368
68.0k
        code->id += 1;
369
68.0k
        size += 3;
370
68.0k
      }
371
2.39M
      else
372
2.39M
        size += 2;
373
2.48M
      break;
374
8.12k
    case XS_CODE_NUMBER:
375
8.12k
      size += 9;
376
8.12k
      break;
377
      
378
0
    case XS_CODE_HOST:
379
0
      size += 3;
380
0
      break;
381
      
382
6.22M
    default:
383
6.22M
      size++;
384
6.22M
      break;
385
16.7M
    }
386
16.7M
    code = code->nextCode;
387
16.7M
#ifdef mxMetering
388
16.7M
    meterIndex++;
389
16.7M
#endif
390
16.7M
  }  
391
339k
#ifdef mxMetering
392
339k
  fxMeterSome(parser->console, meterIndex);
393
339k
#endif
394
395
339k
  code = coder.firstCode;
396
339k
  size = 0;
397
17.0M
  while (code) {
398
16.7M
    switch (code->id) {
399
665k
    case XS_NO_CODE:
400
665k
      ((txTargetCode*)code)->offset = size;
401
665k
      break;
402
40.6k
    case XS_CODE_BRANCH_1:
403
56.5k
    case XS_CODE_BRANCH_CHAIN_1:
404
273k
    case XS_CODE_BRANCH_COALESCE_1:
405
293k
    case XS_CODE_BRANCH_ELSE_1:
406
377k
    case XS_CODE_BRANCH_IF_1:
407
378k
    case XS_CODE_BRANCH_STATUS_1:
408
411k
    case XS_CODE_CATCH_1:
409
461k
    case XS_CODE_CODE_1:
410
461k
      offset = ((txBranchCode*)code)->target->offset - (size + 5);
411
461k
      if ((offset < -32768) || (offset + delta > 32767)) {
412
37.6k
        code->id += 2;
413
37.6k
        size += 5;
414
37.6k
      }
415
423k
      else if ((offset < -128) || (offset + delta > 127)) {
416
324k
        code->id += 1;
417
324k
        delta -= 2;
418
324k
        size += 3;
419
324k
      }
420
99.1k
      else {
421
99.1k
        delta -= 3;
422
99.1k
        size += 2;
423
99.1k
      }
424
461k
      break;
425
      
426
12.3k
    case XS_CODE_ARGUMENT:
427
12.7k
    case XS_CODE_ARGUMENTS:
428
13.6k
    case XS_CODE_ARGUMENTS_SLOPPY:
429
13.6k
    case XS_CODE_ARGUMENTS_STRICT:
430
170k
    case XS_CODE_BEGIN_SLOPPY:
431
172k
    case XS_CODE_BEGIN_STRICT:
432
173k
    case XS_CODE_BEGIN_STRICT_BASE:
433
174k
    case XS_CODE_BEGIN_STRICT_DERIVED:
434
175k
    case XS_CODE_BEGIN_STRICT_FIELD:
435
175k
    case XS_CODE_MODULE:
436
175k
      size += 2;
437
175k
      break;
438
507k
    case XS_CODE_LINE:
439
507k
      size += 3;
440
507k
      break;
441
546
    case XS_CODE_ASYNC_FUNCTION:
442
682
    case XS_CODE_ASYNC_GENERATOR_FUNCTION:
443
36.9k
    case XS_CODE_CONSTRUCTOR_FUNCTION:
444
40.0k
    case XS_CODE_DELETE_PROPERTY:
445
40.0k
    case XS_CODE_DELETE_SUPER:
446
201k
    case XS_CODE_FILE:
447
213k
    case XS_CODE_FUNCTION:
448
213k
    case XS_CODE_GENERATOR_FUNCTION:
449
599k
    case XS_CODE_GET_PROPERTY:
450
599k
    case XS_CODE_GET_SUPER:
451
622k
    case XS_CODE_GET_THIS_VARIABLE:
452
1.08M
    case XS_CODE_GET_VARIABLE:
453
1.08M
    case XS_CODE_EVAL_PRIVATE:
454
1.13M
    case XS_CODE_EVAL_REFERENCE:
455
1.14M
    case XS_CODE_NAME:
456
1.16M
    case XS_CODE_NEW_CLOSURE:
457
1.22M
    case XS_CODE_NEW_LOCAL:
458
1.29M
    case XS_CODE_NEW_PROPERTY:
459
1.54M
    case XS_CODE_PROGRAM_REFERENCE:
460
2.43M
    case XS_CODE_SET_PROPERTY:
461
2.43M
    case XS_CODE_SET_SUPER:
462
2.48M
    case XS_CODE_SET_VARIABLE:
463
2.48M
    case XS_CODE_SYMBOL:
464
2.48M
      symbol = ((txSymbolCode*)code)->symbol;
465
2.48M
      if (symbol && symbol->string)
466
2.45M
        symbol->usage |= 1;
467
2.48M
      size += 1 + sizeof(txID);
468
2.48M
      break;
469
49.7k
    case XS_CODE_PROFILE:
470
49.7k
      size += 1 + sizeof(txID);
471
49.7k
      break;
472
      
473
7.35k
    case XS_CODE_CONST_CLOSURE_1:
474
29.8k
    case XS_CODE_CONST_LOCAL_1:
475
48.4k
    case XS_CODE_GET_CLOSURE_1:
476
623k
    case XS_CODE_GET_LOCAL_1:
477
623k
    case XS_CODE_GET_PRIVATE_1:
478
623k
    case XS_CODE_HAS_PRIVATE_1:
479
625k
    case XS_CODE_LET_CLOSURE_1:
480
630k
    case XS_CODE_LET_LOCAL_1:
481
630k
    case XS_CODE_NEW_PRIVATE_1:
482
630k
    case XS_CODE_PULL_CLOSURE_1:
483
741k
    case XS_CODE_PULL_LOCAL_1:
484
741k
    case XS_CODE_REFRESH_CLOSURE_1:
485
741k
    case XS_CODE_REFRESH_LOCAL_1:
486
804k
    case XS_CODE_RESERVE_1:
487
804k
    case XS_CODE_RESET_CLOSURE_1:
488
804k
    case XS_CODE_RESET_LOCAL_1:
489
813k
    case XS_CODE_RETRIEVE_1:
490
815k
    case XS_CODE_SET_CLOSURE_1:
491
987k
    case XS_CODE_SET_LOCAL_1:
492
987k
    case XS_CODE_SET_PRIVATE_1:
493
1.21M
    case XS_CODE_STORE_1:
494
1.50M
    case XS_CODE_UNWIND_1:
495
1.50M
    case XS_CODE_USED_1:
496
1.51M
    case XS_CODE_VAR_CLOSURE_1:
497
1.54M
    case XS_CODE_VAR_LOCAL_1:
498
1.54M
      size += 2;
499
1.54M
      break;
500
3.45k
    case XS_CODE_CONST_CLOSURE_2:
501
3.53k
    case XS_CODE_CONST_LOCAL_2:
502
3.53k
    case XS_CODE_GET_CLOSURE_2:
503
920k
    case XS_CODE_GET_LOCAL_2:
504
920k
    case XS_CODE_GET_PRIVATE_2:
505
920k
    case XS_CODE_HAS_PRIVATE_2:
506
920k
    case XS_CODE_LET_CLOSURE_2:
507
920k
    case XS_CODE_LET_LOCAL_2:
508
920k
    case XS_CODE_NEW_PRIVATE_2:
509
920k
    case XS_CODE_PULL_CLOSURE_2:
510
941k
    case XS_CODE_PULL_LOCAL_2:
511
941k
    case XS_CODE_REFRESH_CLOSURE_2:
512
941k
    case XS_CODE_REFRESH_LOCAL_2:
513
941k
    case XS_CODE_RESERVE_2:
514
941k
    case XS_CODE_RESET_CLOSURE_2:
515
941k
    case XS_CODE_RESET_LOCAL_2:
516
941k
    case XS_CODE_RETRIEVE_2:
517
941k
    case XS_CODE_SET_CLOSURE_2:
518
1.30M
    case XS_CODE_SET_LOCAL_2:
519
1.30M
    case XS_CODE_SET_PRIVATE_2:
520
1.31M
    case XS_CODE_STORE_2:
521
1.31M
    case XS_CODE_UNWIND_2:
522
1.31M
    case XS_CODE_USED_2:
523
1.31M
    case XS_CODE_VAR_CLOSURE_2:
524
1.31M
    case XS_CODE_VAR_LOCAL_2:
525
1.31M
      size += 3;
526
1.31M
      break;
527
    
528
1.79M
    case XS_CODE_INTEGER_1: 
529
2.39M
    case XS_CODE_RUN_1: 
530
2.39M
    case XS_CODE_RUN_TAIL_1: 
531
2.39M
      size += 2;
532
2.39M
      break;
533
68.0k
    case XS_CODE_INTEGER_2: 
534
68.0k
    case XS_CODE_RUN_2: 
535
68.0k
    case XS_CODE_RUN_TAIL_2: 
536
68.0k
      size += 3;
537
68.0k
      break;
538
15.4k
    case XS_CODE_INTEGER_4: 
539
15.4k
    case XS_CODE_RUN_4: 
540
15.4k
    case XS_CODE_RUN_TAIL_4: 
541
15.4k
      size += 5;
542
15.4k
      break;
543
8.12k
    case XS_CODE_NUMBER:
544
8.12k
      size += 9;
545
8.12k
      break;
546
789k
    case XS_CODE_STRING_1:
547
789k
      size += 2 + ((txStringCode*)code)->length;
548
789k
      break;
549
7.91k
    case XS_CODE_STRING_2:
550
7.91k
      size += 3 + ((txStringCode*)code)->length;
551
7.91k
      break;
552
0
    case XS_CODE_STRING_4:
553
0
      size += 5 + ((txStringCode*)code)->length;
554
0
      break;
555
12.8k
    case XS_CODE_BIGINT_1:
556
12.8k
      size += 2 + fxBigIntMeasure(&((txBigIntCode*)code)->bigint);
557
12.8k
      break;
558
0
    case XS_CODE_BIGINT_2:
559
0
      size += 3 + fxBigIntMeasure(&((txBigIntCode*)code)->bigint);
560
0
      break;
561
      
562
0
    case XS_CODE_HOST:
563
0
      size += 3;
564
0
      break;
565
    
566
6.22M
    default:
567
6.22M
      size++;
568
6.22M
      break;
569
16.7M
    }
570
16.7M
    code = code->nextCode;
571
16.7M
  }  
572
  
573
339k
  node = parser->firstHostNode;
574
339k
  while (node) {
575
0
    if (node->symbol)
576
0
      node->symbol->usage |= 1;
577
0
    node = node->nextHostNode;
578
0
  }
579
  
580
339k
  address = parser->symbolTable;
581
339k
  c = parser->symbolModulo;
582
339k
  id = 1;
583
339k
  total = sizeof(txID);
584
676M
  for (i = 0; i < c; i++) {
585
676M
    txSymbol* symbol = *address;
586
696M
    while (symbol) {
587
20.3M
      if (symbol->usage & 1) {
588
836k
        symbol->ID = id;
589
836k
        id++;
590
836k
        total += symbol->length;
591
836k
      }
592
20.3M
      symbol = symbol->next;
593
20.3M
    }
594
676M
    address++;
595
676M
  }
596
339k
  count = id;
597
    
598
339k
  script->codeBuffer = c_malloc(size);
599
339k
  if (!script->codeBuffer) goto bail;
600
339k
  script->codeSize = size;
601
  
602
339k
  code = coder.firstCode;
603
339k
  p = script->codeBuffer;
604
17.0M
  while (code) {
605
16.7M
    txS1 s1; txS2 s2; txS4 s4; 
606
16.7M
    txU1 u1; txU2 u2;
607
16.7M
    txNumber n;
608
16.7M
    if (code->id)
609
16.0M
      *p++ = (txS1)(code->id);
610
16.7M
    switch (code->id) {
611
19.6k
    case XS_CODE_BRANCH_1:
612
24.8k
    case XS_CODE_BRANCH_CHAIN_1:
613
27.1k
    case XS_CODE_BRANCH_COALESCE_1:
614
38.2k
    case XS_CODE_BRANCH_ELSE_1:
615
54.9k
    case XS_CODE_BRANCH_IF_1:
616
55.5k
    case XS_CODE_BRANCH_STATUS_1:
617
63.1k
    case XS_CODE_CATCH_1:
618
99.1k
    case XS_CODE_CODE_1:
619
99.1k
      offset = mxPtrDiff(p + 1 - script->codeBuffer);
620
99.1k
      s1 = (txS1)(((txBranchCode*)code)->target->offset - offset);
621
99.1k
      *p++ = s1;
622
99.1k
      break;
623
16.8k
    case XS_CODE_BRANCH_2:
624
27.4k
    case XS_CODE_BRANCH_CHAIN_2:
625
229k
    case XS_CODE_BRANCH_COALESCE_2:
626
238k
    case XS_CODE_BRANCH_ELSE_2:
627
286k
    case XS_CODE_BRANCH_IF_2:
628
286k
    case XS_CODE_BRANCH_STATUS_2:
629
311k
    case XS_CODE_CATCH_2:
630
324k
    case XS_CODE_CODE_2:
631
324k
      offset = mxPtrDiff(p + 2 - script->codeBuffer);
632
324k
      s2 = (txS2)(((txBranchCode*)code)->target->offset - offset);
633
324k
      mxEncode2(p, s2);
634
324k
      break;
635
4.17k
    case XS_CODE_BRANCH_4:
636
4.27k
    case XS_CODE_BRANCH_CHAIN_4:
637
16.5k
    case XS_CODE_BRANCH_COALESCE_4:
638
16.5k
    case XS_CODE_BRANCH_ELSE_4:
639
36.4k
    case XS_CODE_BRANCH_IF_4:
640
36.4k
    case XS_CODE_BRANCH_STATUS_4:
641
36.7k
    case XS_CODE_CATCH_4:
642
37.6k
    case XS_CODE_CODE_4:
643
37.6k
      offset = mxPtrDiff(p + 4 - script->codeBuffer);
644
37.6k
      s4 = (txS4)(((txBranchCode*)code)->target->offset  - offset);
645
37.6k
      mxEncode4(p, s4);
646
37.6k
      break;
647
      
648
546
    case XS_CODE_ASYNC_FUNCTION:
649
682
    case XS_CODE_ASYNC_GENERATOR_FUNCTION:
650
36.9k
    case XS_CODE_CONSTRUCTOR_FUNCTION:
651
40.0k
    case XS_CODE_DELETE_PROPERTY:
652
40.0k
    case XS_CODE_DELETE_SUPER:
653
201k
    case XS_CODE_FILE:
654
213k
    case XS_CODE_FUNCTION:
655
213k
    case XS_CODE_GENERATOR_FUNCTION:
656
599k
    case XS_CODE_GET_PROPERTY:
657
599k
    case XS_CODE_GET_SUPER:
658
622k
    case XS_CODE_GET_THIS_VARIABLE:
659
1.08M
    case XS_CODE_GET_VARIABLE:
660
1.08M
    case XS_CODE_EVAL_PRIVATE:
661
1.13M
    case XS_CODE_EVAL_REFERENCE:
662
1.14M
    case XS_CODE_NAME:
663
1.16M
    case XS_CODE_NEW_CLOSURE:
664
1.22M
    case XS_CODE_NEW_LOCAL:
665
1.29M
    case XS_CODE_NEW_PROPERTY:
666
1.54M
    case XS_CODE_PROGRAM_REFERENCE:
667
2.43M
    case XS_CODE_SET_PROPERTY:
668
2.43M
    case XS_CODE_SET_SUPER:
669
2.48M
    case XS_CODE_SET_VARIABLE:
670
2.48M
    case XS_CODE_SYMBOL:
671
2.48M
      symbol = ((txSymbolCode*)code)->symbol;
672
2.48M
      if (symbol && symbol->string)
673
2.45M
        id = symbol->ID;
674
26.7k
      else
675
26.7k
        id = XS_NO_ID;
676
2.48M
      mxEncodeID(p, id);
677
2.48M
      break;
678
49.7k
    case XS_CODE_PROFILE:
679
49.7k
      id = fxGenerateProfileID(parser->console);
680
49.7k
      mxEncodeID(p, id);
681
49.7k
      break;
682
      
683
12.3k
    case XS_CODE_ARGUMENT:
684
12.7k
    case XS_CODE_ARGUMENTS:
685
13.6k
    case XS_CODE_ARGUMENTS_SLOPPY:
686
13.6k
    case XS_CODE_ARGUMENTS_STRICT:
687
170k
    case XS_CODE_BEGIN_SLOPPY:
688
172k
    case XS_CODE_BEGIN_STRICT:
689
173k
    case XS_CODE_BEGIN_STRICT_BASE:
690
174k
    case XS_CODE_BEGIN_STRICT_DERIVED:
691
175k
    case XS_CODE_BEGIN_STRICT_FIELD:
692
175k
    case XS_CODE_MODULE:
693
238k
    case XS_CODE_RESERVE_1:
694
246k
    case XS_CODE_RETRIEVE_1:
695
537k
    case XS_CODE_UNWIND_1:
696
537k
      u1 = (txU1)(((txIndexCode*)code)->index);
697
537k
      *((txU1*)p++) = u1;
698
537k
      break;
699
507k
    case XS_CODE_LINE:
700
507k
    case XS_CODE_RESERVE_2:
701
507k
    case XS_CODE_RETRIEVE_2:
702
507k
    case XS_CODE_UNWIND_2:
703
507k
      u2 = (txU2)(((txIndexCode*)code)->index);
704
507k
      mxEncode2(p, u2);
705
507k
      break;
706
707
7.35k
    case XS_CODE_CONST_CLOSURE_1:
708
29.8k
    case XS_CODE_CONST_LOCAL_1:
709
48.4k
    case XS_CODE_GET_CLOSURE_1:
710
623k
    case XS_CODE_GET_LOCAL_1:
711
623k
    case XS_CODE_GET_PRIVATE_1:
712
623k
    case XS_CODE_HAS_PRIVATE_1:
713
625k
    case XS_CODE_LET_CLOSURE_1:
714
630k
    case XS_CODE_LET_LOCAL_1:
715
630k
    case XS_CODE_NEW_PRIVATE_1:
716
630k
    case XS_CODE_PULL_CLOSURE_1:
717
741k
    case XS_CODE_PULL_LOCAL_1:
718
741k
    case XS_CODE_REFRESH_CLOSURE_1:
719
741k
    case XS_CODE_REFRESH_LOCAL_1:
720
741k
    case XS_CODE_RESET_CLOSURE_1:
721
742k
    case XS_CODE_RESET_LOCAL_1:
722
744k
    case XS_CODE_SET_CLOSURE_1:
723
916k
    case XS_CODE_SET_LOCAL_1:
724
916k
    case XS_CODE_SET_PRIVATE_1:
725
1.14M
    case XS_CODE_STORE_1:
726
1.14M
    case XS_CODE_USED_1:
727
1.15M
    case XS_CODE_VAR_CLOSURE_1:
728
1.18M
    case XS_CODE_VAR_LOCAL_1:
729
1.18M
      u1 = (txU1)(((txIndexCode*)code)->index + 1);
730
1.18M
      *((txU1*)p++) = u1;
731
1.18M
      break;
732
733
3.45k
    case XS_CODE_CONST_CLOSURE_2:
734
3.53k
    case XS_CODE_CONST_LOCAL_2:
735
3.53k
    case XS_CODE_GET_CLOSURE_2:
736
920k
    case XS_CODE_GET_LOCAL_2:
737
920k
    case XS_CODE_GET_PRIVATE_2:
738
920k
    case XS_CODE_HAS_PRIVATE_2:
739
920k
    case XS_CODE_LET_CLOSURE_2:
740
920k
    case XS_CODE_LET_LOCAL_2:
741
920k
    case XS_CODE_NEW_PRIVATE_2:
742
920k
    case XS_CODE_PULL_CLOSURE_2:
743
941k
    case XS_CODE_PULL_LOCAL_2:
744
941k
    case XS_CODE_REFRESH_CLOSURE_2:
745
941k
    case XS_CODE_REFRESH_LOCAL_2:
746
941k
    case XS_CODE_RESET_CLOSURE_2:
747
941k
    case XS_CODE_RESET_LOCAL_2:
748
941k
    case XS_CODE_SET_CLOSURE_2:
749
1.30M
    case XS_CODE_SET_LOCAL_2:
750
1.30M
    case XS_CODE_SET_PRIVATE_2:
751
1.31M
    case XS_CODE_STORE_2:
752
1.31M
    case XS_CODE_USED_2:
753
1.31M
    case XS_CODE_VAR_CLOSURE_2:
754
1.31M
    case XS_CODE_VAR_LOCAL_2:
755
1.31M
      u2 = (txU2)(((txIndexCode*)code)->index + 1);
756
1.31M
      mxEncode2(p, u2);
757
1.31M
      break;
758
  
759
1.79M
    case XS_CODE_INTEGER_1: 
760
2.39M
    case XS_CODE_RUN_1: 
761
2.39M
    case XS_CODE_RUN_TAIL_1: 
762
2.39M
      s1 = (txS1)(((txIntegerCode*)code)->integer);
763
2.39M
      *p++ = s1;
764
2.39M
      break;
765
68.0k
    case XS_CODE_INTEGER_2: 
766
68.0k
    case XS_CODE_RUN_2: 
767
68.0k
    case XS_CODE_RUN_TAIL_2: 
768
68.0k
      s2 = (txS2)(((txIntegerCode*)code)->integer);
769
68.0k
      mxEncode2(p, s2);
770
68.0k
      break;
771
15.4k
    case XS_CODE_INTEGER_4: 
772
15.4k
    case XS_CODE_RUN_4: 
773
15.4k
    case XS_CODE_RUN_TAIL_4: 
774
15.4k
      s4 = (txS4)(((txIntegerCode*)code)->integer);
775
15.4k
      mxEncode4(p, s4);
776
15.4k
      break;
777
8.12k
    case XS_CODE_NUMBER:
778
8.12k
      n = ((txNumberCode*)code)->number;
779
8.12k
      mxEncode8(p, n);
780
8.12k
      break;
781
789k
    case XS_CODE_STRING_1:
782
789k
      u1 = (txU1)(((txStringCode*)code)->length);
783
789k
      *((txU1*)p++) = u1;
784
789k
      c_memcpy(p, ((txStringCode*)code)->string, u1);
785
789k
      p += u1;
786
789k
      break;
787
7.91k
    case XS_CODE_STRING_2:
788
7.91k
      u2 = (txU2)(((txStringCode*)code)->length);
789
7.91k
      mxEncode2(p, u2);
790
7.91k
      c_memcpy(p, ((txStringCode*)code)->string, u2);
791
7.91k
      p += u2;
792
7.91k
      break;
793
0
    case XS_CODE_STRING_4:
794
0
      s4 = (txS4)(((txStringCode*)code)->length);
795
0
      mxEncode4(p, s4);
796
0
      c_memcpy(p, ((txStringCode*)code)->string, s4);
797
0
      p += s4;
798
0
      break;
799
12.8k
    case XS_CODE_BIGINT_1:
800
12.8k
      u1 = (txU1)fxBigIntMeasure(&((txBigIntCode*)code)->bigint);
801
12.8k
      *((txU1*)p++) = u1;
802
12.8k
      fxBigIntEncode(p, &((txBigIntCode*)code)->bigint, u1);
803
12.8k
      p += u1;
804
12.8k
      break;
805
0
    case XS_CODE_BIGINT_2:
806
0
      u2 = (txU2)fxBigIntMeasure(&((txBigIntCode*)code)->bigint);
807
0
            mxEncode2(p, u2);
808
0
      fxBigIntEncode(p, &((txBigIntCode*)code)->bigint, u2);
809
0
      p += u2;
810
0
      break;
811
      
812
0
    case XS_CODE_HOST:
813
0
      u2 = (txU2)(((txIndexCode*)code)->index);
814
0
      mxEncode2(p, u2);
815
0
      break;
816
16.7M
    }
817
16.7M
    code = code->nextCode;
818
16.7M
  }  
819
  
820
#ifdef mxCodePrint
821
  fprintf(stderr, "\n");
822
  code = coder.firstCode;
823
  while (code) {
824
    txInteger tab;
825
    for (tab = 0; tab < code->stackLevel; tab++)
826
      fprintf(stderr, "\t");
827
    switch (code->id) {
828
    case XS_NO_CODE:
829
      fprintf(stderr, "_%d\n", ((txTargetCode*)code)->index);
830
      break;
831
    
832
    case XS_CODE_BRANCH_1:
833
    case XS_CODE_BRANCH_2:
834
    case XS_CODE_BRANCH_4:
835
    case XS_CODE_BRANCH_CHAIN_1:
836
    case XS_CODE_BRANCH_CHAIN_2:
837
    case XS_CODE_BRANCH_CHAIN_4:
838
    case XS_CODE_BRANCH_COALESCE_1:
839
    case XS_CODE_BRANCH_COALESCE_2:
840
    case XS_CODE_BRANCH_COALESCE_4:
841
    case XS_CODE_BRANCH_ELSE_1:
842
    case XS_CODE_BRANCH_ELSE_2:
843
    case XS_CODE_BRANCH_ELSE_4:
844
    case XS_CODE_BRANCH_IF_1:
845
    case XS_CODE_BRANCH_IF_2:
846
    case XS_CODE_BRANCH_IF_4:
847
    case XS_CODE_BRANCH_STATUS_1:
848
    case XS_CODE_BRANCH_STATUS_2:
849
    case XS_CODE_BRANCH_STATUS_4:
850
    case XS_CODE_CATCH_1:
851
    case XS_CODE_CATCH_2:
852
    case XS_CODE_CATCH_4:
853
    case XS_CODE_CODE_1:
854
    case XS_CODE_CODE_2:
855
    case XS_CODE_CODE_4:
856
      fprintf(stderr, "%s _%d\n", gxCodeNames[code->id], ((txBranchCode*)code)->target->index);
857
      break;
858
    
859
    case XS_CODE_ARGUMENT:
860
    case XS_CODE_ARGUMENTS:
861
    case XS_CODE_ARGUMENTS_SLOPPY:
862
    case XS_CODE_ARGUMENTS_STRICT:
863
    case XS_CODE_BEGIN_SLOPPY:
864
    case XS_CODE_BEGIN_STRICT:
865
    case XS_CODE_BEGIN_STRICT_BASE:
866
    case XS_CODE_BEGIN_STRICT_DERIVED:
867
    case XS_CODE_BEGIN_STRICT_FIELD:
868
    case XS_CODE_LINE:
869
    case XS_CODE_MODULE:
870
      fprintf(stderr, "%s %d\n", gxCodeNames[code->id], ((txIndexCode*)code)->index);
871
      break;
872
      
873
    case XS_CODE_ASYNC_FUNCTION:
874
    case XS_CODE_ASYNC_GENERATOR_FUNCTION:
875
    case XS_CODE_CONSTRUCTOR_FUNCTION:
876
    case XS_CODE_DELETE_PROPERTY:
877
    case XS_CODE_DELETE_SUPER:
878
    case XS_CODE_FILE:
879
    case XS_CODE_FUNCTION:
880
    case XS_CODE_GENERATOR_FUNCTION:
881
    case XS_CODE_GET_PROPERTY:
882
    case XS_CODE_GET_SUPER:
883
    case XS_CODE_GET_THIS_VARIABLE:
884
    case XS_CODE_GET_VARIABLE:
885
    case XS_CODE_EVAL_PRIVATE:
886
    case XS_CODE_EVAL_REFERENCE:
887
    case XS_CODE_NAME:
888
    case XS_CODE_NEW_PROPERTY:
889
    case XS_CODE_PROGRAM_REFERENCE:
890
    case XS_CODE_SET_PROPERTY:
891
    case XS_CODE_SET_SUPER:
892
    case XS_CODE_SET_VARIABLE:
893
    case XS_CODE_SYMBOL:
894
      symbol = ((txSymbolCode*)code)->symbol;
895
      if (symbol && symbol->string)
896
        fprintf(stderr, "%s %s\n", gxCodeNames[code->id], symbol->string);
897
      else
898
        fprintf(stderr, "%s ?\n", gxCodeNames[code->id]);
899
      break;
900
    
901
    case XS_CODE_CONST_CLOSURE_1:
902
    case XS_CODE_CONST_CLOSURE_2:
903
    case XS_CODE_CONST_LOCAL_1:
904
    case XS_CODE_CONST_LOCAL_2:
905
    case XS_CODE_GET_CLOSURE_1:
906
    case XS_CODE_GET_CLOSURE_2:
907
    case XS_CODE_GET_LOCAL_1:
908
    case XS_CODE_GET_LOCAL_2:
909
    case XS_CODE_GET_PRIVATE_1:
910
    case XS_CODE_GET_PRIVATE_2:
911
    case XS_CODE_HAS_PRIVATE_1:
912
    case XS_CODE_HAS_PRIVATE_2:
913
    case XS_CODE_LET_CLOSURE_1:
914
    case XS_CODE_LET_CLOSURE_2:
915
    case XS_CODE_LET_LOCAL_1:
916
    case XS_CODE_LET_LOCAL_2:
917
    case XS_CODE_NEW_PRIVATE_1:
918
    case XS_CODE_NEW_PRIVATE_2:
919
    case XS_CODE_PULL_CLOSURE_1:
920
    case XS_CODE_PULL_CLOSURE_2:
921
    case XS_CODE_PULL_LOCAL_1:
922
    case XS_CODE_PULL_LOCAL_2:
923
    case XS_CODE_REFRESH_CLOSURE_1:
924
    case XS_CODE_REFRESH_CLOSURE_2:
925
    case XS_CODE_REFRESH_LOCAL_1:
926
    case XS_CODE_REFRESH_LOCAL_2:
927
    case XS_CODE_RESET_CLOSURE_1:
928
    case XS_CODE_RESET_CLOSURE_2:
929
    case XS_CODE_RESET_LOCAL_1:
930
    case XS_CODE_RESET_LOCAL_2:
931
    case XS_CODE_SET_CLOSURE_1:
932
    case XS_CODE_SET_CLOSURE_2:
933
    case XS_CODE_SET_LOCAL_1:
934
    case XS_CODE_SET_LOCAL_2:
935
    case XS_CODE_SET_PRIVATE_1:
936
    case XS_CODE_SET_PRIVATE_2:
937
    case XS_CODE_STORE_1:
938
    case XS_CODE_STORE_2:
939
    case XS_CODE_USED_1:
940
    case XS_CODE_USED_2:
941
    case XS_CODE_VAR_CLOSURE_1:
942
    case XS_CODE_VAR_CLOSURE_2:
943
    case XS_CODE_VAR_LOCAL_1:
944
    case XS_CODE_VAR_LOCAL_2:
945
      fprintf(stderr, "%s [%d]\n", gxCodeNames[code->id], ((txIndexCode*)code)->index);
946
      break;
947
    
948
    case XS_CODE_RESERVE_1:
949
    case XS_CODE_RESERVE_2:
950
    case XS_CODE_UNWIND_1:
951
    case XS_CODE_UNWIND_2:
952
      fprintf(stderr, "%s #%d\n", gxCodeNames[code->id], ((txIndexCode*)code)->index);
953
      break;
954
    case XS_CODE_NEW_CLOSURE:
955
    case XS_CODE_NEW_LOCAL:
956
      fprintf(stderr, "[%d] %s %s\n", ((txVariableCode*)code)->index, gxCodeNames[code->id], ((txSymbolCode*)code)->symbol->string);
957
      break;
958
    case XS_CODE_NEW_TEMPORARY:
959
      fprintf(stderr, "[%d] %s\n", ((txIndexCode*)code)->index, gxCodeNames[code->id]);
960
      break;
961
    case XS_CODE_RETRIEVE_1:
962
    case XS_CODE_RETRIEVE_2:
963
      {
964
        txInteger i, c = ((txIndexCode*)code)->index;
965
        fprintf(stderr, "[0");
966
        for (i = 1; i < c; i++)
967
          fprintf(stderr, ",%d", i);
968
        fprintf(stderr, "] %s\n", gxCodeNames[code->id]);
969
      }
970
      break;
971
    
972
    case XS_CODE_INTEGER_1: 
973
    case XS_CODE_INTEGER_2: 
974
    case XS_CODE_INTEGER_4: 
975
    case XS_CODE_RUN_1: 
976
    case XS_CODE_RUN_2: 
977
    case XS_CODE_RUN_4: 
978
    case XS_CODE_RUN_TAIL_1: 
979
    case XS_CODE_RUN_TAIL_2: 
980
    case XS_CODE_RUN_TAIL_4: 
981
      fprintf(stderr, "%s %d\n", gxCodeNames[code->id], ((txIntegerCode*)code)->integer);
982
      break;
983
    case XS_CODE_NUMBER:
984
      fprintf(stderr, "%s %lf\n", gxCodeNames[code->id], ((txNumberCode*)code)->number);
985
      break;
986
    case XS_CODE_STRING_1:
987
    case XS_CODE_STRING_2:
988
    case XS_CODE_STRING_4:
989
      fprintf(stderr, "%s %d \"%s\"\n", gxCodeNames[code->id], ((txStringCode*)code)->length, ((txStringCode*)code)->string);
990
      break;
991
    case XS_CODE_BIGINT_1:
992
    case XS_CODE_BIGINT_2:
993
      fprintf(stderr, "%s %d\n", gxCodeNames[code->id], fxBigIntMeasure(&((txBigIntCode*)code)->bigint));
994
      break;
995
      
996
    case XS_CODE_HOST:
997
      fprintf(stderr, "%s %d\n", gxCodeNames[code->id], ((txIndexCode*)code)->index);
998
      break;
999
  
1000
    default:
1001
      fprintf(stderr, "%s\n", gxCodeNames[code->id]);
1002
      break;
1003
    }
1004
    code = code->nextCode;
1005
  }
1006
#endif
1007
339k
  script->symbolsBuffer = c_malloc(total);
1008
339k
  if (!script->symbolsBuffer) goto bail;
1009
339k
  script->symbolsSize = total;
1010
  
1011
339k
  p = script->symbolsBuffer;
1012
339k
  mxEncodeID(p, count);
1013
  
1014
339k
  address = parser->symbolTable;
1015
339k
  c = parser->symbolModulo;
1016
676M
  for (i = 0; i < c; i++) {
1017
676M
    txSymbol* symbol = *address;
1018
696M
    while (symbol) {
1019
20.3M
      if (symbol->usage & 1) {
1020
836k
        c_memcpy(p, symbol->string, symbol->length);
1021
836k
        p += symbol->length;
1022
836k
      }
1023
20.3M
      symbol = symbol->next;
1024
20.3M
    }
1025
676M
    address++;
1026
676M
  }
1027
  
1028
339k
  c = (txS2)(parser->hostNodeIndex);
1029
339k
  if (c) {
1030
0
    size = sizeof(txID);
1031
0
    node = parser->firstHostNode;
1032
0
    while (node) {
1033
0
      size += 1 + sizeof(txID) + node->at->length + 1;
1034
0
      node = node->nextHostNode;
1035
0
    }
1036
  
1037
0
    script->hostsBuffer = c_malloc(size);
1038
0
    if (!script->hostsBuffer) goto bail;
1039
0
    script->hostsSize = size;
1040
  
1041
0
    p = script->hostsBuffer;
1042
0
    mxEncodeID(p, c);
1043
0
    node = parser->firstHostNode;
1044
0
    while (node) {
1045
0
      *p++ = (txS1)(node->paramsCount);
1046
0
      if (node->symbol)
1047
0
        c = node->symbol->ID;
1048
0
      else
1049
0
        c = XS_NO_ID;
1050
0
      mxEncodeID(p, c);
1051
0
      c_memcpy(p, node->at->value, node->at->length);
1052
0
      p += node->at->length;
1053
0
      *p++ = 0;
1054
0
      node = node->nextHostNode;
1055
0
    }
1056
0
  }
1057
1058
339k
  return script;
1059
0
bail:
1060
0
  fxDeleteScript(script);
1061
0
  return C_NULL;
1062
339k
}
1063
1064
void fxCoderAdd(txCoder* self, txInteger delta, void* it)
1065
16.9M
{
1066
16.9M
  txByteCode* code = it;
1067
16.9M
  if (self->lastCode)
1068
16.6M
    self->lastCode->nextCode = code;
1069
343k
  else
1070
343k
    self->firstCode = code;
1071
16.9M
  self->lastCode = code;
1072
16.9M
  self->stackLevel += delta;
1073
16.9M
  code->stackLevel = self->stackLevel;
1074
//  if (self->stackLevel < 0)
1075
//    c_fprintf(stderr, "# oops %d\n", code->id);   //@@
1076
16.9M
}
1077
1078
void fxCoderAddBigInt(txCoder* self, txInteger delta, txInteger id, txBigInt* bigint)
1079
13.8k
{
1080
13.8k
  txBigIntCode* code = fxNewParserChunkClear(self->parser, sizeof(txBigIntCode));
1081
13.8k
  fxCoderAdd(self, delta, code);
1082
13.8k
  code->id = id;
1083
13.8k
  code->bigint = *bigint;
1084
13.8k
}
1085
1086
void fxCoderAddBranch(txCoder* self, txInteger delta, txInteger id, txTargetCode* target)
1087
497k
{
1088
497k
  txBranchCode* code = fxNewParserChunkClear(self->parser, sizeof(txBranchCode));
1089
497k
  fxCoderAdd(self, delta, code);
1090
497k
  code->id = id;
1091
497k
  code->target = target;
1092
497k
  target->used = 1;
1093
497k
}
1094
1095
void fxCoderAddByte(txCoder* self, txInteger delta, txInteger id)
1096
5.73M
{
1097
5.73M
  txByteCode* code = fxNewParserChunkClear(self->parser, sizeof(txByteCode));
1098
5.73M
  fxCoderAdd(self, delta, code);
1099
5.73M
  code->id = id;
1100
5.73M
}
1101
1102
void fxCoderAddIndex(txCoder* self, txInteger delta, txInteger id, txInteger index)
1103
4.20M
{
1104
4.20M
  txIndexCode* code = fxNewParserChunkClear(self->parser, sizeof(txIndexCode));
1105
4.20M
  fxCoderAdd(self, delta, code);
1106
4.20M
  code->id = id;
1107
4.20M
  code->index = index;
1108
4.20M
}
1109
1110
void fxCoderAddInteger(txCoder* self, txInteger delta, txInteger id, txInteger integer)
1111
2.48M
{
1112
2.48M
  txIntegerCode* code = fxNewParserChunkClear(self->parser, sizeof(txIntegerCode));
1113
2.48M
  fxCoderAdd(self, delta, code);
1114
2.48M
  code->id = id;
1115
2.48M
  code->integer = integer;
1116
2.48M
}
1117
1118
void fxCoderAddLine(txCoder* self, txInteger delta, txInteger id, txNode* node)
1119
2.48M
{
1120
2.48M
  if (self->parser->flags & mxDebugFlag) {
1121
2.48M
    if (self->parser->lines) {
1122
0
      if (node->path != self->parser->path) {
1123
0
        node->path = self->parser->path;
1124
0
        node->line = self->parser->lines[node->line];
1125
0
      }
1126
0
    }
1127
2.48M
    else if (self->parser->source) {
1128
2.48M
      node->path = self->parser->source;
1129
2.48M
    }
1130
2.48M
    if (self->path != node->path) {
1131
167k
      if (node->path) {
1132
167k
        fxCoderAddSymbol(self, 0, XS_CODE_FILE, node->path);
1133
167k
        fxCoderAddIndex(self, 0, id, node->line);
1134
167k
      }
1135
167k
      self->path = node->path;
1136
167k
      self->line = node->line;
1137
167k
    }
1138
2.31M
    else if (self->line != node->line) {
1139
392k
      if (self->path) {
1140
392k
        txIndexCode* code = (txIndexCode*)self->lastCode;
1141
392k
        if (code && (code->id == id) && (code->index != 0))
1142
82.6k
          code->index = node->line;
1143
309k
        else
1144
309k
          fxCoderAddIndex(self, 0, id, node->line);
1145
392k
      }
1146
392k
      self->line = node->line;
1147
392k
    }
1148
2.48M
  }
1149
2.48M
}
1150
1151
void fxCoderAddNumber(txCoder* self, txInteger delta, txInteger id, txNumber number)
1152
8.12k
{
1153
8.12k
  txNumberCode* code = fxNewParserChunkClear(self->parser, sizeof(txNumberCode));
1154
8.12k
  fxCoderAdd(self, delta, code);
1155
8.12k
  code->id = id;
1156
8.12k
  code->number = number;
1157
8.12k
}
1158
1159
void fxCoderAddString(txCoder* self, txInteger delta, txInteger id, txInteger length, txString string)
1160
797k
{
1161
797k
  txStringCode* code = fxNewParserChunkClear(self->parser, sizeof(txStringCode));
1162
797k
  fxCoderAdd(self, delta, code);
1163
797k
  code->id = id;
1164
797k
  code->length = length + 1;
1165
797k
  code->string = string;
1166
797k
}
1167
1168
void fxCoderAddSymbol(txCoder* self, txInteger delta, txInteger id, txSymbol* symbol)
1169
2.43M
{
1170
2.43M
  txSymbolCode* code = fxNewParserChunkClear(self->parser, sizeof(txSymbolCode));
1171
2.43M
  fxCoderAdd(self, delta, code);
1172
2.43M
  code->id = id;
1173
2.43M
  code->symbol = symbol;
1174
2.43M
}
1175
1176
void fxCoderAddVariable(txCoder* self, txInteger delta, txInteger id, txSymbol* symbol, txInteger index)
1177
92.1k
{
1178
92.1k
  txVariableCode* code = fxNewParserChunkClear(self->parser, sizeof(txVariableCode));
1179
92.1k
  fxCoderAdd(self, delta, code);
1180
92.1k
  code->id = id;
1181
92.1k
  code->symbol = symbol;
1182
92.1k
  code->index = index;
1183
92.1k
}
1184
1185
void fxCoderAdjustEnvironment(txCoder* self, txTargetCode* target)
1186
16.7k
{
1187
16.7k
  txInteger count = self->environmentLevel - target->environmentLevel;
1188
23.3k
  while (count) {
1189
6.61k
    fxCoderAddByte(self, 0, XS_CODE_WITHOUT);
1190
6.61k
    count--;
1191
6.61k
  }
1192
16.7k
}
1193
1194
void fxCoderAdjustScope(txCoder* self, txTargetCode* target)
1195
16.7k
{
1196
16.7k
  txInteger count = self->scopeLevel - target->scopeLevel;
1197
16.7k
  if (count)
1198
4.74k
    fxCoderAddIndex(self, 0, XS_CODE_UNWIND_1, count);
1199
16.7k
}
1200
1201
txTargetCode* fxCoderAliasTargets(txCoder* self, txTargetCode* target)
1202
35.5k
{
1203
35.5k
  txTargetCode* result = NULL;
1204
35.5k
  if (target) {
1205
28.1k
    txTargetCode* alias = result = fxNewParserChunkClear(self->parser, sizeof(txTargetCode));
1206
28.1k
    alias->index = self->targetIndex++;
1207
28.1k
    alias->label = target->label;
1208
28.1k
    alias->environmentLevel = self->environmentLevel;
1209
28.1k
    alias->scopeLevel = self->scopeLevel;
1210
28.1k
    alias->stackLevel = self->stackLevel;
1211
28.1k
    alias->original = target;
1212
28.1k
    target = target->nextTarget;
1213
57.4k
    while (target) {
1214
29.2k
      alias = alias->nextTarget = fxNewParserChunkClear(self->parser, sizeof(txTargetCode));
1215
29.2k
      alias->index = self->targetIndex++;
1216
29.2k
      alias->label = target->label;
1217
29.2k
      alias->environmentLevel = self->environmentLevel;
1218
29.2k
      alias->scopeLevel = self->scopeLevel;
1219
29.2k
      alias->stackLevel = self->stackLevel;
1220
29.2k
      alias->original = target;
1221
29.2k
      target = target->nextTarget;
1222
29.2k
    }
1223
28.1k
  }
1224
35.5k
  return result;
1225
35.5k
}
1226
1227
txInteger fxCoderCountParameters(txCoder* self, txNode* params)
1228
53.0k
{
1229
53.0k
  txNode* item = ((txParamsBindingNode*)params)->items->first;
1230
53.0k
  txInteger count = 0;
1231
66.4k
  while (item) {
1232
13.7k
    if (item->description->token == XS_TOKEN_REST_BINDING)
1233
391
      break;
1234
13.3k
    if ((item->description->token != XS_TOKEN_ARG) && (item->description->token != XS_TOKEN_ARRAY_BINDING) && (item->description->token != XS_TOKEN_OBJECT_BINDING))
1235
27
      break;
1236
13.3k
    count++;
1237
13.3k
    item = item->next;
1238
13.3k
  }
1239
53.0k
  return count;
1240
53.0k
}
1241
1242
txTargetCode* fxCoderCreateTarget(txCoder* self)
1243
685k
{
1244
685k
  txTargetCode* result = fxNewParserChunkClear(self->parser, sizeof(txTargetCode));
1245
685k
  result->index = self->targetIndex++;
1246
685k
  result->environmentLevel = self->environmentLevel;
1247
685k
  result->scopeLevel = self->scopeLevel;
1248
685k
  result->stackLevel = self->stackLevel;
1249
685k
  return result;
1250
685k
}
1251
1252
txTargetCode* fxCoderFinalizeTargets(txCoder* self, txTargetCode* alias, txInteger selector, txInteger* address, txTargetCode* finallyTarget)
1253
32.4k
{
1254
32.4k
  txTargetCode* result = NULL;
1255
32.4k
  txInteger selection = *address;
1256
32.4k
  if (alias) {
1257
27.0k
    result = alias->original;
1258
83.4k
    while (alias) {
1259
56.3k
      if (alias->used) {
1260
39
        fxCoderAdd(self, 0, alias);
1261
39
        fxCoderAddInteger(self, 1, XS_CODE_INTEGER_1, selection);
1262
39
        fxCoderAddIndex(self, -1, XS_CODE_PULL_LOCAL_1, selector);
1263
39
        fxCoderAddBranch(self, 0, XS_CODE_BRANCH_1, finallyTarget);
1264
39
        alias->original->used = 1;
1265
39
      }
1266
56.3k
      alias = alias->nextTarget;
1267
56.3k
      selection++;
1268
56.3k
    }
1269
27.0k
  }
1270
32.4k
  *address = selection;
1271
32.4k
  return result;
1272
32.4k
}
1273
1274
void fxCoderJumpTargets(txCoder* self, txTargetCode* target, txInteger selector, txInteger* address)
1275
32.4k
{
1276
32.4k
  txInteger selection = *address;
1277
88.8k
  while (target) {
1278
56.3k
    if (target->used) {
1279
3.13k
      txTargetCode* elseTarget = fxCoderCreateTarget(self);
1280
3.13k
      fxCoderAddInteger(self, 1, XS_CODE_INTEGER_1, selection);
1281
3.13k
      fxCoderAddIndex(self, 1, XS_CODE_GET_LOCAL_1, selector);
1282
3.13k
      fxCoderAddByte(self, -1, XS_CODE_STRICT_EQUAL);
1283
3.13k
      fxCoderAddBranch(self, -1, XS_CODE_BRANCH_ELSE_1, elseTarget);
1284
3.13k
      fxCoderAdjustEnvironment(self, target);
1285
3.13k
      fxCoderAdjustScope(self, target);
1286
3.13k
      fxCoderAddBranch(self, 0, XS_CODE_BRANCH_1, target);
1287
3.13k
      fxCoderAdd(self, 0, elseTarget);
1288
3.13k
    }
1289
56.3k
    target = target->nextTarget;
1290
56.3k
    selection++;
1291
56.3k
  }
1292
32.4k
  *address = selection;
1293
32.4k
}
1294
1295
void fxCoderOptimize(txCoder* self)
1296
339k
{
1297
339k
  txByteCode** address;
1298
339k
  txByteCode* code;
1299
  
1300
  // branch to (target | unwind)* end => end
1301
339k
  address = &self->firstCode;
1302
17.1M
  while ((code = *address)) {
1303
16.7M
    if (code->id == XS_CODE_BRANCH_1) {
1304
67.4k
      txByteCode* nextCode = ((txBranchCode*)code)->target->nextCode;
1305
68.7k
      while ((nextCode->id == XS_NO_CODE) || (nextCode->id == XS_CODE_UNWIND_1))
1306
1.24k
        nextCode = nextCode->nextCode;
1307
67.4k
      if ((XS_CODE_END <= nextCode->id) && (nextCode->id <= XS_CODE_END_DERIVED)) {
1308
16.6k
        txByteCode* end = fxNewParserChunkClear(self->parser, sizeof(txByteCode));
1309
16.6k
        end->nextCode = code->nextCode;
1310
16.6k
        end->id = nextCode->id;
1311
16.6k
        end->stackLevel = code->stackLevel;
1312
16.6k
        *address = end;
1313
16.6k
      }
1314
50.7k
      else
1315
50.7k
        address = &code->nextCode;
1316
67.4k
    }
1317
16.7M
    else
1318
16.7M
      address = &code->nextCode;
1319
16.7M
  }
1320
  // unwind (target | unwind)* end => (target | unwind)* end
1321
339k
  address = &self->firstCode;
1322
17.1M
  while ((code = *address)) {
1323
16.7M
    if (code->id == XS_CODE_UNWIND_1) {
1324
302k
      txByteCode* nextCode = code->nextCode;
1325
326k
      while ((nextCode->id == XS_NO_CODE) || (nextCode->id == XS_CODE_UNWIND_1))
1326
23.9k
        nextCode = nextCode->nextCode;
1327
302k
      if ((XS_CODE_END <= nextCode->id) && (nextCode->id <= XS_CODE_END_DERIVED))
1328
10.9k
        *address = code->nextCode;
1329
291k
      else
1330
291k
        address = &code->nextCode;
1331
302k
    }
1332
16.4M
    else
1333
16.4M
      address = &code->nextCode;
1334
16.7M
  }
1335
  // end target* end => target* end
1336
339k
  address = &self->firstCode;
1337
17.0M
  while ((code = *address)) {
1338
16.7M
    if ((XS_CODE_END <= code->id) && (code->id <= XS_CODE_END_DERIVED)) {
1339
66.6k
      txByteCode* nextCode = code->nextCode;
1340
66.6k
      if (!nextCode)
1341
230
        break;
1342
130k
      while (nextCode->id == XS_NO_CODE)
1343
64.0k
        nextCode = nextCode->nextCode;
1344
66.4k
      if (nextCode->id == code->id)
1345
10.3k
        *address = code->nextCode;
1346
56.0k
      else
1347
56.0k
        address = &code->nextCode;
1348
66.4k
    }
1349
16.6M
    else
1350
16.6M
      address = &code->nextCode;
1351
16.7M
  }
1352
  // branch to next =>
1353
339k
  address = &self->firstCode;
1354
17.0M
  while ((code = *address)) {
1355
16.7M
    if (code->id == XS_CODE_BRANCH_1) {
1356
50.7k
      if (code->nextCode == (txByteCode*)(((txBranchCode*)code)->target))
1357
10.1k
        *address = code->nextCode;
1358
40.6k
      else
1359
40.6k
        address = &code->nextCode;
1360
50.7k
    }
1361
16.6M
    else
1362
16.6M
      address = &code->nextCode;
1363
16.7M
  }
1364
339k
}
1365
1366
txInteger fxCoderUseTemporaryVariable(txCoder* self)
1367
592k
{
1368
592k
  txInteger result = self->scopeLevel++;
1369
592k
  fxCoderAddIndex(self, 0, XS_CODE_NEW_TEMPORARY, result);
1370
592k
  return result;
1371
592k
}
1372
1373
void fxCoderUnuseTemporaryVariables(txCoder* self, txInteger count)
1374
286k
{
1375
286k
  fxCoderAddIndex(self, 0, XS_CODE_UNWIND_1, count);
1376
286k
  self->scopeLevel -= count;
1377
286k
}
1378
1379
void fxScopeCoded(txScope* self, txCoder* coder) 
1380
73.1k
{
1381
73.1k
  if (self->declareNodeCount) {
1382
10.5k
    if (self->flags & mxEvalFlag) {
1383
3.07k
      coder->environmentLevel--;
1384
3.07k
      fxCoderAddByte(coder, 0, XS_CODE_WITHOUT);
1385
3.07k
    }
1386
10.5k
    fxCoderAddIndex(coder, 0, XS_CODE_UNWIND_1, self->declareNodeCount);
1387
10.5k
    coder->scopeLevel -= self->declareNodeCount;
1388
10.5k
  }
1389
73.1k
}
1390
1391
void fxScopeCodedBody(txScope* self, txCoder* coder) 
1392
50.5k
{
1393
50.5k
  txScope* functionScope = self->scope;
1394
50.5k
  if ((functionScope->node->flags & mxEvalFlag) && !(functionScope->node->flags & mxStrictFlag)) {
1395
1.03k
    coder->environmentLevel--;
1396
1.03k
    fxCoderAddByte(coder, 0, XS_CODE_WITHOUT);
1397
1.03k
    coder->environmentLevel--;
1398
1.03k
    fxCoderAddByte(coder, 0, XS_CODE_WITHOUT);
1399
1.03k
    fxCoderAddIndex(coder, 0, XS_CODE_UNWIND_1, self->declareNodeCount);
1400
1.03k
    coder->scopeLevel -= self->declareNodeCount;
1401
1.03k
  }
1402
49.4k
  else 
1403
49.4k
    fxScopeCoded(self, coder);
1404
50.5k
}
1405
1406
void fxScopeCodingBlock(txScope* self, txCoder* coder) 
1407
78.4k
{
1408
78.4k
  if (self->declareNodeCount) {
1409
14.2k
    txDeclareNode* node = self->firstDeclareNode;
1410
41.9k
    while (node) {
1411
27.6k
      if (node->flags & mxDeclareNodeClosureFlag) {
1412
16.7k
        if (!(node->flags & mxDeclareNodeUseClosureFlag)) {
1413
16.7k
          node->index = coder->scopeLevel++;
1414
16.7k
          fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1415
16.7k
          if (node->description->token == XS_TOKEN_VAR) {
1416
4.43k
            fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1417
4.43k
            fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1418
4.43k
            fxCoderAddByte(coder, -1, XS_CODE_POP);
1419
4.43k
          }
1420
16.7k
        }
1421
16.7k
      }
1422
10.9k
      else {
1423
10.9k
        node->index = coder->scopeLevel++;
1424
10.9k
        if (node->symbol)
1425
9.89k
          fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1426
1.01k
        else
1427
1.01k
          fxCoderAddIndex(coder, 0, XS_CODE_NEW_TEMPORARY, node->index);
1428
10.9k
        if (node->description->token == XS_TOKEN_VAR) {
1429
3.54k
          fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1430
3.54k
          fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1431
3.54k
          fxCoderAddByte(coder, -1, XS_CODE_POP);
1432
3.54k
        }
1433
10.9k
      }
1434
27.6k
      node = node->nextDeclareNode;
1435
27.6k
    }
1436
14.2k
    if (self->flags & mxEvalFlag) {
1437
3.07k
      fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1438
3.07k
      fxCoderAddByte(coder, 0, XS_CODE_WITH);
1439
3.07k
      node = self->firstDeclareNode;
1440
11.7k
      while (node) {
1441
8.64k
        fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1442
8.64k
        node = node->nextDeclareNode;
1443
8.64k
      }
1444
3.07k
      fxCoderAddByte(coder, -1, XS_CODE_POP);
1445
3.07k
      coder->environmentLevel++;
1446
3.07k
    }
1447
14.2k
  }
1448
78.4k
}
1449
1450
void fxScopeCodingBody(txScope* self, txCoder* coder) 
1451
53.0k
{
1452
53.0k
  if ((self->node->flags & mxEvalFlag) && !(self->node->flags & mxStrictFlag)) {
1453
1.03k
    txDeclareNode* node = self->firstDeclareNode;
1454
1.52k
    while (node) {
1455
490
      if (node->description->token == XS_TOKEN_DEFINE) {
1456
19
        node->index = coder->scopeLevel++;
1457
19
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1458
19
        fxCoderAddByte(coder, 1, XS_CODE_NULL);
1459
19
        fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1460
19
        fxCoderAddByte(coder, -1, XS_CODE_POP);
1461
19
      }
1462
471
      else if (node->description->token == XS_TOKEN_VAR) {
1463
84
        node->index = coder->scopeLevel++;
1464
84
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1465
84
        fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1466
84
        fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, node->index);
1467
84
        fxCoderAddByte(coder, -1, XS_CODE_POP);
1468
84
      }
1469
490
      node = node->nextDeclareNode;
1470
490
    }
1471
1.03k
    fxCoderAddByte(coder, 1, XS_CODE_NULL);
1472
1.03k
    fxCoderAddByte(coder, 0, XS_CODE_WITH);
1473
1.03k
    node = self->firstDeclareNode;
1474
1.52k
    while (node) {
1475
490
      if ((node->description->token == XS_TOKEN_DEFINE) || (node->description->token == XS_TOKEN_VAR))
1476
103
        fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1477
490
      node = node->nextDeclareNode;
1478
490
    }
1479
1.03k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
1480
1.03k
    coder->environmentLevel++;
1481
1.03k
    node = self->firstDeclareNode;
1482
1.52k
    while (node) {
1483
490
      if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1484
387
        node->index = coder->scopeLevel++;
1485
387
        if (node->symbol)
1486
387
          fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1487
0
        else
1488
0
          fxCoderAddIndex(coder, 0, XS_CODE_NEW_TEMPORARY, node->index);
1489
387
      }
1490
490
      node = node->nextDeclareNode;
1491
490
    }
1492
1.03k
    fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1493
1.03k
    fxCoderAddByte(coder, 0, XS_CODE_WITH);
1494
1.03k
    node = self->firstDeclareNode;
1495
1.52k
    while (node) {
1496
490
      if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1497
387
        if (node->symbol)
1498
387
          fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1499
387
      }
1500
490
      node = node->nextDeclareNode;
1501
490
    }
1502
1.03k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
1503
1.03k
    coder->environmentLevel++;
1504
1.03k
  }
1505
52.0k
  else 
1506
52.0k
    fxScopeCodingBlock(self, coder);
1507
53.0k
}
1508
1509
void fxScopeCodingEval(txScope* self, txCoder* coder) 
1510
76.2k
{
1511
76.2k
  txProgramNode* programNode = (txProgramNode*)self->node;
1512
76.2k
  txDeclareNode* node;
1513
76.2k
  if (self->flags & mxStrictFlag) {
1514
739
    if (programNode->scopeCount) {
1515
697
      fxCoderAddIndex(coder, 0, XS_CODE_RESERVE_1, programNode->scopeCount);
1516
697
      fxScopeCodingBlock(self, coder);
1517
697
      node = self->firstDeclareNode;
1518
1.99k
      while (node) {
1519
1.30k
        if (node->description->token == XS_TOKEN_PRIVATE) {
1520
0
          fxCoderAddSymbol(coder, 1, XS_CODE_EVAL_PRIVATE, node->symbol);
1521
0
          fxCoderAddIndex(coder, 0, XS_CODE_CONST_CLOSURE_1, node->index);
1522
0
          fxCoderAddByte(coder, -1, XS_CODE_POP);
1523
0
        }
1524
1.30k
        node = node->nextDeclareNode;
1525
1.30k
      }
1526
697
    }
1527
739
  }
1528
75.5k
  else {
1529
75.5k
    txInteger count = 0;
1530
75.5k
    node = self->firstDeclareNode;
1531
80.8k
    while (node) {
1532
5.32k
      if ((node->description->token == XS_TOKEN_DEFINE) || (node->description->token == XS_TOKEN_VAR))
1533
2.63k
        count++;
1534
5.32k
      node = node->nextDeclareNode;
1535
5.32k
    }
1536
75.5k
    if (count) {
1537
1.67k
      fxCoderAddIndex(coder, 0, XS_CODE_RESERVE_1, count);
1538
1.67k
      node = self->firstDeclareNode;
1539
5.22k
      while (node) {
1540
3.55k
        if (node->description->token == XS_TOKEN_DEFINE) {
1541
0
          node->index = coder->scopeLevel++;
1542
0
          fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1543
0
          fxCoderAddByte(coder, 1, XS_CODE_NULL);
1544
0
          fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1545
0
          fxCoderAddByte(coder, -1, XS_CODE_POP);
1546
0
        }
1547
3.55k
        else if (node->description->token == XS_TOKEN_VAR) {
1548
2.63k
          node->index = coder->scopeLevel++;
1549
2.63k
          fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1550
2.63k
          fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1551
2.63k
          fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1552
2.63k
          fxCoderAddByte(coder, -1, XS_CODE_POP);
1553
2.63k
        }
1554
3.55k
        node = node->nextDeclareNode;
1555
3.55k
      }
1556
1.67k
    }
1557
75.5k
    fxCoderAddByte(coder, 0, XS_CODE_EVAL_ENVIRONMENT);
1558
75.5k
    coder->scopeLevel = 0;
1559
75.5k
    if (programNode->scopeCount) {
1560
3.61k
      fxCoderAddIndex(coder, 0, XS_CODE_RESERVE_1, programNode->scopeCount);
1561
3.61k
      if (self->declareNodeCount) {
1562
2.50k
        node = self->firstDeclareNode;
1563
6.43k
        while (node) {
1564
3.93k
          if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1565
2.69k
            node->index = coder->scopeLevel++;
1566
2.69k
            if (node->flags & mxDeclareNodeClosureFlag) {
1567
408
              fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1568
408
            }
1569
2.28k
            else {
1570
2.28k
              fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1571
2.28k
            }
1572
2.69k
          }
1573
3.93k
          node = node->nextDeclareNode;
1574
3.93k
        }
1575
2.50k
        if (self->flags & mxEvalFlag) {
1576
0
          fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1577
0
          fxCoderAddByte(coder, 0, XS_CODE_WITH);
1578
0
          node = self->firstDeclareNode;
1579
0
          while (node) {
1580
0
            if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR))
1581
0
              fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1582
0
            node = node->nextDeclareNode;
1583
0
          }
1584
0
          fxCoderAddByte(coder, -1, XS_CODE_POP);
1585
0
          coder->environmentLevel++;
1586
0
        }
1587
2.50k
      }
1588
3.61k
    }
1589
75.5k
  }
1590
76.2k
}
1591
1592
void fxScopeCodingParams(txScope* self, txCoder* coder) 
1593
53.0k
{
1594
53.0k
  txDeclareNode* node = self->firstDeclareNode;
1595
102k
  while (node) {
1596
49.0k
    txToken token = node->description->token;
1597
49.0k
    if ((token == XS_TOKEN_ARG) || (token == XS_TOKEN_VAR) || (token == XS_TOKEN_CONST)) {
1598
38.4k
      if (node->flags & mxDeclareNodeClosureFlag) {
1599
4.60k
        if (node->flags & mxDeclareNodeUseClosureFlag) {
1600
0
          fxReportParserError(self->parser, node->line, "argument %s use closure", node->symbol->string);
1601
0
        }
1602
4.60k
        node->index = coder->scopeLevel++;
1603
4.60k
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1604
4.60k
      }
1605
33.8k
      else {
1606
33.8k
        node->index = coder->scopeLevel++;
1607
33.8k
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1608
33.8k
      }
1609
38.4k
    }
1610
49.0k
    node = node->nextDeclareNode;
1611
49.0k
  }
1612
53.0k
  if (self->flags & mxEvalFlag) {
1613
3.64k
    if (!(self->node->flags & mxStrictFlag)) { 
1614
2.78k
      fxCoderAddByte(coder, 1, XS_CODE_NULL);
1615
2.78k
      fxCoderAddByte(coder, 0, XS_CODE_WITH);
1616
2.78k
      fxCoderAddByte(coder, -1, XS_CODE_POP);
1617
2.78k
      coder->environmentLevel++;
1618
2.78k
    }
1619
3.64k
    fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1620
3.64k
    fxCoderAddByte(coder, 0, XS_CODE_WITH);
1621
3.64k
    node = self->firstDeclareNode;
1622
8.53k
    while (node) {
1623
4.89k
      txToken token = node->description->token;
1624
4.89k
      if ((token == XS_TOKEN_ARG) || (token == XS_TOKEN_VAR) || (token == XS_TOKEN_CONST))
1625
2.38k
        fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->index);
1626
4.89k
      node = node->nextDeclareNode;
1627
4.89k
    }
1628
3.64k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
1629
3.64k
    coder->environmentLevel++;
1630
3.64k
  }
1631
53.0k
}
1632
1633
void fxScopeCodingProgram(txScope* self, txCoder* coder) 
1634
39.5k
{
1635
39.5k
  txProgramNode* programNode = (txProgramNode*)self->node;
1636
39.5k
  txDeclareNode* node;
1637
39.5k
  txInteger count = 0;
1638
39.5k
  if (programNode->variableCount) {
1639
10.0k
    fxCoderAddIndex(coder, 0, XS_CODE_RESERVE_1, programNode->variableCount);
1640
10.0k
    node = self->firstDeclareNode;
1641
31.3k
    while (node) {
1642
21.2k
      if ((node->description->token != XS_TOKEN_DEFINE) && (node->description->token != XS_TOKEN_VAR)) {
1643
4.58k
        node->index = coder->scopeLevel++;
1644
4.58k
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_CLOSURE, node->symbol, node->index);
1645
4.58k
      }
1646
21.2k
      node = node->nextDeclareNode;
1647
21.2k
    }
1648
10.0k
    count = coder->scopeLevel;
1649
10.0k
    node = self->firstDeclareNode;
1650
31.3k
    while (node) {
1651
21.2k
      if (node->description->token == XS_TOKEN_DEFINE) {
1652
        // closure -> global property
1653
1.25k
        node->index = coder->scopeLevel++;
1654
1.25k
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1655
1.25k
        fxCoderAddByte(coder, 1, XS_CODE_NULL);
1656
1.25k
        fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1657
1.25k
        fxCoderAddByte(coder, -1, XS_CODE_POP);
1658
1.25k
      }
1659
20.0k
      else if (node->description->token == XS_TOKEN_VAR) {
1660
        // closure -> global property
1661
15.4k
        node->index = coder->scopeLevel++;
1662
15.4k
        fxCoderAddVariable(coder, 0, XS_CODE_NEW_LOCAL, node->symbol, node->index);
1663
15.4k
        fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1664
15.4k
        fxCoderAddIndex(coder, 0, XS_CODE_VAR_LOCAL_1, node->index);
1665
15.4k
        fxCoderAddByte(coder, -1, XS_CODE_POP);
1666
15.4k
      }
1667
21.2k
      node = node->nextDeclareNode;
1668
21.2k
    }
1669
10.0k
    fxCoderAddByte(coder, 0, XS_CODE_PROGRAM_ENVIRONMENT);
1670
10.0k
    coder->scopeLevel = count;
1671
10.0k
  }
1672
39.5k
  if (programNode->scopeCount > count)
1673
9.35k
    fxCoderAddIndex(coder, 0, XS_CODE_RESERVE_1, programNode->scopeCount - count);
1674
39.5k
}
1675
1676
void fxScopeCodeDefineNodes(txScope* self, txCoder* coder) 
1677
239k
{
1678
239k
  txDefineNode* node = self->firstDefineNode;
1679
265k
  while (node) {
1680
25.4k
    fxDefineNodeCode(node, coder);
1681
25.4k
    node = node->nextDefineNode;
1682
25.4k
  }
1683
239k
}
1684
1685
txInteger fxScopeCodeSpecifierNodes(txScope* self, txCoder* coder) 
1686
230
{
1687
230
  txDeclareNode* node = self->firstDeclareNode;
1688
230
  txInteger count = 0;
1689
614
  while (node) {
1690
384
    if (node->flags & mxDeclareNodeUseClosureFlag) {
1691
384
      txSpecifierNode* specifier = node->importSpecifier;
1692
384
      txInteger index = 3;
1693
384
      txBoolean flag = 0;
1694
384
      if (node->symbol)
1695
355
        fxCoderAddSymbol(coder, 1, XS_CODE_SYMBOL, node->symbol);
1696
29
      else
1697
29
        fxCoderAddByte(coder, 1, XS_CODE_NULL);
1698
384
      if (specifier) {
1699
100
        if (coder->parser->flags & mxDebugFlag) {
1700
100
          fxCoderAddLine(coder, 0, XS_CODE_LINE, (txNode*)specifier);
1701
100
        }
1702
100
        fxStringNodeCode(specifier->from, coder);
1703
100
        if (specifier->with)
1704
0
          flag = 1;
1705
100
        if (specifier->symbol)
1706
66
          fxCoderAddSymbol(coder, 1, XS_CODE_SYMBOL, specifier->symbol);
1707
34
        else
1708
34
          fxCoderAddByte(coder, 1, XS_CODE_NULL);
1709
100
      }
1710
284
      else {
1711
284
        fxCoderAddByte(coder, 1, XS_CODE_NULL);
1712
284
        fxCoderAddByte(coder, 1, XS_CODE_NULL);
1713
284
      }
1714
384
      specifier = node->firstExportSpecifier;
1715
677
      while (specifier) {
1716
293
        if (specifier->asSymbol) {
1717
18
          fxCoderAddSymbol(coder, 1, XS_CODE_SYMBOL, specifier->asSymbol);
1718
18
          index++;
1719
18
        }
1720
275
        else if (specifier->symbol) {
1721
273
          fxCoderAddSymbol(coder, 1, XS_CODE_SYMBOL, specifier->symbol);
1722
273
          index++;
1723
273
        }
1724
2
        else {
1725
2
          fxCoderAddByte(coder, 1, XS_CODE_NULL);
1726
2
          index++;
1727
2
        }
1728
293
        specifier = specifier->nextSpecifier;
1729
293
      }
1730
384
      fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, index);
1731
384
      if (flag)
1732
0
        fxCoderAddByte(coder, 0 - index, XS_CODE_TRANSFER_JSON);
1733
384
      else
1734
384
        fxCoderAddByte(coder, 0 - index, XS_CODE_TRANSFER);
1735
384
      count++;
1736
384
    }
1737
384
    node = node->nextDeclareNode;
1738
384
  }
1739
230
  return count;
1740
230
}
1741
1742
void fxScopeCodeRefresh(txScope* self, txCoder* coder) 
1743
9.96k
{
1744
9.96k
  txDeclareNode* node = self->firstDeclareNode;
1745
10.3k
  while (node) {
1746
362
    if (node->flags & mxDeclareNodeClosureFlag)
1747
22
      fxCoderAddIndex(coder, 0, XS_CODE_REFRESH_CLOSURE_1, node->index);
1748
340
    else
1749
340
      fxCoderAddIndex(coder, 0, XS_CODE_REFRESH_LOCAL_1, node->index);
1750
362
    node = node->nextDeclareNode;
1751
362
  }
1752
9.96k
}
1753
1754
void fxScopeCodeReset(txScope* self, txCoder* coder) 
1755
6.43k
{
1756
6.43k
  txDeclareNode* node = self->firstDeclareNode;
1757
7.21k
  while (node) {
1758
774
    if (node->flags & mxDeclareNodeClosureFlag)
1759
88
      fxCoderAddIndex(coder, 0, XS_CODE_RESET_CLOSURE_1, node->index);
1760
686
    else if (node->symbol)
1761
686
      fxCoderAddIndex(coder, 0, XS_CODE_RESET_LOCAL_1, node->index);
1762
0
    else {
1763
0
      fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1764
0
      fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, node->index);
1765
0
    }
1766
774
    node = node->nextDeclareNode;
1767
774
  }
1768
6.43k
}
1769
1770
void fxScopeCodeRetrieve(txScope* self, txCoder* coder) 
1771
53.3k
{
1772
53.3k
  txDeclareNode* node;
1773
53.3k
  txInteger count = 0;
1774
53.3k
  node = self->firstDeclareNode;
1775
102k
  while (node) {
1776
49.4k
    if ((node->flags & mxDeclareNodeUseClosureFlag) && node->symbol) {
1777
10.9k
      node->index = coder->scopeLevel++;
1778
10.9k
      count++;
1779
10.9k
    }
1780
49.4k
    node = node->nextDeclareNode;
1781
49.4k
  }
1782
53.3k
  if ((self->node->flags & mxArrowFlag) && ((self->node->flags & mxDefaultFlag) || (self->flags & mxEvalFlag))) {
1783
1.43k
    fxCoderAddIndex(coder, 0, XS_CODE_RETRIEVE_1, count);
1784
1.43k
    fxCoderAddByte(coder, 0, XS_CODE_RETRIEVE_TARGET);
1785
1.43k
    fxCoderAddByte(coder, 0, XS_CODE_RETRIEVE_THIS);
1786
1.43k
  }
1787
51.9k
  else if (count)
1788
7.83k
    fxCoderAddIndex(coder, 0, XS_CODE_RETRIEVE_1, count);
1789
53.3k
  self->closureNodeCount = count;
1790
53.3k
}
1791
1792
void fxScopeCodeStore(txScope* self, txCoder* coder) 
1793
11.2k
{
1794
11.2k
  txDeclareNode* node = self->firstDeclareNode;
1795
11.2k
  txUnsigned flags = self->flags & mxEvalFlag;
1796
27.6k
  while (node) {
1797
16.3k
    if (node->flags & mxDeclareNodeUseClosureFlag) {
1798
10.6k
      fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->declaration->index);
1799
10.6k
      node->declaration->flags |= flags;
1800
10.6k
    }
1801
16.3k
    node = node->nextDeclareNode;
1802
16.3k
  }
1803
11.2k
  if ((self->node->flags & mxArrowFlag) && ((self->node->flags & mxDefaultFlag) || (self->flags & mxEvalFlag)))
1804
1.43k
    fxCoderAddByte(coder, 0, XS_CODE_STORE_ARROW);
1805
11.2k
  if (self->flags & mxEvalFlag)
1806
3.63k
    fxScopeCodeStoreAll(self->scope, coder);
1807
11.2k
}
1808
1809
void fxScopeCodeStoreAll(txScope* self, txCoder* coder) 
1810
3.63k
{
1811
3.63k
  txScope* scope = self;
1812
10.5k
  while (scope) {
1813
8.75k
    txDeclareNode* node;
1814
8.75k
    if (scope->token == XS_TOKEN_WITH)
1815
66
      break;
1816
8.69k
    node = scope->firstDeclareNode;
1817
304k
    while (node) {
1818
295k
      if (node->flags & mxEvalFlag)
1819
2.51k
        node->flags &= ~mxEvalFlag;
1820
293k
      else if ((!(node->flags & mxDeclareNodeUseClosureFlag)) && node->declaration)
1821
211k
        fxCoderAddIndex(coder, 0, XS_CODE_STORE_1, node->declaration->index);
1822
295k
      node = node->nextDeclareNode;
1823
295k
    }
1824
8.69k
    if ((scope->token == XS_TOKEN_FUNCTION) || (scope->token == XS_TOKEN_MODULE))
1825
1.73k
      break;
1826
6.95k
    scope = scope->scope;
1827
6.95k
  }
1828
3.63k
}
1829
1830
void fxScopeCodeUsed(txScope* self, txCoder* coder, txUsingContext* context) 
1831
1
{
1832
1
  txTargetCode* normalTarget = fxCoderCreateTarget(coder);
1833
1
  txTargetCode* uncatchTarget = fxCoderCreateTarget(coder);
1834
1
  txTargetCode* finallyTarget = fxCoderCreateTarget(coder);
1835
1
  txTargetCode* elseTarget = fxCoderCreateTarget(coder);
1836
1
  txInteger selection;
1837
  
1838
1
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, normalTarget);
1839
1
  fxCoderAdd(coder, 0, context->catchTarget);
1840
1
  fxCoderAddByte(coder, 1, XS_CODE_EXCEPTION);
1841
1
  fxCoderAddIndex(coder, 0, XS_CODE_PULL_LOCAL_1, context->exception);
1842
1
  fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, 0);
1843
1
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, context->selector);
1844
1
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, finallyTarget);
1845
1
  selection = 1;
1846
1
  coder->firstBreakTarget = fxCoderFinalizeTargets(coder, coder->firstBreakTarget, context->selector, &selection, uncatchTarget);
1847
1
  coder->firstContinueTarget = fxCoderFinalizeTargets(coder, coder->firstContinueTarget, context->selector, &selection, uncatchTarget);
1848
1
  coder->returnTarget = fxCoderFinalizeTargets(coder, coder->returnTarget, context->selector, &selection, uncatchTarget);
1849
1
  fxCoderAdd(coder, 0, normalTarget);
1850
1
  fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, selection);
1851
1
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, context->selector);
1852
1
  fxCoderAdd(coder, 0, uncatchTarget);
1853
1
  fxCoderAddByte(coder, 0, XS_CODE_UNCATCH);
1854
1
  fxCoderAdd(coder, 0, finallyTarget);
1855
  
1856
1
  fxScopeCodeUsedReverse(self, coder, self->firstDeclareNode, context->exception, context->selector);
1857
  
1858
1
  fxCoderAddIndex(coder, 1, XS_CODE_GET_LOCAL_1, context->selector);
1859
1
  fxCoderAddBranch(coder, -1, XS_CODE_BRANCH_IF_1, elseTarget);
1860
1
  fxCoderAddIndex(coder, 1, XS_CODE_GET_LOCAL_1, context->exception);
1861
1
  fxCoderAddByte(coder, -1, XS_CODE_THROW);
1862
1
  fxCoderAdd(coder, 0, elseTarget);
1863
1
  selection = 1;
1864
1
  fxCoderJumpTargets(coder, coder->firstBreakTarget, context->selector, &selection);
1865
1
  fxCoderJumpTargets(coder, coder->firstContinueTarget, context->selector, &selection);
1866
1
  fxCoderJumpTargets(coder, coder->returnTarget, context->selector, &selection);
1867
1
  fxCoderUnuseTemporaryVariables(coder, 2);
1868
1
}
1869
1870
void fxScopeCodeUsedReverse(txScope* self, txCoder* coder, txDeclareNode* node, txInteger exception, txInteger selector) 
1871
14.4k
{
1872
14.4k
  if (node) {
1873
1.54k
    fxCheckParserStack(coder->parser, node->line);
1874
1.54k
    fxScopeCodeUsedReverse(self, coder, node->nextDeclareNode, exception, selector);
1875
1.54k
    if (node->description->token == XS_TOKEN_USING) {
1876
1
      txTargetCode* catchTarget = fxCoderCreateTarget(coder);
1877
1
      txTargetCode* chainTarget = fxCoderCreateTarget(coder);
1878
1
      txTargetCode* normalTarget = fxCoderCreateTarget(coder);
1879
      
1880
1
      fxCoderAddIndex(coder, 1, XS_CODE_GET_LOCAL_1, node->index + 1);
1881
1
      fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
1882
1
      fxCoderAddByte(coder, -1, XS_CODE_STRICT_EQUAL);
1883
1
      fxCoderAddBranch(coder, -1, XS_CODE_BRANCH_IF_1, normalTarget);
1884
      
1885
1
      fxCoderAddBranch(coder, 0, XS_CODE_CATCH_1, catchTarget);
1886
      
1887
1
      fxCoderAddIndex(coder, 1, (node->flags & mxDeclareNodeClosureFlag) ? XS_CODE_GET_CLOSURE_1: XS_CODE_GET_LOCAL_1, node->index);
1888
1
      fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_CHAIN_1, chainTarget);
1889
1
      fxCoderAddIndex(coder, 1, XS_CODE_GET_LOCAL_1, node->index + 1);
1890
1
      fxCoderAddByte(coder, 1, XS_CODE_CALL);
1891
1
      fxCoderAddInteger(coder, -2, XS_CODE_RUN_1, 0);
1892
      
1893
1
      fxCoderAdd(coder, 0, chainTarget);
1894
1
      if (node->flags & mxAwaitingFlag) {
1895
0
        fxCoderAddByte(coder, 0, XS_CODE_AWAIT);
1896
0
        fxCoderAddByte(coder, 0, XS_CODE_THROW_STATUS);
1897
0
      }
1898
1
      fxCoderAddByte(coder, -1, XS_CODE_POP);
1899
      
1900
1
      fxCoderAddByte(coder, 0, XS_CODE_UNCATCH);
1901
1
      fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, normalTarget);
1902
1
      fxCoderAdd(coder, 0, catchTarget);
1903
1
      fxCoderAddIndex(coder, 1, XS_CODE_USED_1, selector);
1904
      
1905
1
      fxCoderAdd(coder, 0, normalTarget);
1906
1
    }
1907
1.54k
  }
1908
14.4k
}
1909
1910
void fxScopeCodeUsing(txScope* self, txCoder* coder, txUsingContext* context) 
1911
1.01k
{
1912
1.01k
  context->exception = fxCoderUseTemporaryVariable(coder);
1913
1.01k
  context->selector = fxCoderUseTemporaryVariable(coder);
1914
1.01k
  coder->firstBreakTarget = fxCoderAliasTargets(coder, coder->firstBreakTarget);
1915
1.01k
  coder->firstContinueTarget = fxCoderAliasTargets(coder, coder->firstContinueTarget);
1916
1.01k
  coder->returnTarget = fxCoderAliasTargets(coder, coder->returnTarget);
1917
1.01k
  context->catchTarget = fxCoderCreateTarget(coder);
1918
1.01k
  fxCoderAddBranch(coder, 0, XS_CODE_CATCH_1, context->catchTarget);
1919
1.01k
}
1920
1921
void fxScopeCodeUsingStatement(txScope* self, txCoder* coder, txNode* statement) 
1922
59.5k
{
1923
59.5k
  if (self->disposableNodeCount) {
1924
1.01k
    txUsingContext context;
1925
1.01k
    fxScopeCodeUsing(self, coder, &context);
1926
1.01k
    fxNodeDispatchCode(statement, coder);
1927
1.01k
    fxScopeCodeUsed(self, coder, &context);
1928
1.01k
  }
1929
58.5k
  else
1930
58.5k
    fxNodeDispatchCode(statement, coder);
1931
59.5k
}
1932
1933
void fxNodeDispatchCode(void* it, void* param)
1934
2.33M
{
1935
2.33M
  txNode* self = it;
1936
2.33M
  txCoder* coder = param;
1937
2.33M
  fxCheckParserStack(coder->parser, self->line);
1938
2.33M
  if (self->line >= 0)
1939
1.95M
    fxCoderAddLine(coder, 0, XS_CODE_LINE, self); 
1940
2.33M
  (*self->description->dispatch->code)(it, param);
1941
2.33M
}
1942
1943
void fxNodeDispatchCodeAssign(void* it, void* param, txFlag flag)
1944
83.8k
{
1945
83.8k
  txNode* self = it;
1946
83.8k
  txCoder* coder = param;
1947
83.8k
  fxCheckParserStack(coder->parser, self->line);
1948
83.8k
  if (self->line >= 0)
1949
79.5k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, self); 
1950
83.8k
  (*self->description->dispatch->codeAssign)(self, param, flag);
1951
83.8k
}
1952
1953
void fxNodeDispatchCodeDelete(void* it, void* param)
1954
3.81k
{
1955
3.81k
  txNode* self = it;
1956
3.81k
  txCoder* coder = param;
1957
3.81k
  fxCheckParserStack(coder->parser, self->line);
1958
3.81k
  if (self->line >= 0)
1959
3.36k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, self); 
1960
3.81k
  (*self->description->dispatch->codeDelete)(self, param);
1961
3.81k
}
1962
1963
void fxNodeDispatchCodeReference(void* it, void* param, txFlag flag)
1964
75.8k
{
1965
75.8k
  txNode* self = it;
1966
75.8k
  txCoder* coder = param;
1967
75.8k
  fxCheckParserStack(coder->parser, self->line);
1968
75.8k
  if (self->line >= 0)
1969
71.7k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, self); 
1970
75.8k
  (*self->description->dispatch->codeReference)(self, param, flag);
1971
75.8k
}
1972
1973
txFlag fxNodeDispatchCodeThis(void* it, void* param, txFlag flag) 
1974
316k
{
1975
316k
  txNode* self = it;
1976
316k
  txCoder* coder = param;
1977
316k
  fxCheckParserStack(coder->parser, self->line);
1978
316k
  if (self->line >= 0)
1979
208k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, self); 
1980
316k
  return (*self->description->dispatch->codeThis)(self, param, flag);
1981
316k
}
1982
1983
void fxNodeCode(void* it, void* param) 
1984
1
{
1985
1
  txNode* self = it;
1986
1
  txCoder* coder = param;
1987
1
  fxReportParserError(coder->parser, self->line, "no value");
1988
1
  fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
1989
1
}
1990
1991
void fxNodeCodeAssign(void* it, void* param, txFlag flag) 
1992
2
{
1993
2
  txNode* self = it;
1994
2
  txCoder* coder = param;
1995
2
  fxReportParserError(coder->parser, self->line, "no reference");
1996
2
}
1997
1998
void fxNodeCodeDelete(void* it, void* param) 
1999
442
{
2000
442
  fxNodeDispatchCode(it, param);
2001
442
  fxCoderAddByte(param, -1, XS_CODE_POP);
2002
442
  fxCoderAddByte(param, 1, XS_CODE_TRUE);
2003
442
}
2004
2005
void fxNodeCodeReference(void* it, void* param, txFlag flag) 
2006
679
{
2007
679
}
2008
2009
txFlag fxNodeCodeName(txNode* value)
2010
40.4k
{
2011
40.4k
  txToken token = value->description->token;
2012
40.4k
  if (token == XS_TOKEN_EXPRESSIONS) {
2013
16
    value = ((txExpressionsNode*)value)->items->first;
2014
16
    if (value->next)
2015
6
      return 0;
2016
10
    token = value->description->token;
2017
10
  }
2018
40.4k
  if (token == XS_TOKEN_CLASS) {
2019
1
    txClassNode* node = (txClassNode*)value;
2020
1
    if (node->symbol)
2021
0
      return 0;
2022
1
  }
2023
40.4k
  else if ((token == XS_TOKEN_FUNCTION) || (token == XS_TOKEN_GENERATOR) || (token == XS_TOKEN_HOST)) {
2024
1.60k
    txFunctionNode* node = (txFunctionNode*)value;
2025
1.60k
    if (node->symbol)
2026
20
      return 0;
2027
1.60k
  }
2028
38.8k
  else
2029
38.8k
    return 0;
2030
1.59k
  return 1;
2031
40.4k
}
2032
2033
txFlag fxNodeCodeThis(void* it, void* param, txFlag flag) 
2034
214k
{
2035
214k
  fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2036
214k
  fxNodeDispatchCode(it, param);
2037
214k
  return 1;
2038
214k
}
2039
2040
void fxAccessNodeCode(void* it, void* param) 
2041
267k
{
2042
267k
  txAccessNode* self = it;
2043
267k
  txDeclareNode* declaration = self->declaration;
2044
267k
  if (!declaration) {
2045
245k
    fxAccessNodeCodeReference(it, param, 0);
2046
245k
    fxCoderAddSymbol(param, 0, XS_CODE_GET_VARIABLE, self->symbol);
2047
245k
  }
2048
22.4k
  else
2049
22.4k
    fxCoderAddIndex(param, 1, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_GET_CLOSURE_1 : XS_CODE_GET_LOCAL_1, declaration->index);
2050
267k
}
2051
2052
void fxAccessNodeCodeAssign(void* it, void* param, txFlag flag) 
2053
24.0k
{
2054
24.0k
  txAccessNode* self = it;
2055
24.0k
  txDeclareNode* declaration = self->declaration;
2056
24.0k
  if (!declaration)
2057
20.3k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_VARIABLE, self->symbol);
2058
3.72k
  else
2059
3.72k
    fxCoderAddIndex(param, 0, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_SET_CLOSURE_1 : XS_CODE_SET_LOCAL_1, declaration->index);
2060
24.0k
}
2061
2062
void fxAccessNodeCodeDelete(void* it, void* param) 
2063
2.42k
{
2064
2.42k
  txAccessNode* self = it;
2065
2.42k
  txCoder* coder = param;
2066
2.42k
  txDeclareNode* declaration = self->declaration;
2067
2.42k
  if (self->flags & mxStrictFlag)
2068
0
    fxReportParserError(coder->parser, self->line, "delete identifier (strict code)");
2069
2.42k
  if (!declaration) {
2070
2.36k
    fxAccessNodeCodeReference(it, param, 0);
2071
2.36k
    fxCoderAddSymbol(param, 0, XS_CODE_DELETE_PROPERTY, self->symbol);
2072
2.36k
  }
2073
61
  else
2074
61
    fxCoderAddByte(param, 1, XS_CODE_FALSE);
2075
2.42k
}
2076
2077
void fxAccessNodeCodeReference(void* it, void* param, txFlag flag) 
2078
287k
{
2079
287k
  txAccessNode* self = it;
2080
287k
  txCoder* coder = param;
2081
287k
  txDeclareNode* declaration = self->declaration;
2082
287k
  if (!declaration) {
2083
284k
    if (coder->evalFlag)
2084
60.9k
      fxCoderAddSymbol(param, 1, XS_CODE_EVAL_REFERENCE, self->symbol);
2085
223k
    else
2086
223k
      fxCoderAddSymbol(param, 1, XS_CODE_PROGRAM_REFERENCE, self->symbol);
2087
284k
  }
2088
287k
}
2089
2090
txFlag fxAccessNodeCodeThis(void* it, void* param, txFlag flag) 
2091
27.3k
{
2092
27.3k
  txAccessNode* self = it;
2093
27.3k
  txDeclareNode* declaration = self->declaration;
2094
27.3k
  if (!flag)
2095
17.9k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2096
27.3k
  if (!declaration) {
2097
23.9k
    fxAccessNodeCodeReference(it, param, 0);
2098
23.9k
    if (flag)
2099
8.21k
      fxCoderAddByte(param, 1, XS_CODE_DUB);
2100
23.9k
    fxCoderAddSymbol(param, 0, XS_CODE_GET_THIS_VARIABLE, self->symbol);
2101
23.9k
  }
2102
3.34k
  else {
2103
3.34k
    fxCoderAddIndex(param, 1, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_GET_CLOSURE_1 : XS_CODE_GET_LOCAL_1, declaration->index);
2104
3.34k
    flag = 0;
2105
3.34k
  }
2106
27.3k
  return flag;
2107
27.3k
}
2108
2109
void fxAndExpressionNodeCode(void* it, void* param) 
2110
898
{
2111
898
  txBinaryExpressionNode* self = it;
2112
898
  txTargetCode* endTarget = fxCoderCreateTarget(param);
2113
898
  self->right->flags |= (self->flags & mxTailRecursionFlag);
2114
898
  fxNodeDispatchCode(self->left, param);
2115
898
  fxCoderAddByte(param, 1, XS_CODE_DUB);
2116
898
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, endTarget);
2117
898
  fxCoderAddByte(param, -1, XS_CODE_POP);
2118
898
  fxNodeDispatchCode(self->right, param);
2119
898
  fxCoderAdd(param, 0, endTarget);
2120
898
}
2121
2122
void fxArgumentsNodeCode(void* it, void* param) 
2123
0
{
2124
0
  fxCoderAddIndex(param, 1, XS_CODE_ARGUMENTS, 0);
2125
0
}
2126
2127
void fxArrayNodeCode(void* it, void* param) 
2128
29.5k
{
2129
29.5k
  txArrayNode* self = it;
2130
29.5k
  txCoder* coder = param;
2131
29.5k
  txInteger array = fxCoderUseTemporaryVariable(param);
2132
29.5k
  fxCoderAddByte(param, 1, XS_CODE_ARRAY);
2133
29.5k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, array);
2134
29.5k
  if (self->items) {
2135
29.5k
    txNode* item = self->items->first;
2136
29.5k
    if (self->flags & mxSpreadFlag) {
2137
475
      txInteger counter = fxCoderUseTemporaryVariable(param);
2138
475
      fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 0);
2139
475
      fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, counter);
2140
1.46k
      while (item) {
2141
992
        if (item->description->token == XS_TOKEN_SPREAD) {
2142
542
          txInteger iterator = fxCoderUseTemporaryVariable(param);
2143
542
          txInteger result = fxCoderUseTemporaryVariable(param);
2144
542
          txTargetCode* nextTarget = fxCoderCreateTarget(param);
2145
542
          txTargetCode* doneTarget = fxCoderCreateTarget(param);
2146
542
          fxNodeDispatchCode(((txSpreadNode*)item)->expression, param);
2147
542
          fxCoderAddByte(param, 0, XS_CODE_FOR_OF);
2148
542
          fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, iterator);
2149
542
          fxCoderAddByte(param, -1, XS_CODE_POP);
2150
542
          fxCoderAdd(param, 0, nextTarget);
2151
542
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2152
542
          fxCoderAddByte(param, 1, XS_CODE_DUB);
2153
542
          fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
2154
542
          fxCoderAddByte(param, 1, XS_CODE_CALL);
2155
542
          fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2156
542
          fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2157
542
          fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
2158
542
          fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
2159
542
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2160
542
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
2161
542
          fxCoderAddByte(param, 0, XS_CODE_AT);
2162
542
          fxCoderAddIndex(param, 0, XS_CODE_GET_LOCAL_1, result);
2163
542
          fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2164
542
          fxCoderAddByte(param, -2, XS_CODE_SET_PROPERTY_AT);
2165
542
          fxCoderAddByte(param, -1, XS_CODE_POP);
2166
542
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
2167
542
          fxCoderAddByte(param, 0, XS_CODE_INCREMENT);
2168
542
          fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, counter);
2169
542
          fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
2170
542
          fxCoderAdd(param, 1, doneTarget);
2171
542
          fxCoderUnuseTemporaryVariables(param, 2);
2172
542
        }
2173
450
        else {
2174
450
          if (item->description->token != XS_TOKEN_ELISION) {
2175
342
            fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2176
342
            fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
2177
342
            fxCoderAddByte(param, 0, XS_CODE_AT);
2178
342
            fxNodeDispatchCode(item, param);
2179
342
            fxCoderAddByte(param, -2, XS_CODE_SET_PROPERTY_AT);
2180
342
            fxCoderAddByte(param, -1, XS_CODE_POP);
2181
342
            fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
2182
342
            fxCoderAddByte(param, 0, XS_CODE_INCREMENT);
2183
342
            fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, counter);
2184
342
          }
2185
108
          else {
2186
108
            fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2187
108
            fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
2188
108
            fxCoderAddByte(param, 0, XS_CODE_INCREMENT);
2189
108
            fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, counter);
2190
108
            fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, coder->parser->lengthSymbol);
2191
108
            fxCoderAddByte(param, -1, XS_CODE_POP);
2192
108
          }
2193
450
        }
2194
992
        item = item->next;
2195
992
      }
2196
475
      fxCoderUnuseTemporaryVariables(param, 1);
2197
475
    }
2198
29.0k
    else {
2199
29.0k
      txInteger index = 0;
2200
29.0k
      txInteger count = self->items->length;
2201
29.0k
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2202
29.0k
      fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, count);
2203
29.0k
      fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, coder->parser->lengthSymbol);
2204
29.0k
      fxCoderAddByte(param, -1, XS_CODE_POP);
2205
153k
      while (item) {
2206
124k
        if (item->description->token == XS_TOKEN_ELISION)
2207
457
          break;
2208
124k
        item = item->next;
2209
124k
      }
2210
//      if (!item) {
2211
//        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2212
//        fxCoderAddByte(param, 1, XS_CODE_DUB);
2213
//        fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->fillSymbol);
2214
//        fxCoderAddByte(param, 1, XS_CODE_CALL);
2215
//        fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2216
//        fxCoderAddByte(param, -1, XS_CODE_POP);
2217
//      }
2218
29.0k
      item = self->items->first;
2219
159k
      while (item) {
2220
130k
        if (item->description->token != XS_TOKEN_ELISION) {
2221
126k
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, array);
2222
126k
          fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, index);
2223
126k
          fxCoderAddByte(param, 0, XS_CODE_AT);
2224
126k
          fxNodeDispatchCode(item, param);
2225
126k
          fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
2226
126k
          fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, 0);
2227
126k
        }
2228
130k
        item = item->next;
2229
130k
        index++;
2230
130k
      }
2231
29.0k
    }
2232
29.5k
  }
2233
29.5k
  fxCoderUnuseTemporaryVariables(param, 1);
2234
29.5k
}
2235
2236
void fxArrayBindingNodeCode(void* it, void* param)
2237
9.32k
{
2238
9.32k
  txArrayBindingNode* self = it;
2239
9.32k
  txCoder* coder = param;
2240
9.32k
  fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
2241
9.32k
  fxArrayBindingNodeCodeAssign(self, param, 0);
2242
9.32k
}
2243
2244
void fxArrayBindingNodeCodeAssign(void* it, void* param, txFlag flag) 
2245
9.70k
{
2246
9.70k
  txArrayBindingNode* self = it;
2247
9.70k
  txCoder* coder = param;
2248
9.70k
  txNode* item = self->items->first;
2249
9.70k
  txInteger iterator;
2250
9.70k
  txInteger next;
2251
9.70k
  txInteger done;
2252
9.70k
  txInteger rest;
2253
9.70k
  txInteger result;
2254
9.70k
  txInteger selector;
2255
9.70k
  txInteger selection;
2256
9.70k
  txTargetCode* catchTarget;
2257
9.70k
  txTargetCode* normalTarget;
2258
9.70k
  txTargetCode* finallyTarget;
2259
  
2260
9.70k
  txTargetCode* returnTarget;
2261
9.70k
  txTargetCode* stepTarget;
2262
9.70k
  txTargetCode* doneTarget;
2263
9.70k
  txTargetCode* nextTarget;
2264
  
2265
9.70k
  iterator = fxCoderUseTemporaryVariable(param);
2266
9.70k
  next = fxCoderUseTemporaryVariable(param);
2267
9.70k
  done = fxCoderUseTemporaryVariable(param);
2268
9.70k
  selector = fxCoderUseTemporaryVariable(param);
2269
9.70k
  rest = fxCoderUseTemporaryVariable(param);
2270
9.70k
  result = fxCoderUseTemporaryVariable(param);
2271
  
2272
9.70k
  coder->returnTarget = fxCoderAliasTargets(param, coder->returnTarget);
2273
9.70k
  catchTarget = fxCoderCreateTarget(param);
2274
9.70k
  normalTarget = fxCoderCreateTarget(param);
2275
9.70k
  finallyTarget = fxCoderCreateTarget(param);
2276
  
2277
9.70k
  fxCoderAddByte(param, 1, XS_CODE_DUB);
2278
9.70k
  fxCoderAddByte(param, 0, XS_CODE_FOR_OF);
2279
9.70k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, iterator);
2280
9.70k
  fxCoderAddByte(param, 1, XS_CODE_FALSE);
2281
9.70k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
2282
9.70k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 0);
2283
9.70k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, selector);
2284
9.70k
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2285
  
2286
9.70k
  if (item) {
2287
716
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2288
716
    fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
2289
716
    fxCoderAddIndex(param, 0, XS_CODE_PULL_LOCAL_1, next);
2290
  
2291
26.4k
    while (item && (item->description->token != XS_TOKEN_REST_BINDING)) {
2292
25.7k
      stepTarget = fxCoderCreateTarget(param);
2293
      
2294
25.7k
      if (item->description->token == XS_TOKEN_SKIP_BINDING) {
2295
18.0k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, done);
2296
18.0k
        fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, stepTarget);
2297
18.0k
        fxCoderAddByte(param, 1, XS_CODE_TRUE);
2298
18.0k
        fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
2299
18.0k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2300
18.0k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, next);
2301
18.0k
        fxCoderAddByte(param, 1, XS_CODE_CALL);
2302
18.0k
        fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2303
18.0k
        fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2304
18.0k
        fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
2305
18.0k
        fxCoderAddIndex(param, 0, XS_CODE_PULL_LOCAL_1, done);
2306
18.0k
        fxCoderAdd(param, 1, stepTarget);
2307
18.0k
      }
2308
7.70k
      else {
2309
7.70k
        doneTarget = fxCoderCreateTarget(param);
2310
7.70k
        nextTarget = fxCoderCreateTarget(param);
2311
7.70k
        fxNodeDispatchCodeReference(item, param, 1);
2312
        
2313
7.70k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, done);
2314
7.70k
        fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, stepTarget);
2315
7.70k
        fxCoderAddByte(param, 1, XS_CODE_TRUE);
2316
7.70k
        fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
2317
7.70k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2318
7.70k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, next);
2319
7.70k
        fxCoderAddByte(param, 1, XS_CODE_CALL);
2320
7.70k
        fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2321
7.70k
        fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2322
7.70k
        fxCoderAddByte(param, 1, XS_CODE_DUB);
2323
7.70k
        fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
2324
7.70k
        fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, done);
2325
7.70k
        fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
2326
7.70k
        fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2327
7.70k
        fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
2328
7.70k
        fxCoderAdd(param, 1, doneTarget);
2329
7.70k
        fxCoderAddByte(param, -1, XS_CODE_POP);
2330
7.70k
        fxCoderAdd(param, 1, stepTarget);
2331
7.70k
        fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2332
7.70k
        fxCoderAdd(param, 1, nextTarget);
2333
7.70k
        fxNodeDispatchCodeAssign(item, param, 1);
2334
7.70k
        fxCoderAddByte(param, -1, XS_CODE_POP);
2335
7.70k
      }
2336
25.7k
      item = item->next;
2337
25.7k
    }
2338
716
    if (item) {
2339
15
      nextTarget = fxCoderCreateTarget(param);
2340
15
      doneTarget = fxCoderCreateTarget(param);
2341
    
2342
15
      fxNodeDispatchCodeReference(((txRestBindingNode*)item)->binding, param, 1);
2343
15
      fxCoderAddByte(param, 1, XS_CODE_ARRAY);
2344
15
      fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, rest);
2345
      
2346
15
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, done);
2347
15
      fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
2348
2349
15
      fxCoderAdd(param, 0, nextTarget);
2350
15
      fxCoderAddByte(param, 1, XS_CODE_TRUE);
2351
15
      fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
2352
15
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2353
15
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, next);
2354
15
      fxCoderAddByte(param, 1, XS_CODE_CALL);
2355
15
      fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2356
15
      fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2357
15
      fxCoderAddIndex(param, 1, XS_CODE_SET_LOCAL_1, result);
2358
15
      fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
2359
15
      fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, done);
2360
      
2361
15
      fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
2362
    
2363
15
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, rest);
2364
15
      fxCoderAddByte(param, 1, XS_CODE_DUB);
2365
15
      fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->lengthSymbol);
2366
15
      fxCoderAddByte(param, 0, XS_CODE_AT);
2367
15
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2368
15
      fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2369
15
      fxCoderAddByte(param, -2, XS_CODE_SET_PROPERTY_AT);
2370
15
      fxCoderAddByte(param, -1, XS_CODE_POP);
2371
  
2372
15
      fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
2373
15
      fxCoderAdd(param, 1, doneTarget);
2374
    
2375
15
      fxCoderAddIndex(param, 0, XS_CODE_GET_LOCAL_1, rest);
2376
15
      fxNodeDispatchCodeAssign(((txRestBindingNode*)item)->binding, param, 1);
2377
15
      fxCoderAddByte(param, -1, XS_CODE_POP);
2378
15
    }
2379
  
2380
716
  }
2381
9.70k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, normalTarget);
2382
  
2383
9.70k
  selection = 1;
2384
9.70k
  coder->returnTarget = fxCoderFinalizeTargets(param, coder->returnTarget, selector, &selection, finallyTarget);
2385
9.70k
  fxCoderAdd(param, 0, normalTarget);
2386
9.70k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, selection);
2387
9.70k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, selector);
2388
9.70k
  fxCoderAddByte(param, -1, XS_CODE_POP);
2389
9.70k
  fxCoderAdd(param, 0, finallyTarget);
2390
9.70k
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
2391
9.70k
  fxCoderAdd(param, 0, catchTarget);
2392
  
2393
9.70k
  nextTarget = fxCoderCreateTarget(param);
2394
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, selector);
2395
9.70k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, nextTarget);
2396
9.70k
  fxCoderAddByte(param, 1, XS_CODE_EXCEPTION);
2397
9.70k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2398
9.70k
  fxCoderAddByte(param, -1, XS_CODE_POP);
2399
9.70k
  catchTarget = fxCoderCreateTarget(param);
2400
9.70k
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2401
9.70k
  fxCoderAdd(param, 0, nextTarget);
2402
  
2403
9.70k
  doneTarget = fxCoderCreateTarget(param);
2404
9.70k
  returnTarget = fxCoderCreateTarget(param);
2405
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, done);
2406
9.70k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
2407
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2408
9.70k
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->returnSymbol);
2409
9.70k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_CHAIN_1, returnTarget);
2410
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2411
9.70k
  fxCoderAddByte(param, 0, XS_CODE_SWAP);
2412
9.70k
  fxCoderAddByte(param, 1, XS_CODE_CALL);
2413
9.70k
  fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2414
9.70k
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2415
9.70k
  fxCoderAdd(param, 0, returnTarget);
2416
9.70k
  fxCoderAddByte(param, -1, XS_CODE_POP);
2417
9.70k
  fxCoderAdd(param, 0, doneTarget);
2418
  
2419
9.70k
  nextTarget = fxCoderCreateTarget(param);
2420
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, selector);
2421
9.70k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, nextTarget);
2422
9.70k
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
2423
9.70k
  fxCoderAdd(param, 0, catchTarget);
2424
9.70k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2425
9.70k
  fxCoderAddByte(param, -1, XS_CODE_THROW);
2426
9.70k
  fxCoderAdd(param, 0, nextTarget);
2427
2428
9.70k
  selection = 1;
2429
9.70k
  fxCoderJumpTargets(param, coder->returnTarget, selector, &selection);
2430
2431
9.70k
  fxCoderUnuseTemporaryVariables(param, 6);
2432
9.70k
}
2433
2434
void fxAssignNodeCode(void* it, void* param) 
2435
20.0k
{
2436
20.0k
  txAssignNode* self = it;
2437
20.0k
  fxNodeDispatchCodeReference(self->reference, param, 1);
2438
20.0k
  fxNodeDispatchCode(self->value, param);
2439
20.0k
  fxNodeDispatchCodeAssign(self->reference, param, 1);
2440
20.0k
}
2441
2442
void fxAwaitNodeCode(void* it, void* param)
2443
191
{
2444
191
  txStatementNode* self = it;
2445
191
  txCoder* coder = param;
2446
191
  txTargetCode* target = fxCoderCreateTarget(coder);
2447
191
  fxNodeDispatchCode(self->expression, param);
2448
191
  fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2449
191
  fxCoderAddBranch(coder, 1, XS_CODE_BRANCH_STATUS_1, target);
2450
191
  fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
2451
191
  fxCoderAdjustEnvironment(coder, coder->returnTarget);
2452
191
  fxCoderAdjustScope(coder, coder->returnTarget);
2453
191
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, coder->returnTarget);
2454
191
  fxCoderAdd(coder, 0, target);
2455
191
}
2456
2457
void fxBigIntNodeCode(void* it, void* param) 
2458
13.8k
{
2459
13.8k
  txBigIntNode* self = it;
2460
13.8k
  fxCoderAddBigInt(param, 1, XS_CODE_BIGINT_1, &self->value);
2461
13.8k
}
2462
2463
void fxBinaryExpressionNodeCode(void* it, void* param) 
2464
40.2k
{
2465
40.2k
  txBinaryExpressionNode* self = it;
2466
40.2k
  fxNodeDispatchCode(self->left, param);
2467
40.2k
  fxNodeDispatchCode(self->right, param);
2468
40.2k
  fxCoderAddByte(param, -1, self->description->code);
2469
40.2k
}
2470
2471
void fxBindingNodeCode(void* it, void* param) 
2472
25.1k
{
2473
25.1k
  txBindingNode* self = it;
2474
25.1k
  txCoder* coder = param;
2475
  
2476
25.1k
  if (self->target->description->token == XS_TOKEN_ACCESS) {
2477
2
    fxReportParserError(coder->parser, self->line, "invalid initializer");
2478
2
    fxNodeDispatchCode(self->initializer, param);
2479
2
    return;
2480
2
  }
2481
  
2482
25.1k
  fxNodeDispatchCodeReference(self->target, param, 0);
2483
25.1k
  fxNodeDispatchCode(self->initializer, param);
2484
25.1k
  fxNodeDispatchCodeAssign(self->target, param, 0);
2485
25.1k
  fxCoderAddByte(coder, -1, XS_CODE_POP);
2486
25.1k
}
2487
2488
void fxBindingNodeCodeAssign(void* it, void* param, txFlag flag) 
2489
175
{
2490
175
  txBindingNode* self = it;
2491
175
  txTargetCode* target = fxCoderCreateTarget(param);
2492
175
  fxCoderAddByte(param, 1, XS_CODE_DUB);
2493
175
  fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2494
175
  fxCoderAddByte(param, -1, XS_CODE_STRICT_NOT_EQUAL);
2495
175
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, target);
2496
175
  fxCoderAddByte(param, -1, XS_CODE_POP);
2497
175
  fxNodeDispatchCode(self->initializer, param);
2498
175
  fxCoderAdd(param, 0, target);
2499
175
  fxNodeDispatchCodeAssign(self->target, param, flag);
2500
175
}
2501
2502
void fxBindingNodeCodeReference(void* it, void* param, txFlag flag) 
2503
175
{
2504
175
  txBindingNode* self = it;
2505
175
  fxNodeDispatchCodeReference(self->target, param, flag);
2506
175
}
2507
2508
void fxBlockNodeCode(void* it, void* param) 
2509
5.30k
{
2510
5.30k
  txBlockNode* self = it;
2511
5.30k
  fxScopeCodingBlock(self->scope, param);
2512
5.30k
  fxScopeCodeDefineNodes(self->scope, param);
2513
5.30k
  fxScopeCodeUsingStatement(self->scope, param, self->statement);
2514
5.30k
  fxScopeCoded(self->scope, param);
2515
5.30k
}
2516
2517
void fxBodyNodeCode(void* it, void* param) 
2518
53.0k
{
2519
53.0k
  txBlockNode* self = it;
2520
53.0k
  txCoder* coder = param;
2521
53.0k
  txBoolean evalFlag = coder->evalFlag;
2522
53.0k
  if ((self->flags & mxEvalFlag) && !(self->flags & mxStrictFlag))
2523
1.03k
    coder->evalFlag = 1;
2524
53.0k
  fxScopeCodingBody(self->scope, param);
2525
53.0k
  fxScopeCodeDefineNodes(self->scope, param);
2526
53.0k
  fxScopeCodeUsingStatement(self->scope, param, self->statement);
2527
53.0k
  fxScopeCodedBody(self->scope, param);
2528
53.0k
  if ((self->flags & mxEvalFlag) && !(self->flags & mxStrictFlag))
2529
1.03k
    coder->evalFlag = evalFlag;
2530
53.0k
}
2531
2532
void fxBreakContinueNodeCode(void* it, void* param) 
2533
1.71k
{
2534
1.71k
  txBreakContinueNode* self = it;
2535
1.71k
  txCoder* coder = param;
2536
1.71k
  txTargetCode* target = (self->description->token == XS_TOKEN_BREAK) ? coder->firstBreakTarget : coder->firstContinueTarget;
2537
1.71k
  while (target) {
2538
155
    txLabelNode* label = target->label;
2539
173
    while (label) {
2540
166
      if (label->symbol == self->symbol) {
2541
148
        fxCoderAdjustEnvironment(coder, target);
2542
148
        fxCoderAdjustScope(coder, target);
2543
148
        fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, target);
2544
148
        return;
2545
148
      }
2546
18
      label = label->nextLabel;
2547
18
    }
2548
7
    target = target->nextTarget;
2549
7
  }
2550
1.56k
  if (self->description->token == XS_TOKEN_BREAK)
2551
12
    fxReportParserError(coder->parser, self->line, "invalid break");
2552
1.55k
  else
2553
1.55k
    fxReportParserError(coder->parser, self->line, "invalid continue");
2554
1.56k
}
2555
2556
void fxCallNodeCode(void* it, void* param) 
2557
90.2k
{
2558
90.2k
  txCallNewNode* self = it;
2559
90.2k
  fxNodeDispatchCodeThis(self->reference, param, 0);
2560
90.2k
  fxCoderAddByte(param, 1, XS_CODE_CALL);
2561
90.2k
  self->params->flags |= self->flags & mxTailRecursionFlag;
2562
90.2k
  fxNodeDispatchCode(self->params, param);
2563
90.2k
}
2564
2565
void fxCatchNodeCode(void* it, void* param) 
2566
1.14k
{
2567
1.14k
  txCatchNode* self = it;
2568
1.14k
  if (self->parameter) {
2569
1.09k
    fxScopeCodingBlock(self->scope, param);
2570
1.09k
    fxNodeDispatchCodeReference(self->parameter, param, 0);
2571
1.09k
    fxCoderAddByte(param, 1, XS_CODE_EXCEPTION);
2572
1.09k
    fxNodeDispatchCodeAssign(self->parameter, param, 0);
2573
1.09k
    fxCoderAddByte(param, -1, XS_CODE_POP);
2574
1.09k
    fxScopeCodingBlock(self->statementScope, param);
2575
1.09k
    fxScopeCodeDefineNodes(self->statementScope, param);
2576
1.09k
    fxScopeCodeUsingStatement(self->statementScope, param, self->statement);
2577
1.09k
    fxScopeCoded(self->statementScope, param);
2578
1.09k
    fxScopeCoded(self->scope, param);
2579
1.09k
  }
2580
41
  else {
2581
41
    fxScopeCodingBlock(self->statementScope, param);
2582
41
    fxScopeCodeDefineNodes(self->statementScope, param);
2583
41
    fxScopeCodeUsingStatement(self->statementScope, param, self->statement);
2584
41
    fxScopeCoded(self->statementScope, param);
2585
41
  }
2586
1.14k
}
2587
2588
void fxChainNodeCode(void* it, void* param)
2589
419
{
2590
419
  txUnaryExpressionNode* self = it;
2591
419
  txCoder* coder = param;
2592
419
  txTargetCode* chainTarget = coder->chainTarget;
2593
419
  coder->chainTarget = fxCoderCreateTarget(param);
2594
419
  fxNodeDispatchCode(self->right, param);
2595
419
  fxCoderAdd(param, 0, coder->chainTarget);
2596
419
  coder->chainTarget = chainTarget;
2597
419
}
2598
2599
txFlag fxChainNodeCodeThis(void* it, void* param, txFlag flag)
2600
18
{
2601
18
  txUnaryExpressionNode* self = it;
2602
18
  txCoder* coder = param;
2603
18
  txTargetCode* chainTarget = coder->chainTarget;
2604
18
  coder->chainTarget = fxCoderCreateTarget(param);
2605
18
  flag = fxNodeDispatchCodeThis(self->right, param, flag);
2606
18
    fxCoderAdd(param, 0, coder->chainTarget);
2607
18
  coder->chainTarget = chainTarget;
2608
18
  return flag;
2609
18
}
2610
2611
void fxClassNodeCode(void* it, void* param) 
2612
3.04k
{
2613
3.04k
  txClassNode* self = it;
2614
3.04k
  txCoder* coder = param;
2615
3.04k
  txClassNode* former = coder->classNode;
2616
3.04k
  txFlag flag;
2617
3.04k
  txInteger prototype = fxCoderUseTemporaryVariable(coder);
2618
3.04k
  txInteger constructor = fxCoderUseTemporaryVariable(coder);
2619
3.04k
  txDeclareNode* declaration = self->scope->firstDeclareNode;
2620
3.04k
  txNode* item = self->items->first;
2621
3.04k
  if (self->symbol)
2622
2.87k
    fxScopeCodingBlock(self->symbolScope, param);
2623
3.04k
  if (self->heritage) {
2624
282
    if (self->heritage->description->token == XS_TOKEN_HOST) {
2625
0
      fxCoderAddByte(param, 1, XS_CODE_NULL);
2626
0
      fxNodeDispatchCode(self->heritage, param);
2627
0
    }
2628
282
    else {
2629
282
      fxNodeDispatchCode(self->heritage, param);
2630
282
      fxCoderAddByte(param, 1, XS_CODE_EXTEND);
2631
282
    }
2632
282
  }
2633
2.76k
  else {
2634
2.76k
    fxCoderAddByte(param, 1, XS_CODE_NULL);
2635
2.76k
    fxCoderAddByte(param, 1, XS_CODE_OBJECT);
2636
2.76k
  }
2637
3.04k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, prototype);
2638
3.04k
  fxScopeCodingBlock(self->scope, param);
2639
  
2640
3.04k
  coder->classNode = self;
2641
3.04k
  fxNodeDispatchCode(self->constructor, param);
2642
  
2643
3.04k
  fxCoderAddByte(param, 0, XS_CODE_TO_INSTANCE);
2644
3.04k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, constructor);
2645
3.04k
  fxCoderAddByte(param, -3, XS_CODE_CLASS);
2646
3.04k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, constructor);
2647
3.04k
  if (self->symbol)
2648
2.87k
    fxCoderAddSymbol(param, 0, XS_CODE_NAME, self->symbol);
2649
    
2650
12.2k
  while (item) {
2651
9.22k
    if (item->description->token == XS_TOKEN_PROPERTY) {
2652
3.27k
      txPropertyNode* property = (txPropertyNode*)item;
2653
3.27k
      if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag)) {
2654
342
        if (item->flags & mxStaticFlag)
2655
29
          fxCoderAddByte(param, 1, XS_CODE_DUB);
2656
313
        else
2657
313
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, prototype);
2658
342
        fxNodeDispatchCode(property->value, param);
2659
342
        fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, property->symbol);
2660
342
        flag = XS_DONT_ENUM_FLAG;
2661
342
        if (item->flags & mxMethodFlag)
2662
139
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG;
2663
203
        else if (item->flags & mxGetterFlag)
2664
77
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_GETTER_FLAG;
2665
126
        else if (item->flags & mxSetterFlag)
2666
26
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_SETTER_FLAG;
2667
342
        fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, flag);
2668
342
      }
2669
3.27k
    }
2670
5.95k
    else if (item->description->token == XS_TOKEN_PROPERTY_AT) {
2671
3.79k
      txPropertyAtNode* property = (txPropertyAtNode*)item;
2672
3.79k
      if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag)) {
2673
42
        if (item->flags & mxStaticFlag)
2674
33
          fxCoderAddByte(param, 1, XS_CODE_DUB);
2675
9
        else
2676
9
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, prototype);
2677
42
        fxNodeDispatchCode(property->at, param);
2678
42
        fxCoderAddByte(param, 0, XS_CODE_AT);
2679
42
        fxNodeDispatchCode(property->value, param);
2680
42
        fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
2681
42
        flag = XS_DONT_ENUM_FLAG;
2682
42
        if (item->flags & mxMethodFlag)
2683
31
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG;
2684
11
        else if (item->flags & mxGetterFlag)
2685
8
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_GETTER_FLAG;
2686
3
        else if (item->flags & mxSetterFlag)
2687
3
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_SETTER_FLAG;
2688
42
        fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, flag);
2689
42
      }
2690
3.75k
      else {
2691
3.75k
        fxNodeDispatchCode(property->at, param);
2692
3.75k
        fxCoderAddByte(param, 0, XS_CODE_AT);
2693
3.75k
        fxCoderAddIndex(param, 0, XS_CODE_CONST_CLOSURE_1, declaration->index);
2694
3.75k
        fxCoderAddByte(param, -1, XS_CODE_POP);
2695
3.75k
        declaration = declaration->nextDeclareNode;
2696
3.75k
      }
2697
3.79k
    }
2698
2.16k
    else  {
2699
2.16k
      txPrivatePropertyNode* property = (txPrivatePropertyNode*)item;
2700
2.16k
      fxCoderAddIndex(param, 0, XS_CODE_CONST_CLOSURE_1, declaration->index);
2701
2.16k
      declaration = declaration->nextDeclareNode;
2702
2.16k
      if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag)) {
2703
1.00k
        fxNodeDispatchCode(property->value, param);
2704
1.00k
        fxCoderAddIndex(param, 0, XS_CODE_CONST_CLOSURE_1, declaration->index);
2705
1.00k
        fxCoderAddByte(param, -1, XS_CODE_POP);
2706
1.00k
        declaration = declaration->nextDeclareNode;
2707
1.00k
      }
2708
2.16k
    }
2709
9.22k
    item = item->next;
2710
9.22k
  }
2711
3.04k
  if (self->symbol)
2712
1.86k
    fxCoderAddIndex(param, 0, XS_CODE_CONST_CLOSURE_1, self->symbolScope->firstDeclareNode->index);
2713
3.04k
  if (self->instanceInit) {
2714
991
    fxNodeDispatchCode(self->instanceInit, param);
2715
991
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, prototype);
2716
991
    fxCoderAddByte(param, -1, XS_CODE_SET_HOME);
2717
991
    fxCoderAddIndex(param, 0, XS_CODE_CONST_CLOSURE_1, declaration->index);
2718
991
    fxCoderAddByte(param, -1, XS_CODE_POP);
2719
991
  }
2720
3.04k
  if (self->constructorInit) {
2721
58
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, constructor);
2722
58
    fxNodeDispatchCode(self->constructorInit, param);
2723
58
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, constructor);
2724
58
    fxCoderAddByte(param, -1, XS_CODE_SET_HOME);
2725
58
    fxCoderAddByte(param, 1, XS_CODE_CALL);
2726
58
    fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2727
58
    fxCoderAddByte(param, -1, XS_CODE_POP);
2728
58
  }
2729
3.04k
  coder->classNode = former;
2730
3.04k
  fxScopeCoded(self->scope, param);
2731
3.04k
  if (self->symbol)
2732
1.86k
    fxScopeCoded(self->symbolScope, param);
2733
3.04k
  fxCoderUnuseTemporaryVariables(coder, 2);
2734
3.04k
}
2735
2736
void fxCoalesceExpressionNodeCode(void* it, void* param) 
2737
295
{
2738
295
  txBinaryExpressionNode* self = it;
2739
295
  txTargetCode* endTarget = fxCoderCreateTarget(param);
2740
295
  self->right->flags |= (self->flags & mxTailRecursionFlag);
2741
295
  fxNodeDispatchCode(self->left, param);
2742
295
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_COALESCE_1, endTarget);
2743
295
  fxNodeDispatchCode(self->right, param);
2744
295
  fxCoderAdd(param, 0, endTarget);
2745
295
}
2746
2747
void fxCompoundExpressionNodeCode(void* it, void* param) 
2748
3.05k
{
2749
3.05k
  txAssignNode* self = it;
2750
3.05k
  txCoder* coder = param;
2751
3.05k
  txToken token = self->description->token;
2752
3.05k
  txFlag shortcut = ((token == XS_TOKEN_AND_ASSIGN) || (token == XS_TOKEN_COALESCE_ASSIGN) || (token == XS_TOKEN_OR_ASSIGN)) ? 1 : 0;
2753
3.05k
  txTargetCode* elseTarget = (shortcut) ? fxCoderCreateTarget(param) : C_NULL;
2754
3.05k
  txTargetCode* endTarget = (shortcut) ? fxCoderCreateTarget(param) : C_NULL;
2755
3.05k
  txInteger stackLevel;
2756
3.05k
  txFlag swap = fxNodeDispatchCodeThis(self->reference, param, 1);
2757
3.05k
  switch (self->description->token) {
2758
482
  case XS_TOKEN_AND_ASSIGN:
2759
482
    fxCoderAddByte(param, 1, XS_CODE_DUB);
2760
482
    fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, elseTarget);
2761
482
    fxCoderAddByte(param, -1, XS_CODE_POP);
2762
482
    fxNodeDispatchCode(self->value, param);
2763
482
    fxCompoundExpressionNodeCodeName(it, param);
2764
482
    stackLevel = coder->stackLevel;
2765
482
    break;
2766
368
  case XS_TOKEN_COALESCE_ASSIGN:
2767
368
    fxCoderAddBranch(param, -1, XS_CODE_BRANCH_COALESCE_1, elseTarget);
2768
368
    fxNodeDispatchCode(self->value, param);
2769
368
    fxCompoundExpressionNodeCodeName(it, param);
2770
368
    stackLevel = coder->stackLevel;
2771
368
    break;
2772
347
  case XS_TOKEN_OR_ASSIGN:
2773
347
    fxCoderAddByte(param, 1, XS_CODE_DUB);
2774
347
    fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, elseTarget);
2775
347
    fxCoderAddByte(param, -1, XS_CODE_POP);
2776
347
    fxNodeDispatchCode(self->value, param);
2777
347
    fxCompoundExpressionNodeCodeName(it, param);
2778
347
    stackLevel = coder->stackLevel;
2779
347
    break;
2780
1.85k
  default:
2781
1.85k
    fxNodeDispatchCode(self->value, param);
2782
1.85k
    fxCoderAddByte(param, -1, self->description->code);
2783
1.85k
    break;
2784
3.05k
  }
2785
3.05k
  fxNodeDispatchCodeAssign(self->reference, param, 0);
2786
3.05k
  if (shortcut) {
2787
1.19k
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, endTarget);
2788
1.19k
    coder->stackLevel = stackLevel;
2789
1.19k
    fxCoderAdd(param, 0, elseTarget);
2790
1.87k
    while (swap > 0) {
2791
676
      if (!(self->flags & mxExpressionNoValue))
2792
656
        fxCoderAddByte(param, 0, XS_CODE_SWAP);
2793
676
      fxCoderAddByte(param, -1, XS_CODE_POP);
2794
676
      swap--;
2795
676
    }
2796
1.19k
    fxCoderAdd(param, 0, endTarget);
2797
1.19k
  }
2798
3.05k
}
2799
2800
void fxCompoundExpressionNodeCodeName(void* it, void* param) 
2801
1.19k
{
2802
1.19k
  txAssignNode* self = it;
2803
1.19k
  txAccessNode* reference = (txAccessNode*)(self->reference);
2804
1.19k
  txToken token = reference->description->token;
2805
1.19k
  txNode* value = self->value;
2806
1.19k
  if (token != XS_TOKEN_ACCESS)
2807
66
    return;
2808
1.13k
  if (fxNodeCodeName(value))
2809
204
    fxCoderAddSymbol(param, 0, XS_CODE_NAME, reference->symbol);
2810
1.13k
}
2811
2812
void fxDebuggerNodeCode(void* it, void* param) 
2813
64
{
2814
64
  fxCoderAddByte(param, 0, XS_CODE_DEBUGGER);
2815
64
}
2816
2817
void fxDeclareNodeCode(void* it, void* param) 
2818
10.1k
{
2819
10.1k
  txDeclareNode* self = it;
2820
10.1k
  txCoder* coder = param;
2821
10.1k
  if (self->description->token == XS_TOKEN_CONST)
2822
284
    fxReportParserError(coder->parser, self->line, "invalid const");
2823
9.84k
  else if (self->description->token == XS_TOKEN_LET) {
2824
1.13k
    fxNodeDispatchCodeReference(self, param, 0);
2825
1.13k
    fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
2826
1.13k
    fxNodeDispatchCodeAssign(self, param, 0);
2827
1.13k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
2828
1.13k
  }
2829
8.71k
  else if (self->description->token == XS_TOKEN_USING)
2830
1.01k
    fxReportParserError(coder->parser, self->line, "invalid using");
2831
10.1k
}
2832
2833
void fxDeclareNodeCodeAssign(void* it, void* param, txFlag flag) 
2834
79.1k
{
2835
79.1k
  txDeclareNode* self = it;
2836
79.1k
  txDeclareNode* declaration = self->declaration;
2837
79.1k
  if (!declaration)
2838
26.9k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_VARIABLE, self->symbol);
2839
52.1k
  else {
2840
52.1k
    if (self->description->token == XS_TOKEN_CONST)
2841
29.1k
      fxCoderAddIndex(param, 0, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_CONST_CLOSURE_1: XS_CODE_CONST_LOCAL_1, declaration->index);
2842
23.0k
    else if (self->description->token == XS_TOKEN_LET)
2843
6.78k
      fxCoderAddIndex(param, 0, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_LET_CLOSURE_1: XS_CODE_LET_LOCAL_1, declaration->index);
2844
16.2k
    else if (self->description->token == XS_TOKEN_USING) {
2845
1
      fxCoderAddIndex(param, 0, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_CONST_CLOSURE_1: XS_CODE_CONST_LOCAL_1, declaration->index);
2846
1
      if (self->flags & mxAwaitingFlag)
2847
0
        fxCoderAddByte(param, 0, XS_CODE_USING_ASYNC);
2848
1
      else
2849
1
        fxCoderAddByte(param, 0, XS_CODE_USING);
2850
1
      fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, declaration->index + 1);
2851
1
    }
2852
16.2k
    else
2853
16.2k
      fxCoderAddIndex(param, 0, (declaration->flags & mxDeclareNodeClosureFlag) ? XS_CODE_VAR_CLOSURE_1 : XS_CODE_VAR_LOCAL_1, declaration->index);
2854
52.1k
  }
2855
79.1k
}
2856
2857
void fxDeclareNodeCodeReference(void* it, void* param, txFlag flag) 
2858
80.1k
{
2859
80.1k
  txAccessNode* self = it;
2860
80.1k
  txCoder* coder = param;
2861
80.1k
  txDeclareNode* declaration = self->declaration;
2862
80.1k
  if (!declaration) {
2863
26.9k
    if (coder->evalFlag)
2864
1.69k
      fxCoderAddSymbol(param, 1, XS_CODE_EVAL_REFERENCE, self->symbol);
2865
25.2k
    else
2866
25.2k
      fxCoderAddSymbol(param, 1, XS_CODE_PROGRAM_REFERENCE, self->symbol);
2867
26.9k
  }
2868
80.1k
}
2869
2870
void fxDefineNodeCode(void* it, void* param) 
2871
27.2k
{
2872
27.2k
  txDefineNode* self = it;
2873
27.2k
  txCoder* coder = param;
2874
27.2k
  if (self->flags & mxDefineNodeCodedFlag)
2875
1.78k
    return;
2876
25.4k
  self->flags |= mxDefineNodeCodedFlag;
2877
25.4k
  fxDeclareNodeCodeReference(it, param, 0);
2878
25.4k
  fxNodeDispatchCode(self->initializer, coder);
2879
25.4k
    self->initializer = C_NULL;
2880
25.4k
  fxDeclareNodeCodeAssign(it, param, 0);
2881
25.4k
  fxCoderAddByte(coder, -1, XS_CODE_POP);
2882
25.4k
}
2883
2884
void fxDelegateNodeCode(void* it, void* param)
2885
26
{
2886
26
  txStatementNode* self = it;
2887
26
  txBoolean async = (self->flags & mxAsyncFlag) ? 1 : 0;
2888
26
  txCoder* coder = param;
2889
26
  txInteger iterator;
2890
26
  txInteger method;
2891
26
  txInteger next;
2892
26
  txInteger result;
2893
2894
26
  txTargetCode* nextTarget = fxCoderCreateTarget(param);
2895
26
  txTargetCode* catchTarget = fxCoderCreateTarget(param);
2896
26
  txTargetCode* rethrowTarget = fxCoderCreateTarget(param);
2897
26
  txTargetCode* returnTarget = fxCoderCreateTarget(param);
2898
26
  txTargetCode* normalTarget = fxCoderCreateTarget(param);
2899
26
  txTargetCode* doneTarget = fxCoderCreateTarget(param);
2900
  
2901
26
  iterator = fxCoderUseTemporaryVariable(param);
2902
26
  method = fxCoderUseTemporaryVariable(param);
2903
26
  next = fxCoderUseTemporaryVariable(param);
2904
26
  result = fxCoderUseTemporaryVariable(param);
2905
  
2906
26
  fxNodeDispatchCode(self->expression, param);
2907
26
  if (async)
2908
10
    fxCoderAddByte(param, 0, XS_CODE_FOR_AWAIT_OF);
2909
16
  else
2910
16
    fxCoderAddByte(param, 0, XS_CODE_FOR_OF);
2911
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, iterator);
2912
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
2913
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, next);
2914
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2915
  
2916
26
  fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2917
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2918
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2919
26
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2920
26
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, normalTarget);
2921
  
2922
// LOOP 
2923
26
  fxCoderAdd(param, 0, nextTarget);
2924
26
  if (async)
2925
10
    fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2926
26
  fxCoderAddByte(coder, 0, XS_CODE_YIELD_STAR);
2927
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2928
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2929
26
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
2930
26
  fxCoderAddBranch(coder, 1, XS_CODE_BRANCH_STATUS_1, normalTarget);
2931
  
2932
// RETURN 
2933
26
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
2934
26
  if (async) {
2935
10
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2936
10
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2937
10
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
2938
10
    fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2939
10
    fxCoderAddByte(param, -1, XS_CODE_POP);
2940
10
  }  
2941
  
2942
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2943
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->returnSymbol);
2944
26
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_CHAIN_1, returnTarget);
2945
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2946
26
  fxCoderAddByte(param, 0, XS_CODE_SWAP);
2947
26
  fxCoderAddByte(param, 1, XS_CODE_CALL);
2948
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2949
26
  fxCoderAddInteger(param, -3, XS_CODE_RUN_1, 1);
2950
26
  if (async) {
2951
10
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2952
10
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
2953
10
  }
2954
26
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2955
26
  fxCoderAddByte(param, 1, XS_CODE_DUB);
2956
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
2957
26
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, nextTarget);
2958
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
2959
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
2960
26
  fxCoderAdd(coder, 0, returnTarget);
2961
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2962
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
2963
26
  if (async) {
2964
10
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2965
10
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
2966
10
  }  
2967
26
  fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
2968
26
  fxCoderAdjustEnvironment(coder, coder->returnTarget);
2969
26
  fxCoderAdjustScope(coder, coder->returnTarget);
2970
26
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, coder->returnTarget);
2971
  
2972
// THROW  
2973
26
  fxCoderAdd(coder, 0, catchTarget);
2974
2975
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2976
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->throwSymbol);
2977
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, method);
2978
26
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_COALESCE_1, doneTarget);
2979
  
2980
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2981
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->returnSymbol);
2982
26
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_CHAIN_1, rethrowTarget);
2983
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
2984
26
  fxCoderAddByte(param, 0, XS_CODE_SWAP);
2985
26
  fxCoderAddByte(param, 1, XS_CODE_CALL);
2986
26
  fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
2987
26
  if (async) {
2988
10
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
2989
10
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
2990
10
  }
2991
26
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2992
26
  fxCoderAdd(coder, 0, rethrowTarget);
2993
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2994
  
2995
26
  fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
2996
26
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
2997
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
2998
  
2999
// NORMAL 
3000
26
  fxCoderAdd(coder, 0, normalTarget);
3001
26
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
3002
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, next);
3003
26
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, method);
3004
26
  fxCoderAdd(param, 1, doneTarget);
3005
26
  fxCoderAddByte(param, -1, XS_CODE_POP);
3006
3007
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
3008
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, method);
3009
26
  fxCoderAddByte(param, 1, XS_CODE_CALL);
3010
26
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
3011
26
  fxCoderAddInteger(param, -3, XS_CODE_RUN_1, 1);
3012
26
  if (async) {
3013
10
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
3014
10
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
3015
10
  }
3016
26
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
3017
26
  fxCoderAddByte(param, 1, XS_CODE_DUB);
3018
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
3019
26
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, nextTarget);
3020
26
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
3021
3022
26
  fxCoderUnuseTemporaryVariables(param, 4);
3023
26
}
3024
3025
void fxDeleteNodeCode(void* it, void* param) 
3026
3.68k
{
3027
3.68k
  txDeleteNode* self = it;
3028
3.68k
  fxNodeDispatchCodeDelete(self->reference, param);
3029
3.68k
}
3030
3031
void fxDoNodeCode(void* it, void* param) 
3032
130
{
3033
130
  txDoNode* self = it;
3034
130
  txCoder* coder = param;
3035
130
  txTargetCode* loopTarget = fxCoderCreateTarget(param);
3036
130
  if (coder->programFlag) {
3037
108
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3038
108
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
3039
108
  }
3040
130
  fxCoderAdd(param, 0, loopTarget);
3041
130
  fxNodeDispatchCode(self->statement, param);
3042
130
  fxCoderAdd(param, 0, coder->firstContinueTarget);
3043
130
  fxNodeDispatchCode(self->expression, param);
3044
130
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, loopTarget);
3045
130
}
3046
3047
void fxExportNodeCode(void* it, void* param) 
3048
295
{
3049
295
}
3050
3051
void fxExpressionsNodeCode(void* it, void* param) 
3052
38.7k
{
3053
38.7k
  txExpressionsNode* self = it;
3054
38.7k
  if (self->items) {
3055
38.7k
    txNode* item = self->items->first;
3056
38.7k
    txNode* previous = NULL;
3057
38.7k
    txNode* next;
3058
89.1k
    while (item) {
3059
50.3k
      next = item->next;
3060
50.3k
      if (previous)
3061
11.5k
        fxCoderAddByte(param, -1, XS_CODE_POP);
3062
50.3k
      if (!next)
3063
38.7k
        item->flags |= (self->flags & mxTailRecursionFlag);
3064
50.3k
      fxNodeDispatchCode(item, param);
3065
50.3k
      previous = item;
3066
50.3k
      item = next;
3067
50.3k
    }
3068
38.7k
  }
3069
38.7k
}
3070
3071
txFlag fxExpressionsNodeCodeThis(void* it, void* param, txFlag flag) 
3072
500
{
3073
500
  txExpressionsNode* self = it;
3074
500
  if (self->items) {
3075
500
    txNode* item = self->items->first;
3076
500
    if (item->next == C_NULL) {
3077
492
      return fxNodeDispatchCodeThis(item, param, flag);
3078
492
    }
3079
500
  }
3080
8
  return fxNodeCodeThis(it, param, flag);
3081
500
}
3082
3083
void fxExpressionsNodeCodeDelete(void* it, void* param) 
3084
140
 {
3085
140
  txExpressionsNode* self = it;
3086
140
  if (self->items) {
3087
140
    txNode* item = self->items->first;
3088
140
    if (item->next == C_NULL) {
3089
132
      fxNodeDispatchCodeDelete(item, param);
3090
132
      return;
3091
132
    }
3092
140
  }
3093
8
  fxNodeCodeDelete(it, param);
3094
8
 }
3095
3096
void fxFieldNodeCode(void* it, void* param) 
3097
4.79k
{
3098
4.79k
  txFieldNode* self = it;
3099
4.79k
  txNode* item = self->item;
3100
4.79k
  fxCoderAddByte(param, 1, XS_CODE_THIS);
3101
4.79k
  if (item->description->token == XS_TOKEN_PROPERTY) {
3102
1.92k
    fxNodeDispatchCode(self->value, param);
3103
1.92k
    fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, ((txPropertyNode*)item)->symbol);
3104
1.92k
    fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, fxNodeCodeName(self->value) ? XS_NAME_FLAG : 0);
3105
1.92k
  }
3106
2.87k
  else if (item->description->token == XS_TOKEN_PROPERTY_AT) {
3107
2.63k
    fxCoderAddIndex(param, 1, XS_CODE_GET_CLOSURE_1, ((txPropertyAtNode*)item)->atAccess->declaration->index);
3108
2.63k
    fxNodeDispatchCode(self->value, param);
3109
2.63k
    fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
3110
2.63k
    fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, fxNodeCodeName(self->value) ? XS_NAME_FLAG : 0);
3111
2.63k
  }
3112
238
  else {
3113
238
    if (item->flags & (mxMethodFlag | mxGetterFlag | mxSetterFlag))
3114
93
      fxCoderAddIndex(param, 1, XS_CODE_GET_CLOSURE_1, ((txPrivatePropertyNode*)item)->valueAccess->declaration->index);
3115
145
    else
3116
145
      fxNodeDispatchCode(self->value, param);
3117
238
    fxCoderAddIndex(param, -2, XS_CODE_NEW_PRIVATE_1, ((txPrivatePropertyNode*)item)->symbolAccess->declaration->index);
3118
238
    if (item->flags & mxMethodFlag)
3119
93
      fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, XS_NAME_FLAG | XS_METHOD_FLAG);
3120
145
    else if (item->flags & mxGetterFlag)
3121
0
      fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, XS_NAME_FLAG | XS_METHOD_FLAG | XS_GETTER_FLAG);
3122
145
    else if (item->flags & mxSetterFlag)
3123
0
      fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, XS_NAME_FLAG | XS_METHOD_FLAG | XS_SETTER_FLAG);
3124
145
    else
3125
145
      fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, fxNodeCodeName(self->value) ? XS_NAME_FLAG : 0);
3126
238
  }
3127
4.79k
}
3128
3129
void fxForNodeCode(void* it, void* param) 
3130
5.03k
{
3131
5.03k
  txForNode* self = it;
3132
5.03k
  txCoder* coder = param;
3133
5.03k
  txTargetCode* continueTarget;
3134
5.03k
  txTargetCode* nextTarget;
3135
5.03k
  txTargetCode* doneTarget;
3136
5.03k
  txUsingContext context;
3137
  
3138
5.03k
  continueTarget = coder->firstContinueTarget;
3139
5.03k
  coder->firstContinueTarget = continueTarget->nextTarget;
3140
5.03k
  continueTarget->nextTarget = C_NULL;
3141
  
3142
5.03k
  fxScopeCodingBlock(self->scope, param);
3143
5.03k
  fxScopeCodeDefineNodes(self->scope, param);
3144
5.03k
  if (self->scope->disposableNodeCount)
3145
0
    fxScopeCodeUsing(self->scope, coder, &context); 
3146
5.03k
  nextTarget = fxCoderCreateTarget(param);
3147
5.03k
  doneTarget = fxCoderCreateTarget(param);
3148
5.03k
  if (self->initialization)
3149
4.94k
    fxNodeDispatchCode(self->initialization, param);
3150
5.03k
  if (coder->programFlag) {
3151
2.42k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3152
2.42k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
3153
2.42k
  }
3154
5.03k
  fxScopeCodeRefresh(self->scope, param);
3155
5.03k
  fxCoderAdd(param, 0, nextTarget);
3156
5.03k
  if (self->expression) {
3157
4.93k
    fxNodeDispatchCode(self->expression, param);
3158
4.93k
    fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, doneTarget);
3159
4.93k
  }
3160
  
3161
5.03k
  continueTarget->environmentLevel = coder->environmentLevel;
3162
5.03k
  continueTarget->scopeLevel = coder->scopeLevel;
3163
5.03k
  continueTarget->stackLevel = coder->stackLevel;
3164
5.03k
  continueTarget->nextTarget = coder->firstContinueTarget;
3165
5.03k
  coder->firstContinueTarget = continueTarget;
3166
5.03k
  fxNodeDispatchCode(self->statement, param);
3167
5.03k
  fxCoderAdd(param, 0, continueTarget);
3168
5.03k
  coder->firstContinueTarget = continueTarget->nextTarget;
3169
5.03k
  continueTarget->nextTarget = C_NULL;
3170
  
3171
5.03k
  if (self->iteration) {
3172
4.93k
    fxScopeCodeRefresh(self->scope, param);
3173
4.93k
    self->iteration->flags |= mxExpressionNoValue;
3174
4.93k
    fxNodeDispatchCode(self->iteration, param);
3175
4.93k
    fxCoderAddByte(param, -1, XS_CODE_POP);
3176
4.93k
  }
3177
5.03k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
3178
5.03k
  fxCoderAdd(param, 0, doneTarget);
3179
5.03k
  if (self->scope->disposableNodeCount)
3180
0
    fxScopeCodeUsed(self->scope, coder, &context);
3181
5.03k
  fxScopeCoded(self->scope, param);
3182
  
3183
5.03k
  continueTarget->nextTarget = coder->firstContinueTarget;
3184
5.03k
  coder->firstContinueTarget = continueTarget;
3185
5.03k
}
3186
3187
void fxForInForOfNodeCode(void* it, void* param) 
3188
6.44k
{
3189
6.44k
  txForInForOfNode* self = it;
3190
6.44k
  txCoder* coder = param;
3191
6.44k
  txBoolean async = (self->description->code == XS_CODE_FOR_AWAIT_OF) ? 1 : 0;
3192
6.44k
  txTargetCode* continueTarget;
3193
6.44k
  txInteger iterator;
3194
6.44k
  txInteger next;
3195
6.44k
  txInteger done;
3196
6.44k
  txInteger result;
3197
6.44k
  txInteger exception;
3198
6.44k
  txInteger selector;
3199
6.44k
  txInteger selection;
3200
6.44k
  txTargetCode* nextTarget;
3201
6.44k
  txTargetCode* returnTarget;
3202
6.44k
  txTargetCode* doneTarget;
3203
6.44k
  txTargetCode* catchTarget;
3204
6.44k
  txTargetCode* normalTarget;
3205
6.44k
  txTargetCode* uncatchTarget;
3206
6.44k
  txTargetCode* finallyTarget;
3207
6.44k
  txTargetCode* elseTarget;
3208
  
3209
6.44k
  iterator = fxCoderUseTemporaryVariable(param);
3210
6.44k
  next = fxCoderUseTemporaryVariable(param);
3211
6.44k
  done = fxCoderUseTemporaryVariable(param);
3212
6.44k
  result = fxCoderUseTemporaryVariable(param);
3213
6.44k
  exception = fxCoderUseTemporaryVariable(coder);
3214
6.44k
  selector = fxCoderUseTemporaryVariable(coder);
3215
  
3216
6.44k
  continueTarget = coder->firstContinueTarget;
3217
6.44k
  coder->firstContinueTarget = continueTarget->nextTarget;
3218
6.44k
  continueTarget->nextTarget = C_NULL;
3219
  
3220
6.44k
  fxScopeCodingBlock(self->scope, param);
3221
6.44k
  fxScopeCodeDefineNodes(self->scope, param);
3222
3223
6.44k
  if (coder->programFlag) {
3224
4.53k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3225
4.53k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
3226
4.53k
  }
3227
6.44k
  fxNodeDispatchCode(self->expression, param);
3228
6.44k
  fxCoderAddByte(param, 0, self->description->code);
3229
6.44k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, iterator);
3230
6.44k
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
3231
6.44k
  fxCoderAddIndex(param, 0, XS_CODE_PULL_LOCAL_1, next);
3232
3233
6.44k
  coder->firstBreakTarget = fxCoderAliasTargets(param, coder->firstBreakTarget);
3234
6.44k
  coder->firstContinueTarget = fxCoderAliasTargets(param, coder->firstContinueTarget);
3235
6.44k
  coder->returnTarget = fxCoderAliasTargets(param, coder->returnTarget);
3236
6.44k
  catchTarget = fxCoderCreateTarget(param);
3237
6.44k
  normalTarget = fxCoderCreateTarget(param);
3238
6.44k
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
3239
  
3240
// LOOP 
3241
6.44k
  nextTarget = fxCoderCreateTarget(param);
3242
6.44k
  fxCoderAdd(param, 0, nextTarget);
3243
6.44k
  fxCoderAddByte(param, 1, XS_CODE_TRUE);
3244
6.44k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
3245
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
3246
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, next);
3247
6.44k
  fxCoderAddByte(param, 1, XS_CODE_CALL);
3248
6.44k
  fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
3249
6.44k
  if (async) {
3250
5
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
3251
5
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
3252
5
  }
3253
6.44k
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
3254
6.44k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, result);
3255
6.44k
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
3256
6.44k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, done);
3257
6.44k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, normalTarget);
3258
3259
6.44k
  fxScopeCodeReset(self->scope, param);
3260
6.44k
  fxNodeDispatchCodeReference(self->reference, param, 0);
3261
6.44k
  fxCoderAddByte(param, 1, XS_CODE_TRUE);
3262
6.44k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
3263
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
3264
6.44k
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
3265
6.44k
  fxCoderAddByte(param, 1, XS_CODE_FALSE);
3266
6.44k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, done);
3267
6.44k
  fxNodeDispatchCodeAssign(self->reference, param, 0);
3268
6.44k
  fxCoderAddByte(param, -1, XS_CODE_POP);
3269
3270
6.44k
  continueTarget->environmentLevel = coder->environmentLevel;
3271
6.44k
  continueTarget->scopeLevel = coder->scopeLevel;
3272
6.44k
  continueTarget->stackLevel = coder->stackLevel;
3273
6.44k
  continueTarget->nextTarget = coder->firstContinueTarget;
3274
6.44k
  coder->firstContinueTarget = continueTarget;
3275
6.44k
  fxNodeDispatchCode(self->statement, param);
3276
6.44k
  fxCoderAdd(param, 0, coder->firstContinueTarget);
3277
6.44k
  coder->firstContinueTarget = continueTarget->nextTarget;
3278
6.44k
  continueTarget->nextTarget = C_NULL;
3279
  
3280
6.44k
  fxScopeCodeUsedReverse(self->scope, coder, self->scope->firstDeclareNode, exception, selector);
3281
3282
6.44k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
3283
3284
//   PRE FINALLY
3285
6.44k
  uncatchTarget = fxCoderCreateTarget(param);
3286
6.44k
  finallyTarget = fxCoderCreateTarget(param);
3287
3288
6.44k
  fxCoderAdd(coder, 0, catchTarget);
3289
6.44k
  fxCoderAddByte(coder, 1, XS_CODE_EXCEPTION);
3290
6.44k
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, exception);
3291
6.44k
  fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, 0);
3292
6.44k
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, selector);
3293
6.44k
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, finallyTarget);
3294
6.44k
  selection = 1;
3295
6.44k
  coder->firstBreakTarget = fxCoderFinalizeTargets(param, coder->firstBreakTarget, selector, &selection, uncatchTarget);
3296
6.44k
  coder->firstContinueTarget = fxCoderFinalizeTargets(param, coder->firstContinueTarget, selector, &selection, uncatchTarget);
3297
6.44k
  coder->returnTarget = fxCoderFinalizeTargets(param, coder->returnTarget, selector, &selection, uncatchTarget);
3298
6.44k
  fxCoderAdd(param, 0, normalTarget);
3299
6.44k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, selection);
3300
6.44k
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, selector);
3301
6.44k
  fxCoderAdd(coder, 0, uncatchTarget);
3302
6.44k
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
3303
6.44k
  fxCoderAdd(param, 0, finallyTarget);
3304
  
3305
//   FINALLY
3306
6.44k
  catchTarget = fxCoderCreateTarget(param);
3307
6.44k
  normalTarget = fxCoderCreateTarget(param);
3308
3309
6.44k
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
3310
3311
6.44k
  doneTarget = fxCoderCreateTarget(param);
3312
6.44k
  returnTarget = fxCoderCreateTarget(param);
3313
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, done);
3314
6.44k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
3315
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
3316
6.44k
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->returnSymbol);
3317
6.44k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_CHAIN_1, returnTarget);
3318
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
3319
6.44k
  fxCoderAddByte(param, 0, XS_CODE_SWAP);
3320
6.44k
  fxCoderAddByte(param, 1, XS_CODE_CALL);
3321
6.44k
  fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
3322
6.44k
  if (async) {
3323
5
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
3324
5
    fxCoderAddByte(param, 0, XS_CODE_THROW_STATUS);
3325
5
  }
3326
6.44k
  fxCoderAddByte(param, 0, XS_CODE_CHECK_INSTANCE);
3327
6.44k
  fxCoderAdd(param, 0, returnTarget);
3328
6.44k
  fxCoderAddByte(param, -1, XS_CODE_POP);
3329
6.44k
  fxCoderAdd(param, 0, doneTarget);
3330
  
3331
6.44k
  fxCoderAddByte(coder, 0, XS_CODE_UNCATCH);
3332
6.44k
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, normalTarget);
3333
  
3334
6.44k
  fxCoderAdd(coder, 0, catchTarget);
3335
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, selector);
3336
6.44k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, normalTarget);
3337
6.44k
  fxCoderAddByte(coder, 1, XS_CODE_EXCEPTION);
3338
6.44k
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, exception);
3339
6.44k
  fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, 0);
3340
6.44k
  fxCoderAddIndex(coder, -1, XS_CODE_PULL_LOCAL_1, selector);
3341
6.44k
  fxCoderAdd(param, 0, normalTarget);
3342
3343
6.44k
  fxScopeCodeUsedReverse(self->scope, coder, self->scope->firstDeclareNode, exception, selector);
3344
3345
//   POST FINALLY
3346
6.44k
  elseTarget = fxCoderCreateTarget(param);
3347
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, selector);
3348
6.44k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, elseTarget);
3349
6.44k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, exception);
3350
6.44k
  fxCoderAddByte(param, -1, XS_CODE_THROW);
3351
6.44k
  fxCoderAdd(param, 0, elseTarget);
3352
6.44k
  selection = 1;
3353
6.44k
  fxCoderJumpTargets(param, coder->firstBreakTarget, selector, &selection);
3354
6.44k
  fxCoderJumpTargets(param, coder->firstContinueTarget, selector, &selection);
3355
6.44k
  fxCoderJumpTargets(param, coder->returnTarget, selector, &selection);
3356
  
3357
6.44k
  fxScopeCoded(self->scope, param);
3358
6.44k
  continueTarget->nextTarget = coder->firstContinueTarget;
3359
6.44k
  coder->firstContinueTarget = continueTarget;
3360
  
3361
6.44k
  fxCoderUnuseTemporaryVariables(param, 6);
3362
6.44k
}
3363
3364
void fxFunctionNodeCode(void* it, void* param) 
3365
53.0k
{
3366
53.0k
  txFunctionNode* self = it;
3367
53.0k
  txCoder* coder = param;
3368
53.0k
  txInteger environmentLevel = coder->environmentLevel;
3369
53.0k
  txBoolean evalFlag = coder->evalFlag;
3370
53.0k
  txInteger line = coder->line;
3371
53.0k
  txBoolean programFlag = coder->programFlag;
3372
53.0k
  txInteger scopeLevel = coder->scopeLevel;
3373
53.0k
  txTargetCode* firstBreakTarget = coder->firstBreakTarget;
3374
53.0k
  txTargetCode* firstContinueTarget = coder->firstContinueTarget;
3375
53.0k
  txTargetCode* returnTarget = coder->returnTarget;
3376
53.0k
  txSymbol* name = self->symbol;
3377
53.0k
  txTargetCode* target = fxCoderCreateTarget(param);
3378
  
3379
53.0k
  if ((self->flags & mxEvalFlag) && !(self->flags & mxStrictFlag))
3380
1.03k
    coder->evalFlag = 1;
3381
53.0k
  coder->line = -1;
3382
53.0k
  coder->programFlag = 0;
3383
53.0k
  coder->scopeLevel = 0;
3384
53.0k
  coder->firstBreakTarget = NULL;
3385
53.0k
  coder->firstContinueTarget = NULL;
3386
3387
53.0k
    if (name) {
3388
28.3k
        if (self->flags & mxGetterFlag) {
3389
0
            txString buffer = coder->parser->buffer;
3390
0
            c_strcpy(buffer, "get ");
3391
0
            c_strcat(buffer, name->string);
3392
0
            name = fxNewParserSymbol(coder->parser, buffer);
3393
0
        }
3394
28.3k
        else if (self->flags & mxSetterFlag) {
3395
0
            txString buffer = coder->parser->buffer;
3396
0
            c_strcpy(buffer, "set ");
3397
0
            c_strcat(buffer, name->string);
3398
0
            name = fxNewParserSymbol(coder->parser, buffer);
3399
0
        }
3400
28.3k
    }
3401
    
3402
53.0k
  if (self->flags & mxAsyncFlag) {
3403
679
    if (self->flags & mxGeneratorFlag)
3404
136
      fxCoderAddSymbol(param, 1, XS_CODE_ASYNC_GENERATOR_FUNCTION, name);
3405
543
    else
3406
543
      fxCoderAddSymbol(param, 1, XS_CODE_ASYNC_FUNCTION, name);
3407
679
  }
3408
52.4k
  else if (self->flags & mxGeneratorFlag)
3409
298
    fxCoderAddSymbol(param, 1, XS_CODE_GENERATOR_FUNCTION, name);
3410
52.1k
  else if (self->flags & (mxArrowFlag | mxMethodFlag | mxGetterFlag | mxSetterFlag))
3411
14.2k
    fxCoderAddSymbol(param, 1, XS_CODE_FUNCTION, name);
3412
37.8k
  else
3413
37.8k
    fxCoderAddSymbol(param, 1, XS_CODE_CONSTRUCTOR_FUNCTION, name);
3414
53.0k
  if (coder->parser->flags & mxDebugFlag)
3415
53.0k
    fxCoderAddByte(param, 0, XS_CODE_PROFILE);
3416
53.0k
  fxCoderAddBranch(param, 0, XS_CODE_CODE_1, target);
3417
53.0k
  if (self->flags & mxFieldFlag)
3418
1.04k
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT_FIELD, fxCoderCountParameters(coder, self->params));
3419
52.0k
  else if (self->flags & mxDerivedFlag)
3420
282
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT_DERIVED, fxCoderCountParameters(coder, self->params));
3421
51.7k
  else if (self->flags & mxBaseFlag)
3422
2.76k
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT_BASE, fxCoderCountParameters(coder, self->params));
3423
49.0k
  else if (self->flags & mxStrictFlag)
3424
1.57k
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT, fxCoderCountParameters(coder, self->params));
3425
47.4k
  else
3426
47.4k
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_SLOPPY, fxCoderCountParameters(coder, self->params));
3427
53.0k
  coder->path = C_NULL;
3428
53.0k
  if (self->line >= 0)
3429
51.5k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, it); 
3430
53.0k
  if (self->scopeCount)
3431
42.3k
    fxCoderAddIndex(param, 0, XS_CODE_RESERVE_1, self->scopeCount);
3432
53.0k
  fxScopeCodeRetrieve(self->scope, param);
3433
53.0k
  fxScopeCodingParams(self->scope, param);
3434
53.0k
  if ((self->flags & mxAsyncFlag) && !(self->flags & mxGeneratorFlag))
3435
543
    fxCoderAddByte(param, 0, XS_CODE_START_ASYNC);
3436
53.0k
  if (self->flags & mxBaseFlag) {
3437
2.76k
    if (coder->classNode->instanceInitAccess) {
3438
1.99k
      fxCoderAddByte(param, 1, XS_CODE_THIS);
3439
1.99k
      fxCoderAddIndex(param, 1, XS_CODE_GET_CLOSURE_1, coder->classNode->instanceInitAccess->declaration->index);
3440
1.99k
      fxCoderAddByte(param, 1, XS_CODE_CALL);
3441
1.99k
      fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
3442
1.99k
      fxCoderAddByte(param, -1, XS_CODE_POP);
3443
1.99k
    }
3444
2.76k
  }
3445
53.0k
  fxNodeDispatchCode(self->params, param);
3446
53.0k
  if ((coder->parser->flags & mxDebugFlag) && coder->path)
3447
51.5k
    fxCoderAddIndex(coder, 0, XS_CODE_LINE, 0);
3448
53.0k
  fxScopeCodeDefineNodes(self->scope, param);
3449
53.0k
  coder->returnTarget = fxCoderCreateTarget(param);
3450
53.0k
  if (self->flags & mxGeneratorFlag) {
3451
434
    if (self->flags & mxAsyncFlag)
3452
136
      fxCoderAddByte(param, 0, XS_CODE_START_ASYNC_GENERATOR);
3453
298
    else
3454
298
      fxCoderAddByte(param, 0, XS_CODE_START_GENERATOR);
3455
434
  }
3456
53.0k
  fxNodeDispatchCode(self->body, param);
3457
53.0k
  fxCoderAdd(param, 0, coder->returnTarget);
3458
53.0k
  if (self->flags & mxArrowFlag)
3459
9.34k
    fxCoderAddByte(param, 0, XS_CODE_END_ARROW);
3460
43.7k
  else if (self->flags & mxBaseFlag)
3461
2.76k
    fxCoderAddByte(param, 0, XS_CODE_END_BASE);
3462
40.9k
  else if (self->flags & mxDerivedFlag)
3463
282
    fxCoderAddByte(param, 0, XS_CODE_END_DERIVED);
3464
40.7k
  else
3465
40.7k
    fxCoderAddByte(param, 0, XS_CODE_END);
3466
53.0k
  fxCoderAdd(param, 0, target);
3467
  
3468
53.0k
  if ((self->scope->flags & mxEvalFlag) || coder->evalFlag) {
3469
6.14k
    fxCoderAddByte(coder, 1, XS_CODE_FUNCTION_ENVIRONMENT);
3470
6.14k
    fxScopeCodeStore(self->scope, param);
3471
6.14k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
3472
6.14k
  }
3473
46.9k
  else if (self->scope->closureNodeCount || ((self->flags & mxArrowFlag) && (self->flags & mxDefaultFlag))) {
3474
5.07k
    fxCoderAddByte(coder, 1, XS_CODE_ENVIRONMENT);
3475
5.07k
    fxScopeCodeStore(self->scope, param);
3476
5.07k
    fxCoderAddByte(coder, -1, XS_CODE_POP);
3477
5.07k
  }
3478
53.0k
  if ((self->flags & (mxArrowFlag | mxBaseFlag | mxDerivedFlag | mxGeneratorFlag | mxStrictFlag | mxMethodFlag)) == 0) {
3479
35.4k
    fxCoderAddByte(param, 1, XS_CODE_DUB);
3480
35.4k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3481
35.4k
    fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, coder->parser->callerSymbol);
3482
35.4k
    fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, XS_DONT_ENUM_FLAG);
3483
35.4k
  }
3484
  
3485
53.0k
  coder->returnTarget = returnTarget;
3486
53.0k
  coder->firstContinueTarget = firstContinueTarget;
3487
53.0k
  coder->firstBreakTarget = firstBreakTarget;
3488
53.0k
  coder->scopeLevel = scopeLevel;
3489
53.0k
  coder->programFlag = programFlag;
3490
53.0k
  coder->line = line;
3491
53.0k
  coder->evalFlag = evalFlag;
3492
53.0k
  coder->environmentLevel = environmentLevel;
3493
53.0k
}
3494
3495
void fxHostNodeCode(void* it, void* param) 
3496
0
{
3497
0
  txHostNode* self = it;
3498
0
  txCoder* coder = param;
3499
0
  txParser* parser = coder->parser;
3500
0
    if (self->symbol) {
3501
0
        if (self->flags & mxGetterFlag) {
3502
0
            txString buffer = coder->parser->buffer;
3503
0
            c_strcpy(buffer, "get ");
3504
0
            c_strcat(buffer, self->symbol->string);
3505
0
            self->symbol = fxNewParserSymbol(coder->parser, buffer);
3506
0
        }
3507
0
        else if (self->flags & mxSetterFlag) {
3508
0
            txString buffer = coder->parser->buffer;
3509
0
            c_strcpy(buffer, "set ");
3510
0
            c_strcat(buffer, self->symbol->string);
3511
0
            self->symbol = fxNewParserSymbol(coder->parser, buffer);
3512
0
        }
3513
0
    }
3514
0
  if (self->params)
3515
0
    self->paramsCount = fxCoderCountParameters(coder, self->params);
3516
0
  else
3517
0
    self->paramsCount = -1; 
3518
0
  if (parser->firstHostNode)
3519
0
    parser->lastHostNode->nextHostNode = self;
3520
0
  else
3521
0
    parser->firstHostNode = self;
3522
0
  parser->lastHostNode = self;
3523
0
  fxCoderAddIndex(param, 1, XS_CODE_HOST, parser->hostNodeIndex);
3524
0
  parser->hostNodeIndex++;
3525
0
}
3526
3527
void fxIfNodeCode(void* it, void* param) 
3528
2.10k
{
3529
2.10k
  txIfNode* self = it;
3530
2.10k
  txCoder* coder = param;
3531
2.10k
  fxNodeDispatchCode(self->expression, param);
3532
2.10k
  if (coder->programFlag) {
3533
1.54k
    txTargetCode* elseTarget = fxCoderCreateTarget(param);
3534
1.54k
    txTargetCode* endTarget = fxCoderCreateTarget(param);
3535
1.54k
    fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, elseTarget);
3536
1.54k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3537
1.54k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
3538
1.54k
    fxNodeDispatchCode(self->thenStatement, param);
3539
1.54k
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, endTarget);
3540
1.54k
    fxCoderAdd(param, 0, elseTarget);
3541
1.54k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3542
1.54k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
3543
1.54k
    if (self->elseStatement)
3544
215
      fxNodeDispatchCode(self->elseStatement, param);
3545
1.54k
    fxCoderAdd(param, 0, endTarget);
3546
1.54k
  }
3547
561
  else {
3548
561
    if (self->elseStatement) {
3549
173
      txTargetCode* elseTarget = fxCoderCreateTarget(param);
3550
173
      txTargetCode* endTarget = fxCoderCreateTarget(param);
3551
173
      fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, elseTarget);
3552
173
      fxNodeDispatchCode(self->thenStatement, param);
3553
173
      fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, endTarget);
3554
173
      fxCoderAdd(param, 0, elseTarget);
3555
173
      fxNodeDispatchCode(self->elseStatement, param);
3556
173
      fxCoderAdd(param, 0, endTarget);
3557
173
    }
3558
388
    else {
3559
388
      txTargetCode* endTarget = fxCoderCreateTarget(param);
3560
388
      fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, endTarget);
3561
388
      fxNodeDispatchCode(self->thenStatement, param);
3562
388
      fxCoderAdd(param, 0, endTarget);
3563
388
    }
3564
561
  }
3565
2.10k
}
3566
3567
void fxImportNodeCode(void* it, void* param) 
3568
77
{
3569
77
}
3570
3571
void fxImportCallNodeCode(void* it, void* param)
3572
423
{
3573
423
  txCoder* coder = param;
3574
423
  txImportCallNode* self = it;
3575
423
  fxNodeDispatchCode(self->expression, param);
3576
423
  if (self->withExpression)
3577
13
    fxNodeDispatchCode(self->withExpression, param);
3578
410
  else
3579
410
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3580
423
  coder->importFlag = 1;
3581
423
  fxCoderAddByte(param, -1, XS_CODE_IMPORT);
3582
423
}
3583
3584
void fxImportMetaNodeCode(void* it, void* param)
3585
79
{
3586
79
  txCoder* coder = param;
3587
79
  coder->importMetaFlag = 1;
3588
79
  fxCoderAddByte(param, 1, XS_CODE_IMPORT_META);
3589
79
}
3590
3591
void fxIncludeNodeCode(void* it, void* param) 
3592
0
{
3593
0
  txIncludeNode* self = it;
3594
0
  fxNodeDispatchCode(self->body, param);
3595
0
}
3596
3597
void fxIntegerNodeCode(void* it, void* param) 
3598
173k
{
3599
173k
  txIntegerNode* self = it;
3600
173k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, self->value);
3601
173k
}
3602
3603
void fxLabelNodeCode(void* it, void* param) 
3604
16.4k
{
3605
16.4k
  txLabelNode* self = it;
3606
16.4k
  txCoder* coder = param;
3607
16.4k
  txNode* statement = self->statement;
3608
16.4k
  txTargetCode* breakTarget;
3609
16.6k
  while (statement->description->token == XS_TOKEN_LABEL) {
3610
190
    txLabelNode* former = (txLabelNode*)statement;
3611
190
    txLabelNode* current = self;
3612
461
    while (current) {
3613
271
      if (former->symbol && current->symbol && (former->symbol == current->symbol)) {
3614
8
        fxReportParserError(coder->parser, current->line, "duplicate label %s", current->symbol->string);
3615
8
      }
3616
271
      current = current->nextLabel;
3617
271
    }
3618
190
    former->nextLabel = self;
3619
190
    self = former;
3620
190
    statement = self->statement;
3621
190
  }
3622
16.4k
  breakTarget = coder->firstBreakTarget;
3623
33.7k
  while (breakTarget) {
3624
17.3k
    txLabelNode* former = breakTarget->label;
3625
17.3k
    if (former) {
3626
17.3k
      txLabelNode* current = self;
3627
34.9k
      while (current) {
3628
17.5k
        if (former->symbol && current->symbol && (former->symbol == current->symbol)) {
3629
1
          fxReportParserError(coder->parser, current->line, "duplicate label %s", current->symbol->string);
3630
1
        }
3631
17.5k
        current = current->nextLabel;
3632
17.5k
      }
3633
17.3k
    }
3634
17.3k
    breakTarget = breakTarget->nextTarget;
3635
17.3k
  }
3636
16.4k
  breakTarget = fxCoderCreateTarget(coder);
3637
16.4k
  breakTarget->nextTarget = coder->firstBreakTarget;
3638
16.4k
  coder->firstBreakTarget = breakTarget;
3639
16.4k
  breakTarget->label = self;
3640
16.4k
  if (self->symbol)
3641
2.44k
    fxNodeDispatchCode(statement, param);
3642
13.9k
  else {
3643
13.9k
    txTargetCode* continueTarget = fxCoderCreateTarget(coder);
3644
13.9k
    continueTarget->nextTarget = coder->firstContinueTarget;
3645
13.9k
    coder->firstContinueTarget = continueTarget;
3646
13.9k
    continueTarget->label = self;
3647
13.9k
    fxNodeDispatchCode(statement, param);
3648
13.9k
    coder->firstContinueTarget = continueTarget->nextTarget;
3649
13.9k
  }
3650
16.4k
  fxCoderAdd(param, 0, coder->firstBreakTarget);
3651
16.4k
  coder->firstBreakTarget = breakTarget->nextTarget;
3652
16.4k
}
3653
3654
void fxMemberNodeCode(void* it, void* param) 
3655
23.3k
{
3656
23.3k
  txMemberNode* self = it;
3657
23.3k
  fxNodeDispatchCode(self->reference, param);
3658
23.3k
  fxCoderAddSymbol(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_GET_SUPER : XS_CODE_GET_PROPERTY, self->symbol);
3659
23.3k
}
3660
3661
void fxMemberNodeCodeAssign(void* it, void* param, txFlag flag) 
3662
3.51k
{
3663
3.51k
  txMemberNode* self = it;
3664
3.51k
  fxCoderAddSymbol(param, -1, (self->reference->flags & mxSuperFlag) ? XS_CODE_SET_SUPER : XS_CODE_SET_PROPERTY, self->symbol);
3665
3.51k
}
3666
3667
void fxMemberNodeCodeDelete(void* it, void* param) 
3668
718
{
3669
718
  txMemberNode* self = it;
3670
718
  fxNodeDispatchCode(self->reference, param);
3671
718
  fxCoderAddSymbol(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_DELETE_SUPER : XS_CODE_DELETE_PROPERTY, self->symbol);
3672
718
}
3673
3674
void fxMemberNodeCodeReference(void* it, void* param, txFlag flag) 
3675
3.23k
{
3676
3.23k
  txMemberNode* self = it;
3677
3.23k
  fxNodeDispatchCode(self->reference, param);
3678
3.23k
}
3679
3680
txFlag fxMemberNodeCodeThis(void* it, void* param, txFlag flag) 
3681
73.7k
{
3682
73.7k
  txMemberNode* self = it;
3683
73.7k
  fxNodeDispatchCode(self->reference, param);
3684
73.7k
  fxCoderAddByte(param, 1, XS_CODE_DUB);
3685
73.7k
  fxCoderAddSymbol(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_GET_SUPER : XS_CODE_GET_PROPERTY, self->symbol);
3686
73.7k
  return 1;
3687
73.7k
}
3688
3689
void fxMemberAtNodeCode(void* it, void* param) 
3690
3.70k
{
3691
3.70k
  txMemberAtNode* self = it;
3692
3.70k
  fxNodeDispatchCode(self->reference, param);
3693
3.70k
  fxNodeDispatchCode(self->at, param);
3694
3.70k
  fxCoderAddByte(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_SUPER_AT : XS_CODE_AT);
3695
3.70k
  fxCoderAddByte(param, -1, (self->reference->flags & mxSuperFlag) ? XS_CODE_GET_SUPER_AT : XS_CODE_GET_PROPERTY_AT);
3696
3.70k
}
3697
3698
void fxMemberAtNodeCodeAssign(void* it, void* param, txFlag flag) 
3699
1.80k
{
3700
1.80k
  txMemberAtNode* self = it;
3701
1.80k
  if (flag)
3702
1.47k
    fxCoderAddByte(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_SUPER_AT_2 : XS_CODE_AT_2);
3703
1.80k
  fxCoderAddByte(param, -2, (self->reference->flags & mxSuperFlag) ? XS_CODE_SET_SUPER_AT : XS_CODE_SET_PROPERTY_AT);
3704
1.80k
}
3705
3706
void fxMemberAtNodeCodeDelete(void* it, void* param) 
3707
104
{
3708
104
  txMemberAtNode* self = it;
3709
104
  fxMemberAtNodeCodeReference(it, param, (self->reference->flags & mxSuperFlag) ? 1 : 0);
3710
104
  fxCoderAddByte(param, -1, (self->reference->flags & mxSuperFlag) ? XS_CODE_DELETE_SUPER_AT : XS_CODE_DELETE_PROPERTY_AT);
3711
104
}
3712
3713
void fxMemberAtNodeCodeReference(void* it, void* param, txFlag flag) 
3714
1.90k
{
3715
1.90k
  txMemberAtNode* self = it;
3716
1.90k
  fxNodeDispatchCode(self->reference, param);
3717
1.90k
  fxNodeDispatchCode(self->at, param);
3718
1.90k
  if (!flag)
3719
430
    fxCoderAddByte(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_SUPER_AT : XS_CODE_AT);
3720
1.90k
}
3721
3722
txFlag fxMemberAtNodeCodeThis(void* it, void* param, txFlag flag) 
3723
801
{
3724
801
  txMemberAtNode* self = it;
3725
801
  if (flag) {
3726
324
    fxMemberAtNodeCodeReference(it, param, 0);
3727
324
    fxCoderAddByte(param, 2, XS_CODE_DUB_AT);
3728
324
    flag = 2;
3729
324
  }
3730
477
  else {
3731
477
    fxNodeDispatchCode(self->reference, param);
3732
477
    fxCoderAddByte(param, 1, XS_CODE_DUB);
3733
477
    fxNodeDispatchCode(self->at, param);
3734
477
    fxCoderAddByte(param, 0, (self->reference->flags & mxSuperFlag) ? XS_CODE_SUPER_AT : XS_CODE_AT);
3735
477
  }
3736
801
  fxCoderAddByte(param, -1, (self->reference->flags & mxSuperFlag) ? XS_CODE_GET_SUPER_AT : XS_CODE_GET_PROPERTY_AT);
3737
801
  return flag;
3738
801
}
3739
3740
void fxModuleNodeCode(void* it, void* param) 
3741
230
{
3742
230
  txModuleNode* self = it;
3743
230
  txCoder* coder = param;
3744
230
  txTargetCode* target = fxCoderCreateTarget(param);
3745
230
  txDeclareNode* declaration;
3746
230
  txInteger count;
3747
230
  txSymbol* name = /*(coder->parser->flags & mxDebugFlag) ? self->path :*/ C_NULL;
3748
230
  txFlag flag = 0;
3749
  
3750
230
  coder->line = -1;
3751
230
  coder->programFlag = 0;
3752
230
  coder->scopeLevel = 0;
3753
230
  coder->firstBreakTarget = NULL;
3754
230
  coder->firstContinueTarget = NULL;
3755
3756
230
  count = 0;
3757
230
  declaration = self->scope->firstDeclareNode;
3758
614
  while (declaration) {
3759
384
    if ((declaration->description->token == XS_TOKEN_DEFINE) || (declaration->description->token == XS_TOKEN_VAR))
3760
14
      count++;
3761
384
    declaration = declaration->nextDeclareNode;
3762
384
  }
3763
230
  if (count) {
3764
12
    fxCoderAddSymbol(param, 1, XS_CODE_FUNCTION, name);
3765
12
    if (coder->parser->flags & mxDebugFlag)
3766
12
      fxCoderAddByte(param, 0, XS_CODE_PROFILE);
3767
12
    fxCoderAddBranch(param, 0, XS_CODE_CODE_1, target);
3768
12
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT, 0);
3769
12
    coder->path = C_NULL;
3770
12
    if (self->line >= 0)
3771
12
      fxCoderAddLine(coder, 0, XS_CODE_LINE, it); 
3772
12
    if (self->scopeCount)
3773
12
      fxCoderAddIndex(param, 0, XS_CODE_RESERVE_1, self->scopeCount);
3774
12
    fxScopeCodeRetrieve(self->scope, param);
3775
12
    declaration = self->scope->firstDeclareNode;
3776
64
    while (declaration) {
3777
52
      if (declaration->description->token == XS_TOKEN_VAR) {
3778
12
        fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
3779
12
        fxCoderAddIndex(coder, 0, XS_CODE_VAR_CLOSURE_1, declaration->index);
3780
12
        fxCoderAddByte(coder, -1, XS_CODE_POP);
3781
12
      }
3782
52
      declaration = declaration->nextDeclareNode;
3783
52
    }
3784
12
    fxScopeCodeDefineNodes(self->scope, param);
3785
12
    fxCoderAddByte(param, 0, XS_CODE_END);
3786
12
    fxCoderAdd(param, 0, target);
3787
12
    fxCoderAddByte(param, 1, XS_CODE_ENVIRONMENT);
3788
12
    fxCoderAddByte(param, -1, XS_CODE_POP);
3789
  
3790
12
    target = fxCoderCreateTarget(param);
3791
12
    coder->line = -1;
3792
12
    coder->programFlag = 0;
3793
12
    coder->scopeLevel = 0;
3794
12
    coder->firstBreakTarget = NULL;
3795
12
    coder->firstContinueTarget = NULL;
3796
12
  }
3797
218
  else {
3798
218
    fxCoderAddByte(coder, 1, XS_CODE_NULL);
3799
218
  }
3800
  
3801
230
  if (self->flags & mxAwaitingFlag)
3802
3
    fxCoderAddSymbol(param, 1, XS_CODE_ASYNC_FUNCTION, name);
3803
227
  else
3804
227
    fxCoderAddSymbol(param, 1, XS_CODE_FUNCTION, name);
3805
230
  if (coder->parser->flags & mxDebugFlag)
3806
230
    fxCoderAddByte(param, 0, XS_CODE_PROFILE);
3807
230
  fxCoderAddBranch(param, 0, XS_CODE_CODE_1, target);
3808
230
  fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT, 0);
3809
230
  coder->path = C_NULL;
3810
230
  if (self->line >= 0)
3811
230
    fxCoderAddLine(coder, 0, XS_CODE_LINE, it); 
3812
230
  if (self->scopeCount)
3813
182
    fxCoderAddIndex(param, 0, XS_CODE_RESERVE_1, self->scopeCount);
3814
230
  fxScopeCodeRetrieve(self->scope, param);
3815
  
3816
230
  if (self->flags & mxAwaitingFlag)
3817
3
    fxCoderAddByte(param, 0, XS_CODE_START_ASYNC);
3818
3819
230
  coder->returnTarget = fxCoderCreateTarget(param);
3820
  
3821
230
  fxNodeDispatchCode(self->body, param);
3822
  
3823
230
  fxCoderAdd(param, 0, coder->returnTarget);
3824
230
  fxCoderAddByte(param, 0, XS_CODE_END);
3825
230
  fxCoderAdd(param, 0, target);
3826
  
3827
230
  fxCoderAddByte(param, 1, XS_CODE_ENVIRONMENT);
3828
230
  fxCoderAddByte(param, -1, XS_CODE_POP);
3829
  
3830
230
  count = 2 + fxScopeCodeSpecifierNodes(self->scope, coder);
3831
230
  fxCoderAddInteger(coder, 1, XS_CODE_INTEGER_1, count);
3832
230
  if (!(self->flags & mxStrictFlag))
3833
0
    flag |= XS_JSON_MODULE_FLAG;
3834
230
  if (coder->importFlag)
3835
4
    flag |= XS_IMPORT_FLAG;
3836
230
  if (coder->importMetaFlag)
3837
77
    flag |= XS_IMPORT_META_FLAG;
3838
230
  fxCoderAddIndex(coder, 0 - count, XS_CODE_MODULE, flag);
3839
230
  fxCoderAddByte(coder, -1, XS_CODE_SET_RESULT);
3840
230
  fxCoderAddByte(coder, 0, XS_CODE_END);
3841
230
}
3842
3843
void fxNewNodeCode(void* it, void* param) 
3844
14.5k
{
3845
14.5k
  txCallNewNode* self = it;
3846
14.5k
  fxNodeDispatchCode(self->reference, param);
3847
14.5k
  fxCoderAddByte(param, 2, XS_CODE_NEW);
3848
14.5k
  fxNodeDispatchCode(self->params, param);
3849
14.5k
}
3850
3851
void fxNumberNodeCode(void* it, void* param) 
3852
8.12k
{
3853
8.12k
  txNumberNode* self = it;
3854
8.12k
  fxCoderAddNumber(param, 1, XS_CODE_NUMBER, self->value);
3855
8.12k
}
3856
3857
void fxObjectNodeCode(void* it, void* param) 
3858
18.5k
{
3859
18.5k
  txObjectNode* self = it;
3860
18.5k
  txCoder* coder = param;
3861
18.5k
  txInteger object = fxCoderUseTemporaryVariable(param);
3862
18.5k
  txNode* item;
3863
18.5k
  txFlag flag = 0;
3864
18.5k
  if (self->items) {
3865
18.5k
    item = self->items->first;
3866
54.3k
    while (item) {
3867
35.8k
      if (item->description->token == XS_TOKEN_PROPERTY) {
3868
34.5k
        if (!(item->flags & mxShorthandFlag) && (((txPropertyNode*)item)->symbol == coder->parser->__proto__Symbol)) {
3869
27
          if (flag)
3870
0
            fxReportParserError(coder->parser, item->line, "invalid __proto__");
3871
27
          flag = 1;
3872
27
          fxNodeDispatchCode(((txPropertyNode*)item)->value, param);
3873
27
          fxCoderAddByte(param, 0, XS_CODE_INSTANTIATE);
3874
27
        }
3875
34.5k
      }
3876
35.8k
      item = item->next;
3877
35.8k
    }
3878
18.5k
  }
3879
18.5k
  if (!flag)
3880
18.5k
    fxCoderAddByte(param, 1, XS_CODE_OBJECT);
3881
18.5k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, object);
3882
18.5k
  if (self->items) {
3883
18.5k
    item = self->items->first;
3884
54.3k
    while (item) {
3885
35.8k
      if (item->description->token == XS_TOKEN_SPREAD) {
3886
174
        fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3887
174
        fxCoderAddByte(param, 1, XS_CODE_COPY_OBJECT);
3888
174
        fxCoderAddByte(param, 1, XS_CODE_CALL);
3889
174
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3890
174
        fxNodeDispatchCode(((txSpreadNode*)item)->expression, param);
3891
174
        fxCoderAddInteger(param, -4, XS_CODE_RUN_1, 2);
3892
174
        fxCoderAddByte(param, -1, XS_CODE_POP);
3893
174
      }
3894
35.6k
      else {
3895
35.6k
        txNode* value;
3896
35.6k
        if (item->description->token == XS_TOKEN_PROPERTY) {
3897
34.5k
          if (!(item->flags & mxShorthandFlag) && (((txPropertyNode*)item)->symbol == coder->parser->__proto__Symbol)) {
3898
27
            item = item->next;
3899
27
            continue;
3900
27
          }
3901
34.5k
          value = ((txPropertyNode*)item)->value;
3902
34.5k
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3903
34.5k
          fxNodeDispatchCode(value, param);
3904
34.5k
          fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, ((txPropertyNode*)item)->symbol);
3905
34.5k
        }
3906
1.10k
        else {
3907
1.10k
          value = ((txPropertyAtNode*)item)->value;
3908
1.10k
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3909
1.10k
          fxNodeDispatchCode(((txPropertyAtNode*)item)->at, param);
3910
1.10k
          fxCoderAddByte(param, 0, XS_CODE_AT);
3911
1.10k
          fxNodeDispatchCode(value, param);
3912
1.10k
          fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
3913
1.10k
        }
3914
35.6k
        flag = 0;
3915
35.6k
        if (item->flags & mxMethodFlag)
3916
723
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG;
3917
34.9k
        else if (item->flags & mxGetterFlag)
3918
269
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_GETTER_FLAG;
3919
34.6k
        else if (item->flags & mxSetterFlag)
3920
57
          flag |= XS_NAME_FLAG | XS_METHOD_FLAG | XS_SETTER_FLAG;
3921
34.6k
        else if (fxNodeCodeName(value))
3922
1.38k
          flag |= XS_NAME_FLAG;
3923
35.6k
        fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, flag);
3924
35.6k
      }
3925
35.8k
      item = item->next;
3926
35.8k
    }
3927
18.5k
  }
3928
18.5k
  fxCoderUnuseTemporaryVariables(param, 1);
3929
18.5k
}
3930
3931
void fxObjectBindingNodeCode(void* it, void* param)
3932
2
{
3933
2
  txObjectBindingNode* self = it;
3934
2
  txCoder* coder = param;
3935
2
  fxCoderAddByte(coder, 1, XS_CODE_UNDEFINED);
3936
2
  fxObjectBindingNodeCodeAssign(self, param, 0);
3937
2
}
3938
3939
void fxObjectBindingNodeCodeAssign(void* it, void* param, txFlag flag) 
3940
302
{
3941
302
  txObjectBindingNode* self = it;
3942
302
  txNode* item = self->items->first;
3943
302
  txInteger object;
3944
302
  txInteger at;
3945
302
  txInteger c = 0;
3946
302
  object = fxCoderUseTemporaryVariable(param);
3947
302
  at = fxCoderUseTemporaryVariable(param);
3948
302
  fxCoderAddByte(param, 1, XS_CODE_DUB);
3949
302
  fxCoderAddByte(param, 0, XS_CODE_TO_INSTANCE);
3950
302
  fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, object);
3951
302
  if (self->flags & mxSpreadFlag) {
3952
73
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
3953
73
    fxCoderAddByte(param, 1, XS_CODE_COPY_OBJECT);
3954
73
    fxCoderAddByte(param, 1, XS_CODE_CALL);
3955
73
    fxCoderAddByte(param, 1, XS_CODE_OBJECT);
3956
73
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3957
73
    c = 2;
3958
73
  }
3959
681
  while (item && (item->description->token != XS_TOKEN_REST_BINDING)) {
3960
379
    if (item->description->token == XS_TOKEN_PROPERTY_BINDING) {
3961
304
      if (self->flags & mxSpreadFlag) {
3962
6
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3963
6
        fxCoderAddSymbol(param, 1, XS_CODE_SYMBOL, ((txPropertyBindingNode*)item)->symbol);
3964
6
        fxCoderAddByte(param, 0, XS_CODE_AT);
3965
6
        fxCoderAddByte(param, 0, XS_CODE_SWAP);
3966
6
        fxCoderAddByte(param, -1, XS_CODE_POP);
3967
6
        c++;
3968
6
      }
3969
304
      fxNodeDispatchCodeReference(((txPropertyBindingNode*)item)->binding, param, 1);
3970
304
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3971
304
      fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, ((txPropertyBindingNode*)item)->symbol);
3972
304
      fxNodeDispatchCodeAssign(((txPropertyBindingNode*)item)->binding, param, 1);
3973
304
    }
3974
75
    else {
3975
75
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3976
75
      fxNodeDispatchCode(((txPropertyBindingAtNode*)item)->at, param);
3977
75
      fxCoderAddByte(param, 0, XS_CODE_AT);
3978
75
      if (self->flags & mxSpreadFlag) {
3979
2
        fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, at);
3980
2
        fxCoderAddByte(param, 0, XS_CODE_SWAP);
3981
2
        fxCoderAddByte(param, -1, XS_CODE_POP);
3982
2
        c++;
3983
2
      }
3984
73
      else {
3985
73
        fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, at);
3986
73
        fxCoderAddByte(param, -1, XS_CODE_POP);
3987
73
      }
3988
75
      fxNodeDispatchCodeReference(((txPropertyBindingAtNode*)item)->binding, param, 1);
3989
75
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
3990
75
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, at);
3991
75
      fxCoderAddByte(param, -1, XS_CODE_GET_PROPERTY_AT);
3992
75
      fxNodeDispatchCodeAssign(((txPropertyBindingAtNode*)item)->binding, param, 1);
3993
75
    }
3994
379
    fxCoderAddByte(param, -1, XS_CODE_POP);
3995
379
    item = item->next;
3996
379
  }
3997
302
  if (self->flags & mxSpreadFlag) {
3998
73
    fxCoderAddInteger(param, -2 - c, XS_CODE_RUN_1, c);
3999
73
    fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, object);
4000
73
    fxNodeDispatchCodeReference(((txRestBindingNode*)item)->binding, param, 1);
4001
73
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, object);
4002
73
    fxNodeDispatchCodeAssign(((txRestBindingNode*)item)->binding, param, 1);
4003
73
        fxCoderAddByte(param, -1, XS_CODE_POP);
4004
73
  }
4005
302
  fxCoderUnuseTemporaryVariables(param, 2);
4006
302
}
4007
4008
void fxOptionNodeCode(void* it, void* param) 
4009
405
{
4010
405
  txUnaryExpressionNode* self = it;
4011
405
  txCoder* coder = param;
4012
405
  self->right->flags |= (self->flags & mxTailRecursionFlag);
4013
405
  fxNodeDispatchCode(self->right, param);
4014
405
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_CHAIN_1, coder->chainTarget);
4015
405
}
4016
4017
txFlag fxOptionNodeCodeThis(void* it, void* param, txFlag flag) 
4018
48
{
4019
48
  txUnaryExpressionNode* self = it;
4020
48
  txCoder* coder = param;
4021
48
  txTargetCode* swapTarget = fxCoderCreateTarget(param);
4022
48
  txTargetCode* skipTarget = fxCoderCreateTarget(param);
4023
48
  self->right->flags |= (self->flags & mxTailRecursionFlag);
4024
48
  flag = fxNodeDispatchCodeThis(self->right, param, flag);
4025
48
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_CHAIN_1, swapTarget);
4026
48
  fxCoderAddBranch(param, 1, XS_CODE_BRANCH_1, skipTarget);
4027
48
  fxCoderAdd(param, 0, swapTarget);
4028
48
  fxCoderAddByte(param, 0, XS_CODE_SWAP);
4029
48
  fxCoderAddByte(param, -1, XS_CODE_POP);
4030
48
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, coder->chainTarget);
4031
48
  fxCoderAdd(param, 0, skipTarget);
4032
48
  return flag;
4033
48
}
4034
4035
void fxOrExpressionNodeCode(void* it, void* param) 
4036
723
{
4037
723
  txBinaryExpressionNode* self = it;
4038
723
  txTargetCode* endTarget = fxCoderCreateTarget(param);
4039
723
  self->right->flags |= (self->flags & mxTailRecursionFlag);
4040
723
  fxNodeDispatchCode(self->left, param);
4041
723
  fxCoderAddByte(param, 1, XS_CODE_DUB);
4042
723
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, endTarget);
4043
723
  fxCoderAddByte(param, -1, XS_CODE_POP);
4044
723
  fxNodeDispatchCode(self->right, param);
4045
723
  fxCoderAdd(param, 0, endTarget);
4046
723
}
4047
4048
void fxParamsNodeCode(void* it, void* param) 
4049
105k
{
4050
105k
  txParamsNode* self = it;
4051
105k
  txInteger c = 0;
4052
105k
  if (self->flags & mxSpreadFlag) {
4053
355
    txInteger counter = fxCoderUseTemporaryVariable(param);
4054
355
    fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 0);
4055
355
    fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, counter);
4056
355
    fxCoderAddByte(param, -1, XS_CODE_POP);
4057
355
    if (self->items) {
4058
355
      txNode* item = self->items->first;
4059
853
      while (item) {
4060
498
        if (item->description->token == XS_TOKEN_SPREAD) {
4061
368
          fxSpreadNodeCode(item, param, counter);
4062
368
        }
4063
130
        else {
4064
130
          c++;
4065
130
          fxNodeDispatchCode(item, param);
4066
130
          fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
4067
130
          fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 1);
4068
130
          fxCoderAddByte(param, -1, XS_CODE_ADD);
4069
130
          fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, counter);
4070
130
          fxCoderAddByte(param, -1, XS_CODE_POP);
4071
130
        }
4072
498
        item = item->next;
4073
498
      }
4074
355
    }
4075
355
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
4076
355
    if (self->flags & mxEvalParametersFlag)
4077
0
      fxCoderAddByte(param, -3 - c, (self->flags & mxTailRecursionFlag) ? XS_CODE_EVAL_TAIL : XS_CODE_EVAL);
4078
355
    else
4079
355
      fxCoderAddByte(param, -3 - c, (self->flags & mxTailRecursionFlag) ? XS_CODE_RUN_TAIL : XS_CODE_RUN);
4080
355
    fxCoderUnuseTemporaryVariables(param, 1);
4081
355
  }
4082
104k
  else {
4083
104k
    if (self->items) {
4084
104k
      txNode* item = self->items->first;
4085
276k
      while (item) {
4086
172k
        fxNodeDispatchCode(item, param);
4087
172k
        c++;
4088
172k
        item = item->next;
4089
172k
      }
4090
104k
      if (self->flags & mxEvalParametersFlag) {
4091
1.96k
        fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, c);
4092
1.96k
        fxCoderAddByte(param, -3 - c, (self->flags & mxTailRecursionFlag) ? XS_CODE_EVAL_TAIL : XS_CODE_EVAL);
4093
1.96k
      }
4094
102k
      else
4095
102k
        fxCoderAddInteger(param, -2 - c, (self->flags & mxTailRecursionFlag) ? XS_CODE_RUN_TAIL_1 : XS_CODE_RUN_1, c);
4096
104k
    }
4097
104k
  }
4098
105k
}
4099
4100
void fxParamsBindingNodeCode(void* it, void* param) 
4101
53.0k
{
4102
53.0k
  txParamsBindingNode* self = it;
4103
53.0k
  txNode* item = self->items->first;
4104
53.0k
  txInteger index = 0;
4105
53.0k
  if (self->declaration) {
4106
918
    if (self->mapped)
4107
894
      fxCoderAddIndex(param, 1, XS_CODE_ARGUMENTS_SLOPPY, self->items->length);
4108
24
    else
4109
24
      fxCoderAddIndex(param, 1, XS_CODE_ARGUMENTS_STRICT, self->items->length);
4110
918
    if (self->declaration->flags & mxDeclareNodeClosureFlag)
4111
52
      fxCoderAddIndex(param, 0, XS_CODE_VAR_CLOSURE_1, self->declaration->index);
4112
866
    else 
4113
866
      fxCoderAddIndex(param, 0, XS_CODE_VAR_LOCAL_1, self->declaration->index);
4114
918
    fxCoderAddByte(param, -1, XS_CODE_POP);
4115
918
  }
4116
66.8k
  while (item) {
4117
13.7k
    if (item->description->token == XS_TOKEN_REST_BINDING) {
4118
391
      fxNodeDispatchCodeReference(((txRestBindingNode*)item)->binding, param, 0);
4119
391
      fxCoderAddIndex(param, 1, XS_CODE_ARGUMENTS, index);
4120
391
      fxNodeDispatchCodeAssign(((txRestBindingNode*)item)->binding, param, 0);
4121
391
    }
4122
13.3k
    else {
4123
13.3k
      fxNodeDispatchCodeReference(item, param, 0);
4124
13.3k
      fxCoderAddIndex(param, 1, XS_CODE_ARGUMENT, index);
4125
13.3k
      fxNodeDispatchCodeAssign(item, param, 0);
4126
13.3k
    }
4127
13.7k
    fxCoderAddByte(param, -1, XS_CODE_POP);
4128
13.7k
    item = item->next;
4129
13.7k
    index++;
4130
13.7k
  }
4131
53.0k
}
4132
4133
void fxPostfixExpressionNodeCode(void* it, void* param) 
4134
6.91k
{
4135
6.91k
  txPostfixExpressionNode* self = it;
4136
6.91k
  txInteger value;
4137
6.91k
  fxNodeDispatchCodeThis(self->left, param, 1);
4138
6.91k
  if (!(self->flags & mxExpressionNoValue)) {
4139
1.14k
    value = fxCoderUseTemporaryVariable(param);
4140
1.14k
    fxCoderAddByte(param, 0, XS_CODE_TO_NUMERIC);
4141
1.14k
    fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, value);
4142
1.14k
  }
4143
6.91k
  fxCoderAddByte(param, 0, self->description->code);
4144
6.91k
  fxNodeDispatchCodeAssign(self->left, param, 0);
4145
6.91k
  if (!(self->flags & mxExpressionNoValue)) {
4146
1.14k
    fxCoderAddByte(param, -1, XS_CODE_POP);
4147
1.14k
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, value);
4148
1.14k
    fxCoderUnuseTemporaryVariables(param, 1);
4149
1.14k
  }
4150
6.91k
}
4151
4152
void fxPrivateIdentifierNodeCode(void* it, void* param) 
4153
0
{
4154
0
  txPrivateMemberNode* self = it;
4155
0
  fxNodeDispatchCode(self->reference, param);
4156
0
  fxCoderAddIndex(param, 0,  XS_CODE_HAS_PRIVATE_1, self->declaration->index);
4157
0
}
4158
4159
void fxPrivateMemberNodeCode(void* it, void* param) 
4160
220
{
4161
220
  txPrivateMemberNode* self = it;
4162
220
  fxNodeDispatchCode(self->reference, param);
4163
220
  fxCoderAddIndex(param, 0,  XS_CODE_GET_PRIVATE_1, self->declaration->index);
4164
220
}
4165
4166
void fxPrivateMemberNodeCodeAssign(void* it, void* param, txFlag flag) 
4167
37
{
4168
37
  txPrivateMemberNode* self = it;
4169
37
  fxCoderAddIndex(param, -1, XS_CODE_SET_PRIVATE_1, self->declaration->index);
4170
37
}
4171
4172
void fxPrivateMemberNodeCodeDelete(void* it, void* param) 
4173
0
{
4174
0
  txPrivateMemberNode* self = it;
4175
0
  txCoder* coder = param;
4176
0
  fxNodeDispatchCode(self->reference, param);
4177
0
  fxReportParserError(coder->parser, self->line, "delete private property");
4178
0
}
4179
4180
void fxPrivateMemberNodeCodeReference(void* it, void* param, txFlag flag) 
4181
23
{
4182
23
  txPrivateMemberNode* self = it;
4183
23
  fxNodeDispatchCode(self->reference, param);
4184
23
}
4185
4186
txFlag fxPrivateMemberNodeCodeThis(void* it, void* param, txFlag flag) 
4187
15
{
4188
15
  txPrivateMemberNode* self = it;
4189
15
  fxNodeDispatchCode(self->reference, param);
4190
15
  fxCoderAddByte(param, 1, XS_CODE_DUB);
4191
15
  fxCoderAddIndex(param, 0, XS_CODE_GET_PRIVATE_1, self->declaration->index);
4192
15
  return 1;
4193
15
}
4194
4195
void fxProgramNodeCode(void* it, void* param) 
4196
115k
{
4197
115k
  txProgramNode* self = it;
4198
115k
  txCoder* coder = param;
4199
  
4200
115k
  coder->line = -1;
4201
115k
  coder->programFlag = 1;
4202
115k
  coder->scopeLevel = 0;
4203
115k
  coder->firstBreakTarget = NULL;
4204
115k
  coder->firstContinueTarget = NULL;
4205
  
4206
115k
  if (self->flags & mxStrictFlag)
4207
791
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_STRICT, 0);
4208
115k
  else
4209
115k
    fxCoderAddIndex(param, 0, XS_CODE_BEGIN_SLOPPY, 0);
4210
115k
  coder->path = C_NULL;
4211
115k
  if (self->line >= 0)
4212
115k
    fxCoderAddLine(coder, 0, XS_CODE_LINE, it); 
4213
115k
  if (coder->parser->flags & mxEvalFlag) {
4214
76.2k
    coder->evalFlag = 1;
4215
76.2k
    fxScopeCodingEval(self->scope, param);
4216
76.2k
  }
4217
39.5k
  else
4218
39.5k
    fxScopeCodingProgram(self->scope, param);
4219
115k
  coder->returnTarget = fxCoderCreateTarget(param);
4220
115k
  fxScopeCodeDefineNodes(self->scope, param);
4221
115k
  fxNodeDispatchCode(self->body, param);
4222
115k
  fxCoderAdd(param, 0, coder->returnTarget);
4223
115k
  fxCoderAddByte(param, 0, XS_CODE_RETURN);
4224
115k
}
4225
4226
void fxQuestionMarkNodeCode(void* it, void* param) 
4227
256
{
4228
256
  txQuestionMarkNode* self = it;
4229
256
  txTargetCode* elseTarget = fxCoderCreateTarget(param);
4230
256
  txTargetCode* endTarget = fxCoderCreateTarget(param);
4231
256
  self->thenExpression->flags |= (self->flags & mxTailRecursionFlag);
4232
256
  self->elseExpression->flags |= (self->flags & mxTailRecursionFlag);
4233
256
  fxNodeDispatchCode(self->expression, param);
4234
256
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, elseTarget);
4235
256
  fxNodeDispatchCode(self->thenExpression, param);
4236
256
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, endTarget);
4237
256
  fxCoderAdd(param, -1, elseTarget);
4238
256
  fxNodeDispatchCode(self->elseExpression, param);
4239
256
  fxCoderAdd(param, 0, endTarget);
4240
256
}
4241
4242
void fxRegexpNodeCode(void* it, void* param) 
4243
4.82k
{
4244
4.82k
  txRegexpNode* self = it;
4245
4.82k
  fxCoderAddByte(param, 1, XS_CODE_REGEXP);
4246
4.82k
  fxCoderAddByte(param, 2, XS_CODE_NEW);
4247
4.82k
  fxNodeDispatchCode(self->modifier, param);
4248
4.82k
  fxNodeDispatchCode(self->value, param);
4249
4.82k
  fxCoderAddInteger(param, -4, XS_CODE_RUN_1, 2);
4250
4.82k
}
4251
4252
void fxReturnNodeCode(void* it, void* param) 
4253
12.8k
{
4254
12.8k
  txStatementNode* self = it;
4255
12.8k
  txCoder* coder = param;
4256
12.8k
  if (coder->programFlag)
4257
0
    fxReportParserError(coder->parser, self->line, "invalid return");
4258
12.8k
  if (self->expression) { 
4259
11.6k
    if (((self->flags & (mxStrictFlag | mxGeneratorFlag)) == mxStrictFlag) && (coder->returnTarget->original == NULL))
4260
236
      self->expression->flags |= mxTailRecursionFlag;
4261
11.6k
    fxNodeDispatchCode(self->expression, param);
4262
11.6k
    if ((self->flags & (mxAsyncFlag | mxGeneratorFlag)) == (mxAsyncFlag | mxGeneratorFlag)) {
4263
9
      fxCoderAddByte(param, 0, XS_CODE_AWAIT);
4264
9
      fxCoderAddByte(coder, 0, XS_CODE_THROW_STATUS);
4265
9
    }
4266
11.6k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4267
11.6k
  }
4268
1.26k
  else if ((self->flags & (mxAsyncFlag | mxGeneratorFlag)) != (mxAsyncFlag | mxGeneratorFlag)) {
4269
1.26k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4270
1.26k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4271
1.26k
  }
4272
12.8k
  fxCoderAdjustEnvironment(coder, coder->returnTarget);
4273
12.8k
  fxCoderAdjustScope(coder, coder->returnTarget);
4274
12.8k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, coder->returnTarget);
4275
12.8k
}
4276
4277
void fxSpreadNodeCode(void* it, void* param, txInteger counter) 
4278
368
{
4279
368
  txSpreadNode* self = it;
4280
368
  txCoder* coder = param;
4281
368
  txTargetCode* nextTarget = fxCoderCreateTarget(param);
4282
368
  txTargetCode* doneTarget = fxCoderCreateTarget(param);
4283
368
  txInteger iterator;
4284
368
  fxNodeDispatchCode(self->expression, param);
4285
368
  fxCoderAddByte(param, 0, XS_CODE_FOR_OF);
4286
368
  iterator = fxCoderUseTemporaryVariable(param);
4287
368
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, iterator);
4288
368
  fxCoderAddByte(param, -1, XS_CODE_POP);
4289
368
  fxCoderAdd(param, 0, nextTarget);
4290
368
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, iterator);
4291
368
  fxCoderAddByte(param, 1, XS_CODE_DUB);
4292
368
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->nextSymbol);
4293
368
  fxCoderAddByte(param, 1, XS_CODE_CALL);
4294
368
  fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
4295
368
  fxCoderAddByte(param, 1, XS_CODE_DUB);
4296
368
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->doneSymbol);
4297
368
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, doneTarget);
4298
368
  fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, coder->parser->valueSymbol);
4299
368
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, counter);
4300
368
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 1);
4301
368
  fxCoderAddByte(param, -1, XS_CODE_ADD);
4302
368
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, counter);
4303
368
  fxCoderAddByte(param, -1, XS_CODE_POP);
4304
368
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, nextTarget);
4305
368
  fxCoderAdd(param, 1, doneTarget);
4306
368
  fxCoderAddByte(param, -1, XS_CODE_POP);
4307
368
  fxCoderUnuseTemporaryVariables(param, 1);
4308
368
}
4309
4310
void fxStatementNodeCode(void* it, void* param) 
4311
273k
{
4312
273k
  txStatementNode* self = it;
4313
273k
  txCoder* coder = param;
4314
273k
  if (coder->programFlag) {
4315
185k
    fxNodeDispatchCode(self->expression, param);
4316
185k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4317
185k
  }
4318
87.9k
  else {
4319
87.9k
    self->expression->flags |= mxExpressionNoValue;
4320
87.9k
    fxNodeDispatchCode(self->expression, param);
4321
87.9k
    if (coder->lastCode->id == XS_CODE_SET_CLOSURE_1) {
4322
465
      coder->lastCode->id = XS_CODE_PULL_CLOSURE_1;
4323
465
      coder->stackLevel--;
4324
465
      coder->lastCode->stackLevel = coder->stackLevel;
4325
465
    }
4326
87.5k
    else if (coder->lastCode->id == XS_CODE_SET_LOCAL_1) {
4327
225
      coder->lastCode->id = XS_CODE_PULL_LOCAL_1;
4328
225
      coder->stackLevel--;
4329
225
      coder->lastCode->stackLevel = coder->stackLevel;
4330
225
    }
4331
87.3k
    else
4332
87.3k
      fxCoderAddByte(param, -1, XS_CODE_POP);
4333
87.9k
  }
4334
273k
}
4335
4336
void fxStatementsNodeCode(void* it, void* param) 
4337
41.4k
{
4338
41.4k
  txStatementsNode* self = it;
4339
41.4k
  txNode* item = self->items->first;
4340
248k
  while (item) {
4341
207k
    fxNodeDispatchCode(item, param);
4342
207k
    item = item->next;
4343
207k
  }
4344
41.4k
}
4345
4346
void fxStringNodeCode(void* it, void* param) 
4347
570k
{
4348
570k
  txStringNode* self = it;
4349
570k
  txCoder* coder = param;
4350
570k
  txParser* parser = coder->parser;
4351
570k
  if (self->flags & mxStringErrorFlag)
4352
1.04k
    fxReportParserError(parser, self->line, "invalid escape sequence");
4353
570k
  fxCoderAddString(param, 1, XS_CODE_STRING_1, self->length, self->value);
4354
570k
}
4355
4356
void fxSuperNodeCode(void* it, void* param)
4357
277
{
4358
277
  txSuperNode* self = it;
4359
277
  fxCoderAddByte(param, 3, XS_CODE_SUPER);
4360
277
  fxNodeDispatchCode(self->params, param);
4361
277
  fxCoderAddByte(param, 0, XS_CODE_SET_THIS);
4362
277
  if (self->instanceInitAccess) {
4363
11
    fxCoderAddByte(param, 1, XS_CODE_GET_THIS);
4364
11
    fxCoderAddIndex(param, 1, XS_CODE_GET_CLOSURE_1, self->instanceInitAccess->declaration->index);
4365
11
    fxCoderAddByte(param, 1, XS_CODE_CALL);
4366
11
    fxCoderAddInteger(param, -2, XS_CODE_RUN_1, 0);
4367
11
    fxCoderAddByte(param, -1, XS_CODE_POP);
4368
11
  }
4369
277
}
4370
4371
void fxSwitchNodeCode(void* it, void* param) 
4372
769
{
4373
769
  txSwitchNode* self = it;
4374
769
  txCoder* coder = param;
4375
769
  txTargetCode* breakTarget;
4376
769
  txCaseNode* caseNode;
4377
769
  txCaseNode* defaultNode = NULL;
4378
769
  txUsingContext context;
4379
769
  fxNodeDispatchCode(self->expression, param);
4380
769
  fxScopeCodingBlock(self->scope, param);
4381
769
  if (self->scope->disposableNodeCount)
4382
0
    fxScopeCodeUsing(self->scope, coder, &context);
4383
769
  breakTarget = fxCoderCreateTarget(coder);
4384
769
  breakTarget->label = fxNewParserChunkClear(coder->parser, sizeof(txLabelNode));
4385
769
  breakTarget->nextTarget = coder->firstBreakTarget;
4386
769
  coder->firstBreakTarget = breakTarget;
4387
769
  if (coder->programFlag) {
4388
734
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4389
734
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4390
734
  }
4391
769
  caseNode = (txCaseNode*)self->items->first;
4392
1.68k
  while (caseNode) {
4393
919
    caseNode->target = fxCoderCreateTarget(param);
4394
919
    if (caseNode->expression) {
4395
888
      fxCoderAddByte(param, 1, XS_CODE_DUB);
4396
888
      fxNodeDispatchCode(caseNode->expression, param);
4397
888
      fxCoderAddByte(param, -1, XS_CODE_STRICT_EQUAL);
4398
888
      fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, caseNode->target);
4399
888
    }
4400
31
    else
4401
31
      defaultNode = caseNode;
4402
919
    caseNode = (txCaseNode*)caseNode->next;
4403
919
  }
4404
769
  if (defaultNode)
4405
31
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, defaultNode->target);
4406
738
  else
4407
738
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, coder->firstBreakTarget);
4408
769
  caseNode = (txCaseNode*)self->items->first;
4409
1.68k
  while (caseNode) {
4410
919
    fxCoderAdd(param, 0, caseNode->target);
4411
919
    if (caseNode->statement)
4412
530
      fxNodeDispatchCode(caseNode->statement, param);
4413
919
    caseNode = (txCaseNode*)caseNode->next;
4414
919
  }
4415
769
  fxCoderAdd(param, 0, coder->firstBreakTarget);
4416
769
  coder->firstBreakTarget = breakTarget->nextTarget;
4417
769
  if (self->scope->disposableNodeCount)
4418
0
    fxScopeCodeUsed(self->scope, coder, &context);
4419
769
  fxScopeCoded(self->scope, param);
4420
769
  fxCoderAddByte(param, -1, XS_CODE_POP);
4421
769
}
4422
4423
void fxTemplateNodeCode(void* it, void* param) 
4424
231k
{
4425
231k
  txTemplateNode* self = it;
4426
231k
  txCoder* coder = param;
4427
231k
  txParser* parser = coder->parser;
4428
231k
  txNode* item = self->items->first;
4429
  
4430
231k
  if (self->reference) {
4431
215k
    txSymbol* symbol;
4432
215k
    txTargetCode* cacheTarget = fxCoderCreateTarget(param);
4433
215k
    txInteger i = (self->items->length / 2) + 1;
4434
215k
    txInteger raws = fxCoderUseTemporaryVariable(param);
4435
215k
    txInteger strings = fxCoderUseTemporaryVariable(param);
4436
215k
    txFlag flag = XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG;
4437
4438
215k
    fxNodeDispatchCodeThis(self->reference, param, 0);
4439
215k
    fxCoderAddByte(param, 1, XS_CODE_CALL);
4440
4441
215k
    fxGenerateTag(parser->console, parser->buffer, parser->bufferSize, (parser->path) ? parser->path->string : C_NULL);
4442
215k
    symbol = fxNewParserSymbol(parser, parser->buffer);
4443
215k
    fxCoderAddByte(param, 1, XS_CODE_TEMPLATE_CACHE);
4444
215k
    fxCoderAddSymbol(param, 0, XS_CODE_GET_PROPERTY, symbol);
4445
215k
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_COALESCE_1, cacheTarget);
4446
215k
    fxCoderAddByte(param, 1, XS_CODE_TEMPLATE_CACHE);
4447
4448
215k
    fxCoderAddByte(param, 1, XS_CODE_ARRAY);
4449
215k
    fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, strings);
4450
215k
    fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, i);
4451
215k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, coder->parser->lengthSymbol);
4452
215k
    fxCoderAddByte(param, -1, XS_CODE_POP);
4453
215k
    fxCoderAddByte(param, 1, XS_CODE_ARRAY);
4454
215k
    fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, raws);
4455
215k
    fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, i);
4456
215k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, coder->parser->lengthSymbol);
4457
215k
    fxCoderAddByte(param, -1, XS_CODE_POP);
4458
215k
    i = 0;
4459
435k
    while (item) {
4460
219k
      if (item->description->token == XS_TOKEN_TEMPLATE_MIDDLE) {
4461
    
4462
218k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, strings);
4463
218k
        fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, i);
4464
218k
        fxCoderAddByte(param, 0, XS_CODE_AT);
4465
218k
        if (((txTemplateItemNode*)item)->string->flags & mxStringErrorFlag)
4466
1.13k
          fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4467
217k
        else
4468
217k
          fxNodeDispatchCode(((txTemplateItemNode*)item)->string, param);
4469
218k
        fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
4470
218k
        fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, flag);
4471
      
4472
218k
        fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, raws);
4473
218k
        fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, i);
4474
218k
        fxCoderAddByte(param, 0, XS_CODE_AT);
4475
218k
        fxNodeDispatchCode(((txTemplateItemNode*)item)->raw, param);
4476
218k
        fxCoderAddByte(param, -3, XS_CODE_NEW_PROPERTY_AT);
4477
218k
        fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, flag);
4478
      
4479
218k
        i++;
4480
218k
      }
4481
219k
      item = item->next;
4482
219k
    }
4483
215k
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, strings);
4484
215k
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, raws);
4485
215k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, parser->rawSymbol);
4486
215k
    fxCoderAddByte(param, -1, XS_CODE_POP);
4487
215k
    fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, strings);
4488
215k
    fxCoderAddByte(param, 0, XS_CODE_TEMPLATE);
4489
    
4490
215k
    fxCoderAddSymbol(param, -1, XS_CODE_SET_PROPERTY, symbol);
4491
    
4492
215k
    fxCoderAdd(param, 0, cacheTarget);
4493
    
4494
215k
    i = 1;
4495
215k
    item = self->items->first;
4496
435k
    while (item) {
4497
219k
      if (item->description->token != XS_TOKEN_TEMPLATE_MIDDLE) {
4498
1.57k
        fxNodeDispatchCode(item, param);
4499
1.57k
        i++;
4500
1.57k
      }
4501
219k
      item = item->next;
4502
219k
    }
4503
215k
    fxCoderAddInteger(param, -2 - i, (self->flags & mxTailRecursionFlag) ? XS_CODE_RUN_TAIL_1 : XS_CODE_RUN_1, i);
4504
215k
    fxCoderUnuseTemporaryVariables(coder, 2);
4505
215k
  }
4506
15.5k
  else {
4507
15.5k
    fxNodeDispatchCode(((txTemplateItemNode*)item)->string, param);
4508
15.5k
    item = item->next;
4509
16.7k
    while (item) {
4510
1.24k
      if (item->description->token == XS_TOKEN_TEMPLATE_MIDDLE) {
4511
624
        fxNodeDispatchCode(((txTemplateItemNode*)item)->string, param);
4512
624
      }
4513
617
      else {
4514
617
        fxNodeDispatchCode(item, param);
4515
617
        fxCoderAddByte(param, 1, XS_CODE_TO_STRING);
4516
617
      }
4517
1.24k
      fxCoderAddByte(param, -1, XS_CODE_ADD);
4518
1.24k
      item = item->next;
4519
1.24k
    }
4520
15.5k
  }
4521
231k
}
4522
4523
void fxThisNodeCode(void* it, void* param) 
4524
1.82k
{
4525
1.82k
  txNode* self = it;
4526
1.82k
  if (self->flags & mxDerivedFlag)
4527
2
    fxCoderAddByte(param, 1, XS_CODE_GET_THIS);
4528
1.82k
  else
4529
1.82k
    fxCoderAddByte(param, 1, self->description->code);
4530
1.82k
}
4531
4532
void fxThrowNodeCode(void* it, void* param) 
4533
1.99k
{
4534
1.99k
  txStatementNode* self = it;
4535
1.99k
  fxNodeDispatchCode(self->expression, param);
4536
1.99k
  fxCoderAddByte(param, -1, XS_CODE_THROW);
4537
1.99k
}
4538
4539
void fxTryNodeCode(void* it, void* param) 
4540
1.15k
{
4541
1.15k
  txTryNode* self = it;
4542
1.15k
  txCoder* coder = param;
4543
1.15k
  txInteger exception;
4544
1.15k
  txInteger selector;
4545
1.15k
  txInteger result;
4546
1.15k
  txInteger selection;
4547
1.15k
  txTargetCode* catchTarget;
4548
1.15k
  txTargetCode* normalTarget;
4549
1.15k
  txTargetCode* finallyTarget;
4550
4551
1.15k
  exception = fxCoderUseTemporaryVariable(coder);
4552
1.15k
  selector = fxCoderUseTemporaryVariable(coder);
4553
1.15k
  result = fxCoderUseTemporaryVariable(coder);
4554
4555
1.15k
  coder->firstBreakTarget = fxCoderAliasTargets(param, coder->firstBreakTarget);
4556
1.15k
  coder->firstContinueTarget = fxCoderAliasTargets(param, coder->firstContinueTarget);
4557
1.15k
  coder->returnTarget = fxCoderAliasTargets(param, coder->returnTarget);
4558
1.15k
  catchTarget = fxCoderCreateTarget(param);
4559
1.15k
  normalTarget = fxCoderCreateTarget(param);
4560
1.15k
  finallyTarget = fxCoderCreateTarget(param);
4561
4562
1.15k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, 0);
4563
1.15k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, selector);
4564
1.15k
  fxCoderAddByte(param, -1, XS_CODE_POP);
4565
4566
1.15k
  fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
4567
1.15k
  if (coder->programFlag) {
4568
1.04k
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4569
1.04k
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4570
1.04k
  }
4571
1.15k
  fxNodeDispatchCode(self->tryBlock, param);
4572
1.15k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, normalTarget);
4573
1.15k
  if (self->catchBlock) {
4574
1.14k
    fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
4575
1.14k
    fxCoderAdd(param, 0, catchTarget);
4576
1.14k
    catchTarget = fxCoderCreateTarget(param);
4577
1.14k
    fxCoderAddBranch(param, 0, XS_CODE_CATCH_1, catchTarget);
4578
1.14k
    if (coder->programFlag) {
4579
1.03k
      fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4580
1.03k
      fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4581
1.03k
    }
4582
1.14k
    fxNodeDispatchCode(self->catchBlock, param);
4583
1.14k
    fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, normalTarget);
4584
1.14k
  }
4585
  
4586
1.15k
  selection = 1;
4587
1.15k
  coder->firstBreakTarget = fxCoderFinalizeTargets(param, coder->firstBreakTarget, selector, &selection, finallyTarget);
4588
1.15k
  coder->firstContinueTarget = fxCoderFinalizeTargets(param, coder->firstContinueTarget, selector, &selection, finallyTarget);
4589
1.15k
  coder->returnTarget = fxCoderFinalizeTargets(param, coder->returnTarget, selector, &selection, finallyTarget);
4590
1.15k
  fxCoderAdd(param, 0, normalTarget);
4591
1.15k
  fxCoderAddInteger(param, 1, XS_CODE_INTEGER_1, selection);
4592
1.15k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, selector);
4593
1.15k
  fxCoderAddByte(param, -1, XS_CODE_POP);
4594
1.15k
  fxCoderAdd(param, 0, finallyTarget);
4595
1.15k
  fxCoderAddByte(param, 0, XS_CODE_UNCATCH);
4596
1.15k
  fxCoderAdd(param, 0, catchTarget);
4597
1.15k
  fxCoderAddByte(param, 1, XS_CODE_EXCEPTION);
4598
1.15k
  fxCoderAddIndex(param, 0, XS_CODE_SET_LOCAL_1, exception);
4599
1.15k
  fxCoderAddByte(param, -1, XS_CODE_POP);
4600
1.15k
  if (self->finallyBlock) {
4601
26
    if (coder->programFlag) {
4602
11
      fxCoderAddByte(param, 1, XS_CODE_GET_RESULT);
4603
11
      fxCoderAddIndex(param, -1, XS_CODE_PULL_LOCAL_1, result);
4604
11
      fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4605
11
      fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4606
11
    }
4607
26
    fxNodeDispatchCode(self->finallyBlock, param);
4608
26
    if (coder->programFlag) {
4609
11
      fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, result);
4610
11
      fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4611
11
    }    
4612
26
  }
4613
1.15k
  catchTarget = fxCoderCreateTarget(param);
4614
1.15k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, selector);
4615
1.15k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_IF_1, catchTarget);
4616
1.15k
  fxCoderAddIndex(param, 1, XS_CODE_GET_LOCAL_1, exception);
4617
1.15k
  fxCoderAddByte(param, -1, XS_CODE_THROW);
4618
1.15k
  fxCoderAdd(param, 0, catchTarget);
4619
1.15k
  selection = 1;
4620
1.15k
  fxCoderJumpTargets(param, coder->firstBreakTarget, selector, &selection);
4621
1.15k
  fxCoderJumpTargets(param, coder->firstContinueTarget, selector, &selection);
4622
1.15k
  fxCoderJumpTargets(param, coder->returnTarget, selector, &selection);
4623
1.15k
  fxCoderUnuseTemporaryVariables(coder, 3);
4624
1.15k
}
4625
4626
void fxUnaryExpressionNodeCode(void* it, void* param) 
4627
21.3k
{
4628
21.3k
  txUnaryExpressionNode* self = it;
4629
21.3k
  fxNodeDispatchCode(self->right, param);
4630
21.3k
  fxCoderAddByte(param, 0, self->description->code);
4631
21.3k
}
4632
4633
void fxUndefinedNodeCodeAssign(void* it, void* param, txFlag flag) 
4634
0
{
4635
0
  txCoder* coder = param;
4636
0
  fxCoderAddSymbol(param, -1, XS_CODE_SET_VARIABLE, coder->parser->undefinedSymbol);
4637
0
}
4638
4639
void fxUndefinedNodeCodeDelete(void* it, void* param) 
4640
0
{
4641
0
  txNode* self = it;
4642
0
  txCoder* coder = param;
4643
0
  if (self->flags & mxStrictFlag)
4644
0
    fxReportParserError(coder->parser, self->line, "delete identifier (strict code)");
4645
0
  fxCoderAddByte(param, 1, XS_CODE_FALSE);
4646
0
}
4647
4648
void fxUndefinedNodeCodeReference(void* it, void* param, txFlag flag) 
4649
0
{
4650
0
  txCoder* coder = param;
4651
0
  if (coder->evalFlag)
4652
0
    fxCoderAddSymbol(param, 1, XS_CODE_EVAL_REFERENCE, coder->parser->undefinedSymbol);
4653
0
  else
4654
0
    fxCoderAddSymbol(param, 1, XS_CODE_PROGRAM_REFERENCE, coder->parser->undefinedSymbol);
4655
0
}
4656
4657
void fxValueNodeCode(void* it, void* param) 
4658
54.1k
{
4659
54.1k
  txNode* self = it;
4660
54.1k
  fxCoderAddByte(param, 1, self->description->code);
4661
54.1k
}
4662
4663
void fxWhileNodeCode(void* it, void* param) 
4664
2.38k
{
4665
2.38k
  txWhileNode* self = it;
4666
2.38k
  txCoder* coder = param;
4667
2.38k
  if (coder->programFlag) {
4668
13
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4669
13
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4670
13
  }
4671
2.38k
  fxCoderAdd(param, 0, coder->firstContinueTarget);
4672
2.38k
  fxNodeDispatchCode(self->expression, param);
4673
2.38k
  fxCoderAddBranch(param, -1, XS_CODE_BRANCH_ELSE_1, coder->firstBreakTarget);
4674
2.38k
  fxNodeDispatchCode(self->statement, param);
4675
2.38k
  fxCoderAddBranch(param, 0, XS_CODE_BRANCH_1, coder->firstContinueTarget);
4676
2.38k
}
4677
4678
void fxWithNodeCode(void* it, void* param)
4679
1.89k
{
4680
1.89k
  txWithNode* self = it;
4681
1.89k
  txCoder* coder = param;
4682
1.89k
  txBoolean evalFlag;
4683
1.89k
  fxNodeDispatchCode(self->expression, param);
4684
1.89k
  fxCoderAddByte(param, 0, XS_CODE_TO_INSTANCE);
4685
1.89k
  fxCoderAddByte(param, 0, XS_CODE_WITH);
4686
1.89k
  fxCoderAddByte(param, -1, XS_CODE_POP);
4687
1.89k
  evalFlag = coder->evalFlag;
4688
1.89k
  coder->environmentLevel++;
4689
1.89k
  coder->evalFlag = 1;
4690
1.89k
  if (coder->programFlag) {
4691
110
    fxCoderAddByte(param, 1, XS_CODE_UNDEFINED);
4692
110
    fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4693
110
  }
4694
1.89k
  fxNodeDispatchCode(self->statement, param);
4695
1.89k
  coder->evalFlag = evalFlag;
4696
1.89k
  coder->environmentLevel--;
4697
1.89k
  fxCoderAddByte(param, 0, XS_CODE_WITHOUT);
4698
1.89k
}
4699
4700
void fxYieldNodeCode(void* it, void* param) 
4701
369
{
4702
369
  txStatementNode* self = it;
4703
369
  txBoolean async = (self->flags & mxAsyncFlag) ? 1 : 0;
4704
369
  txCoder* coder = param;
4705
369
  txTargetCode* target = fxCoderCreateTarget(coder);
4706
369
  if (async) {
4707
20
    fxNodeDispatchCode(self->expression, param);
4708
20
  }
4709
349
  else {
4710
349
    fxCoderAddByte(param, 1, XS_CODE_OBJECT);
4711
349
    fxCoderAddByte(param, 1, XS_CODE_DUB);
4712
349
    fxNodeDispatchCode(self->expression, param);
4713
349
    fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, coder->parser->valueSymbol);
4714
349
    fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, 0);
4715
349
    fxCoderAddByte(param, 1, XS_CODE_DUB);
4716
349
    fxCoderAddByte(param, 1, XS_CODE_FALSE);
4717
349
    fxCoderAddSymbol(param, -2, XS_CODE_NEW_PROPERTY, coder->parser->doneSymbol);
4718
349
    fxCoderAddInteger(param, 0, XS_CODE_INTEGER_1, 0);
4719
349
  }
4720
369
  fxCoderAddByte(coder, 0, XS_CODE_YIELD);
4721
369
  fxCoderAddBranch(coder, 1, XS_CODE_BRANCH_STATUS_1, target);
4722
369
  if (async) {
4723
20
    fxCoderAddByte(param, 0, XS_CODE_AWAIT);
4724
20
    fxCoderAddByte(coder, 0, XS_CODE_THROW_STATUS);
4725
20
  }
4726
369
  fxCoderAddByte(param, -1, XS_CODE_SET_RESULT);
4727
369
  fxCoderAdjustEnvironment(coder, coder->returnTarget);
4728
369
  fxCoderAdjustScope(coder, coder->returnTarget);
4729
369
  fxCoderAddBranch(coder, 0, XS_CODE_BRANCH_1, coder->returnTarget);
4730
369
  fxCoderAdd(coder, 0, target);
4731
369
}
4732