Coverage Report

Created: 2026-05-16 07:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/moddable/xs/sources/xsRun.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 "xsAll.h"
39
40
//#define mxTrace 1
41
//#define mxTraceCall 1
42
43
#define c_iszero(NUMBER) (C_FP_ZERO == c_fpclassify(NUMBER))
44
45
static void fxRunArguments(txMachine* the, txIndex offset);
46
static void fxRunBase(txMachine* the);
47
static void fxRunConstructor(txMachine* the);
48
static txBoolean fxRunDefine(txMachine* the, txSlot* instance, txSlot* check, txID id, txIndex index, txSlot* slot, txFlag mask);
49
static txBoolean fxRunDelete(txMachine* the, txSlot* instance, txID id, txIndex index);
50
static void fxRunDerived(txMachine* the);
51
static void fxRunExtends(txMachine* the);
52
static void fxRunForOf(txMachine* the);
53
static txBoolean fxRunHas(txMachine* the, txSlot* instance, txID id, txIndex index);
54
static void fxRunIn(txMachine* the);
55
static void fxRunInstantiate(txMachine* the);
56
static void fxRunProxy(txMachine* the, txSlot* instance);
57
static void fxRunInstanceOf(txMachine* the);
58
static void fxRunUsed(txMachine* the, txSlot* selector);
59
static void fxRunUsing(txMachine* the);
60
static void fxRunUsingAsync(txMachine* the);
61
static txBoolean fxIsScopableSlot(txMachine* the, txSlot* instance, txID id);
62
static txBoolean fxToNumericInteger(txMachine* the, txSlot* theSlot);
63
static txBoolean fxToNumericIntegerUnary(txMachine* the, txSlot* theSlot, txBigIntUnary op);
64
static txBoolean fxToNumericIntegerBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op);
65
static txBoolean fxToNumericNumber(txMachine* the, txSlot* theSlot);
66
static txBoolean fxToNumericNumberUnary(txMachine* the, txSlot* theSlot, txBigIntUnary op);
67
static txBoolean fxToNumericNumberBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op);
68
69
#if defined(__GNUC__) && defined(__OPTIMIZE__)
70
  #if defined(mxFrequency)
71
    #define mxBreak \
72
      the->frequencies[byte]++; \
73
      goto *bytes[byte]
74
  #elif defined(mxTrace)
75
    #define mxBreak \
76
      if (gxDoTrace) fxTraceCode(the, stack, byte); \
77
      goto *bytes[byte]
78
  #elif defined(mxMetering)
79
    #define mxBreak \
80
0
      the->meterIndex += XS_CODE_METERING; \
81
0
      goto *bytes[byte]
82
  #else
83
    #define mxBreak \
84
      goto *bytes[byte]
85
  #endif
86
0
  #define mxCase(OPCODE) OPCODE:
87
0
  #define mxSwitch(OPCODE) mxBreak;
88
#else
89
  #define mxBreak \
90
    break
91
  #define mxCase(OPCODE) \
92
    case OPCODE:
93
  #if defined(mxFrequency)
94
    #define mxSwitch(OPCODE) \
95
      the->frequencies[OPCODE]++; \
96
      switch(OPCODE)
97
  #else
98
    #define mxSwitch(OPCODE) \
99
      switch(OPCODE)
100
  #endif
101
#endif
102
103
118k
#define mxCode code
104
318k
#define mxFrame frame
105
18.2k
#define mxEnvironment environment
106
100k
#define mxScope scope
107
274k
#define mxStack stack
108
109
13.6k
#define mxFrameEnd (mxFrame + ((mxFrame->flag & XS_TARGET_FLAG) ? 5 : 4))
110
0
#define mxFrameThis (mxFrame + 3)
111
0
#define mxFrameFunction (mxFrame + 2)
112
18.2k
#define mxFrameResult (mxFrame + 1)
113
0
#define mxFrameTarget (mxFrame + 4)
114
0
#define mxFrameHasTarget (mxFrame->flag & XS_TARGET_FLAG)
115
0
#define mxFrameArgc ((txInteger)(mxFrame->ID))
116
0
#define mxFrameArgv(THE_INDEX) (mxFrame - 1 - (THE_INDEX))
117
118
18.2k
#define mxRestoreState { \
119
18.2k
  mxStack = the->stack; \
120
18.2k
  mxScope = the->scope; \
121
18.2k
  mxFrame = the->frame; \
122
18.2k
  mxEnvironment = mxFrameToEnvironment(mxFrame); \
123
18.2k
  mxCode = the->code; \
124
18.2k
}
125
0
#define mxRestoreStateKeepStack { \
126
0
  mxScope = the->scope; \
127
0
  mxFrame = the->frame; \
128
0
  mxEnvironment = mxFrameToEnvironment(mxFrame); \
129
0
  mxCode = the->code; \
130
0
}
131
#if defined(mxFrequency)
132
  #define mxSaveState { \
133
    the->exits[byte]++; \
134
    the->stack = mxStack; \
135
    the->scope = mxScope; \
136
    the->frame = mxFrame; \
137
    the->code = mxCode; \
138
  }
139
  #define mxSaveStateKeepStack { \
140
    the->exits[byte]++; \
141
    the->scope = mxScope; \
142
    the->frame = mxFrame; \
143
    the->code = mxCode; \
144
  }
145
#else
146
31.8k
  #define mxSaveState { \
147
31.8k
    the->stack = mxStack; \
148
31.8k
    the->scope = mxScope; \
149
31.8k
    the->frame = mxFrame; \
150
31.8k
    the->code = mxCode; \
151
31.8k
  }
152
0
  #define mxSaveStateKeepStack { \
153
0
    the->scope = mxScope; \
154
0
    the->frame = mxFrame; \
155
0
    the->code = mxCode; \
156
0
  }
157
#endif
158
159
#if mxBoundsCheck
160
#define mxAllocStack(_COUNT) \
161
31.8k
  if ((mxStack - _COUNT) < the->stackBottom) \
162
31.8k
    goto STACK_OVERFLOW; \
163
31.8k
  mxStack -= _COUNT
164
#else
165
#define mxAllocStack(_COUNT) \
166
  mxStack -= _COUNT
167
#endif
168
169
18.2k
#define mxPushKind(_KIND) { \
170
18.2k
  mxAllocStack(1); \
171
18.2k
  mxStack->next = C_NULL;  \
172
18.2k
  mxInitSlotKind(mxStack, _KIND); \
173
18.2k
}
174
175
0
#define mxRunDebug(_ERROR, ...) { \
176
0
  mxSaveState; \
177
0
  fxThrowMessage(the, NULL, 0, _ERROR, __VA_ARGS__); \
178
0
}
179
180
0
#define mxRunDebugID(_ERROR, _MESSAGE, _ID) { \
181
0
  mxSaveState; \
182
0
  fxIDToString(the, _ID, the->nameBuffer, sizeof(the->nameBuffer)); \
183
0
  fxThrowMessage(the, NULL, 0, _ERROR, _MESSAGE, the->nameBuffer); \
184
0
}
185
186
#define mxToBoolean(SLOT) \
187
0
  if (XS_BOOLEAN_KIND != (SLOT)->kind) { \
188
0
    if (XS_SYMBOL_KIND <= (SLOT)->kind) { \
189
0
      mxSaveState; \
190
0
      fxToBoolean(the, SLOT); \
191
0
      mxRestoreState; \
192
0
    } \
193
0
    else \
194
0
      fxToBoolean(the, SLOT); \
195
0
  }
196
197
#define mxToInteger(SLOT) \
198
  if (XS_INTEGER_KIND != (SLOT)->kind) { \
199
    if (XS_STRING_KIND <= (SLOT)->kind) { \
200
      mxSaveState; \
201
      fxToInteger(the, SLOT); \
202
      mxRestoreState; \
203
    } \
204
    else \
205
      fxToInteger(the, SLOT); \
206
  }
207
  
208
#define mxToNumber(SLOT) \
209
0
  if (XS_NUMBER_KIND != (SLOT)->kind) { \
210
0
    if (XS_STRING_KIND <= (SLOT)->kind) { \
211
0
      mxSaveState; \
212
0
      fxToNumber(the, SLOT); \
213
0
      mxRestoreState; \
214
0
    } \
215
0
    else \
216
0
      fxToNumber(the, SLOT); \
217
0
  }
218
  
219
#define mxToString(SLOT) \
220
0
  if ((XS_STRING_KIND != (SLOT)->kind) && (XS_STRING_X_KIND != (SLOT)->kind)) { \
221
0
    mxSaveState; \
222
0
    fxToString(the, SLOT); \
223
0
    mxRestoreState; \
224
0
  }
225
  
226
#define mxToInstance(SLOT) \
227
0
  if (XS_REFERENCE_KIND != (SLOT)->kind) { \
228
0
    mxSaveState; \
229
0
    variable = fxToInstance(the, SLOT); \
230
0
    mxRestoreState; \
231
0
    primitive = 1; \
232
0
  } \
233
0
  else { \
234
0
    variable = (SLOT)->value.reference; \
235
0
    primitive = 0; \
236
0
  }
237
238
#ifndef mxUnalignedAccess
239
  #define mxUnalignedAccess 1
240
#endif
241
242
0
#define mxRunS1(OFFSET) ((txS1*)mxCode)[OFFSET]
243
0
#define mxRunU1(OFFSET) ((txU1*)mxCode)[OFFSET]
244
#if mxBigEndian
245
  #define mxRunS2(OFFSET) (((txS1*)mxCode)[OFFSET+0] << 8) | ((txU1*)mxCode)[OFFSET+1]
246
  #define mxRunS4(OFFSET) (((txS1*)mxCode)[OFFSET+0] << 24) | (((txU1*)mxCode)[OFFSET+1] << 16) | (((txU1*)mxCode)[OFFSET+2] << 8) | ((txU1*)mxCode)[OFFSET+3]
247
  #define mxRunU2(OFFSET) (((txU1*)mxCode)[OFFSET+0] << 8) | ((txU1*)mxCode)[OFFSET+1]
248
#else
249
  #if mxUnalignedAccess
250
0
    #define mxRunS2(OFFSET) *((txS2*)(mxCode + OFFSET))
251
0
    #define mxRunS4(OFFSET) *((txS4*)(mxCode + OFFSET))
252
0
    #define mxRunU2(OFFSET) *((txU2*)(mxCode + OFFSET))
253
  #else 
254
    #define mxRunS2(OFFSET) (((txS1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0]
255
    #define mxRunS4(OFFSET) (((txS1*)mxCode)[OFFSET+3] << 24) | (((txU1*)mxCode)[OFFSET+2] << 16) | (((txU1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0]
256
    #define mxRunU2(OFFSET) (((txU1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0]
257
  #endif
258
#endif
259
#ifdef mx32bitID
260
0
  #define mxRunID(OFFSET) mxRunS4(OFFSET)
261
#else
262
  #define mxRunID(OFFSET) mxRunS2(OFFSET)
263
#endif
264
265
0
#define mxNextCode(OFFSET) { \
266
0
  mxCode += OFFSET; \
267
0
  byte = *((txU1*)mxCode); \
268
0
}
269
0
#define mxSkipCode(OFFSET) { \
270
0
  mxCode += OFFSET; \
271
0
}
272
273
#ifdef mxMetering
274
  #define mxCheckMeter() \
275
0
    if (the->meterInterval && (the->meterIndex > the->meterCount)) { \
276
0
      mxSaveState; \
277
0
      fxCheckMetering(the); \
278
0
      mxRestoreState; \
279
0
    }
280
  #define mxBranch(INDEX, OFFSET) \
281
0
    if ((OFFSET) < 0) { \
282
0
      mxCheckMeter(); \
283
0
    } \
284
0
    mxNextCode((txS4)INDEX + OFFSET)
285
  #define mxBranchElse(TEST, INDEX, OFFSET) \
286
0
    if (TEST) { \
287
0
      mxNextCode((txS4)INDEX); \
288
0
    } \
289
0
    else { \
290
0
      mxBranch(INDEX, OFFSET); \
291
0
    }
292
  #define mxBranchIf(TEST, INDEX, OFFSET) \
293
0
    if (TEST) { \
294
0
      mxBranch(INDEX, OFFSET); \
295
0
    } \
296
0
    else { \
297
0
      mxNextCode((txS4)index); \
298
0
    }
299
  #define mxFirstCode() \
300
0
    mxCheckMeter(); \
301
0
    byte = *((txU1*)mxCode)
302
#else
303
  #define mxBranch(INDEX, OFFSET) \
304
    mxNextCode((txS4)INDEX + OFFSET)
305
  #define mxBranchElse(TEST, INDEX, OFFSET) \
306
    mxNextCode((TEST) ? (txS4)INDEX : (txS4)INDEX + OFFSET)
307
  #define mxBranchIf(TEST, INDEX, OFFSET) \
308
    mxNextCode((TEST) ? (txS4)INDEX + OFFSET : (txS4)INDEX)
309
  #define mxFirstCode() \
310
    byte = *((txU1*)mxCode)
311
#endif
312
313
#ifdef mxTrace
314
short gxDoTrace = 1;
315
316
#ifdef mxMetering
317
static void fxTraceCode(txMachine* the, txSlot* stack, txU1 theCode) 
318
{
319
  if (((XS_NO_CODE < theCode) && (theCode < XS_CODE_COUNT)))
320
    fprintf(stderr, "\n%u %ld: %s", the->meterIndex, the->stackTop - stack, gxCodeNames[theCode]);
321
  else
322
    fprintf(stderr, "\n%u %ld: ?", the->meterIndex, the->stackTop - stack);
323
}
324
#else
325
static void fxTraceCode(txMachine* the, txSlot* stack, txU1 theCode) 
326
{
327
  if (((XS_NO_CODE < theCode) && (theCode < XS_CODE_COUNT)))
328
    fprintf(stderr, "\n%ld: %s", (long int)(the->stackTop - stack), gxCodeNames[theCode]);
329
  else
330
    fprintf(stderr, "\n%ld: ?", (long int)(the->stackTop - stack));
331
}
332
#endif
333
334
static void fxTraceID(txMachine* the, txID id, txIndex index) 
335
{
336
  if (id) {
337
    char* key = fxGetKeyName(the, id);
338
    if (key)
339
      fprintf(stderr, " [%s]", key);
340
    else
341
      fprintf(stderr, " [?]");
342
  }
343
  else
344
    fprintf(stderr, " [%d]", (int)index);
345
}
346
347
static void fxTraceIndex(txMachine* the, txU2 theIndex) 
348
{
349
  fprintf(stderr, " %d", theIndex);
350
}
351
352
static void fxTraceInteger(txMachine* the, txInteger theInteger) 
353
{
354
  fprintf(stderr, " %ld", (long)theInteger);
355
}
356
357
static void fxTraceNumber(txMachine* the, txNumber theNumber) 
358
{
359
  fprintf(stderr, " %lf", theNumber);
360
}
361
362
static void fxTraceReturn(txMachine* the) 
363
{
364
  fprintf(stderr, "\n");
365
}
366
367
static void fxTraceString(txMachine* the, txString theString) 
368
{
369
  fprintf(stderr, " \"%s\"", theString);
370
}
371
#endif
372
373
#ifdef mxTraceCall
374
int gxTraceCall = 0;
375
static int depth = 0;
376
static void fxTraceCallBegin(txMachine* the, txSlot* function)
377
{
378
  if (gxTraceCall) {
379
    txSlot* slot = mxBehaviorGetProperty(the, function->value.reference, mxID(_name), 0, XS_ANY);
380
    int i;
381
    for (i = 0; i < depth; i++)
382
      fprintf(stderr, "\t");
383
    if (slot && ((slot->kind == XS_STRING_KIND) ||  (slot->kind == XS_STRING_X_KIND)))
384
      fprintf(stderr, " [%s]\n", slot->value.string);
385
    else
386
      fprintf(stderr, " [?]\n");
387
    depth++;
388
  }
389
}
390
static void fxTraceCallEnd(txMachine* the, txSlot* function)
391
{
392
  if (gxTraceCall) {
393
    depth--;
394
    if (depth < 0)
395
      depth = 0;
396
  }
397
}
398
#endif
399
400
#if defined(mxInstrument) && !defined(mxDebug)
401
static void fxTraceException(txMachine *the)
402
{
403
#ifndef mxNoConsole
404
  if (XS_REFERENCE_KIND == mxException.kind) {
405
    txSlot* internal = mxException.value.reference->next;
406
    if (internal && (internal->kind == XS_ERROR_KIND)) {
407
      txSlot* msg = internal->next;
408
      if (msg && ((msg->kind == XS_STRING_KIND) || (msg->kind == XS_STRING_X_KIND)))
409
        c_printf("Exception %s: %s\n", gxErrorNames[internal->value.error.which], msg->value.string);
410
      else
411
        c_printf("Exception %s\n", gxErrorNames[internal->value.error.which]);
412
    }
413
  }
414
  else
415
    c_printf("Exception\n");
416
#endif
417
}
418
#endif
419
420
void fxRunID(txMachine* the, txSlot* generator, txInteger count)
421
18.2k
{
422
18.2k
  register txSlot* stack = the->stack;
423
18.2k
  register txSlot* scope = the->scope;
424
18.2k
  register txSlot* frame = the->frame;
425
18.2k
  register txSlot* environment;
426
18.2k
  register txByte* code = the->code;
427
18.2k
  register txSlot* variable;
428
18.2k
  register txSlot* slot;
429
18.2k
  register txU1 byte = 0;
430
18.2k
  register txU4 index;
431
18.2k
  register txS4 offset;
432
18.2k
  txU1 primitive = 0;
433
18.2k
  txU1 ignore = 0;
434
18.2k
#if defined(__GNUC__) && defined(__OPTIMIZE__)
435
18.2k
  static void *const
436
18.2k
  #if !defined(__ets__) || ESP32
437
18.2k
    ICACHE_RAM_ATTR
438
18.2k
  #endif
439
18.2k
    gxBytes[] = {
440
18.2k
    &&XS_NO_CODE,
441
18.2k
    &&XS_CODE_ADD,
442
18.2k
    &&XS_CODE_ARGUMENT,
443
18.2k
    &&XS_CODE_ARGUMENTS,
444
18.2k
    &&XS_CODE_ARGUMENTS_SLOPPY,
445
18.2k
    &&XS_CODE_ARGUMENTS_STRICT,
446
18.2k
    &&XS_CODE_ARRAY,
447
18.2k
    &&XS_CODE_ASYNC_FUNCTION,
448
18.2k
    &&XS_CODE_ASYNC_GENERATOR_FUNCTION,
449
18.2k
    &&XS_CODE_AT,
450
18.2k
    &&XS_CODE_AWAIT,
451
18.2k
    &&XS_CODE_BEGIN_SLOPPY,
452
18.2k
    &&XS_CODE_BEGIN_STRICT,
453
18.2k
    &&XS_CODE_BEGIN_STRICT_BASE,
454
18.2k
    &&XS_CODE_BEGIN_STRICT_DERIVED,
455
18.2k
    &&XS_CODE_BEGIN_STRICT_FIELD,
456
18.2k
    &&XS_CODE_BIGINT_1,
457
18.2k
    &&XS_CODE_BIGINT_2,
458
18.2k
    &&XS_CODE_BIT_AND,
459
18.2k
    &&XS_CODE_BIT_NOT,
460
18.2k
    &&XS_CODE_BIT_OR,
461
18.2k
    &&XS_CODE_BIT_XOR,
462
18.2k
    &&XS_CODE_BRANCH_1,
463
18.2k
    &&XS_CODE_BRANCH_2,
464
18.2k
    &&XS_CODE_BRANCH_4,
465
18.2k
    &&XS_CODE_BRANCH_CHAIN_1,
466
18.2k
    &&XS_CODE_BRANCH_CHAIN_2,
467
18.2k
    &&XS_CODE_BRANCH_CHAIN_4,
468
18.2k
    &&XS_CODE_BRANCH_COALESCE_1,
469
18.2k
    &&XS_CODE_BRANCH_COALESCE_2,
470
18.2k
    &&XS_CODE_BRANCH_COALESCE_4,
471
18.2k
    &&XS_CODE_BRANCH_ELSE_1,
472
18.2k
    &&XS_CODE_BRANCH_ELSE_2,
473
18.2k
    &&XS_CODE_BRANCH_ELSE_4,
474
18.2k
    &&XS_CODE_BRANCH_IF_1,
475
18.2k
    &&XS_CODE_BRANCH_IF_2,
476
18.2k
    &&XS_CODE_BRANCH_IF_4,
477
18.2k
    &&XS_CODE_BRANCH_STATUS_1,
478
18.2k
    &&XS_CODE_BRANCH_STATUS_2,
479
18.2k
    &&XS_CODE_BRANCH_STATUS_4,
480
18.2k
    &&XS_CODE_CALL,
481
18.2k
    &&XS_CODE_CATCH_1,
482
18.2k
    &&XS_CODE_CATCH_2,
483
18.2k
    &&XS_CODE_CATCH_4,
484
18.2k
    &&XS_CODE_CHECK_INSTANCE,
485
18.2k
    &&XS_CODE_CLASS,
486
18.2k
    &&XS_CODE_CODE_1,
487
18.2k
    &&XS_CODE_CODE_2,
488
18.2k
    &&XS_CODE_CODE_4,
489
18.2k
    &&XS_CODE_CODE_ARCHIVE_1,
490
18.2k
    &&XS_CODE_CODE_ARCHIVE_2,
491
18.2k
    &&XS_CODE_CODE_ARCHIVE_4,
492
18.2k
    &&XS_CODE_CONST_CLOSURE_1,
493
18.2k
    &&XS_CODE_CONST_CLOSURE_2,
494
18.2k
    &&XS_CODE_CONST_LOCAL_1,
495
18.2k
    &&XS_CODE_CONST_LOCAL_2,
496
18.2k
    &&XS_CODE_CONSTRUCTOR_FUNCTION,
497
18.2k
    &&XS_CODE_COPY_OBJECT,
498
18.2k
    &&XS_CODE_CURRENT,
499
18.2k
    &&XS_CODE_DEBUGGER,
500
18.2k
    &&XS_CODE_DECREMENT,
501
18.2k
    &&XS_CODE_DELETE_PROPERTY,
502
18.2k
    &&XS_CODE_DELETE_PROPERTY_AT,
503
18.2k
    &&XS_CODE_DELETE_SUPER,
504
18.2k
    &&XS_CODE_DELETE_SUPER_AT,
505
18.2k
    &&XS_CODE_DIVIDE,
506
18.2k
    &&XS_CODE_DUB,
507
18.2k
    &&XS_CODE_DUB_AT,
508
18.2k
    &&XS_CODE_END,
509
18.2k
    &&XS_CODE_END_ARROW,
510
18.2k
    &&XS_CODE_END_BASE,
511
18.2k
    &&XS_CODE_END_DERIVED,
512
18.2k
    &&XS_CODE_ENVIRONMENT,
513
18.2k
    &&XS_CODE_EQUAL,
514
18.2k
    &&XS_CODE_EVAL,
515
18.2k
    &&XS_CODE_EVAL_ENVIRONMENT,
516
18.2k
    &&XS_CODE_EVAL_PRIVATE,
517
18.2k
    &&XS_CODE_EVAL_REFERENCE,
518
18.2k
    &&XS_CODE_EVAL_TAIL,
519
18.2k
    &&XS_CODE_EXCEPTION,
520
18.2k
    &&XS_CODE_EXPONENTIATION,
521
18.2k
    &&XS_CODE_EXTEND,
522
18.2k
    &&XS_CODE_FALSE,
523
18.2k
    &&XS_CODE_FILE,
524
18.2k
    &&XS_CODE_FOR_AWAIT_OF,
525
18.2k
    &&XS_CODE_FOR_IN,
526
18.2k
    &&XS_CODE_FOR_OF,
527
18.2k
    &&XS_CODE_FUNCTION,
528
18.2k
    &&XS_CODE_FUNCTION_ENVIRONMENT,
529
18.2k
    &&XS_CODE_GENERATOR_FUNCTION,
530
18.2k
    &&XS_CODE_GET_CLOSURE_1,
531
18.2k
    &&XS_CODE_GET_CLOSURE_2,
532
18.2k
    &&XS_CODE_GET_LOCAL_1,
533
18.2k
    &&XS_CODE_GET_LOCAL_2,
534
18.2k
    &&XS_CODE_GET_PRIVATE_1,
535
18.2k
    &&XS_CODE_GET_PRIVATE_2,
536
18.2k
    &&XS_CODE_GET_PROPERTY,
537
18.2k
    &&XS_CODE_GET_PROPERTY_AT,
538
18.2k
    &&XS_CODE_GET_RESULT,
539
18.2k
    &&XS_CODE_GET_SUPER,
540
18.2k
    &&XS_CODE_GET_SUPER_AT,
541
18.2k
    &&XS_CODE_GET_THIS,
542
18.2k
    &&XS_CODE_GET_VARIABLE,
543
18.2k
    &&XS_CODE_GET_THIS_VARIABLE,
544
18.2k
    &&XS_CODE_GLOBAL,
545
18.2k
    &&XS_CODE_HAS_PRIVATE_1,
546
18.2k
    &&XS_CODE_HAS_PRIVATE_2,
547
18.2k
    &&XS_CODE_HOST,
548
18.2k
    &&XS_CODE_IMPORT,
549
18.2k
    &&XS_CODE_IMPORT_META,
550
18.2k
    &&XS_CODE_IN,
551
18.2k
    &&XS_CODE_INCREMENT,
552
18.2k
    &&XS_CODE_INSTANCEOF,
553
18.2k
    &&XS_CODE_INSTANTIATE,
554
18.2k
    &&XS_CODE_INTEGER_1,
555
18.2k
    &&XS_CODE_INTEGER_2,
556
18.2k
    &&XS_CODE_INTEGER_4,
557
18.2k
    &&XS_CODE_LEFT_SHIFT,
558
18.2k
    &&XS_CODE_LESS,
559
18.2k
    &&XS_CODE_LESS_EQUAL,
560
18.2k
    &&XS_CODE_LET_CLOSURE_1,
561
18.2k
    &&XS_CODE_LET_CLOSURE_2,
562
18.2k
    &&XS_CODE_LET_LOCAL_1,
563
18.2k
    &&XS_CODE_LET_LOCAL_2,
564
18.2k
    &&XS_CODE_LINE,
565
18.2k
    &&XS_CODE_MINUS,
566
18.2k
    &&XS_CODE_MODULE,
567
18.2k
    &&XS_CODE_MODULO,
568
18.2k
    &&XS_CODE_MORE,
569
18.2k
    &&XS_CODE_MORE_EQUAL,
570
18.2k
    &&XS_CODE_MULTIPLY,
571
18.2k
    &&XS_CODE_NAME,
572
18.2k
    &&XS_CODE_NEW,
573
18.2k
    &&XS_CODE_NEW_CLOSURE,
574
18.2k
    &&XS_CODE_NEW_LOCAL,
575
18.2k
    &&XS_CODE_NEW_PRIVATE_1,
576
18.2k
    &&XS_CODE_NEW_PRIVATE_2,
577
18.2k
    &&XS_CODE_NEW_PROPERTY,
578
18.2k
    &&XS_CODE_NEW_PROPERTY_AT,
579
18.2k
    &&XS_CODE_NEW_TEMPORARY,
580
18.2k
    &&XS_CODE_NOT,
581
18.2k
    &&XS_CODE_NOT_EQUAL,
582
18.2k
    &&XS_CODE_NULL,
583
18.2k
    &&XS_CODE_NUMBER,
584
18.2k
    &&XS_CODE_OBJECT,
585
18.2k
    &&XS_CODE_PLUS,
586
18.2k
    &&XS_CODE_POP,
587
18.2k
    &&XS_CODE_PROGRAM_ENVIRONMENT,
588
18.2k
    &&XS_CODE_PROGRAM_REFERENCE,
589
18.2k
    &&XS_CODE_PULL_CLOSURE_1,
590
18.2k
    &&XS_CODE_PULL_CLOSURE_2,
591
18.2k
    &&XS_CODE_PULL_LOCAL_1,
592
18.2k
    &&XS_CODE_PULL_LOCAL_2,
593
18.2k
    &&XS_CODE_REFRESH_CLOSURE_1,
594
18.2k
    &&XS_CODE_REFRESH_CLOSURE_2,
595
18.2k
    &&XS_CODE_REFRESH_LOCAL_1,
596
18.2k
    &&XS_CODE_REFRESH_LOCAL_2,
597
18.2k
    &&XS_CODE_REGEXP,
598
18.2k
    &&XS_CODE_RESERVE_1,
599
18.2k
    &&XS_CODE_RESERVE_2,
600
18.2k
    &&XS_CODE_RESET_CLOSURE_1,
601
18.2k
    &&XS_CODE_RESET_CLOSURE_2,
602
18.2k
    &&XS_CODE_RESET_LOCAL_1,
603
18.2k
    &&XS_CODE_RESET_LOCAL_2,
604
18.2k
    &&XS_CODE_RETHROW,
605
18.2k
    &&XS_CODE_RETRIEVE_1,
606
18.2k
    &&XS_CODE_RETRIEVE_2,
607
18.2k
    &&XS_CODE_RETRIEVE_TARGET,
608
18.2k
    &&XS_CODE_RETRIEVE_THIS,
609
18.2k
    &&XS_CODE_RETURN,
610
18.2k
    &&XS_CODE_RUN,
611
18.2k
    &&XS_CODE_RUN_1,
612
18.2k
    &&XS_CODE_RUN_2,
613
18.2k
    &&XS_CODE_RUN_4,
614
18.2k
    &&XS_CODE_RUN_TAIL,
615
18.2k
    &&XS_CODE_RUN_TAIL_1,
616
18.2k
    &&XS_CODE_RUN_TAIL_2,
617
18.2k
    &&XS_CODE_RUN_TAIL_4,
618
18.2k
    &&XS_CODE_SET_CLOSURE_1,
619
18.2k
    &&XS_CODE_SET_CLOSURE_2,
620
18.2k
    &&XS_CODE_SET_HOME,
621
18.2k
    &&XS_CODE_SET_LOCAL_1,
622
18.2k
    &&XS_CODE_SET_LOCAL_2,
623
18.2k
    &&XS_CODE_SET_PRIVATE_1,
624
18.2k
    &&XS_CODE_SET_PRIVATE_2,
625
18.2k
    &&XS_CODE_SET_PROPERTY,
626
18.2k
    &&XS_CODE_SET_PROPERTY_AT,
627
18.2k
    &&XS_CODE_SET_RESULT,
628
18.2k
    &&XS_CODE_SET_SUPER,
629
18.2k
    &&XS_CODE_SET_SUPER_AT,
630
18.2k
    &&XS_CODE_SET_THIS,
631
18.2k
    &&XS_CODE_SET_VARIABLE,
632
18.2k
    &&XS_CODE_SIGNED_RIGHT_SHIFT,
633
18.2k
    &&XS_CODE_START_ASYNC,
634
18.2k
    &&XS_CODE_START_ASYNC_GENERATOR,
635
18.2k
    &&XS_CODE_START_GENERATOR,
636
18.2k
    &&XS_CODE_STORE_1,
637
18.2k
    &&XS_CODE_STORE_2,
638
18.2k
    &&XS_CODE_STORE_ARROW,
639
18.2k
    &&XS_CODE_STRICT_EQUAL,
640
18.2k
    &&XS_CODE_STRICT_NOT_EQUAL,
641
18.2k
    &&XS_CODE_STRING_1,
642
18.2k
    &&XS_CODE_STRING_2,
643
18.2k
    &&XS_CODE_STRING_4,
644
18.2k
    &&XS_CODE_STRING_ARCHIVE_1,
645
18.2k
    &&XS_CODE_STRING_ARCHIVE_2,
646
18.2k
    &&XS_CODE_STRING_ARCHIVE_4,
647
18.2k
    &&XS_CODE_SUBTRACT,
648
18.2k
    &&XS_CODE_SUPER,
649
18.2k
    &&XS_CODE_SWAP,
650
18.2k
    &&XS_CODE_SYMBOL,
651
18.2k
    &&XS_CODE_TARGET,
652
18.2k
    &&XS_CODE_TEMPLATE,
653
18.2k
    &&XS_CODE_TEMPLATE_CACHE,
654
18.2k
    &&XS_CODE_THIS,
655
18.2k
    &&XS_CODE_THROW,
656
18.2k
    &&XS_CODE_THROW_STATUS,
657
18.2k
    &&XS_CODE_TO_INSTANCE,
658
18.2k
    &&XS_CODE_TO_NUMERIC,
659
18.2k
    &&XS_CODE_TO_STRING,
660
18.2k
    &&XS_CODE_TRANSFER,
661
18.2k
    &&XS_CODE_TRUE,
662
18.2k
    &&XS_CODE_TYPEOF,
663
18.2k
    &&XS_CODE_UNCATCH,
664
18.2k
    &&XS_CODE_UNDEFINED,
665
18.2k
    &&XS_CODE_UNSIGNED_RIGHT_SHIFT,
666
18.2k
    &&XS_CODE_UNWIND_1,
667
18.2k
    &&XS_CODE_UNWIND_2,
668
18.2k
    &&XS_CODE_VAR_CLOSURE_1,
669
18.2k
    &&XS_CODE_VAR_CLOSURE_2,
670
18.2k
    &&XS_CODE_VAR_LOCAL_1,
671
18.2k
    &&XS_CODE_VAR_LOCAL_2,
672
18.2k
    &&XS_CODE_VOID,
673
18.2k
    &&XS_CODE_WITH,
674
18.2k
    &&XS_CODE_WITHOUT,
675
18.2k
    &&XS_CODE_YIELD,
676
18.2k
    &&XS_CODE_PROFILE,
677
18.2k
    &&XS_CODE_YIELD_STAR,
678
18.2k
    &&XS_CODE_USED_1,
679
18.2k
    &&XS_CODE_USED_2,
680
18.2k
    &&XS_CODE_USING,
681
18.2k
    &&XS_CODE_USING_ASYNC,
682
18.2k
    &&XS_CODE_AT_2,
683
18.2k
    &&XS_CODE_SUPER_AT,
684
18.2k
    &&XS_CODE_SUPER_AT_2,
685
18.2k
    &&XS_CODE_TRANSFER_JSON,
686
18.2k
  };
687
18.2k
  register void * const *bytes = gxBytes;
688
18.2k
#endif
689
18.2k
  txJump* jump = C_NULL;
690
18.2k
  txSlot scratch;
691
18.2k
  txSlot** address;
692
18.2k
  txJump* yieldJump = the->firstJump;
693
694
18.2k
  mxCheckCStack();
695
18.2k
  if (generator) {
696
0
    slot = mxStack;
697
0
    variable = generator->next;
698
0
    offset = variable->value.stack.length;
699
0
    mxAllocStack(offset);
700
0
    c_memcpy(mxStack, variable->value.stack.address, offset * sizeof(txSlot));
701
0
    mxCode = (mxStack++)->value.reference->next->value.code.address;
702
0
    offset = (mxStack++)->value.integer;
703
0
    while (offset) {
704
0
      jump = c_malloc(sizeof(txJump));
705
0
      if (jump) {
706
0
        jump->nextJump = the->firstJump;
707
0
        jump->stack = slot - (mxStack++)->value.integer;
708
0
        jump->frame = slot - (mxStack++)->value.integer;
709
0
        jump->scope = slot - (mxStack++)->value.integer;
710
0
        jump->code = mxCode + (mxStack++)->value.integer;
711
0
        jump->flag = 1;
712
0
                the->firstJump = jump;
713
0
        if (c_setjmp(jump->buffer) == 1) {
714
0
          jump = the->firstJump;
715
0
                    the->firstJump = jump->nextJump;
716
0
          mxStack = jump->stack;
717
0
          mxScope = jump->scope;
718
0
          mxFrame = jump->frame;
719
0
          mxEnvironment = mxFrameToEnvironment(mxFrame);
720
0
          mxCode = jump->code;
721
0
          c_free(jump);
722
0
          goto XS_CODE_JUMP;
723
0
        }
724
0
      }
725
0
      else {
726
0
        mxSaveState;
727
0
        fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
728
0
      }
729
0
      offset--;
730
0
    }
731
0
    variable = slot - (mxStack++)->value.integer;
732
0
    variable->next = mxFrame;
733
0
    variable->value.frame.code = the->code;
734
0
    variable->value.frame.scope = mxScope;
735
0
    mxFrame = variable;
736
0
    mxEnvironment = mxFrameToEnvironment(mxFrame);
737
0
    mxScope = slot - (mxStack++)->value.integer;
738
0
    mxCode = mxCode + (mxStack++)->value.integer;
739
0
    mxStack->kind = the->scratch.kind;
740
0
    mxStack->value = the->scratch.value;
741
#ifdef mxTraceCall
742
    fxTraceCallBegin(the, mxFrameFunction);
743
#endif
744
0
XS_CODE_JUMP:
745
0
    mxFirstCode();
746
0
  }
747
18.2k
  else {
748
18.2k
    offset = count;
749
18.2k
    goto XS_CODE_RUN_ALL;
750
18.2k
  }
751
0
  for (;;) {
752
753
#ifdef mxTrace
754
    if (gxDoTrace) fxTraceCode(the, stack, byte);
755
#endif
756
0
#ifdef mxMetering
757
0
    the->meterIndex += XS_CODE_METERING;
758
0
#endif
759
    
760
0
    mxSwitch(byte) {
761
0
    mxCase(XS_NO_CODE)
762
0
      mxBreak;
763
764
0
    mxCase(XS_CODE_RUN_TAIL)
765
0
      mxSkipCode(1);
766
0
      offset = mxStack->value.integer;
767
0
      mxStack++;
768
0
      goto XS_CODE_RUN_TAIL_ALL;
769
0
    mxCase(XS_CODE_RUN_TAIL_4)
770
0
      offset = mxRunS4(1);
771
0
      mxSkipCode(5);
772
0
      goto XS_CODE_RUN_TAIL_ALL;
773
0
    mxCase(XS_CODE_RUN_TAIL_2)
774
0
      offset = mxRunS2(1);
775
0
      mxSkipCode(3);
776
0
      goto XS_CODE_RUN_TAIL_ALL;
777
0
    mxCase(XS_CODE_RUN_TAIL_1)
778
0
      offset = mxRunS1(1);
779
0
      mxSkipCode(2);
780
0
    XS_CODE_RUN_TAIL_ALL:
781
0
      if (mxFrameHasTarget)
782
0
        goto XS_CODE_RUN_ALL;
783
0
#ifdef mxDebug
784
0
      slot = mxStack + offset + 2;
785
0
      if (!fxIsCallable(the, slot))
786
0
        goto XS_CODE_RUN_ALL;
787
0
#endif
788
0
      variable = mxFrameEnd - 4 - offset;
789
0
      mxScope = mxFrame->value.frame.scope;
790
0
      mxCode = mxFrame->value.frame.code;
791
0
      mxFrame = mxFrame->next;
792
0
      c_memmove(variable, mxStack, (4 + offset) * sizeof(txSlot));
793
0
      mxStack = variable;
794
0
      goto XS_CODE_RUN_ALL;
795
796
0
    mxCase(XS_CODE_RUN)
797
0
      mxSkipCode(1);
798
0
      offset = mxStack->value.integer;
799
0
      mxStack++;
800
0
      goto XS_CODE_RUN_ALL;
801
0
    mxCase(XS_CODE_RUN_4)
802
0
      offset = mxRunS4(1);
803
0
      mxSkipCode(5);
804
0
      goto XS_CODE_RUN_ALL;
805
0
    mxCase(XS_CODE_RUN_2)
806
0
      offset = mxRunS2(1);
807
0
      mxSkipCode(3);
808
0
      goto XS_CODE_RUN_ALL;
809
0
    mxCase(XS_CODE_RUN_1)
810
0
      offset = mxRunS1(1);
811
0
      mxSkipCode(2);
812
18.2k
    XS_CODE_RUN_ALL:
813
#ifdef mxTrace
814
      if (gxDoTrace) fxTraceInteger(the, offset);
815
#endif
816
18.2k
      slot = mxStack + offset;
817
      // FRAME
818
18.2k
      slot->kind = XS_FRAME_KIND;
819
18.2k
      slot->next = mxFrame;
820
18.2k
      slot->flag = slot->flag & XS_TARGET_FLAG;
821
18.2k
      slot->ID = (txID)offset; // COUNT
822
18.2k
#ifdef mxDebug
823
18.2k
      if (mxFrame && (mxFrame->flag & XS_STEP_INTO_FLAG))
824
0
        slot->flag |= XS_STEP_INTO_FLAG | XS_STEP_OVER_FLAG;
825
18.2k
#endif
826
18.2k
      slot->value.frame.code = mxCode;
827
18.2k
      slot->value.frame.scope = mxScope;
828
18.2k
      slot++;
829
      // RESULT
830
18.2k
      slot++;
831
      // FUNCTION
832
18.2k
      byte = ((slot + 1)->kind == XS_UNINITIALIZED_KIND) ? 1 : 0;
833
18.2k
      if (byte)
834
6.07k
        (mxStack + offset)->flag |= XS_TARGET_FLAG;
835
18.2k
      if (slot->kind == XS_REFERENCE_KIND) {
836
18.2k
        variable = slot->value.reference;
837
18.2k
        slot = variable->next;
838
18.2k
        if (slot && (slot->flag & XS_INTERNAL_FLAG)) {
839
18.2k
          if ((slot->kind == XS_CODE_KIND) || (slot->kind == XS_CODE_X_KIND)) {
840
0
            if (byte && !mxIsConstructor(variable))
841
0
              mxRunDebug(XS_TYPE_ERROR, "new: not a constructor");
842
0
            variable = slot->value.code.closures;
843
0
            if (variable) {
844
0
              mxPushKind(XS_REFERENCE_KIND);
845
0
              mxStack->value.environment.variable.reference = variable;
846
0
            }
847
0
            else {
848
0
              mxPushKind(XS_NULL_KIND);
849
0
              mxStack->value.environment.variable.reference = C_NULL;
850
0
            }
851
0
      #ifdef mxDebug
852
0
            mxStack->ID = XS_NO_ID;
853
0
            mxStack->value.environment.line = 0;
854
0
      #endif
855
0
            mxFrame = mxStack + 1 + offset;
856
0
            mxEnvironment = mxStack;
857
0
            mxScope = mxStack;
858
0
            mxCode = slot->value.code.address;
859
      #ifdef mxTraceCall
860
            fxTraceCallBegin(the, mxFrameFunction);
861
      #endif
862
0
            mxFirstCode();
863
0
            mxBreak;
864
0
          }
865
18.2k
          if ((slot->kind == XS_CALLBACK_KIND) || (slot->kind == XS_CALLBACK_X_KIND)) {
866
18.2k
            if (byte && !mxIsConstructor(variable))
867
18.2k
              mxRunDebug(XS_TYPE_ERROR, "new: not a constructor");
868
18.2k
            mxPushKind(XS_VAR_KIND);
869
18.2k
            mxStack->value.environment.variable.count = 0;
870
18.2k
      #ifdef mxDebug
871
18.2k
            mxStack->ID = XS_NO_ID;
872
18.2k
            mxStack->value.environment.line = 0;
873
18.2k
      #endif
874
18.2k
            mxFrame = mxStack + 1 + offset;
875
18.2k
            mxFrame->flag |= XS_C_FLAG;
876
18.2k
            mxScope = mxStack;
877
18.2k
            mxCode = C_NULL;
878
18.2k
            byte = XS_CODE_CALL;
879
      #ifdef mxTraceCall
880
            fxTraceCallBegin(the, mxFrameFunction);
881
      #endif
882
18.2k
            mxSaveState;
883
      #ifdef mxLink
884
            if ((txU1*)slot->value.callback.address - (txU1*)the->fakeCallback < 0)
885
              mxRunDebug(XS_TYPE_ERROR, "link: unavailable function");
886
      #endif
887
18.2k
            if (slot->flag & XS_BASE_FLAG)
888
0
              fxRunBase(the);
889
18.2k
            else if (slot->flag & XS_DERIVED_FLAG)
890
0
              fxRunDerived(the);
891
18.2k
            (*(slot->value.callback.address))(the);
892
18.2k
            mxRestoreState;
893
18.2k
            if (mxCode) {
894
0
              byte = *mxCode;
895
0
              mxBreak;
896
0
            }
897
18.2k
      #if defined(mxInstrument) || defined(mxProfile)
898
18.2k
            fxCheckProfiler(the, mxFrame);
899
18.2k
      #endif
900
18.2k
            if (slot->flag & XS_BASE_FLAG)
901
0
              goto XS_CODE_END_BASE_ALL;
902
18.2k
            if (slot->flag & XS_DERIVED_FLAG)
903
0
              goto XS_CODE_END_DERIVED_ALL;
904
18.2k
            slot = mxFrameResult;
905
18.2k
            goto XS_CODE_END_ALL;
906
18.2k
          }
907
0
          if (slot->kind == XS_PROXY_KIND) {
908
0
            mxPushKind(XS_VAR_KIND);
909
0
            mxStack->value.environment.variable.count = 0;
910
0
      #ifdef mxDebug
911
0
            mxStack->ID = XS_NO_ID;
912
0
            mxStack->value.environment.line = 0;
913
0
      #endif
914
0
            mxFrame = mxStack + 1 + offset;
915
0
            mxFrame->flag |= XS_C_FLAG;
916
0
            mxScope = mxStack;
917
0
            mxCode = C_NULL;
918
0
            byte = XS_CODE_CALL;
919
      #ifdef mxTraceCall
920
            fxTraceCallBegin(the, mxFrameFunction);
921
      #endif
922
0
            mxSaveState;
923
0
            fxRunProxy(the, variable);
924
0
            mxRestoreState;
925
0
            slot = mxFrameResult;
926
0
            goto XS_CODE_END_ALL;
927
0
          }
928
0
        }
929
18.2k
      }
930
#if mxHostFunctionPrimitive
931
      else if (slot->kind == XS_HOST_FUNCTION_KIND) {
932
        if (byte)
933
          mxRunDebug(XS_TYPE_ERROR, "new: not a constructor");
934
        mxPushKind(XS_VAR_KIND);
935
        mxStack->value.environment.variable.count = 0;
936
#ifdef mxDebug
937
        mxStack->ID = XS_NO_ID;
938
        mxStack->value.environment.line = 0;
939
#endif
940
        mxFrame = mxStack + 1 + offset;
941
        mxFrame->flag |= XS_C_FLAG;
942
        mxScope = mxStack;
943
        mxCode = C_NULL;
944
        byte = XS_CODE_CALL;
945
#ifdef mxTraceCall
946
        fxTraceCallBegin(the, mxFrameFunction);
947
#endif
948
        mxSaveState;
949
#ifdef mxLink
950
        if ((txU1*)slot->value.hostFunction.builder->callback - (txU1*)the->fakeCallback < 0)
951
          mxRunDebug(XS_TYPE_ERROR, "link: unavailable function");
952
#endif
953
        (*(slot->value.hostFunction.builder->callback))(the);
954
        mxRestoreState;
955
        if (mxCode) {
956
          byte = *mxCode;
957
          mxBreak;
958
        }
959
        slot = mxFrameResult;
960
        goto XS_CODE_END_ALL;
961
      }
962
#endif
963
0
      if (byte) {
964
0
        mxRunDebug(XS_TYPE_ERROR, "new: not a constructor");
965
0
      }
966
0
      else {
967
0
        mxRunDebug(XS_TYPE_ERROR, "call: not a function");
968
0
      }
969
0
      mxBreak;
970
      
971
0
    mxCase(XS_CODE_BEGIN_SLOPPY)
972
0
            if (mxFrameHasTarget && (mxFrameFunction->value.reference->flag & XS_CAN_CONSTRUCT_FLAG)) {
973
0
        mxSaveState;
974
0
        fxRunConstructor(the);
975
0
        mxRestoreState;
976
0
      }
977
0
      else {
978
0
        index = mxFrameThis->kind;
979
0
        if (index < XS_REFERENCE_KIND) {
980
0
          if ((index == XS_UNDEFINED_KIND) || (index == XS_NULL_KIND)) {
981
0
            mxFrameThis->kind = XS_REFERENCE_KIND;
982
0
            variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
983
0
            variable = mxModuleInstanceInternal(variable)->value.module.realm;
984
0
            if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
985
0
            mxFrameThis->value.reference = mxRealmGlobal(variable)->value.reference;
986
0
          }
987
0
          else {
988
0
            mxSaveState;
989
0
            fxToInstance(the, mxFrameThis);
990
0
            mxRestoreState;
991
0
          }
992
0
        }
993
0
      }
994
0
      mxNextCode(2);
995
0
      mxBreak;
996
0
    mxCase(XS_CODE_BEGIN_STRICT)
997
0
      mxFrame->flag |= XS_STRICT_FLAG;
998
0
            if (mxFrameHasTarget && (mxFrameFunction->value.reference->flag & XS_CAN_CONSTRUCT_FLAG)) {
999
0
        mxSaveState;
1000
0
        fxRunConstructor(the);
1001
0
        mxRestoreState;
1002
0
      }
1003
0
      mxNextCode(2);
1004
0
      mxBreak;
1005
0
    mxCase(XS_CODE_BEGIN_STRICT_BASE)
1006
0
      mxFrame->flag |= XS_STRICT_FLAG;
1007
0
      mxSaveState;
1008
0
      fxRunBase(the);
1009
0
      mxRestoreState;
1010
0
      mxNextCode(2);
1011
0
      mxBreak;
1012
0
    mxCase(XS_CODE_BEGIN_STRICT_DERIVED)
1013
0
      mxFrame->flag |= XS_STRICT_FLAG;
1014
0
      mxSaveState;
1015
0
      fxRunDerived(the);
1016
0
      mxRestoreState;
1017
0
      mxNextCode(2);
1018
0
      mxBreak;
1019
0
    mxCase(XS_CODE_BEGIN_STRICT_FIELD)
1020
0
      mxFrame->flag |= XS_STRICT_FLAG | XS_FIELD_FLAG;
1021
0
            if (mxFrameHasTarget) {
1022
0
        mxSaveState;
1023
0
        fxRunConstructor(the);
1024
0
        mxRestoreState;
1025
0
      }
1026
0
      mxNextCode(2);
1027
0
      mxBreak;
1028
          
1029
0
    mxCase(XS_CODE_END_ARROW)
1030
0
      slot = mxFrameResult;
1031
0
      goto XS_CODE_END_ALL;
1032
0
    mxCase(XS_CODE_END_BASE)
1033
0
    XS_CODE_END_BASE_ALL:
1034
0
      slot = mxFrameResult;
1035
0
      if (slot->kind != XS_REFERENCE_KIND)
1036
0
        slot = mxFrameThis;
1037
0
      goto XS_CODE_END_ALL;
1038
0
    mxCase(XS_CODE_END_DERIVED)
1039
0
    XS_CODE_END_DERIVED_ALL:
1040
0
      slot = mxFrameResult;
1041
0
      if (slot->kind != XS_REFERENCE_KIND) {
1042
0
        if ((slot->kind != XS_UNDEFINED_KIND) && (slot->kind != XS_CLOSURE_KIND))
1043
0
          mxRunDebug(XS_TYPE_ERROR, "result: invalid constructor");
1044
0
        slot = mxFrameThis->value.closure;
1045
0
        if (slot->kind < 0)
1046
0
          mxRunDebug(XS_REFERENCE_ERROR, "this: not initialized");
1047
0
      }
1048
0
      goto XS_CODE_END_ALL;
1049
0
    mxCase(XS_CODE_END)
1050
0
      slot = mxFrameResult;
1051
0
      if (mxFrameHasTarget) {
1052
0
        if (slot->kind != XS_REFERENCE_KIND)
1053
0
          slot = mxFrameThis;
1054
0
      }
1055
13.6k
    XS_CODE_END_ALL:
1056
#ifdef mxTraceCall
1057
      fxTraceCallEnd(the, mxFrameFunction);
1058
#endif
1059
#ifdef mxInstrument
1060
      if (the->stackPeak > mxStack)
1061
        the->stackPeak = mxStack;
1062
#endif
1063
13.6k
      mxStack = mxFrameEnd;
1064
13.6k
      mxScope = mxFrame->value.frame.scope;
1065
13.6k
      mxCode = mxFrame->value.frame.code;
1066
13.6k
      mxAllocStack(1);
1067
13.6k
      *mxStack = *slot;
1068
13.6k
      mxFrame = mxFrame->next;
1069
13.6k
      if (!mxFrame || (mxFrame->flag & XS_C_FLAG)) {
1070
#ifdef mxTrace
1071
        if (gxDoTrace) fxTraceReturn(the);
1072
#endif
1073
13.6k
        byte = XS_CODE_END;
1074
13.6k
        mxSaveState;
1075
13.6k
        return; 
1076
13.6k
      }
1077
0
      mxEnvironment = mxFrameToEnvironment(mxFrame);
1078
0
      mxFirstCode();
1079
0
      mxBreak;
1080
0
    mxCase(XS_CODE_RETURN)
1081
0
      mxStack = mxFrameEnd;
1082
0
      mxScope = mxFrame->value.frame.scope;
1083
0
      mxCode = mxFrame->value.frame.code;
1084
0
      mxAllocStack(1);
1085
0
      *mxStack = *mxFrameResult;
1086
0
      mxFrame = mxFrame->next;
1087
#ifdef mxTrace
1088
      if (gxDoTrace)
1089
        if (gxDoTrace) fxTraceReturn(the);
1090
#endif
1091
0
      mxSaveState;
1092
0
      return;
1093
      
1094
0
    mxCase(XS_CODE_START_ASYNC)
1095
0
      mxSkipCode(1);
1096
0
      mxSaveState;
1097
0
      variable = gxDefaults.newAsyncInstance(the);
1098
0
      mxRestoreState;
1099
0
      slot = mxFrameEnd;
1100
0
      mxPushKind(XS_INTEGER_KIND);
1101
0
      mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address);
1102
0
      mxPushKind(XS_INTEGER_KIND);
1103
0
      mxStack->value.integer = mxPtrDiff(slot - mxScope);
1104
0
      mxPushKind(XS_INTEGER_KIND);
1105
0
      mxStack->value.integer = mxPtrDiff(slot - mxFrame);
1106
0
      mxPushKind(XS_INTEGER_KIND);
1107
0
      mxStack->value.integer = 0;
1108
0
      mxPushKind(mxFrameFunction->kind);
1109
0
      mxStack->value = mxFrameFunction->value;
1110
0
      index = mxPtrDiff(slot - mxStack);
1111
0
      slot = variable->next;
1112
0
      variable = slot->value.stack.address;
1113
0
      if (slot->value.stack.length < index) {
1114
0
        mxSaveState;
1115
0
        if (variable)
1116
0
          variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot));
1117
0
        if (!variable)
1118
0
          variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot));
1119
0
        mxRestoreState;
1120
0
        slot->value.stack.address = variable;
1121
0
      }
1122
0
      slot->value.stack.length = index;
1123
0
      c_memcpy(variable, mxStack, index * sizeof(txSlot));
1124
0
      mxStack += 5;
1125
0
      mxSaveState;
1126
0
      gxDefaults.runAsync(the, mxStack->value.reference);
1127
0
      mxRestoreState;
1128
0
      slot = mxFrameResult;
1129
0
      goto XS_CODE_END_ALL;
1130
      
1131
0
    mxCase(XS_CODE_START_ASYNC_GENERATOR)
1132
0
      mxSkipCode(1);
1133
0
            if (mxFrameHasTarget)
1134
0
        mxRunDebug(XS_TYPE_ERROR, "new: async generator");
1135
0
      slot = mxBehaviorGetProperty(the, mxFrameFunction->value.reference, mxID(_prototype), 0, XS_ANY);
1136
0
      mxPushKind(slot->kind);
1137
0
      mxStack->value = slot->value;
1138
0
      mxSaveState;
1139
0
      variable = gxDefaults.newAsyncGeneratorInstance(the);
1140
0
      mxRestoreState;
1141
0
      mxFrameResult->kind = XS_UNINITIALIZED_KIND;
1142
0
      slot = mxFrameEnd;
1143
0
      mxPushKind(XS_INTEGER_KIND);
1144
0
      mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address);
1145
0
      mxPushKind(XS_INTEGER_KIND);
1146
0
      mxStack->value.integer = mxPtrDiff(slot - mxScope);
1147
0
      mxPushKind(XS_INTEGER_KIND);
1148
0
      mxStack->value.integer = mxPtrDiff(slot - mxFrame);
1149
0
      mxPushKind(XS_INTEGER_KIND);
1150
0
      mxStack->value.integer = 0;
1151
0
      mxPushKind(mxFrameFunction->kind);
1152
0
      mxStack->value = mxFrameFunction->value;
1153
0
      index = mxPtrDiff(slot - mxStack);
1154
0
      slot = variable->next;
1155
0
      variable = slot->value.stack.address;
1156
0
      if (slot->value.stack.length < index) {
1157
0
        mxSaveState;
1158
0
        if (variable)
1159
0
          variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot));
1160
0
        if (!variable)
1161
0
          variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot));
1162
0
        mxRestoreState;
1163
0
        slot->value.stack.address = variable;
1164
0
      }
1165
0
      slot->value.stack.length = index;
1166
0
      c_memcpy(variable, mxStack, index * sizeof(txSlot));
1167
0
      mxStack += 5;
1168
0
      *mxFrameResult = *(mxStack++);
1169
0
      slot = mxFrameResult;
1170
0
      goto XS_CODE_END_ALL;
1171
    
1172
0
    mxCase(XS_CODE_START_GENERATOR)
1173
0
      mxSkipCode(1);
1174
0
            if (mxFrameHasTarget)
1175
0
        mxRunDebug(XS_TYPE_ERROR, "new: generator");
1176
0
      slot = mxBehaviorGetProperty(the, mxFrameFunction->value.reference, mxID(_prototype), 0, XS_ANY);
1177
0
      mxPushKind(slot->kind);
1178
0
      mxStack->value = slot->value;
1179
0
      mxSaveState;
1180
0
      variable = gxDefaults.newGeneratorInstance(the);
1181
0
      mxRestoreState;
1182
0
      slot = mxFrameEnd;
1183
0
      mxPushKind(XS_INTEGER_KIND);
1184
0
      mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address);
1185
0
      mxPushKind(XS_INTEGER_KIND);
1186
0
      mxStack->value.integer = mxPtrDiff(slot - mxScope);
1187
0
      mxPushKind(XS_INTEGER_KIND);
1188
0
      mxStack->value.integer = mxPtrDiff(slot - mxFrame);
1189
0
      mxPushKind(XS_INTEGER_KIND);
1190
0
      mxStack->value.integer = 0;
1191
0
      mxPushKind(mxFrameFunction->kind);
1192
0
      mxStack->value = mxFrameFunction->value;
1193
0
      index = mxPtrDiff(slot - mxStack);
1194
0
      slot = variable->next;
1195
0
      variable = slot->value.stack.address;
1196
0
      if (slot->value.stack.length < index) {
1197
0
        mxSaveState;
1198
0
        if (variable)
1199
0
          variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot));
1200
0
        if (!variable)
1201
0
          variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot));
1202
0
        mxRestoreState;
1203
0
        slot->value.stack.address = variable;
1204
0
      }
1205
0
      slot->value.stack.length = index;
1206
0
      c_memcpy(variable, mxStack, index * sizeof(txSlot));
1207
0
      mxStack += 5;
1208
0
      *mxFrameResult = *(mxStack++);
1209
0
      slot = mxFrameResult;
1210
0
      goto XS_CODE_END_ALL;
1211
      
1212
0
    mxCase(XS_CODE_AWAIT)
1213
0
    mxCase(XS_CODE_YIELD)
1214
0
    mxCase(XS_CODE_YIELD_STAR)
1215
0
      generator->next->next->value.integer = byte;
1216
0
      mxSkipCode(1);
1217
0
      slot = mxFrameEnd;
1218
0
      mxPushKind(XS_INTEGER_KIND);
1219
0
      mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address);
1220
0
      mxPushKind(XS_INTEGER_KIND);
1221
0
      mxStack->value.integer = mxPtrDiff(slot - mxScope);
1222
0
      mxPushKind(XS_INTEGER_KIND);
1223
0
      mxStack->value.integer = mxPtrDiff(slot - mxFrame);
1224
0
      jump = the->firstJump;
1225
0
      offset = 0;
1226
0
      while (jump != yieldJump) {
1227
0
        txJump* nextJump = jump->nextJump;
1228
0
        mxPushKind(XS_INTEGER_KIND);
1229
0
        mxStack->value.integer = mxPtrDiff(jump->code - mxFrameFunction->value.reference->next->value.code.address);
1230
0
        mxPushKind(XS_INTEGER_KIND);
1231
0
        mxStack->value.integer = mxPtrDiff(slot - jump->scope);
1232
0
        mxPushKind(XS_INTEGER_KIND);
1233
0
        mxStack->value.integer = mxPtrDiff(slot - jump->frame);
1234
0
        mxPushKind(XS_INTEGER_KIND);
1235
0
        mxStack->value.integer = mxPtrDiff(slot - jump->stack);
1236
0
        c_free(jump);
1237
0
        jump = nextJump;
1238
0
        offset++;
1239
0
      }
1240
0
      the->firstJump = yieldJump;
1241
0
      mxPushKind(XS_INTEGER_KIND);
1242
0
      mxStack->value.integer = offset;
1243
0
      mxPushKind(mxFrameFunction->kind);
1244
0
      mxStack->value = mxFrameFunction->value;
1245
0
      index = mxPtrDiff(slot - mxStack);
1246
0
      slot = generator->next;
1247
0
      variable = slot->value.stack.address;
1248
0
      if (slot->value.stack.length < index) {
1249
0
        mxSaveState;
1250
0
        if (variable)
1251
0
          variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot));
1252
0
        if (!variable)
1253
0
          variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot));
1254
0
        mxRestoreState;
1255
0
        slot->value.stack.address = variable;
1256
0
      }
1257
0
      slot->value.stack.length = index;
1258
0
      c_memcpy(variable, mxStack, index * sizeof(txSlot));
1259
0
      mxStack += 5 + (offset * 4);
1260
0
      *mxFrameResult = *(mxStack++);
1261
0
      slot = mxFrameResult;
1262
0
      goto XS_CODE_END_ALL;
1263
      
1264
  /* FRAMES */    
1265
0
    mxCase(XS_CODE_ARGUMENT)
1266
0
      offset = mxRunU1(1);
1267
#ifdef mxTrace
1268
      if (gxDoTrace) fxTraceInteger(the, offset);
1269
#endif
1270
0
      if (offset < mxFrameArgc) {
1271
0
        slot = mxFrameArgv(offset);
1272
0
        mxPushKind(slot->kind);
1273
0
        mxStack->value = slot->value;
1274
0
      }
1275
0
      else {
1276
0
        mxPushKind(XS_UNDEFINED_KIND);
1277
0
      }
1278
0
      mxNextCode(2);
1279
0
      mxBreak;
1280
0
    mxCase(XS_CODE_ARGUMENTS)
1281
0
      offset = mxRunU1(1);
1282
#ifdef mxTrace
1283
      if (gxDoTrace) fxTraceInteger(the, offset);
1284
#endif
1285
0
      mxSaveState;
1286
0
      fxRunArguments(the, offset);
1287
0
      mxRestoreState;
1288
0
      mxNextCode(2);
1289
0
      mxBreak;
1290
0
    mxCase(XS_CODE_ARGUMENTS_SLOPPY)
1291
0
      offset = mxRunU1(1);
1292
0
      mxAllocStack(1);
1293
0
      *mxStack = mxArgumentsSloppyPrototype;
1294
0
      mxSaveState;
1295
0
      gxDefaults.newArgumentsSloppyInstance(the, offset);
1296
0
      mxRestoreState;
1297
0
      mxNextCode(2);
1298
0
      mxBreak;
1299
0
    mxCase(XS_CODE_ARGUMENTS_STRICT)
1300
0
      offset = mxRunU1(1);
1301
0
      mxAllocStack(1);
1302
0
      *mxStack = mxArgumentsStrictPrototype;
1303
0
      mxSaveState;
1304
0
      gxDefaults.newArgumentsStrictInstance(the, offset);
1305
0
      mxRestoreState;
1306
0
      mxNextCode(2);
1307
0
      mxBreak;
1308
0
    mxCase(XS_CODE_CURRENT)
1309
0
      mxAllocStack(1);
1310
0
      *mxStack = *mxFrameFunction;
1311
0
      if (!(mxFrame->flag & XS_STRICT_FLAG))
1312
0
        ignore = 1;
1313
0
      mxNextCode(1);
1314
0
      mxBreak;
1315
0
    mxCase(XS_CODE_GET_RESULT)
1316
0
      mxAllocStack(1);
1317
0
      *mxStack = *mxFrameResult;
1318
0
      mxNextCode(1);
1319
0
      mxBreak;
1320
0
    mxCase(XS_CODE_SET_RESULT)
1321
0
      *mxFrameResult = *(mxStack++);
1322
0
      mxNextCode(1);
1323
0
      mxBreak;
1324
0
    mxCase(XS_CODE_TARGET)
1325
0
      mxAllocStack(1);
1326
0
      if (mxFrameHasTarget)
1327
0
        *mxStack = *mxFrameTarget;
1328
0
      else {
1329
0
        mxInitSlotKind(mxStack, XS_UNDEFINED_KIND);
1330
0
        mxStack->next = C_NULL;
1331
0
      }
1332
0
      mxNextCode(1);
1333
0
      mxBreak;
1334
0
    mxCase(XS_CODE_THIS)
1335
0
      mxAllocStack(1);
1336
0
      *mxStack = *mxFrameThis;
1337
0
      mxNextCode(1);
1338
0
      mxBreak;
1339
0
    mxCase(XS_CODE_GET_THIS)
1340
0
      slot = mxFrameThis;
1341
0
      variable = slot->value.closure;
1342
0
      if (variable->kind < 0)
1343
0
        mxRunDebug(XS_REFERENCE_ERROR, "this: not initialized yet");
1344
0
      mxPushKind(variable->kind);
1345
0
      mxStack->value = variable->value;
1346
0
      mxNextCode(1);
1347
0
      mxBreak;
1348
0
    mxCase(XS_CODE_SET_THIS)
1349
0
      slot = mxFrameThis;
1350
0
      variable = slot->value.closure;
1351
0
      if (variable->kind >= 0)
1352
0
        mxRunDebug(XS_REFERENCE_ERROR, "this: already initialized");
1353
0
      variable->kind = mxStack->kind;
1354
0
      variable->value = mxStack->value;
1355
0
      mxNextCode(1);
1356
0
      mxBreak;
1357
    
1358
  /* EXCEPTIONS */  
1359
0
    mxCase(XS_CODE_EXCEPTION)
1360
0
      mxAllocStack(1);
1361
0
      *mxStack = mxException;
1362
0
      mxException = mxUndefined;
1363
0
      mxNextCode(1);
1364
0
      mxBreak;
1365
0
    mxCase(XS_CODE_CATCH_4)
1366
0
      offset = mxRunS4(1);
1367
0
      mxNextCode(5);
1368
0
      goto XS_CODE_CATCH;
1369
0
    mxCase(XS_CODE_CATCH_2)
1370
0
      offset = mxRunS2(1);
1371
0
      mxNextCode(3);
1372
0
      goto XS_CODE_CATCH;
1373
0
    mxCase(XS_CODE_CATCH_1)
1374
0
      offset = mxRunS1(1);
1375
0
      mxNextCode(2);
1376
0
    XS_CODE_CATCH:
1377
0
      jump = c_malloc(sizeof(txJump));
1378
0
      if (jump) {
1379
0
        jump->nextJump = the->firstJump;
1380
0
        jump->stack = mxStack;
1381
0
        jump->scope = mxScope;
1382
0
        jump->frame = mxFrame;
1383
0
        jump->environment = mxEnvironment->value.reference;
1384
0
        jump->code = mxCode + offset;
1385
0
        jump->flag = 1;
1386
0
                the->firstJump = jump;
1387
0
        if (c_setjmp(jump->buffer) != 0) {
1388
0
          jump = the->firstJump;
1389
0
                    the->firstJump = jump->nextJump;
1390
0
          mxStack = jump->stack;
1391
0
          mxScope = jump->scope;
1392
0
          mxFrame = jump->frame;
1393
0
          mxEnvironment = mxFrameToEnvironment(mxFrame);
1394
0
          mxEnvironment->value.reference = jump->environment;
1395
0
          mxCode = jump->code;
1396
0
          c_free(jump);
1397
0
          mxFirstCode();
1398
0
        }
1399
0
      }
1400
0
      else {
1401
0
        mxSaveState;
1402
0
        fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT);
1403
0
      }
1404
0
      mxBreak;
1405
0
    mxCase(XS_CODE_RETHROW)
1406
0
      mxSaveState;
1407
0
      fxJump(the);
1408
0
      mxBreak;
1409
0
    mxCase(XS_CODE_THROW)
1410
0
      mxException = *mxStack;
1411
0
    #ifdef mxDebug
1412
0
      mxSaveState;
1413
0
      fxDebugThrow(the, C_NULL, 0, "throw");
1414
0
      mxRestoreState;
1415
    #elif mxInstrument
1416
      mxSaveState;
1417
      fxTraceException(the);
1418
      mxRestoreState;
1419
    #endif
1420
0
      mxSaveState;
1421
0
      fxJump(the);
1422
0
      mxBreak;
1423
0
    mxCase(XS_CODE_THROW_STATUS)
1424
0
      if (the->status & XS_THROW_STATUS) {
1425
0
        mxException = *mxStack;
1426
0
      #ifdef mxDebug
1427
0
        mxSaveState;
1428
0
        fxDebugThrow(the, C_NULL, 0, "throw");
1429
0
        mxRestoreState;
1430
      #elif mxInstrument
1431
        mxSaveState;
1432
        fxTraceException(the);
1433
        mxRestoreState;
1434
      #endif
1435
0
        mxSaveState;
1436
0
        fxJump(the);
1437
0
      }
1438
0
      mxNextCode(1);
1439
0
      mxBreak;
1440
0
    mxCase(XS_CODE_UNCATCH)
1441
0
      jump = the->firstJump;
1442
0
      the->firstJump = jump->nextJump;
1443
0
      c_free(jump);
1444
0
      mxNextCode(1);
1445
0
      mxBreak;
1446
      
1447
  /* BRANCHES */  
1448
0
    mxCase(XS_CODE_BRANCH_1)
1449
0
      offset = mxRunS1(1);
1450
0
      mxBranch(2, offset);
1451
0
      mxBreak;
1452
0
    mxCase(XS_CODE_BRANCH_2)
1453
0
      offset = mxRunS2(1);
1454
0
      mxBranch(3, offset);
1455
0
      mxBreak;
1456
0
    mxCase(XS_CODE_BRANCH_4)
1457
0
      offset = mxRunS4(1);
1458
0
      mxBranch(5, offset);
1459
0
      mxBreak;
1460
0
    mxCase(XS_CODE_BRANCH_CHAIN_4)
1461
0
      offset = mxRunS4(1);
1462
0
      index = 5;
1463
0
      goto XS_CODE_BRANCH_CHAIN;
1464
0
    mxCase(XS_CODE_BRANCH_CHAIN_2)
1465
0
      offset = mxRunS2(1);
1466
0
      index = 3;
1467
0
      goto XS_CODE_BRANCH_CHAIN;
1468
0
    mxCase(XS_CODE_BRANCH_CHAIN_1)
1469
0
      offset = mxRunS1(1);
1470
0
      index = 2;
1471
0
    XS_CODE_BRANCH_CHAIN:
1472
0
      byte = mxStack->kind;
1473
0
      if ((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte)) {
1474
0
        mxStack->kind = XS_UNDEFINED_KIND;
1475
0
        mxBranch(index, offset);
1476
0
      }
1477
0
      else
1478
0
        mxNextCode((txS4)index);
1479
0
      mxBreak;
1480
0
    mxCase(XS_CODE_BRANCH_COALESCE_4)
1481
0
      offset = mxRunS4(1);
1482
0
      index = 5;
1483
0
      goto XS_CODE_BRANCH_COALESCE;
1484
0
    mxCase(XS_CODE_BRANCH_COALESCE_2)
1485
0
      offset = mxRunS2(1);
1486
0
      index = 3;
1487
0
      goto XS_CODE_BRANCH_COALESCE;
1488
0
    mxCase(XS_CODE_BRANCH_COALESCE_1)
1489
0
      offset = mxRunS1(1);
1490
0
      index = 2;
1491
0
    XS_CODE_BRANCH_COALESCE:
1492
0
      byte = mxStack->kind;
1493
0
      if ((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte)) {
1494
0
        mxStack++;
1495
0
        mxNextCode((txS4)index);
1496
0
      }
1497
0
      else {
1498
0
        mxBranch(index, offset);
1499
0
      }
1500
0
      mxBreak;
1501
0
    mxCase(XS_CODE_BRANCH_ELSE_4)
1502
0
      offset = mxRunS4(1);
1503
0
      index = 5;
1504
0
      goto XS_CODE_BRANCH_ELSE;
1505
0
    mxCase(XS_CODE_BRANCH_ELSE_2)
1506
0
      offset = mxRunS2(1);
1507
0
      index = 3;
1508
0
      goto XS_CODE_BRANCH_ELSE;
1509
0
    mxCase(XS_CODE_BRANCH_ELSE_1)
1510
0
      offset = mxRunS1(1);
1511
0
      index = 2;
1512
0
    XS_CODE_BRANCH_ELSE:
1513
0
      byte = mxStack->kind;
1514
0
      if (XS_BOOLEAN_KIND == byte) {
1515
0
        mxBranchElse(mxStack->value.boolean, index, offset);
1516
0
      }
1517
0
      else if (XS_INTEGER_KIND == byte) {
1518
0
        mxBranchElse(mxStack->value.integer, index, offset);
1519
0
      }
1520
0
      else if (XS_NUMBER_KIND == byte) {
1521
0
        mxBranchIf((c_isnan(mxStack->value.number) || c_iszero(mxStack->value.number)), index, offset);
1522
0
        mxFloatingPointOp("else");
1523
0
      }
1524
0
      else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte)) {
1525
0
        mxBranchIf(((mxStack->value.bigint.size == 1) && (mxStack->value.bigint.data[0] == 0)), index, offset);
1526
0
      }
1527
0
      else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte)) {
1528
0
        mxBranchIf(c_isEmpty(mxStack->value.string), index, offset);
1529
0
      }
1530
0
      else {
1531
0
        mxBranchIf((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte), index, offset);
1532
0
      }
1533
0
      mxStack++;
1534
0
      mxBreak;
1535
0
    mxCase(XS_CODE_BRANCH_IF_4)
1536
0
      offset = mxRunS4(1);
1537
0
      index = 5;
1538
0
      goto XS_CODE_BRANCH_IF;
1539
0
    mxCase(XS_CODE_BRANCH_IF_2)
1540
0
      offset = mxRunS2(1);
1541
0
      index = 3;
1542
0
      goto XS_CODE_BRANCH_IF;
1543
0
    mxCase(XS_CODE_BRANCH_IF_1)
1544
0
      offset = mxRunS1(1);
1545
0
      index = 2;
1546
0
    XS_CODE_BRANCH_IF:
1547
0
      byte = mxStack->kind;
1548
0
      if (XS_BOOLEAN_KIND == byte) {
1549
0
        mxBranchIf(mxStack->value.boolean, index, offset);
1550
0
      }
1551
0
      else if (XS_INTEGER_KIND == byte) {
1552
0
        mxBranchIf(mxStack->value.integer, index, offset);
1553
0
      }
1554
0
      else if (XS_NUMBER_KIND == byte) {
1555
0
        mxBranchElse(c_isnan(mxStack->value.number) || c_iszero(mxStack->value.number), index, offset);
1556
0
        mxFloatingPointOp("if");
1557
0
      }
1558
0
      else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte)) {
1559
0
        mxBranchElse((mxStack->value.bigint.size == 1) && (mxStack->value.bigint.data[0] == 0), index, offset);
1560
0
      }
1561
0
      else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte)) {
1562
0
        mxBranchElse(c_isEmpty(mxStack->value.string), index, offset);
1563
0
      }
1564
0
      else {
1565
0
        mxBranchElse((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte), index, offset);
1566
0
      }
1567
0
      mxStack++;
1568
0
      mxBreak;
1569
0
    mxCase(XS_CODE_BRANCH_STATUS_4)
1570
0
      offset = mxRunS4(1);
1571
0
      index = 5;
1572
0
      goto XS_CODE_BRANCH_STATUS;
1573
0
    mxCase(XS_CODE_BRANCH_STATUS_2)
1574
0
      offset = mxRunS2(1);
1575
0
      index = 3;
1576
0
      goto XS_CODE_BRANCH_STATUS;
1577
0
    mxCase(XS_CODE_BRANCH_STATUS_1)
1578
0
      offset = mxRunS1(1);
1579
0
      index = 2;
1580
0
    XS_CODE_BRANCH_STATUS:
1581
0
      if (the->status & XS_THROW_STATUS) {
1582
0
        mxException = *mxStack;
1583
0
      #ifdef mxDebug
1584
0
        mxSaveState;
1585
0
        fxDebugThrow(the, C_NULL, 0, "throw");
1586
0
        mxRestoreState;
1587
      #elif mxInstrument
1588
        mxSaveState;
1589
        fxTraceException(the);
1590
        mxRestoreState;
1591
      #endif
1592
0
        mxSaveState;
1593
0
        fxJump(the);
1594
0
      }
1595
0
      mxNextCode((the->status & XS_RETURN_STATUS) ? index : index + offset);
1596
0
      mxBreak;
1597
      
1598
  /* STACK */  
1599
0
    mxCase(XS_CODE_DUB)
1600
0
      mxAllocStack(1);
1601
0
      *mxStack = *(mxStack + 1);
1602
0
      mxNextCode(1);
1603
0
      mxBreak;
1604
0
    mxCase(XS_CODE_DUB_AT)
1605
0
      mxAllocStack(2);
1606
0
      *(mxStack + 1) = *(mxStack + 3);
1607
0
      *mxStack = *(mxStack + 2);
1608
0
      mxNextCode(1);
1609
0
      mxBreak;
1610
0
    mxCase(XS_CODE_POP)
1611
0
      mxStack++;
1612
0
      mxNextCode(1);
1613
0
      mxBreak;
1614
0
    mxCase(XS_CODE_SWAP)
1615
0
      scratch = *(mxStack);
1616
0
      *(mxStack) = *(mxStack + 1);
1617
0
      *(mxStack + 1) = scratch;
1618
0
      mxNextCode(1);
1619
0
      mxBreak;
1620
1621
  /* SCOPE */    
1622
0
    mxCase(XS_CODE_CONST_CLOSURE_2)
1623
0
      index = mxRunU2(1);
1624
0
      mxNextCode(3);
1625
0
      goto XS_CODE_CONST_CLOSURE;
1626
0
    mxCase(XS_CODE_CONST_CLOSURE_1)
1627
0
      index = mxRunU1(1);
1628
0
      mxNextCode(2);
1629
0
    XS_CODE_CONST_CLOSURE:
1630
#ifdef mxTrace
1631
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1632
#endif
1633
0
      slot = mxEnvironment - index;
1634
0
      variable = slot->value.closure;
1635
0
      if (variable->kind >= 0)
1636
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: already initialized", slot->ID);
1637
//      slot->flag |= XS_DONT_SET_FLAG; //@@
1638
0
      variable->flag |= XS_DONT_SET_FLAG;
1639
0
      variable->kind = mxStack->kind;
1640
0
      variable->value = mxStack->value;
1641
0
      if (!(mxFrame->flag & XS_STRICT_FLAG) && ignore) {
1642
0
        ignore = 0;
1643
0
        variable->flag |= XS_DONT_ENUM_FLAG;
1644
0
      }
1645
0
      mxBreak;
1646
0
    mxCase(XS_CODE_CONST_LOCAL_2)
1647
0
      index = mxRunU2(1);
1648
0
      mxNextCode(3);
1649
0
      goto XS_CODE_CONST_LOCAL;
1650
0
    mxCase(XS_CODE_CONST_LOCAL_1)
1651
0
      index = mxRunU1(1);
1652
0
      mxNextCode(2);
1653
0
    XS_CODE_CONST_LOCAL:
1654
#ifdef mxTrace
1655
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1656
#endif
1657
0
      variable = mxEnvironment - index;
1658
0
      if (variable->kind >= 0)
1659
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: already initialized", variable->ID);
1660
0
      variable->flag |= XS_DONT_SET_FLAG;
1661
0
      variable->kind = mxStack->kind;
1662
0
      variable->value = mxStack->value;
1663
0
      if (!(mxFrame->flag & XS_STRICT_FLAG) && ignore) {
1664
0
        ignore = 0;
1665
0
        variable->flag |= XS_DONT_ENUM_FLAG;
1666
0
      }
1667
0
      mxBreak;
1668
            
1669
0
    mxCase(XS_CODE_GET_CLOSURE_2)
1670
0
      index = mxRunU2(1);
1671
0
      mxNextCode(3);
1672
0
      goto XS_CODE_GET_CLOSURE;
1673
0
    mxCase(XS_CODE_GET_CLOSURE_1)
1674
0
      index = mxRunU1(1);
1675
0
      mxNextCode(2);
1676
0
    XS_CODE_GET_CLOSURE:
1677
#ifdef mxTrace
1678
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1679
#endif
1680
0
      slot = mxEnvironment - index;
1681
0
      #ifdef mxDebug
1682
0
        offset = slot->ID;
1683
0
      #endif
1684
0
      variable = slot->value.closure;
1685
0
      if (variable->kind < 0)
1686
0
        mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", slot->ID);
1687
#if mxAliasInstance
1688
      offset = variable->ID;
1689
      if (offset) {
1690
        slot = the->aliasArray[offset];
1691
        if (slot)
1692
          variable = slot;
1693
      } 
1694
#endif
1695
0
      mxPushKind(variable->kind);
1696
0
      mxStack->value = variable->value;
1697
0
      mxBreak;
1698
0
    mxCase(XS_CODE_GET_LOCAL_2)
1699
0
      index = mxRunU2(1);
1700
0
      mxNextCode(3);
1701
0
      goto XS_CODE_GET_LOCAL;
1702
0
    mxCase(XS_CODE_GET_LOCAL_1)
1703
0
      index = mxRunU1(1);
1704
0
      mxNextCode(2);
1705
0
    XS_CODE_GET_LOCAL:
1706
#ifdef mxTrace
1707
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1708
#endif
1709
0
      variable = mxEnvironment - index;
1710
0
      #ifdef mxDebug
1711
0
        offset = variable->ID;
1712
0
      #endif
1713
0
      if (variable->kind < 0)
1714
0
        mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", variable->ID);
1715
0
      mxPushKind(variable->kind);
1716
0
      mxStack->value = variable->value;
1717
0
      mxBreak;
1718
      
1719
0
    mxCase(XS_CODE_LET_CLOSURE_2)
1720
0
      index = mxRunU2(1);
1721
0
      mxNextCode(3);
1722
0
      goto XS_CODE_LET_CLOSURE;
1723
0
    mxCase(XS_CODE_LET_CLOSURE_1)
1724
0
      index = mxRunU1(1);
1725
0
      mxNextCode(2);
1726
0
    XS_CODE_LET_CLOSURE:
1727
#ifdef mxTrace
1728
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1729
#endif
1730
0
      slot = mxEnvironment - index;
1731
0
      variable = slot->value.closure;
1732
0
      variable->kind = mxStack->kind;
1733
0
      variable->value = mxStack->value;
1734
0
      mxBreak;
1735
0
    mxCase(XS_CODE_LET_LOCAL_2)
1736
0
      index = mxRunU2(1);
1737
0
      mxNextCode(3);
1738
0
      goto XS_CODE_LET_LOCAL;
1739
0
    mxCase(XS_CODE_LET_LOCAL_1)
1740
0
      index = mxRunU1(1);
1741
0
      mxNextCode(2);
1742
0
    XS_CODE_LET_LOCAL:
1743
#ifdef mxTrace
1744
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1745
#endif
1746
0
      variable = mxEnvironment - index;
1747
0
      variable->kind = mxStack->kind;
1748
0
      variable->value = mxStack->value;
1749
0
      mxBreak;
1750
      
1751
0
    mxCase(XS_CODE_NEW_CLOSURE)
1752
0
      offset = mxRunID(1);
1753
#ifdef mxTrace
1754
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
1755
#endif
1756
0
      mxNextCode(1 + sizeof(txID));
1757
0
      slot = --mxScope;
1758
#ifdef mxTrace
1759
      if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1);
1760
#endif
1761
0
      mxSaveState;
1762
0
      variable = fxNewSlot(the);
1763
0
      mxRestoreState;
1764
0
      slot->flag = XS_DONT_DELETE_FLAG;
1765
0
      slot->ID = (txID)offset;
1766
0
      slot->kind = XS_CLOSURE_KIND;
1767
0
      slot->value.closure = variable;
1768
0
      variable->kind = XS_UNINITIALIZED_KIND;
1769
0
      mxBreak;
1770
0
    mxCase(XS_CODE_NEW_LOCAL)
1771
0
      offset = mxRunID(1);
1772
#ifdef mxTrace
1773
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
1774
#endif
1775
0
      mxNextCode(1 + sizeof(txID));
1776
0
      variable = --mxScope;
1777
#ifdef mxTrace
1778
      if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1);
1779
#endif
1780
0
      variable->flag = XS_DONT_DELETE_FLAG;
1781
0
      variable->ID = (txID)offset;
1782
0
      variable->kind = XS_UNINITIALIZED_KIND;
1783
0
      mxBreak;
1784
0
    mxCase(XS_CODE_NEW_TEMPORARY)
1785
0
      variable = --mxScope;
1786
#ifdef mxTrace
1787
      if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1);
1788
#endif
1789
0
      mxInitSlotKind(variable, XS_UNDEFINED_KIND);
1790
0
      mxNextCode(1);
1791
0
      mxBreak;
1792
      
1793
0
    mxCase(XS_CODE_PULL_CLOSURE_2)
1794
0
      index = mxRunU2(1);
1795
0
      mxNextCode(3);
1796
0
      goto XS_CODE_PULL_CLOSURE;
1797
0
    mxCase(XS_CODE_PULL_CLOSURE_1)
1798
0
      index = mxRunU1(1);
1799
0
      mxNextCode(2);
1800
0
    XS_CODE_PULL_CLOSURE:
1801
#ifdef mxTrace
1802
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1803
#endif
1804
0
      slot = mxEnvironment - index;
1805
0
      if (slot->flag & XS_DONT_SET_FLAG) // import
1806
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID);
1807
0
      variable = slot->value.closure;
1808
0
      if (variable->kind < 0)
1809
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", slot->ID);
1810
0
      if (variable->flag & XS_DONT_SET_FLAG) {
1811
0
        if (variable->flag & XS_DONT_ENUM_FLAG) {
1812
0
          mxStack++;
1813
0
          mxBreak;
1814
0
        }
1815
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID);
1816
0
      }
1817
#if mxAliasInstance
1818
      offset = variable->ID;
1819
      if (offset) {
1820
        variable = the->aliasArray[offset];
1821
        if (!variable) {
1822
          mxSaveState;
1823
          variable = fxNewSlot(the);
1824
          mxRestoreState;
1825
          the->aliasArray[offset] = variable;
1826
        }
1827
      } 
1828
#endif
1829
0
      variable->kind = mxStack->kind;
1830
0
      variable->value = mxStack->value;
1831
0
      mxStack++;
1832
0
      mxBreak;
1833
0
    mxCase(XS_CODE_PULL_LOCAL_2)
1834
0
      index = mxRunU2(1);
1835
0
      mxNextCode(3);
1836
0
      goto XS_CODE_PULL_LOCAL;
1837
0
    mxCase(XS_CODE_PULL_LOCAL_1)
1838
0
      index = mxRunU1(1);
1839
0
      mxNextCode(2);
1840
0
    XS_CODE_PULL_LOCAL:
1841
#ifdef mxTrace
1842
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1843
#endif
1844
0
      variable = mxEnvironment - index;
1845
0
      if (variable->kind < 0)
1846
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", variable->ID);
1847
0
      if (variable->flag & XS_DONT_SET_FLAG) {
1848
0
        if (variable->flag & XS_DONT_ENUM_FLAG) {
1849
0
          mxStack++;
1850
0
          mxBreak;
1851
0
        }
1852
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", variable->ID);
1853
0
      }
1854
0
      variable->kind = mxStack->kind;
1855
0
      variable->value = mxStack->value;
1856
0
      mxStack++;
1857
0
      mxBreak;
1858
      
1859
0
    mxCase(XS_CODE_REFRESH_CLOSURE_2)
1860
0
      index = mxRunU2(1);
1861
0
      mxNextCode(3);
1862
0
      goto XS_CODE_REFRESH_CLOSURE;
1863
0
    mxCase(XS_CODE_REFRESH_CLOSURE_1)
1864
0
      index = mxRunU1(1);
1865
0
      mxNextCode(2);
1866
0
    XS_CODE_REFRESH_CLOSURE:
1867
#ifdef mxTrace
1868
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1869
#endif
1870
0
      variable = mxEnvironment - index;
1871
0
      mxSaveState;
1872
0
      slot = fxNewSlot(the);
1873
0
      mxRestoreState;
1874
0
      slot->flag = variable->value.closure->flag;
1875
0
      slot->kind = variable->value.closure->kind;
1876
0
      slot->value = variable->value.closure->value;
1877
0
      variable->value.closure = slot;
1878
0
      mxBreak;
1879
0
    mxCase(XS_CODE_REFRESH_LOCAL_2)
1880
0
      index = mxRunU2(1);
1881
0
      mxNextCode(3);
1882
0
      goto XS_CODE_REFRESH_LOCAL;
1883
0
    mxCase(XS_CODE_REFRESH_LOCAL_1)
1884
0
      index = mxRunU1(1);
1885
0
      mxNextCode(2);
1886
0
    XS_CODE_REFRESH_LOCAL:
1887
#ifdef mxTrace
1888
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1889
#endif
1890
0
      variable = mxEnvironment - index;
1891
0
      mxBreak;
1892
      
1893
0
    mxCase(XS_CODE_RESERVE_2)
1894
0
      index = mxRunU2(1);
1895
0
      mxNextCode(3);
1896
0
      goto XS_CODE_RESERVE;
1897
0
    mxCase(XS_CODE_RESERVE_1)
1898
0
      index = mxRunU1(1);
1899
0
      mxNextCode(2);
1900
0
    XS_CODE_RESERVE:
1901
#ifdef mxTrace
1902
      if (gxDoTrace) fxTraceIndex(the, index);
1903
#endif
1904
0
      mxAllocStack(index);    
1905
0
      c_memset(mxStack, 0, index * sizeof(txSlot));
1906
0
      mxBreak;
1907
      
1908
0
    mxCase(XS_CODE_RESET_CLOSURE_2)
1909
0
      index = mxRunU2(1);
1910
0
      mxNextCode(3);
1911
0
      goto XS_CODE_RESET_CLOSURE;
1912
0
    mxCase(XS_CODE_RESET_CLOSURE_1)
1913
0
      index = mxRunU1(1);
1914
0
      mxNextCode(2);
1915
0
    XS_CODE_RESET_CLOSURE:
1916
#ifdef mxTrace
1917
      if (gxDoTrace) fxTraceIndex(the, index);
1918
#endif
1919
0
      slot = mxEnvironment - index;
1920
0
      mxSaveState;
1921
0
      variable = fxNewSlot(the);
1922
0
      mxRestoreState;
1923
0
      variable->kind = XS_UNINITIALIZED_KIND;
1924
0
      slot->value.closure = variable;
1925
0
      mxBreak;
1926
0
    mxCase(XS_CODE_RESET_LOCAL_2)
1927
0
      index = mxRunU2(1);
1928
0
      mxNextCode(3);
1929
0
      goto XS_CODE_RESET_LOCAL;
1930
0
    mxCase(XS_CODE_RESET_LOCAL_1)
1931
0
      index = mxRunU1(1);
1932
0
      mxNextCode(2);
1933
0
    XS_CODE_RESET_LOCAL:
1934
#ifdef mxTrace
1935
      if (gxDoTrace) fxTraceIndex(the, index);
1936
#endif
1937
0
      variable = mxEnvironment - index;
1938
0
      variable->flag = XS_NO_FLAG;
1939
0
      variable->kind = XS_UNINITIALIZED_KIND;
1940
0
      mxBreak;
1941
      
1942
0
    mxCase(XS_CODE_SET_CLOSURE_2)
1943
0
      index = mxRunU2(1);
1944
0
      mxNextCode(3);
1945
0
      goto XS_CODE_SET_CLOSURE;
1946
0
    mxCase(XS_CODE_SET_CLOSURE_1)
1947
0
      index = mxRunU1(1);
1948
0
      mxNextCode(2);
1949
0
    XS_CODE_SET_CLOSURE:
1950
#ifdef mxTrace
1951
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1952
#endif
1953
0
      slot = mxEnvironment - index;
1954
0
      if (slot->flag & XS_DONT_SET_FLAG) // import
1955
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID);
1956
0
      variable = slot->value.closure;
1957
0
      if (variable->kind < 0)
1958
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", slot->ID);
1959
0
      if (variable->flag & XS_DONT_SET_FLAG) {
1960
0
        if (variable->flag & XS_DONT_ENUM_FLAG)
1961
0
          mxBreak;
1962
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID);
1963
0
      }
1964
#if mxAliasInstance
1965
      offset = variable->ID;
1966
      if (offset > 0) {
1967
        variable = the->aliasArray[offset];
1968
        if (!variable) {
1969
          mxSaveState;
1970
          variable = fxNewSlot(the);
1971
          mxRestoreState;
1972
          the->aliasArray[offset] = variable;
1973
        }
1974
      } 
1975
#endif
1976
0
      variable->kind = mxStack->kind;
1977
0
      variable->value = mxStack->value;
1978
0
      mxBreak;
1979
0
    mxCase(XS_CODE_SET_LOCAL_2)
1980
0
      index = mxRunU2(1);
1981
0
      mxNextCode(3);
1982
0
      goto XS_CODE_SET_LOCAL;
1983
0
    mxCase(XS_CODE_SET_LOCAL_1)
1984
0
      index = mxRunU1(1);
1985
0
      mxNextCode(2);
1986
0
    XS_CODE_SET_LOCAL:
1987
#ifdef mxTrace
1988
      if (gxDoTrace) fxTraceIndex(the, index - 1);
1989
#endif
1990
0
      variable = mxEnvironment - index;
1991
0
      if (variable->kind < 0)
1992
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", variable->ID);
1993
0
      if (variable->flag & XS_DONT_SET_FLAG) {
1994
0
        if (variable->flag & XS_DONT_ENUM_FLAG)
1995
0
          mxBreak;
1996
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", variable->ID);
1997
0
      }
1998
0
      variable->kind = mxStack->kind;
1999
0
      variable->value = mxStack->value;
2000
0
      mxBreak;
2001
2002
0
    mxCase(XS_CODE_VAR_CLOSURE_2)
2003
0
      index = mxRunU2(1);
2004
0
      mxNextCode(3);
2005
0
      goto XS_CODE_VAR_CLOSURE;
2006
0
    mxCase(XS_CODE_VAR_CLOSURE_1)
2007
0
      index = mxRunU1(1);
2008
0
      mxNextCode(2);
2009
0
    XS_CODE_VAR_CLOSURE:
2010
#ifdef mxTrace
2011
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2012
#endif
2013
0
      variable = (mxEnvironment - index)->value.closure;
2014
0
      variable->kind = mxStack->kind;
2015
0
      variable->value = mxStack->value;
2016
0
      mxBreak;
2017
0
    mxCase(XS_CODE_VAR_LOCAL_2)
2018
0
      index = mxRunU2(1);
2019
0
      mxNextCode(3);
2020
0
      goto XS_CODE_VAR_LOCAL;
2021
0
    mxCase(XS_CODE_VAR_LOCAL_1)
2022
0
      index = mxRunU1(1);
2023
0
      mxNextCode(2);
2024
0
    XS_CODE_VAR_LOCAL:
2025
#ifdef mxTrace
2026
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2027
#endif
2028
0
      variable = mxEnvironment - index;
2029
0
      variable->kind = mxStack->kind;
2030
0
      variable->value = mxStack->value;
2031
0
      mxBreak;
2032
      
2033
0
    mxCase(XS_CODE_UNWIND_2)
2034
0
      index = mxRunU2(1);
2035
0
      mxNextCode(3);
2036
0
      goto XS_CODE_UNWIND;
2037
0
    mxCase(XS_CODE_UNWIND_1)
2038
0
      index = mxRunU1(1);
2039
0
      mxNextCode(2);
2040
0
    XS_CODE_UNWIND:
2041
#ifdef mxTrace
2042
      if (gxDoTrace) fxTraceIndex(the, index);
2043
#endif
2044
0
      slot = mxScope;
2045
0
      mxScope += index;
2046
0
      while (slot < mxScope)
2047
0
        (slot++)->kind = XS_UNDEFINED_KIND;
2048
0
      mxBreak;
2049
      
2050
0
    mxCase(XS_CODE_RETRIEVE_2)
2051
0
      index = mxRunU2(1);
2052
0
      mxNextCode(3);
2053
0
      goto XS_CODE_RETRIEVE;
2054
0
    mxCase(XS_CODE_RETRIEVE_1)
2055
0
      index = mxRunU1(1);
2056
0
      mxNextCode(2);
2057
0
    XS_CODE_RETRIEVE:
2058
#ifdef mxTrace
2059
      if (gxDoTrace) fxTraceIndex(the, index);
2060
#endif
2061
0
      slot = mxEnvironment->value.reference->next->next;
2062
0
      variable = mxScope;
2063
0
      while (index) {
2064
0
        --variable;
2065
0
        offset = variable->ID = slot->ID;
2066
0
                variable->flag = slot->flag;
2067
0
                variable->kind = slot->kind;
2068
0
        variable->value = slot->value;
2069
#ifdef mxTrace
2070
        if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2071
#endif
2072
0
        index--;
2073
0
        slot = slot->next;
2074
0
      }
2075
0
      mxScope = variable;
2076
0
      mxBreak;
2077
0
    mxCase(XS_CODE_RETRIEVE_TARGET)
2078
0
      if (mxID(_new_target) == slot->ID) {
2079
0
        if (!mxFrameHasTarget) {
2080
0
          mxAllocStack(1);
2081
0
          c_memmove(mxStack, mxStack + 1, (mxFrame + 3 - mxStack) * sizeof(txSlot));
2082
0
          mxScope--;
2083
0
          mxEnvironment--;
2084
0
          mxFrame--;
2085
0
          mxFrame->flag |= XS_TARGET_FLAG;
2086
0
        }
2087
0
        variable = mxFrameTarget;
2088
0
        variable->kind = slot->kind;
2089
0
        variable->value = slot->value;
2090
2091
0
        slot = slot->next;
2092
0
      }
2093
0
      mxNextCode(1);
2094
0
      mxBreak;
2095
0
    mxCase(XS_CODE_RETRIEVE_THIS)
2096
0
      variable = mxFrameThis;
2097
0
      variable->kind = slot->kind;
2098
0
      variable->value = slot->value;
2099
0
      slot = slot->next;
2100
0
      mxNextCode(1);
2101
0
      mxBreak;
2102
      
2103
0
    mxCase(XS_CODE_ENVIRONMENT) 
2104
0
      mxPushKind(XS_UNDEFINED_KIND);
2105
0
      mxSaveState;
2106
0
      slot = fxNewEnvironmentInstance(the, C_NULL);
2107
0
      mxRestoreState;
2108
0
      variable = mxFunctionInstanceCode((mxStack + 1)->value.reference);
2109
0
      variable->value.code.closures = slot;
2110
0
      mxNextCode(1);
2111
0
      mxBreak;
2112
2113
0
    mxCase(XS_CODE_STORE_2)
2114
0
      index = mxRunU2(1);
2115
0
      mxNextCode(3);
2116
0
      goto XS_CODE_STORE;
2117
0
    mxCase(XS_CODE_STORE_1)
2118
0
      index = mxRunU1(1);
2119
0
      mxNextCode(2);
2120
0
    XS_CODE_STORE:
2121
#ifdef mxTrace
2122
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2123
#endif
2124
0
      address = &(mxStack->value.reference->next);
2125
0
      while ((slot = *address)) {
2126
0
        address = &slot->next;
2127
0
      }
2128
0
      mxSaveState;
2129
0
      *address = slot = fxNewSlot(the);
2130
0
      mxRestoreState;
2131
0
      variable = mxEnvironment - index;
2132
0
      offset = slot->ID = variable->ID;
2133
0
            slot->flag = variable->flag;
2134
0
            slot->kind = variable->kind;
2135
0
      slot->value = variable->value;
2136
#ifdef mxTrace
2137
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2138
#endif
2139
0
      mxBreak;
2140
0
    mxCase(XS_CODE_STORE_ARROW)
2141
      // super
2142
0
      variable = mxFunctionInstanceHome(mxFrameFunction->value.reference);
2143
0
      slot = mxFunctionInstanceHome((mxStack + 1)->value.reference);
2144
0
      slot->value.home.object = variable->value.home.object;
2145
      // target
2146
0
      address = &(mxStack->value.reference->next);
2147
0
      while ((slot = *address)) {
2148
0
        address = &slot->next;
2149
0
      }
2150
0
      if (mxFrameHasTarget) {
2151
0
        mxSaveState;
2152
0
        *address = slot = fxNewSlot(the);
2153
0
        mxRestoreState;
2154
0
        slot->ID = mxID(_new_target);
2155
0
        variable = mxFrameTarget;
2156
0
        slot->kind = variable->kind;
2157
0
        slot->value = variable->value;
2158
0
        address = &slot->next;
2159
0
      }
2160
      // this
2161
0
      mxSaveState;
2162
0
      *address = slot = fxNewSlot(the);
2163
0
      mxRestoreState;
2164
0
      variable = mxFrameThis;
2165
0
      slot->ID = mxID(_this);
2166
0
      slot->kind = variable->kind;
2167
0
      slot->value = variable->value;
2168
0
      mxNextCode(1);
2169
0
      mxBreak;
2170
      
2171
0
    mxCase(XS_CODE_USED_2)
2172
0
      index = mxRunU2(1);
2173
0
      mxNextCode(3);
2174
0
      goto XS_CODE_USED;
2175
0
    mxCase(XS_CODE_USED_1)
2176
0
      index = mxRunU1(1);
2177
0
      mxNextCode(2);
2178
0
    XS_CODE_USED:
2179
0
      slot = mxEnvironment - index;
2180
0
      mxSaveState;
2181
0
      fxRunUsed(the, slot);
2182
0
      mxRestoreState;
2183
0
      mxBreak;
2184
0
    mxCase(XS_CODE_USING)
2185
0
      mxNextCode(1);
2186
0
      mxSaveState;
2187
0
      fxRunUsing(the);
2188
0
      mxRestoreState;
2189
0
      mxBreak;
2190
0
    mxCase(XS_CODE_USING_ASYNC)
2191
0
      mxNextCode(1);
2192
0
      mxSaveState;
2193
0
      fxRunUsingAsync(the);
2194
0
      mxRestoreState;
2195
0
      mxBreak;
2196
        
2197
  /* PROPERTIES */  
2198
0
    mxCase(XS_CODE_CHECK_INSTANCE)
2199
0
      if (mxStack->kind != XS_REFERENCE_KIND)
2200
0
        mxRunDebug(XS_TYPE_ERROR, "iterator result: not an object");
2201
0
      mxNextCode(1);
2202
0
      mxBreak;
2203
0
    mxCase(XS_CODE_TO_INSTANCE)
2204
0
      mxToInstance(mxStack);
2205
0
      mxNextCode(1);
2206
0
      mxBreak;
2207
      
2208
0
    mxCase(XS_CODE_SUPER_AT_2)
2209
0
      slot = mxStack + 2;
2210
0
      goto XS_CODE_SUPER_AT_ALL;
2211
0
    mxCase(XS_CODE_SUPER_AT)
2212
0
      slot = mxStack + 1;
2213
      /* continue */
2214
0
    XS_CODE_SUPER_AT_ALL:
2215
0
      mxToInstance(slot);
2216
0
      slot->value.super.reference = variable;
2217
0
      variable = mxFunctionInstanceHome(mxFrameFunction->value.reference);
2218
0
      if (!variable->value.home.object) 
2219
0
        mxRunDebugID(XS_TYPE_ERROR, "super.%s: no home", (txID)offset);
2220
0
      variable = fxGetPrototype(the, variable->value.home.object);
2221
0
      if (!variable)
2222
0
        mxRunDebugID(XS_TYPE_ERROR, "super.%s: no prototype", (txID)offset);
2223
0
      slot->value.super.prototype = variable;
2224
0
      slot--;
2225
0
      goto XS_CODE_AT_ALL;
2226
0
    mxCase(XS_CODE_AT_2)
2227
0
      mxToInstance(mxStack + 2);
2228
0
      slot = mxStack + 1;
2229
0
      goto XS_CODE_AT_ALL;
2230
0
    mxCase(XS_CODE_AT)
2231
0
      mxToInstance(mxStack + 1);
2232
0
      slot = mxStack;
2233
      /* continue */
2234
0
    XS_CODE_AT_ALL:
2235
0
      if (slot->kind == XS_REFERENCE_KIND) {
2236
0
        mxSaveState;
2237
0
        fxToPrimitive(the, slot, XS_STRING_HINT);
2238
0
        mxRestoreState;
2239
0
      }
2240
0
      if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the, slot->value.integer, &(scratch.value.at.index))) {
2241
0
        slot->kind = XS_AT_KIND;
2242
0
        slot->value.at.id = XS_NO_ID;
2243
0
        slot->value.at.index = scratch.value.at.index;
2244
0
      }
2245
0
      else if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the, slot->value.number, &(scratch.value.at.index))) {
2246
0
        slot->kind = XS_AT_KIND;
2247
0
        slot->value.at.id = XS_NO_ID;
2248
0
        slot->value.at.index = scratch.value.at.index;
2249
0
      }
2250
0
      else if (slot->kind == XS_SYMBOL_KIND) {
2251
0
        slot->kind = XS_AT_KIND;
2252
0
        slot->value.at.id = slot->value.symbol;
2253
0
        slot->value.at.index = 0;
2254
0
      }
2255
0
      else {
2256
0
        txFlag flag;
2257
2258
0
        mxToString(slot);
2259
0
        mxSaveState;
2260
0
        flag = fxStringToIndex(the, slot->value.string, &(scratch.value.at.index));
2261
0
        mxRestoreState;
2262
0
        if (flag) {
2263
0
#ifdef mxMetering
2264
0
          the->meterIndex += 2 * XS_CODE_METERING;
2265
0
#endif
2266
0
          slot->kind = XS_AT_KIND;
2267
0
          slot->value.at.id = XS_NO_ID;
2268
0
          slot->value.at.index = scratch.value.at.index;
2269
0
        }
2270
0
        else {
2271
0
          txID id;
2272
0
          mxSaveState;
2273
0
          if (slot->kind == XS_STRING_X_KIND)
2274
0
            id = fxNewNameX(the, slot->value.string);
2275
0
          else
2276
0
            id = fxNewName(the, slot);
2277
0
          mxRestoreState;
2278
0
          slot->kind = XS_AT_KIND;
2279
0
          slot->value.at.id = id;
2280
0
          slot->value.at.index = 0;
2281
0
        }
2282
0
      }
2283
0
      mxNextCode(1);
2284
0
      mxBreak;
2285
2286
0
    mxCase(XS_CODE_DELETE_SUPER_AT)
2287
0
      variable = (mxStack + 1)->value.reference;
2288
0
      offset = XS_NO_ID;
2289
0
      index = 0;
2290
0
      mxStack++;
2291
0
      mxNextCode(1);
2292
0
      goto XS_CODE_DELETE_SUPER_ALL;
2293
0
    mxCase(XS_CODE_DELETE_SUPER)
2294
0
      mxToInstance(mxStack);
2295
0
      offset = mxRunID(1);
2296
0
      index = 0;
2297
0
      mxNextCode(1 + sizeof(txID));
2298
      /* continue */
2299
0
    XS_CODE_DELETE_SUPER_ALL: 
2300
0
      mxRunDebugID(XS_REFERENCE_ERROR, "delete super.%s", (txID)offset);
2301
0
      mxBreak;
2302
2303
0
    mxCase(XS_CODE_DELETE_PROPERTY_AT)
2304
0
      variable = (mxStack + 1)->value.reference;
2305
0
      offset = mxStack->value.at.id;
2306
0
      index = mxStack->value.at.index;
2307
0
      the->stack = mxStack;
2308
0
      mxStack++;
2309
0
      mxNextCode(1);
2310
0
      goto XS_CODE_DELETE_PROPERTY_ALL;
2311
0
    mxCase(XS_CODE_DELETE_PROPERTY)
2312
0
      mxToInstance(mxStack);
2313
0
      offset = mxRunID(1);
2314
0
      index = 0;
2315
0
      the->stack = mxStack;
2316
0
      mxNextCode(1 + sizeof(txID));
2317
      /* continue */
2318
0
    XS_CODE_DELETE_PROPERTY_ALL:  
2319
#ifdef mxTrace
2320
      if (gxDoTrace) fxTraceID(the, (txID)offset, index);
2321
#endif
2322
0
      mxSaveStateKeepStack;
2323
0
      index = (txU4)fxRunDelete(the, variable, (txID)offset, index);
2324
0
      mxRestoreStateKeepStack;
2325
0
      if (!index && (mxFrame->flag & XS_STRICT_FLAG))
2326
0
        mxRunDebugID(XS_TYPE_ERROR, "delete %s: no permission (strict mode)", (txID)offset);
2327
0
      mxStack->kind = XS_BOOLEAN_KIND;
2328
0
      mxStack->value.boolean = index;
2329
0
      mxBreak;
2330
      
2331
0
    mxCase(XS_CODE_GET_THIS_VARIABLE)
2332
0
    mxCase(XS_CODE_GET_VARIABLE)
2333
0
      mxToInstance(mxStack);
2334
0
      offset = mxRunID(1);
2335
0
      index = 0;
2336
0
      mxNextCode(1 + sizeof(txID));
2337
0
    #ifdef mxWithHasGetSequence
2338
0
      if (variable->next && ((variable->next->ID == XS_ENVIRONMENT_BEHAVIOR) || (variable->next->ID == XS_GLOBAL_BEHAVIOR))) {
2339
0
      }
2340
0
      else {
2341
0
              mxSaveState;
2342
0
              index = fxRunHas(the, variable, (txID)offset, index);
2343
0
              mxRestoreState;
2344
0
        if (index == 0) {
2345
0
          if (the->frame->flag & XS_STRICT_FLAG)
2346
0
            mxRunDebugID(XS_REFERENCE_ERROR, "get %s: undefined property", (txID)offset);
2347
0
          mxStack->kind = XS_UNDEFINED_KIND;
2348
0
          mxBreak;
2349
0
        }
2350
0
        else 
2351
0
          index = 0;
2352
0
      }
2353
0
    #endif
2354
0
      slot = mxBehaviorGetProperty(the, variable, (txID)offset, index, XS_ANY);
2355
0
      if (slot) {
2356
0
        if (slot->kind < 0)
2357
0
          mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", (txID)offset);
2358
0
      }
2359
0
      else {
2360
0
        if (byte != XS_CODE_TYPEOF)
2361
0
          mxRunDebugID(XS_REFERENCE_ERROR, "get %s: undefined variable", (txID)offset);
2362
0
      }
2363
0
      goto XS_CODE_GET_ALL;
2364
0
    mxCase(XS_CODE_GET_SUPER_AT)
2365
0
      variable = (mxStack + 1)->value.super.reference;
2366
0
      slot = (mxStack + 1)->value.super.prototype;
2367
0
      offset = mxStack->value.at.id;
2368
0
      index = mxStack->value.at.index;
2369
0
      mxStack++;
2370
0
      mxNextCode(1);
2371
0
      goto XS_CODE_GET_SUPER_ALL;
2372
0
    mxCase(XS_CODE_GET_SUPER)
2373
0
      mxToInstance(mxStack);
2374
0
      offset = mxRunID(1);
2375
0
      index = 0;
2376
0
      mxNextCode(1 + sizeof(txID));
2377
0
      slot = mxFunctionInstanceHome(mxFrameFunction->value.reference);
2378
0
      if (!slot->value.home.object)
2379
0
        mxRunDebugID(XS_TYPE_ERROR, "get super.%s: no home", (txID)offset);
2380
0
      slot = fxGetPrototype(the, slot->value.home.object);
2381
0
      if (!slot)
2382
0
        mxRunDebugID(XS_TYPE_ERROR, "get super.%s: no prototype", (txID)offset);
2383
      /* continue */
2384
0
    XS_CODE_GET_SUPER_ALL:  
2385
0
      slot = mxBehaviorGetProperty(the, slot, (txID)offset, index, XS_ANY);
2386
0
      goto XS_CODE_GET_ALL;
2387
0
    mxCase(XS_CODE_GET_PRIVATE_2)
2388
0
      index = mxRunU2(1);
2389
0
      mxNextCode(3);
2390
0
      goto XS_CODE_GET_PRIVATE;
2391
0
    mxCase(XS_CODE_GET_PRIVATE_1)
2392
0
      index = mxRunU1(1);
2393
0
      mxNextCode(2);
2394
0
    XS_CODE_GET_PRIVATE:
2395
#ifdef mxTrace
2396
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2397
#endif
2398
0
      slot = (mxEnvironment - index);
2399
0
      mxToInstance(mxStack);
2400
0
      offset = slot->ID;
2401
0
      index = 0;
2402
0
      if (slot->value.closure->kind < 0)
2403
0
        mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset);
2404
0
      slot = gxDefaults.getPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset);
2405
0
      if (!slot)
2406
0
        mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset);
2407
0
      goto XS_CODE_GET_ALL;
2408
0
    mxCase(XS_CODE_GET_PROPERTY_AT)
2409
0
      variable = (mxStack + 1)->value.reference;
2410
0
      offset = mxStack->value.at.id;
2411
0
      index = mxStack->value.at.index;
2412
0
      mxStack++;
2413
0
      mxNextCode(1);
2414
0
      goto XS_CODE_GET_PROPERTY_ALL;
2415
0
    mxCase(XS_CODE_GET_PROPERTY)
2416
0
      mxToInstance(mxStack);
2417
0
      offset = mxRunID(1);
2418
0
      index = 0;
2419
0
      mxNextCode(1 + sizeof(txID));
2420
      /* continue */
2421
0
    XS_CODE_GET_PROPERTY_ALL: 
2422
0
      slot = mxBehaviorGetProperty(the, variable, (txID)offset, index, XS_ANY);
2423
0
    XS_CODE_GET_ALL:  
2424
#ifdef mxTrace
2425
      if (gxDoTrace) fxTraceID(the, (txID)offset, index);
2426
#endif
2427
0
      if (!slot) {
2428
0
        mxStack->kind = XS_UNDEFINED_KIND;
2429
0
        mxBreak;
2430
0
      }
2431
0
      if (slot->kind == XS_ACCESSOR_KIND) {
2432
0
        variable = slot->value.accessor.getter;
2433
0
        if (!mxIsFunction(variable)) {
2434
0
          mxStack->kind = XS_UNDEFINED_KIND;
2435
0
          mxBreak;
2436
0
        }
2437
0
        mxAllocStack(3);
2438
0
        slot = mxStack;
2439
0
        mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2440
0
        mxInitSlotKind(slot++, XS_UNDEFINED_KIND);
2441
0
        slot->value.reference = variable;
2442
0
        mxInitSlotKind(slot++, XS_REFERENCE_KIND);
2443
0
        if (primitive) {
2444
0
          variable = slot->value.reference->next;
2445
0
          slot->value = variable->value;
2446
0
          mxInitSlotKind(slot, variable->kind);
2447
0
        }
2448
0
        offset = 0;
2449
0
        goto XS_CODE_RUN_ALL;
2450
0
      }
2451
0
      mxStack->kind = slot->kind;
2452
0
      mxStack->value = slot->value;
2453
0
      mxBreak;
2454
      
2455
0
    mxCase(XS_CODE_NEW_PRIVATE_2)
2456
0
      index = mxRunU2(1);
2457
0
      mxNextCode(3);
2458
0
      goto XS_CODE_NEW_PRIVATE;
2459
0
    mxCase(XS_CODE_NEW_PRIVATE_1)
2460
0
      index = mxRunU1(1);
2461
0
      mxNextCode(2);
2462
0
    XS_CODE_NEW_PRIVATE:
2463
#ifdef mxTrace
2464
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2465
#endif
2466
0
      slot = (mxEnvironment - index);
2467
0
      mxToInstance(mxStack + 1);
2468
0
      offset = slot->ID;
2469
0
      index = 0;
2470
0
      slot = slot->value.closure->value.reference;
2471
0
      the->stack = mxStack;
2472
0
      goto XS_CODE_NEW_PROPERTY_ALL;
2473
0
    mxCase(XS_CODE_NEW_PROPERTY_AT)
2474
0
      mxToInstance(mxStack + 2);
2475
0
      offset = (mxStack + 1)->value.at.id;
2476
0
      index = (mxStack + 1)->value.at.index;
2477
0
      slot = C_NULL;
2478
0
      the->stack = mxStack;
2479
0
      mxStack++;
2480
0
      scratch = *(the->stack);
2481
0
      *(the->stack) = *mxStack;
2482
0
      *mxStack = scratch;
2483
0
      mxNextCode(1);
2484
0
      goto XS_CODE_NEW_PROPERTY_ALL;
2485
0
    mxCase(XS_CODE_NEW_PROPERTY)
2486
0
      mxToInstance(mxStack + 1);
2487
0
      offset = mxRunID(1);
2488
0
      index = 0;
2489
0
      slot = C_NULL;
2490
0
      the->stack = mxStack;
2491
0
      mxNextCode(1 + sizeof(txID));
2492
0
    XS_CODE_NEW_PROPERTY_ALL:
2493
0
      byte = mxRunU1(1);
2494
0
      mxSaveStateKeepStack;
2495
0
      if (byte & XS_GETTER_FLAG) {
2496
0
        mxStack->value.accessor.getter = fxToInstance(the, mxStack);
2497
0
        mxStack->value.accessor.setter = C_NULL;
2498
0
        mxStack->kind = XS_ACCESSOR_KIND;
2499
0
      }
2500
0
      else if (byte & XS_SETTER_FLAG) {
2501
0
        mxStack->value.accessor.setter = fxToInstance(the, mxStack);
2502
0
        mxStack->value.accessor.getter = C_NULL;
2503
0
        mxStack->kind = XS_ACCESSOR_KIND;
2504
0
      }
2505
0
      mxStack->flag = byte & XS_GET_ONLY;
2506
0
      index = fxRunDefine(the, variable, slot, (txID)offset, index, mxStack, byte | XS_GET_ONLY);
2507
0
      mxRestoreStateKeepStack;
2508
0
      mxStack += 2;
2509
0
      if (!index)
2510
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: const", (txID)offset);
2511
0
      mxNextCode(2);
2512
0
      mxBreak;
2513
      
2514
0
    mxCase(XS_CODE_SET_VARIABLE)
2515
0
      mxToInstance(mxStack + 1);
2516
0
      offset = mxRunID(1);
2517
0
      index = 0;
2518
0
      mxNextCode(1 + sizeof(txID));
2519
0
      if (variable->next && (variable->next->ID == XS_ENVIRONMENT_BEHAVIOR)) {
2520
        // nop
2521
0
      }
2522
0
      else {
2523
0
              mxSaveState;
2524
0
              index = fxRunHas(the, variable, (txID)offset, index);
2525
0
              mxRestoreState;
2526
0
        if (index == 0) {
2527
0
          if (the->frame->flag & XS_STRICT_FLAG)
2528
0
            mxRunDebugID(XS_REFERENCE_ERROR, "set %s: undefined property", (txID)offset);
2529
0
        }
2530
0
        else 
2531
0
          index = 0;
2532
0
      }
2533
0
            mxSaveState;
2534
0
      slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_ANY);
2535
0
      mxRestoreState;
2536
0
      if (slot && (slot->kind < 0))
2537
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", (txID)offset);
2538
0
      goto XS_CODE_SET_ALL;
2539
0
    mxCase(XS_CODE_SET_SUPER_AT)
2540
0
      variable = (mxStack + 2)->value.super.reference;
2541
0
      slot = (mxStack + 2)->value.super.prototype;
2542
0
      offset = (mxStack + 1)->value.at.id;
2543
0
      index = (mxStack + 1)->value.at.index;
2544
0
      the->stack = mxStack;
2545
0
      mxStack++;
2546
0
      scratch = *(the->stack);
2547
0
      *(the->stack) = *mxStack;
2548
0
      *mxStack = scratch;
2549
0
      mxNextCode(1);
2550
0
      goto XS_CODE_SET_SUPER_ALL;
2551
0
    mxCase(XS_CODE_SET_SUPER)
2552
0
      mxToInstance(mxStack + 1);
2553
0
      offset = mxRunID(1);
2554
0
      index = 0;
2555
0
      the->stack = mxStack;
2556
0
      mxNextCode(1 + sizeof(txID));
2557
0
      slot = mxFunctionInstanceHome(mxFrameFunction->value.reference);
2558
0
      if (!slot->value.home.object)
2559
0
        mxRunDebugID(XS_TYPE_ERROR, "set super.%s: no home", (txID)offset);
2560
0
      slot = fxGetPrototype(the, slot->value.home.object);
2561
0
      if (!slot)
2562
0
        mxRunDebugID(XS_TYPE_ERROR, "set super.%s: no prototype", (txID)offset);
2563
      /* continue */
2564
0
    XS_CODE_SET_SUPER_ALL:
2565
0
      slot = mxBehaviorGetProperty(the, slot, (txID)offset, index, XS_ANY);
2566
0
      if (!slot || (slot->kind != XS_ACCESSOR_KIND)) {
2567
0
        mxSaveStateKeepStack;
2568
0
        slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_OWN);
2569
0
        mxRestoreStateKeepStack;
2570
0
      }
2571
0
      goto XS_CODE_SET_ALL;
2572
0
    mxCase(XS_CODE_SET_PRIVATE_2)
2573
0
      index = mxRunU2(1);
2574
0
      mxNextCode(3);
2575
0
      goto XS_CODE_SET_PRIVATE;
2576
0
    mxCase(XS_CODE_SET_PRIVATE_1)
2577
0
      index = mxRunU1(1);
2578
0
      mxNextCode(2);
2579
0
    XS_CODE_SET_PRIVATE:
2580
#ifdef mxTrace
2581
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2582
#endif
2583
0
      slot = (mxEnvironment - index);
2584
0
      mxToInstance(mxStack + 1);
2585
0
      offset = slot->ID;
2586
0
      index = 0;
2587
0
      if (slot->value.closure->kind < 0)
2588
0
        mxRunDebugID(XS_REFERENCE_ERROR, "set %s: undefined private property", (txID)offset);
2589
0
      slot = gxDefaults.setPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset);
2590
0
      if (!slot)
2591
0
        mxRunDebugID(XS_TYPE_ERROR, "set %s: undefined private property", (txID)offset);
2592
0
      goto XS_CODE_SET_ALL;
2593
0
    mxCase(XS_CODE_SET_PROPERTY_AT)
2594
0
      variable = (mxStack + 2)->value.reference;
2595
0
      offset = (mxStack + 1)->value.at.id;
2596
0
      index = (mxStack + 1)->value.at.index;
2597
0
      the->stack = mxStack;
2598
0
      mxStack++;
2599
0
      scratch = *(the->stack);
2600
0
      *(the->stack) = *mxStack;
2601
0
      *mxStack = scratch;
2602
0
      mxNextCode(1);
2603
0
      goto XS_CODE_SET_PROPERTY_ALL;
2604
0
    mxCase(XS_CODE_SET_PROPERTY)
2605
0
      mxToInstance(mxStack + 1);
2606
0
      offset = mxRunID(1);
2607
0
      index = 0;
2608
0
      the->stack = mxStack;
2609
0
      mxNextCode(1 + sizeof(txID));
2610
      /* continue */
2611
0
    XS_CODE_SET_PROPERTY_ALL: 
2612
0
      mxSaveStateKeepStack;
2613
0
      slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_ANY);
2614
0
      mxRestoreStateKeepStack;
2615
0
    XS_CODE_SET_ALL:  
2616
#ifdef mxTrace
2617
      if (gxDoTrace) fxTraceID(the, (txID)offset, index);
2618
#endif
2619
0
      if (!slot) {
2620
0
        if (mxFrame->flag & XS_STRICT_FLAG) {
2621
0
          mxRunDebugID(XS_TYPE_ERROR, "set %s: not extensible", (txID)offset);
2622
0
        }
2623
0
        goto XS_CODE_SET_SKIP;
2624
0
      }
2625
0
      if (slot->kind == XS_ACCESSOR_KIND) {
2626
0
        variable = slot->value.accessor.setter;
2627
0
        if (!mxIsFunction(variable)) {
2628
0
          if (mxFrame->flag & XS_STRICT_FLAG) {
2629
0
            mxRunDebugID(XS_TYPE_ERROR, "set %s: no setter", (txID)offset);
2630
0
          }
2631
0
          goto XS_CODE_SET_SKIP;
2632
0
        }
2633
0
        slot = mxStack;
2634
0
        mxAllocStack(3);
2635
0
        mxStack->value = slot->value;
2636
0
        mxInitSlotKind(mxStack, slot->kind);
2637
0
        slot = mxStack + 1;
2638
0
        mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2639
0
        slot->value = mxStack->value;
2640
0
        mxInitSlotKind(slot++, mxStack->kind);
2641
0
        slot->value.reference = variable;
2642
0
        mxInitSlotKind(slot++, XS_REFERENCE_KIND);
2643
0
        offset = 1;
2644
0
        goto XS_CODE_RUN_ALL;
2645
0
      }
2646
0
      if (slot->flag & (XS_DONT_SET_FLAG | XS_MARK_FLAG)) {
2647
0
        if (mxFrame->flag & XS_STRICT_FLAG) {
2648
0
          mxRunDebugID(XS_TYPE_ERROR, "set %s: not writable", (txID)offset);
2649
0
        }
2650
0
        goto XS_CODE_SET_SKIP;
2651
0
      }
2652
0
      slot->kind = mxStack->kind;
2653
0
      slot->value = mxStack->value;
2654
0
    XS_CODE_SET_SKIP:
2655
0
      *(mxStack + 1) = *mxStack;
2656
0
      mxStack++;
2657
0
      mxBreak;
2658
      
2659
0
    mxCase(XS_CODE_HAS_PRIVATE_2)
2660
0
      index = mxRunU2(1);
2661
0
      mxNextCode(3);
2662
0
      goto XS_CODE_HAS_PRIVATE;
2663
0
    mxCase(XS_CODE_HAS_PRIVATE_1)
2664
0
      index = mxRunU1(1);
2665
0
      mxNextCode(2);
2666
0
    XS_CODE_HAS_PRIVATE:
2667
#ifdef mxTrace
2668
      if (gxDoTrace) fxTraceIndex(the, index - 1);
2669
#endif
2670
0
      slot = (mxEnvironment - index);
2671
0
      if (mxStack->kind == XS_REFERENCE_KIND)
2672
0
        variable = mxStack->value.reference; 
2673
0
      else
2674
0
        mxRunDebug(XS_TYPE_ERROR, "in: not an object");
2675
0
      offset = slot->ID;
2676
0
      index = 0;
2677
0
      if (slot->value.closure->kind < 0)
2678
0
        mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset);
2679
0
      slot = gxDefaults.getPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset);
2680
0
      mxStack->kind = XS_BOOLEAN_KIND;
2681
0
      mxStack->value.boolean = (slot) ? 1 : 0;
2682
0
      mxBreak;
2683
            
2684
  /* INSTANCES */  
2685
0
    mxCase(XS_CODE_ARRAY)
2686
//      mxAllocStack(1);
2687
0
      mxSaveState;
2688
0
      fxNewArray(the, 0);
2689
0
      mxRestoreState;
2690
0
      mxNextCode(1);
2691
0
      mxBreak;
2692
0
    mxCase(XS_CODE_CLASS)
2693
0
      variable = fxToInstance(the, mxStack);
2694
0
      slot = mxStack + 2;
2695
0
      variable->flag |= XS_CAN_CONSTRUCT_FLAG;
2696
0
      if (slot->kind == XS_NULL_KIND)
2697
0
        variable->next->flag |= XS_BASE_FLAG;
2698
0
      else {
2699
0
        variable->next->flag |= XS_DERIVED_FLAG;
2700
0
        variable->value.instance.prototype = slot->value.reference;
2701
0
      }
2702
0
      slot = mxStack + 1;
2703
0
      mxFunctionInstanceHome(variable)->value.home.object = slot->value.reference;
2704
0
      mxSaveState;
2705
0
      slot->flag = XS_GET_ONLY;
2706
0
      fxRunDefine(the, variable, C_NULL, mxID(_prototype), 0, slot, XS_GET_ONLY);
2707
0
      slot = mxBehaviorSetProperty(the, slot->value.reference, mxID(_constructor), 0, XS_OWN);
2708
0
      mxRestoreState;
2709
0
      slot->flag |= XS_DONT_ENUM_FLAG;
2710
0
      slot->kind = mxStack->kind;
2711
0
      slot->value = mxStack->value;
2712
0
      mxStack += 3;
2713
0
            mxNextCode(1);
2714
0
      mxBreak;
2715
0
    mxCase(XS_CODE_COPY_OBJECT)
2716
0
      mxNextCode(1);
2717
0
      mxAllocStack(1);
2718
0
      *mxStack = mxCopyObjectFunction;
2719
0
      mxBreak;
2720
0
    mxCase(XS_CODE_EXTEND)
2721
0
      if (mxStack->kind == XS_NULL_KIND) {
2722
0
        mxSaveState;
2723
0
        fxNewInstance(the);
2724
0
        mxRestoreState;
2725
0
      }
2726
0
      else {
2727
0
        mxSaveState;
2728
0
        fxRunExtends(the);
2729
0
        mxRestoreState;
2730
0
      }
2731
0
            mxNextCode(1);
2732
0
      mxBreak;
2733
0
    mxCase(XS_CODE_GLOBAL)
2734
0
      mxPushKind(XS_REFERENCE_KIND);
2735
0
      variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
2736
0
      variable = mxModuleInstanceInternal(variable)->value.module.realm;
2737
0
      if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
2738
0
      mxStack->value.reference = mxRealmGlobal(variable)->value.reference;
2739
0
      mxNextCode(1);
2740
0
      mxBreak;
2741
0
    mxCase(XS_CODE_HOST)
2742
0
      index = mxRunU2(1);
2743
#ifdef mxTrace
2744
      if (gxDoTrace) fxTraceIndex(the, index);
2745
#endif
2746
0
      mxAllocStack(1);
2747
0
      variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
2748
0
      variable = mxModuleInstanceHosts(variable);
2749
0
      *mxStack = *variable;
2750
0
      slot = mxBehaviorGetProperty(the, mxStack->value.reference, 0, index, XS_OWN);
2751
0
      mxStack->kind = slot->kind;
2752
0
      mxStack->value = slot->value;
2753
0
      mxNextCode(3);
2754
0
      mxBreak;
2755
0
    mxCase(XS_CODE_INSTANTIATE)
2756
0
      mxSaveState;
2757
0
      fxRunInstantiate(the);
2758
0
      mxRestoreState;
2759
0
      mxNextCode(1);
2760
0
      mxBreak;
2761
0
    mxCase(XS_CODE_CALL)
2762
0
      mxNextCode(1);
2763
0
      mxAllocStack(2);
2764
0
      slot = mxStack;
2765
0
      mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2766
0
      mxInitSlotKind(slot, XS_UNDEFINED_KIND);
2767
0
      mxBreak;
2768
0
    mxCase(XS_CODE_NEW)
2769
0
      mxNextCode(1);
2770
0
      variable = mxStack;
2771
0
      mxAllocStack(4);
2772
0
      slot = mxStack;
2773
0
      mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2774
0
      mxInitSlotKind(slot++, XS_UNDEFINED_KIND);
2775
0
      slot->value = variable->value;
2776
0
      mxInitSlotKind(slot++, variable->kind);
2777
0
      mxInitSlotKind(slot, XS_UNINITIALIZED_KIND);
2778
0
      mxBreak;
2779
0
    mxCase(XS_CODE_OBJECT)
2780
//      mxAllocStack(1);
2781
0
      mxSaveState;
2782
0
      fxNewObject(the);
2783
0
      mxRestoreState;
2784
0
      mxNextCode(1);
2785
0
      mxBreak;
2786
0
    mxCase(XS_CODE_REGEXP)
2787
0
      mxNextCode(1);
2788
0
      mxAllocStack(1);
2789
0
      *mxStack = mxRegExpConstructor;
2790
0
      mxBreak;
2791
0
    mxCase(XS_CODE_SUPER)
2792
0
      mxNextCode(1);
2793
0
      variable = mxFrameFunction->value.reference;
2794
0
            if (mxIsConstructor(variable))
2795
0
        variable = fxGetPrototype(the, variable);
2796
0
      else {
2797
0
        variable = mxFunctionInstanceHome(variable);
2798
0
        variable = mxBehaviorGetProperty(the, variable->value.home.object, mxID(_constructor), 0, XS_ANY);
2799
0
        variable = fxGetPrototype(the, variable->value.reference);
2800
0
      }
2801
0
            if (!mxIsConstructor(variable))
2802
0
        mxRunDebug(XS_TYPE_ERROR, "super: not a constructor");
2803
0
      mxAllocStack(5);
2804
0
      slot = mxStack;
2805
0
      mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2806
0
      mxInitSlotKind(slot++, XS_UNDEFINED_KIND);
2807
0
      slot->value.reference = variable;
2808
0
      mxInitSlotKind(slot++, XS_REFERENCE_KIND);
2809
0
      mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND);
2810
0
      if (mxFrameHasTarget) {
2811
0
        slot->value = mxFrameTarget->value;
2812
0
        mxInitSlotKind(slot, mxFrameTarget->kind);
2813
0
      }
2814
0
      else
2815
0
        mxInitSlotKind(slot, XS_UNDEFINED_KIND);
2816
0
      mxBreak;
2817
0
    mxCase(XS_CODE_TEMPLATE)
2818
0
      mxNextCode(1);
2819
0
      variable = mxStack->value.reference;
2820
0
      slot = mxBehaviorGetProperty(the, variable, mxID(_raw), 0, XS_OWN);
2821
0
            if (!slot)
2822
0
        mxRunDebug(XS_TYPE_ERROR, "template: no raw");
2823
0
      variable->flag |= XS_DONT_PATCH_FLAG;
2824
0
      variable->next->flag |= XS_DONT_SET_FLAG;
2825
0
      slot->flag |= XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG;
2826
0
      variable = slot->value.reference;
2827
0
      variable->flag |= XS_DONT_PATCH_FLAG;
2828
0
      variable->next->flag |= XS_DONT_SET_FLAG;
2829
0
      mxBreak;
2830
0
    mxCase(XS_CODE_TEMPLATE_CACHE)
2831
0
      mxNextCode(1);
2832
0
            variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
2833
0
            variable = mxModuleInstanceInternal(variable)->value.module.realm;
2834
0
            if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
2835
0
            slot = mxRealmTemplateCache(variable);
2836
0
      mxPushKind(XS_REFERENCE_KIND);
2837
0
      mxStack->value.reference = slot->value.reference;
2838
0
      mxBreak;
2839
      
2840
  /* FUNCTIONS */    
2841
0
    mxCase(XS_CODE_ASYNC_FUNCTION)
2842
0
      offset = mxRunID(1);
2843
#ifdef mxTrace
2844
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2845
#endif
2846
0
      mxAllocStack(1);
2847
0
      *mxStack = mxAsyncFunctionPrototype;
2848
0
      mxSaveState;
2849
0
      fxNewFunctionInstance(the, (txID)offset);
2850
0
      mxRestoreState;
2851
0
      mxNextCode(1 + sizeof(txID));
2852
0
      mxBreak;
2853
0
    mxCase(XS_CODE_ASYNC_GENERATOR_FUNCTION)
2854
0
      offset = mxRunID(1);
2855
#ifdef mxTrace
2856
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2857
#endif
2858
0
      mxAllocStack(1);
2859
0
      *mxStack = mxAsyncGeneratorFunctionPrototype;
2860
0
      mxSaveState;
2861
0
      gxDefaults.newAsyncGeneratorFunctionInstance(the,(txID) offset);
2862
0
      mxRestoreState;
2863
0
      mxNextCode(1 + sizeof(txID));
2864
0
      mxBreak;
2865
0
    mxCase(XS_CODE_CONSTRUCTOR_FUNCTION)
2866
0
      offset = mxRunID(1);
2867
#ifdef mxTrace
2868
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2869
#endif
2870
0
      mxAllocStack(1);
2871
0
      *mxStack = mxFunctionPrototype;
2872
0
      mxSaveState;
2873
0
      fxNewFunctionInstance(the, (txID)offset);
2874
0
      fxDefaultFunctionPrototype(the);
2875
0
      mxRestoreState;
2876
0
      mxNextCode(1 + sizeof(txID));
2877
0
      mxBreak;
2878
0
    mxCase(XS_CODE_FUNCTION)
2879
0
      offset = mxRunID(1);
2880
#ifdef mxTrace
2881
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2882
#endif
2883
0
      mxAllocStack(1);
2884
0
      *mxStack = mxFunctionPrototype;
2885
0
      mxSaveState;
2886
0
      fxNewFunctionInstance(the, (txID)offset);
2887
0
      mxRestoreState;
2888
0
      mxNextCode(1 + sizeof(txID));
2889
0
      mxBreak;
2890
0
    mxCase(XS_CODE_GENERATOR_FUNCTION)
2891
0
      offset = mxRunID(1);
2892
#ifdef mxTrace
2893
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2894
#endif
2895
0
      mxAllocStack(1);
2896
0
      *mxStack = mxGeneratorFunctionPrototype;
2897
0
      mxSaveState;
2898
0
      gxDefaults.newGeneratorFunctionInstance(the,(txID) offset);
2899
0
      mxRestoreState;
2900
0
      mxNextCode(1 + sizeof(txID));
2901
0
      mxBreak;
2902
0
    mxCase(XS_CODE_PROFILE)
2903
0
      offset = mxRunID(1);
2904
0
      variable = mxFunctionInstanceHome(mxStack->value.reference);
2905
0
      variable->ID = offset;
2906
0
      mxNextCode(1 + sizeof(txID));
2907
0
      mxBreak;
2908
0
    mxCase(XS_CODE_NAME)
2909
0
      offset = mxRunID(1);
2910
#ifdef mxTrace
2911
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
2912
#endif
2913
0
      mxSaveState;
2914
0
      fxRenameFunction(the, mxStack->value.reference, (txID)offset, 0, XS_NO_ID, C_NULL);
2915
0
      mxRestoreState;
2916
0
      mxNextCode(1 + sizeof(txID));
2917
0
      mxBreak;
2918
0
    mxCase(XS_CODE_SET_HOME)
2919
0
      slot = mxFunctionInstanceHome((mxStack + 1)->value.reference);
2920
0
      slot->value.home.object = mxStack->value.reference;
2921
0
      mxStack++;
2922
0
      mxNextCode(1);
2923
0
      mxBreak;
2924
0
    mxCase(XS_CODE_CODE_4)
2925
0
      offset = mxRunS4(1);
2926
0
      mxSkipCode(5);
2927
0
      goto XS_CODE_CODE;
2928
0
    mxCase(XS_CODE_CODE_2)
2929
0
      offset = mxRunS2(1);
2930
0
      mxSkipCode(3);
2931
0
      goto XS_CODE_CODE;
2932
0
    mxCase(XS_CODE_CODE_1)
2933
0
      offset = mxRunS1(1);
2934
0
      mxSkipCode(2);
2935
0
    XS_CODE_CODE:
2936
0
      mxSaveState;
2937
0
      scratch.value.code.address = (txByte*)fxNewChunk(the, (txSize)offset);
2938
0
      mxRestoreState;
2939
0
      c_memcpy(scratch.value.code.address, mxCode, offset);
2940
0
      variable = mxStack->value.reference;
2941
0
      slot = mxFunctionInstanceCode(variable);
2942
0
      slot->kind = XS_CODE_KIND;
2943
0
      slot->value.code.address = scratch.value.code.address;
2944
0
      if (gxDefaults.newFunctionLength) {
2945
0
        gxDefaults.newFunctionLength(the, variable, *(((txU1*)scratch.value.code.address + 1)));
2946
0
      }
2947
0
      mxNextCode(offset);
2948
0
      mxBreak;
2949
0
    mxCase(XS_CODE_CODE_ARCHIVE_4)
2950
0
      offset = mxRunS4(1);
2951
0
      mxSkipCode(5);
2952
0
      goto XS_CODE_CODE_ARCHIVE;
2953
0
    mxCase(XS_CODE_CODE_ARCHIVE_2)
2954
0
      offset = mxRunS2(1);
2955
0
      mxSkipCode(3);
2956
0
      goto XS_CODE_CODE_ARCHIVE;
2957
0
    mxCase(XS_CODE_CODE_ARCHIVE_1)
2958
0
      offset = mxRunS1(1);
2959
0
      mxSkipCode(2);
2960
0
    XS_CODE_CODE_ARCHIVE:
2961
0
      variable = mxStack->value.reference;
2962
0
      slot = mxFunctionInstanceCode(variable);
2963
0
      slot->kind = XS_CODE_X_KIND;
2964
0
      slot->value.code.address = mxCode;
2965
0
      if (gxDefaults.newFunctionLength) {
2966
0
        gxDefaults.newFunctionLength(the, variable, mxRunU1(1));
2967
0
      }
2968
0
      mxNextCode(offset);
2969
0
      mxBreak;
2970
2971
  /* VALUES */    
2972
0
    mxCase(XS_CODE_UNDEFINED)
2973
0
      mxPushKind(XS_UNDEFINED_KIND);
2974
0
      mxNextCode(1);
2975
0
      mxBreak; 
2976
0
    mxCase(XS_CODE_NULL)
2977
0
      mxPushKind(XS_NULL_KIND);
2978
0
      mxNextCode(1);
2979
0
      mxBreak; 
2980
0
    mxCase(XS_CODE_FALSE)
2981
0
      mxPushKind(XS_BOOLEAN_KIND);
2982
0
      mxStack->value.boolean = 0;
2983
0
      mxNextCode(1);
2984
0
      mxBreak;
2985
0
    mxCase(XS_CODE_TRUE)
2986
0
      mxPushKind(XS_BOOLEAN_KIND);
2987
0
      mxStack->value.boolean = 1;
2988
0
      mxNextCode(1);
2989
0
      mxBreak;
2990
0
    mxCase(XS_CODE_INTEGER_1)
2991
0
      mxPushKind(XS_INTEGER_KIND);
2992
0
      mxStack->value.integer = mxRunS1(1);
2993
0
      mxNextCode(2);
2994
#ifdef mxTrace
2995
      if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer);
2996
#endif
2997
0
      mxBreak;
2998
0
    mxCase(XS_CODE_INTEGER_2)
2999
0
      mxPushKind(XS_INTEGER_KIND);
3000
0
      mxStack->value.integer = mxRunS2(1);
3001
0
      mxNextCode(3);
3002
#ifdef mxTrace
3003
      if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer);
3004
#endif
3005
0
      mxBreak;
3006
0
    mxCase(XS_CODE_INTEGER_4)
3007
0
      mxPushKind(XS_INTEGER_KIND);
3008
0
      mxStack->value.integer = mxRunS4(1);
3009
0
      mxNextCode(5);
3010
#ifdef mxTrace
3011
      if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer);
3012
#endif
3013
0
      mxBreak;
3014
0
    mxCase(XS_CODE_NUMBER)
3015
0
      mxPushKind(XS_NUMBER_KIND);
3016
0
      {
3017
0
        txByte* number = (txByte*)&(mxStack->value.number);
3018
      #if mxBigEndian
3019
        number[7] = mxCode[1];
3020
        number[6] = mxCode[2];
3021
        number[5] = mxCode[3];
3022
        number[4] = mxCode[4];
3023
        number[3] = mxCode[5];
3024
        number[2] = mxCode[6];
3025
        number[1] = mxCode[7];
3026
        number[0] = mxCode[8];
3027
      #else
3028
0
        number[0] = mxCode[1];
3029
0
        number[1] = mxCode[2];
3030
0
        number[2] = mxCode[3];
3031
0
        number[3] = mxCode[4];
3032
0
        number[4] = mxCode[5];
3033
0
        number[5] = mxCode[6];
3034
0
        number[6] = mxCode[7];
3035
0
        number[7] = mxCode[8];
3036
0
      #endif
3037
0
      }
3038
0
      mxNextCode(9);
3039
#ifdef mxTrace
3040
      if (gxDoTrace) fxTraceNumber(the, mxStack->value.number);
3041
#endif
3042
0
      mxBreak;
3043
      
3044
0
    mxCase(XS_CODE_STRING_4)
3045
0
      index = mxRunS4(1);
3046
0
      mxSkipCode(5);
3047
0
      goto XS_CODE_STRING;
3048
0
    mxCase(XS_CODE_STRING_2)
3049
0
      index = mxRunU2(1);
3050
0
      mxSkipCode(3);
3051
0
      goto XS_CODE_STRING;
3052
0
    mxCase(XS_CODE_STRING_1)
3053
0
      index = mxRunU1(1);
3054
0
      mxSkipCode(2);
3055
0
    XS_CODE_STRING:
3056
0
      mxSaveState;
3057
0
      scratch.value.string = (txString)fxNewChunk(the, index);
3058
0
      mxRestoreState;
3059
0
      c_memcpy(scratch.value.string, mxCode, index);
3060
0
      mxPushKind(XS_STRING_KIND);
3061
0
      mxStack->value.string = scratch.value.string;
3062
0
      mxNextCode(index);
3063
#ifdef mxTrace
3064
      if (gxDoTrace) fxTraceString(the, mxStack->value.string);
3065
#endif
3066
0
      mxBreak;
3067
0
    mxCase(XS_CODE_STRING_ARCHIVE_4)
3068
0
      index = mxRunS4(1);
3069
0
      mxSkipCode(5);
3070
0
      goto XS_CODE_STRING_ARCHIVE;
3071
0
    mxCase(XS_CODE_STRING_ARCHIVE_2)
3072
0
      index = mxRunU2(1);
3073
0
      mxSkipCode(3);
3074
0
      goto XS_CODE_STRING_ARCHIVE;
3075
0
    mxCase(XS_CODE_STRING_ARCHIVE_1)
3076
0
      index = mxRunU1(1);
3077
0
      mxSkipCode(2);
3078
0
    XS_CODE_STRING_ARCHIVE:
3079
0
      mxPushKind(XS_STRING_X_KIND);
3080
0
      mxStack->value.string = (txString)mxCode;
3081
0
      mxNextCode(index);
3082
#ifdef mxTrace
3083
      if (gxDoTrace) fxTraceString(the, mxStack->value.string);
3084
#endif
3085
0
      mxBreak;
3086
0
    mxCase(XS_CODE_TO_STRING)
3087
0
      mxToString(mxStack);
3088
0
      mxNextCode(1);
3089
0
      mxBreak;
3090
      
3091
0
    mxCase(XS_CODE_SYMBOL)
3092
0
      mxPushKind(XS_SYMBOL_KIND);
3093
0
      mxStack->value.symbol = mxRunID(1);
3094
#ifdef mxTrace
3095
      if (gxDoTrace) fxTraceID(the, mxStack->value.symbol, 0);
3096
#endif
3097
0
      mxNextCode(1 + sizeof(txID));
3098
0
      mxBreak;
3099
      
3100
0
    mxCase(XS_CODE_BIGINT_2)
3101
0
      index = mxRunU2(1);
3102
0
      mxSkipCode(3);
3103
0
      goto XS_CODE_BIGINT;
3104
0
    mxCase(XS_CODE_BIGINT_1)
3105
0
      index = mxRunU1(1);
3106
0
      mxSkipCode(2);
3107
0
    XS_CODE_BIGINT:
3108
0
      mxSaveState;
3109
0
      gxTypeBigInt.decode(the, index);
3110
0
      mxRestoreState;
3111
0
      mxNextCode(index);
3112
0
      mxBreak;
3113
3114
  /* EXPRESSIONS */ 
3115
0
    mxCase(XS_CODE_BIT_NOT)
3116
0
      if (mxStack->kind == XS_INTEGER_KIND)
3117
0
        mxStack->value.integer = ~mxStack->value.integer;
3118
0
      else if (mxStack->kind == XS_NUMBER_KIND) {
3119
0
        mxStack->kind = XS_INTEGER_KIND;
3120
0
        mxStack->value.integer = ~fxNumberToInteger(mxStack->value.number);
3121
0
        mxFloatingPointOp("not");
3122
0
      }
3123
0
      else {
3124
0
        mxSaveState;
3125
0
        if (fxToNumericIntegerUnary(the, mxStack, gxTypeBigInt._not))
3126
0
          mxStack->value.integer = ~mxStack->value.integer;
3127
0
        mxRestoreState;
3128
0
      }
3129
0
      mxNextCode(1);
3130
0
      mxBreak;
3131
0
    mxCase(XS_CODE_BIT_AND)
3132
0
      slot = mxStack + 1;
3133
0
      if (slot->kind == XS_INTEGER_KIND) {
3134
0
        if (mxStack->kind == XS_INTEGER_KIND)
3135
0
          slot->value.integer &= mxStack->value.integer;
3136
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3137
0
          slot->value.integer &= fxNumberToInteger(mxStack->value.number);
3138
0
          mxFloatingPointOp("and");
3139
0
        }
3140
0
        else
3141
0
          goto XS_CODE_BIT_AND_GENERAL;
3142
0
      }
3143
0
      else if (slot->kind == XS_NUMBER_KIND) {
3144
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3145
0
          slot->kind = XS_INTEGER_KIND;
3146
0
          slot->value.integer = fxNumberToInteger(slot->value.number) & mxStack->value.integer;
3147
0
          mxFloatingPointOp("and");
3148
0
        }
3149
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3150
0
          slot->kind = XS_INTEGER_KIND;
3151
0
          slot->value.integer = fxNumberToInteger(slot->value.number) & fxNumberToInteger(mxStack->value.number);
3152
0
          mxFloatingPointOp("and");
3153
0
        }
3154
0
        else
3155
0
          goto XS_CODE_BIT_AND_GENERAL;
3156
0
      }
3157
0
      else {
3158
0
    XS_CODE_BIT_AND_GENERAL:
3159
0
        mxSaveState;
3160
0
        if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._and))
3161
0
          slot->value.integer &= mxStack->value.integer;
3162
0
        mxRestoreState;
3163
0
      }
3164
0
      mxStack++;
3165
0
      mxNextCode(1);
3166
0
      mxBreak;
3167
0
    mxCase(XS_CODE_BIT_OR)
3168
0
      slot = mxStack + 1;
3169
0
      if (slot->kind == XS_INTEGER_KIND) {
3170
0
        if (mxStack->kind == XS_INTEGER_KIND)
3171
0
          slot->value.integer |= mxStack->value.integer;
3172
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3173
0
          slot->value.integer |= fxNumberToInteger(mxStack->value.number);
3174
0
          mxFloatingPointOp("or");
3175
0
        }
3176
0
        else
3177
0
          goto XS_CODE_BIT_OR_GENERAL;
3178
0
      }
3179
0
      else if (slot->kind == XS_NUMBER_KIND) {
3180
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3181
0
          slot->kind = XS_INTEGER_KIND;
3182
0
          slot->value.integer = fxNumberToInteger(slot->value.number) | mxStack->value.integer;
3183
0
          mxFloatingPointOp("or");
3184
0
        }
3185
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3186
0
          slot->kind = XS_INTEGER_KIND;
3187
0
          slot->value.integer = fxNumberToInteger(slot->value.number) | fxNumberToInteger(mxStack->value.number);
3188
0
          mxFloatingPointOp("or");
3189
0
        }
3190
0
        else
3191
0
          goto XS_CODE_BIT_OR_GENERAL;
3192
0
      }
3193
0
      else {
3194
0
    XS_CODE_BIT_OR_GENERAL:
3195
0
        mxSaveState;
3196
0
        if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._or))
3197
0
          slot->value.integer |= mxStack->value.integer;
3198
0
        mxRestoreState;
3199
0
      }
3200
0
      mxStack++;
3201
0
      mxNextCode(1);
3202
0
      mxBreak;
3203
0
    mxCase(XS_CODE_BIT_XOR)
3204
0
      slot = mxStack + 1;
3205
0
      if (slot->kind == XS_INTEGER_KIND) {
3206
0
        if (mxStack->kind == XS_INTEGER_KIND)
3207
0
          slot->value.integer ^= mxStack->value.integer;
3208
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3209
0
          slot->value.integer ^= fxNumberToInteger(mxStack->value.number);
3210
0
          mxFloatingPointOp("xor");
3211
0
        }
3212
0
        else
3213
0
          goto XS_CODE_BIT_XOR_GENERAL;
3214
0
      }
3215
0
      else if (slot->kind == XS_NUMBER_KIND) {
3216
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3217
0
          slot->kind = XS_INTEGER_KIND;
3218
0
          slot->value.integer = fxNumberToInteger(slot->value.number) ^ mxStack->value.integer;
3219
0
          mxFloatingPointOp("xor");
3220
0
        }
3221
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3222
0
          slot->kind = XS_INTEGER_KIND;
3223
0
          slot->value.integer = fxNumberToInteger(slot->value.number) ^ fxNumberToInteger(mxStack->value.number);
3224
0
          mxFloatingPointOp("xor");
3225
0
        }
3226
0
        else
3227
0
          goto XS_CODE_BIT_XOR_GENERAL;
3228
0
      }
3229
0
      else {
3230
0
    XS_CODE_BIT_XOR_GENERAL:
3231
0
        mxSaveState;
3232
0
        if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._xor))
3233
0
          slot->value.integer ^= mxStack->value.integer;
3234
0
        mxRestoreState;
3235
0
      }
3236
0
      mxStack++;
3237
0
      mxNextCode(1);
3238
0
      mxBreak;
3239
      
3240
0
    mxCase(XS_CODE_LEFT_SHIFT)
3241
0
      slot = mxStack + 1;
3242
0
      if (slot->kind == XS_INTEGER_KIND) {
3243
0
        if (mxStack->kind == XS_INTEGER_KIND)
3244
0
          slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (mxStack->value.integer & 0x1f));
3245
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3246
0
          slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (fxNumberToInteger(mxStack->value.number) & 0x1f));
3247
0
          mxFloatingPointOp("left shift");
3248
0
        }
3249
0
        else
3250
0
          goto XS_CODE_LEFT_SHIFT_GENERAL;
3251
0
      }
3252
0
      else if (slot->kind == XS_NUMBER_KIND) {
3253
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3254
0
          slot->kind = XS_INTEGER_KIND;
3255
0
          slot->value.integer = (txInteger)(((txUnsigned)fxNumberToInteger(slot->value.number)) << (mxStack->value.integer & 0x1f));
3256
0
          mxFloatingPointOp("left shift");
3257
0
        }
3258
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3259
0
          slot->kind = XS_INTEGER_KIND;
3260
0
          slot->value.integer = (txInteger)(((txUnsigned)fxNumberToInteger(slot->value.number)) << (fxNumberToInteger(mxStack->value.number) & 0x1f));
3261
0
          mxFloatingPointOp("left shift");
3262
0
        }
3263
0
        else
3264
0
          goto XS_CODE_LEFT_SHIFT_GENERAL;
3265
0
      }
3266
0
      else {
3267
0
    XS_CODE_LEFT_SHIFT_GENERAL:
3268
0
        mxSaveState;
3269
0
        if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._lsl))
3270
0
          slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (mxStack->value.integer & 0x1f));
3271
0
        mxRestoreState;
3272
0
      }
3273
0
      mxStack++;
3274
0
      mxNextCode(1);
3275
0
      mxBreak;
3276
0
    mxCase(XS_CODE_SIGNED_RIGHT_SHIFT)
3277
0
      slot = mxStack + 1;
3278
0
      if (slot->kind == XS_INTEGER_KIND) {
3279
0
        if (mxStack->kind == XS_INTEGER_KIND)
3280
0
          slot->value.integer >>= mxStack->value.integer & 0x1f;
3281
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3282
0
          slot->value.integer >>= fxNumberToInteger(mxStack->value.number) & 0x1f;
3283
0
          mxFloatingPointOp("signed right shift");
3284
0
        }
3285
0
        else
3286
0
          goto XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL;
3287
0
      }
3288
0
      else if (slot->kind == XS_NUMBER_KIND) {
3289
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3290
0
          slot->kind = XS_INTEGER_KIND;
3291
0
          slot->value.integer = fxNumberToInteger(slot->value.number) >> (mxStack->value.integer & 0x1f);
3292
0
          mxFloatingPointOp("signed right shift");
3293
0
        }
3294
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3295
0
          slot->kind = XS_INTEGER_KIND;
3296
0
          slot->value.integer = fxNumberToInteger(slot->value.number) >> (fxNumberToInteger(mxStack->value.number) & 0x1f);
3297
0
          mxFloatingPointOp("signed right shift");
3298
0
        }
3299
0
        else
3300
0
          goto XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL;
3301
0
      }
3302
0
      else {
3303
0
    XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL:
3304
0
        mxSaveState;
3305
0
        if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._lsr))
3306
0
          slot->value.integer >>= mxStack->value.integer & 0x1f;
3307
0
        mxRestoreState;
3308
0
      }
3309
0
      mxStack++;
3310
0
      mxNextCode(1);
3311
0
      mxBreak;
3312
0
    mxCase(XS_CODE_UNSIGNED_RIGHT_SHIFT)
3313
0
      slot = mxStack + 1;
3314
0
      if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND))) {
3315
0
        fxUnsigned(the, slot, fxToUnsigned(the, slot) >> (fxToUnsigned(the, mxStack) & 0x1F));
3316
0
      }
3317
0
      else {
3318
0
        mxSaveState;
3319
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._nop))
3320
0
          fxUnsigned(the, slot, fxToUnsigned(the, slot) >> (fxToUnsigned(the, mxStack) & 0x1F));
3321
0
        mxRestoreState;
3322
0
      }
3323
0
      mxStack++;
3324
0
      mxNextCode(1);
3325
0
      mxBreak;
3326
        
3327
0
    mxCase(XS_CODE_MINUS)
3328
0
      if (mxStack->kind == XS_INTEGER_KIND) {
3329
0
        if (mxStack->value.integer & 0x7FFFFFFF)
3330
0
          mxStack->value.integer = -mxStack->value.integer;
3331
0
        else {
3332
0
          mxStack->kind = XS_NUMBER_KIND;
3333
0
          mxStack->value.number = -((txNumber)(mxStack->value.integer));
3334
0
          mxFloatingPointOp("minus");
3335
0
        }
3336
0
      }
3337
0
      else if (mxStack->kind == XS_NUMBER_KIND) {
3338
0
        mxStack->value.number = -mxStack->value.number;
3339
0
        mxFloatingPointOp("minus");
3340
0
      }
3341
0
      else {
3342
0
        mxSaveState;
3343
0
        if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._neg)) {
3344
0
          mxStack->value.number = -mxStack->value.number;
3345
0
          mxFloatingPointOp("minus");
3346
0
        }
3347
0
        mxRestoreState;
3348
0
      }
3349
0
      mxNextCode(1);
3350
0
      mxBreak;
3351
0
    mxCase(XS_CODE_PLUS)
3352
0
      if (mxStack->kind != XS_INTEGER_KIND) {
3353
0
        mxToNumber(mxStack);
3354
0
      }
3355
0
      mxNextCode(1);
3356
0
      mxBreak;
3357
      
3358
0
    mxCase(XS_CODE_TO_NUMERIC)
3359
0
      if ((mxStack->kind != XS_INTEGER_KIND) && (mxStack->kind != XS_NUMBER_KIND)) {
3360
0
        mxSaveState;
3361
0
        fxToNumericNumber(the, mxStack);
3362
0
        mxRestoreState;
3363
0
      }
3364
0
      mxNextCode(1);
3365
0
      mxBreak;
3366
0
    mxCase(XS_CODE_DECREMENT)
3367
0
      if (mxStack->kind == XS_INTEGER_KIND) {
3368
0
        if (mxStack->value.integer != -2147483647)
3369
0
          mxStack->value.integer--;
3370
0
        else {
3371
0
          mxStack->kind = XS_NUMBER_KIND;
3372
0
          mxStack->value.number = mxStack->value.integer;
3373
0
          mxStack->value.number--;
3374
0
          mxFloatingPointOp("decrement");
3375
0
        }
3376
0
      }
3377
0
      else if (mxStack->kind == XS_NUMBER_KIND) {
3378
0
        mxStack->value.number--;
3379
0
        mxFloatingPointOp("decrement");
3380
0
      }
3381
0
      else {
3382
0
        mxSaveState;
3383
0
        if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._dec)) {
3384
0
          mxStack->value.number--;
3385
0
          mxFloatingPointOp("decrement");
3386
0
        }
3387
0
        mxRestoreState;
3388
0
      }
3389
0
      mxNextCode(1);
3390
0
      mxBreak;
3391
0
    mxCase(XS_CODE_INCREMENT)
3392
0
      if (mxStack->kind == XS_INTEGER_KIND) {
3393
0
        if (mxStack->value.integer != 2147483647)
3394
0
          mxStack->value.integer++;
3395
0
        else {
3396
0
          mxStack->kind = XS_NUMBER_KIND;
3397
0
          mxStack->value.number = mxStack->value.integer;
3398
0
          mxStack->value.number++;
3399
0
          mxFloatingPointOp("increment");
3400
0
        }
3401
0
      }
3402
0
      else if (mxStack->kind == XS_NUMBER_KIND) {
3403
0
        mxStack->value.number++;
3404
0
        mxFloatingPointOp("increment");
3405
0
      }
3406
0
      else {
3407
0
        mxSaveState;
3408
0
        if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._inc)) {
3409
0
          mxStack->value.number++;
3410
0
          mxFloatingPointOp("increment");
3411
0
        }
3412
0
        mxRestoreState;
3413
0
      }
3414
0
      mxNextCode(1);
3415
0
      mxBreak;
3416
      
3417
0
    mxCase(XS_CODE_ADD)
3418
0
      slot = mxStack + 1;
3419
0
      if (slot->kind == XS_INTEGER_KIND) {
3420
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3421
0
          #if __has_builtin(__builtin_add_overflow)
3422
0
            if (__builtin_add_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) {
3423
0
              slot->kind = XS_NUMBER_KIND;
3424
0
              slot->value.number = (txNumber)(slot->value.integer) + (txNumber)(mxStack->value.integer);
3425
0
              mxFloatingPointOp("add");
3426
0
            }
3427
0
            else
3428
0
              slot->value.integer = scratch.value.integer;
3429
          #else
3430
            txInteger a = slot->value.integer;
3431
            txInteger b = mxStack->value.integer;
3432
            txInteger c = a + b;
3433
            if (((a ^ c) & (b ^ c)) < 0) {
3434
              slot->kind = XS_NUMBER_KIND;
3435
              slot->value.number = (txNumber)(slot->value.integer) + (txNumber)(mxStack->value.integer);
3436
              mxFloatingPointOp("add");
3437
            }
3438
            else
3439
              slot->value.integer = c;
3440
          #endif
3441
0
        }
3442
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3443
0
          slot->kind = XS_NUMBER_KIND;
3444
0
          slot->value.number = (txNumber)(slot->value.integer) + mxStack->value.number;
3445
0
          mxFloatingPointOp("add");
3446
0
        }
3447
0
        else
3448
0
          goto XS_CODE_ADD_GENERAL;
3449
0
      }
3450
0
      else if (slot->kind == XS_NUMBER_KIND) {
3451
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3452
0
          slot->value.number += (txNumber)(mxStack->value.integer);
3453
0
          mxFloatingPointOp("add");
3454
0
        }
3455
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3456
0
          slot->value.number += mxStack->value.number;
3457
0
          mxFloatingPointOp("add");
3458
0
        }
3459
0
        else
3460
0
          goto XS_CODE_ADD_GENERAL;
3461
0
      }
3462
0
      else {
3463
0
    XS_CODE_ADD_GENERAL:
3464
0
        mxSaveState;
3465
0
        fxToPrimitive(the, slot, XS_NO_HINT);
3466
0
        fxToPrimitive(the, mxStack, XS_NO_HINT);
3467
0
        if ((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)) {
3468
0
          fxToString(the, slot);
3469
0
          fxToString(the, mxStack);
3470
0
          fxConcatString(the, slot, mxStack);
3471
0
        }
3472
0
        else {
3473
0
          if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._add)) {
3474
0
            slot->value.number += mxStack->value.number;
3475
0
            mxFloatingPointOp("add");
3476
0
          }
3477
0
        }
3478
0
        mxRestoreState;
3479
0
      }
3480
0
      mxStack++;
3481
0
      mxNextCode(1);
3482
0
      mxBreak;
3483
0
    mxCase(XS_CODE_SUBTRACT)
3484
0
      slot = mxStack + 1;
3485
0
      if (slot->kind == XS_INTEGER_KIND) {
3486
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3487
0
          #if __has_builtin(__builtin_sub_overflow)
3488
0
            if (__builtin_sub_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) {
3489
0
              slot->kind = XS_NUMBER_KIND;
3490
0
              slot->value.number = (txNumber)(slot->value.integer) - (txNumber)(mxStack->value.integer);
3491
0
              mxFloatingPointOp("subtract");
3492
0
            }
3493
0
            else
3494
0
              slot->value.integer = scratch.value.integer;
3495
          #else
3496
            txInteger a = slot->value.integer;
3497
            txInteger b = -mxStack->value.integer;
3498
            txInteger c = a + b;
3499
            if (((a ^ c) & (b ^ c)) < 0) {
3500
              slot->kind = XS_NUMBER_KIND;
3501
              slot->value.number = (txNumber)(slot->value.integer) - (txNumber)(mxStack->value.integer);
3502
              mxFloatingPointOp("subtract");
3503
            }
3504
            else
3505
              slot->value.integer = c;
3506
          #endif
3507
0
        }
3508
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3509
0
          slot->kind = XS_NUMBER_KIND;
3510
0
          slot->value.number = (txNumber)(slot->value.integer) - mxStack->value.number;
3511
0
          mxFloatingPointOp("subtract");
3512
0
        }
3513
0
        else
3514
0
          goto XS_CODE_SUBTRACT_GENERAL;
3515
0
      }
3516
0
      else if (slot->kind == XS_NUMBER_KIND) {
3517
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3518
0
          slot->value.number -= (txNumber)(mxStack->value.integer);
3519
0
          mxFloatingPointOp("subtract");
3520
0
        }
3521
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3522
0
          slot->value.number -= mxStack->value.number;
3523
0
          mxFloatingPointOp("subtract");
3524
0
        }
3525
0
        else
3526
0
          goto XS_CODE_SUBTRACT_GENERAL;
3527
0
      }
3528
0
      else {
3529
0
    XS_CODE_SUBTRACT_GENERAL:
3530
0
        mxSaveState;
3531
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._sub)) {
3532
0
          slot->value.number -= mxStack->value.number;
3533
0
          mxFloatingPointOp("subtract");
3534
0
        }
3535
0
        mxRestoreState;
3536
0
      }
3537
0
      mxStack++;
3538
0
      mxNextCode(1);
3539
0
      mxBreak;
3540
      
3541
0
    mxCase(XS_CODE_DIVIDE)
3542
0
      slot = mxStack + 1;
3543
0
      if (slot->kind == XS_INTEGER_KIND) {
3544
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3545
0
          slot->kind = XS_NUMBER_KIND;
3546
0
          slot->value.number = (txNumber)(slot->value.integer) / (txNumber)(mxStack->value.integer);
3547
0
        }
3548
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3549
0
          slot->kind = XS_NUMBER_KIND;
3550
0
          slot->value.number = (txNumber)(slot->value.integer) / mxStack->value.number;
3551
0
        }
3552
0
        else
3553
0
          goto XS_CODE_DIVIDE_GENERAL;
3554
0
      }
3555
0
      else if (slot->kind == XS_NUMBER_KIND) {
3556
0
        if (mxStack->kind == XS_INTEGER_KIND)
3557
0
          slot->value.number /= (txNumber)(mxStack->value.integer);
3558
0
        else if (mxStack->kind == XS_NUMBER_KIND)
3559
0
          slot->value.number /= mxStack->value.number;
3560
0
        else
3561
0
          goto XS_CODE_DIVIDE_GENERAL;
3562
0
      }
3563
0
      else {
3564
0
    XS_CODE_DIVIDE_GENERAL:
3565
0
        mxSaveState;
3566
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._div))
3567
0
          slot->value.number /= mxStack->value.number;
3568
0
        mxRestoreState;
3569
0
      }
3570
0
      mxFloatingPointOp("divide");
3571
0
      mxStack++;
3572
0
      mxNextCode(1);
3573
0
      mxBreak;
3574
0
    mxCase(XS_CODE_EXPONENTIATION)
3575
0
      slot = mxStack + 1;
3576
0
      if (slot->kind == XS_INTEGER_KIND) {
3577
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3578
0
          slot->kind = XS_NUMBER_KIND;
3579
0
          slot->value.number = fx_pow((txNumber)(slot->value.integer), (txNumber)(mxStack->value.integer));
3580
0
        }
3581
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3582
0
          slot->kind = XS_NUMBER_KIND;
3583
0
          slot->value.number = fx_pow((txNumber)(slot->value.integer), mxStack->value.number);
3584
0
        }
3585
0
        else
3586
0
          goto XS_CODE_EXPONENTIATION_GENERAL;
3587
0
      }
3588
0
      else if (slot->kind == XS_NUMBER_KIND) {
3589
0
        if (mxStack->kind == XS_INTEGER_KIND)
3590
0
          slot->value.number = fx_pow(slot->value.number, (txNumber)(mxStack->value.integer));
3591
0
        else if (mxStack->kind == XS_NUMBER_KIND)
3592
0
          slot->value.number = fx_pow(slot->value.number, mxStack->value.number);
3593
0
        else
3594
0
          goto XS_CODE_EXPONENTIATION_GENERAL;
3595
0
      }
3596
0
      else {
3597
0
    XS_CODE_EXPONENTIATION_GENERAL:
3598
0
        mxSaveState;
3599
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._exp))
3600
0
          slot->value.number = fx_pow(slot->value.number, mxStack->value.number);
3601
0
        mxRestoreState;
3602
0
      }
3603
0
      mxFloatingPointOp("exponent");
3604
0
      mxStack++;
3605
0
      mxNextCode(1);
3606
0
      mxBreak;
3607
0
    mxCase(XS_CODE_MULTIPLY)
3608
0
      slot = mxStack + 1;
3609
0
      if (slot->kind == XS_INTEGER_KIND) {
3610
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3611
0
        #ifdef mxMinusZero
3612
0
          if (slot->value.integer == 0) {
3613
0
            if (mxStack->value.integer < 0) {
3614
0
              slot->kind = XS_NUMBER_KIND;
3615
0
              slot->value.number = -0.0;
3616
0
            }
3617
0
          }
3618
0
          else if (mxStack->value.integer == 0) {
3619
0
            if (slot->value.integer < 0) {
3620
0
              slot->kind = XS_NUMBER_KIND;
3621
0
              slot->value.number = -0.0;
3622
0
            }
3623
0
            else
3624
0
              slot->value.integer = 0;
3625
0
          }
3626
0
          else {
3627
0
        #endif
3628
0
          #if __has_builtin(__builtin_mul_overflow)
3629
0
            if (__builtin_mul_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) {
3630
0
              slot->kind = XS_NUMBER_KIND;
3631
0
              slot->value.number = (txNumber)(slot->value.integer) * (txNumber)(mxStack->value.integer);
3632
0
              mxFloatingPointOp("multiply");
3633
0
            }
3634
0
            else
3635
0
              slot->value.integer = scratch.value.integer;
3636
          #else
3637
            slot->kind = XS_NUMBER_KIND;
3638
            slot->value.number = (txNumber)(slot->value.integer) * (txNumber)(mxStack->value.integer);
3639
            mxFloatingPointOp("multiply");
3640
          #endif
3641
0
        #ifdef mxMinusZero
3642
0
          }
3643
0
        #endif
3644
0
        }
3645
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3646
0
          slot->kind = XS_NUMBER_KIND;
3647
0
          slot->value.number = (txNumber)(slot->value.integer) * mxStack->value.number;
3648
0
          mxFloatingPointOp("multiply");
3649
0
        }
3650
0
        else
3651
0
          goto XS_CODE_MULTIPLY_GENERAL;
3652
0
      }
3653
0
      else if (slot->kind == XS_NUMBER_KIND) {
3654
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3655
0
          slot->value.number *= (txNumber)(mxStack->value.integer);
3656
0
          mxFloatingPointOp("multiply");
3657
0
        }
3658
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3659
0
          slot->value.number *= mxStack->value.number;
3660
0
          mxFloatingPointOp("multiply");
3661
0
        }
3662
0
        else
3663
0
          goto XS_CODE_MULTIPLY_GENERAL;
3664
0
      }
3665
0
      else {
3666
0
    XS_CODE_MULTIPLY_GENERAL:
3667
0
        mxSaveState;
3668
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._mul))
3669
0
          slot->value.number *= mxStack->value.number;
3670
0
        mxRestoreState;
3671
0
      }
3672
0
      mxStack++;
3673
0
      mxNextCode(1);
3674
0
      mxBreak;
3675
0
    mxCase(XS_CODE_MODULO)
3676
0
      slot = mxStack + 1;
3677
0
      if (slot->kind == XS_INTEGER_KIND) {
3678
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3679
0
          if (mxStack->value.integer == 0) {
3680
0
            slot->kind = XS_NUMBER_KIND;
3681
0
            slot->value.number = C_NAN;
3682
0
          }
3683
0
        #if mxIntegerDivideOverflowException
3684
0
          else if ((-1 == mxStack->value.integer) && ((txInteger)0x80000000 == slot->value.integer)) {
3685
0
            slot->kind = XS_NUMBER_KIND;
3686
0
            slot->value.number = -0.0;
3687
0
          }
3688
0
        #endif 
3689
0
        #ifdef mxMinusZero
3690
0
          else if (slot->value.integer < 0) {
3691
0
            slot->value.integer %= mxStack->value.integer;
3692
0
            if (slot->value.integer == 0) {
3693
0
              slot->kind = XS_NUMBER_KIND;
3694
0
              slot->value.number = -0.0;
3695
0
            }
3696
0
          }
3697
0
        #endif
3698
0
          else
3699
0
            slot->value.integer %= mxStack->value.integer;
3700
0
        }
3701
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3702
0
          slot->kind = XS_NUMBER_KIND;
3703
0
          slot->value.number = c_fmod((txNumber)(slot->value.integer), mxStack->value.number);
3704
0
          mxFloatingPointOp("modulo");
3705
0
        }
3706
0
        else
3707
0
          goto XS_CODE_MODULO_GENERAL;
3708
0
      }
3709
0
      else if (slot->kind == XS_NUMBER_KIND) {
3710
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3711
0
          slot->value.number = c_fmod(slot->value.number, (txNumber)(mxStack->value.integer));
3712
0
          mxFloatingPointOp("modulo");
3713
0
        }
3714
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3715
0
          slot->value.number = c_fmod(slot->value.number, mxStack->value.number);
3716
0
          mxFloatingPointOp("modulo");
3717
0
        }
3718
0
        else
3719
0
          goto XS_CODE_MODULO_GENERAL;
3720
0
      }
3721
0
      else {
3722
0
    XS_CODE_MODULO_GENERAL:
3723
0
        mxSaveState;
3724
0
        if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._rem)) {
3725
0
          slot->value.number = c_fmod(slot->value.number, mxStack->value.number);
3726
0
          mxFloatingPointOp("modulo");
3727
0
        }
3728
0
        mxRestoreState;
3729
0
      }
3730
0
      mxStack++;
3731
0
      mxNextCode(1);
3732
0
      mxBreak;
3733
      
3734
0
    mxCase(XS_CODE_NOT)
3735
0
      mxToBoolean(mxStack);
3736
0
      mxStack->value.boolean = !mxStack->value.boolean;
3737
0
      mxNextCode(1);
3738
0
      mxBreak;
3739
0
    mxCase(XS_CODE_LESS)
3740
0
      slot = mxStack + 1;
3741
0
      if (slot->kind == XS_INTEGER_KIND) {
3742
0
        if (mxStack->kind == XS_INTEGER_KIND)
3743
0
          offset = slot->value.integer < mxStack->value.integer;
3744
0
        else if (mxStack->kind == XS_NUMBER_KIND)  {
3745
0
          offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) < mxStack->value.number);
3746
0
          mxFloatingPointOp("less");
3747
0
        }
3748
0
        else
3749
0
          goto XS_CODE_LESS_GENERAL;
3750
0
      }
3751
0
      else if (slot->kind == XS_NUMBER_KIND) {
3752
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3753
0
          offset = (!c_isnan(slot->value.number)) && (slot->value.number < (txNumber)(mxStack->value.integer));
3754
0
          mxFloatingPointOp("less");
3755
0
        }
3756
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3757
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number < mxStack->value.number);
3758
0
          mxFloatingPointOp("less");
3759
0
        }
3760
0
        else
3761
0
          goto XS_CODE_LESS_GENERAL;
3762
0
      }
3763
0
      else {
3764
0
    XS_CODE_LESS_GENERAL:
3765
0
        mxSaveState; 
3766
0
        fxToPrimitive(the, slot, XS_NUMBER_HINT); 
3767
0
        fxToPrimitive(the, mxStack, XS_NUMBER_HINT); 
3768
0
        if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)))
3769
0
          offset = fxUTF8Compare(slot->value.string, mxStack->value.string) < 0;
3770
0
        else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND))
3771
0
          offset = gxTypeBigInt.compare(the, 1, 0, 0, slot, mxStack);
3772
0
        else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))
3773
0
          offset = gxTypeBigInt.compare(the, 0, 0, 1, mxStack, slot);
3774
0
        else {
3775
0
          fxToNumber(the, slot);
3776
0
          fxToNumber(the, mxStack);
3777
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number < mxStack->value.number);
3778
0
          mxFloatingPointOp("less");
3779
0
        }
3780
0
        mxRestoreState;
3781
0
      }
3782
0
      slot->kind = XS_BOOLEAN_KIND;
3783
0
      slot->value.boolean = offset;
3784
0
      mxStack++;
3785
0
      mxNextCode(1);
3786
0
      mxBreak;
3787
0
    mxCase(XS_CODE_LESS_EQUAL)
3788
0
      slot = mxStack + 1;
3789
0
      if (slot->kind == XS_INTEGER_KIND) {
3790
0
        if (mxStack->kind == XS_INTEGER_KIND)
3791
0
          offset = slot->value.integer <= mxStack->value.integer;
3792
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3793
0
          offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) <= mxStack->value.number);
3794
0
          mxFloatingPointOp("less or equal");
3795
0
        }
3796
0
        else
3797
0
          goto XS_CODE_LESS_EQUAL_GENERAL;
3798
0
      }
3799
0
      else if (slot->kind == XS_NUMBER_KIND) {
3800
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3801
0
          offset = (!c_isnan(slot->value.number)) && (slot->value.number <= (txNumber)(mxStack->value.integer));
3802
0
          mxFloatingPointOp("less or equal");
3803
0
        }
3804
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3805
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number <= mxStack->value.number);
3806
0
          mxFloatingPointOp("less or equal");
3807
0
        }
3808
0
        else
3809
0
          goto XS_CODE_LESS_EQUAL_GENERAL;
3810
0
      }
3811
0
      else {
3812
0
    XS_CODE_LESS_EQUAL_GENERAL:
3813
0
        mxSaveState; 
3814
0
        fxToPrimitive(the, slot, XS_NUMBER_HINT); 
3815
0
        fxToPrimitive(the, mxStack, XS_NUMBER_HINT); 
3816
0
        if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)))
3817
0
          offset = fxUTF8Compare(slot->value.string, mxStack->value.string) <= 0;
3818
0
        else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND))
3819
0
          offset = gxTypeBigInt.compare(the, 1, 1, 0, slot, mxStack);
3820
0
        else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))
3821
0
          offset = gxTypeBigInt.compare(the, 0, 1, 1, mxStack, slot);
3822
0
        else {
3823
0
          fxToNumber(the, slot);
3824
0
          fxToNumber(the, mxStack);
3825
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number <= mxStack->value.number);
3826
0
          mxFloatingPointOp("less or equal");
3827
0
        }
3828
0
        mxRestoreState;
3829
0
      }
3830
0
      slot->kind = XS_BOOLEAN_KIND;
3831
0
      slot->value.boolean = offset;
3832
0
      mxStack++;
3833
0
      mxNextCode(1);
3834
0
      mxBreak;
3835
0
    mxCase(XS_CODE_MORE)
3836
0
      slot = mxStack + 1;
3837
0
      if (slot->kind == XS_INTEGER_KIND) {
3838
0
        if (mxStack->kind == XS_INTEGER_KIND)
3839
0
          offset = slot->value.integer > mxStack->value.integer;
3840
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3841
0
          offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) > mxStack->value.number);
3842
0
          mxFloatingPointOp("more");
3843
0
        }
3844
0
        else
3845
0
          goto XS_CODE_MORE_GENERAL;
3846
0
      }
3847
0
      else if (slot->kind == XS_NUMBER_KIND) {
3848
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3849
0
          offset = (!c_isnan(slot->value.number)) && (slot->value.number > (txNumber)(mxStack->value.integer));
3850
0
          mxFloatingPointOp("more");
3851
0
        }
3852
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3853
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number > mxStack->value.number);
3854
0
          mxFloatingPointOp("more");
3855
0
        }
3856
0
        else
3857
0
          goto XS_CODE_MORE_GENERAL;
3858
0
      }
3859
0
      else {
3860
0
    XS_CODE_MORE_GENERAL:
3861
0
        mxSaveState; 
3862
0
        fxToPrimitive(the, slot, XS_NUMBER_HINT); 
3863
0
        fxToPrimitive(the, mxStack, XS_NUMBER_HINT); 
3864
0
        if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)))
3865
0
          offset = fxUTF8Compare(slot->value.string, mxStack->value.string) > 0;
3866
0
        else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND))
3867
0
          offset = gxTypeBigInt.compare(the, 0, 0, 1, slot, mxStack);
3868
0
        else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))
3869
0
          offset = gxTypeBigInt.compare(the, 1, 0, 0, mxStack, slot);
3870
0
        else {
3871
0
          fxToNumber(the, slot);
3872
0
          fxToNumber(the, mxStack);
3873
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number > mxStack->value.number);
3874
0
          mxFloatingPointOp("more");
3875
0
        }
3876
0
        mxRestoreState;
3877
0
      }
3878
0
      slot->kind = XS_BOOLEAN_KIND;
3879
0
      slot->value.boolean = offset;
3880
0
      mxStack++;
3881
0
      mxNextCode(1);
3882
0
      mxBreak;
3883
0
    mxCase(XS_CODE_MORE_EQUAL)
3884
0
      slot = mxStack + 1;
3885
0
      if (slot->kind == XS_INTEGER_KIND) {
3886
0
        if (mxStack->kind == XS_INTEGER_KIND)
3887
0
          offset = slot->value.integer >= mxStack->value.integer;
3888
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3889
0
          offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) >= mxStack->value.number);
3890
0
          mxFloatingPointOp("more or equal");
3891
0
        }
3892
0
        else
3893
0
          goto XS_CODE_MORE_EQUAL_GENERAL;
3894
0
      }
3895
0
      else if (slot->kind == XS_NUMBER_KIND) {
3896
0
        if (mxStack->kind == XS_INTEGER_KIND) {
3897
0
          offset = (!c_isnan(slot->value.number)) && (slot->value.number >= (txNumber)(mxStack->value.integer));
3898
0
          mxFloatingPointOp("more or equal");
3899
0
        }
3900
0
        else if (mxStack->kind == XS_NUMBER_KIND) {
3901
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number >= mxStack->value.number);
3902
0
          mxFloatingPointOp("more or equal");
3903
0
        }
3904
0
        else
3905
0
          goto XS_CODE_MORE_EQUAL_GENERAL;
3906
0
      }
3907
0
      else {
3908
0
    XS_CODE_MORE_EQUAL_GENERAL:
3909
0
        mxSaveState; 
3910
0
        fxToPrimitive(the, slot, XS_NUMBER_HINT); 
3911
0
        fxToPrimitive(the, mxStack, XS_NUMBER_HINT); 
3912
0
        if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)))
3913
0
          offset = fxUTF8Compare(slot->value.string, mxStack->value.string) >= 0;
3914
0
        else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND))
3915
0
          offset = gxTypeBigInt.compare(the, 0, 1, 1, slot, mxStack);
3916
0
        else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))
3917
0
          offset = gxTypeBigInt.compare(the, 1, 1, 0, mxStack, slot);
3918
0
        else {
3919
0
          fxToNumber(the, slot);
3920
0
          fxToNumber(the, mxStack);
3921
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number >= mxStack->value.number);
3922
0
          mxFloatingPointOp("more or equal");
3923
0
        }
3924
0
        mxRestoreState;
3925
0
      }
3926
0
      slot->kind = XS_BOOLEAN_KIND;
3927
0
      slot->value.boolean = offset;
3928
0
      mxStack++;
3929
0
      mxNextCode(1);
3930
0
      mxBreak;
3931
3932
0
    mxCase(XS_CODE_EQUAL)
3933
0
    mxCase(XS_CODE_STRICT_EQUAL)
3934
0
      slot = mxStack + 1;
3935
0
    XS_CODE_EQUAL_AGAIN:
3936
0
      if (slot->kind == mxStack->kind) {
3937
0
        if ((XS_UNDEFINED_KIND == slot->kind) || (XS_NULL_KIND == slot->kind))
3938
0
          offset = 1;
3939
0
        else if (XS_BOOLEAN_KIND == slot->kind)
3940
0
          offset = slot->value.boolean == stack->value.boolean;
3941
0
        else if (XS_INTEGER_KIND == slot->kind)
3942
0
          offset = slot->value.integer == stack->value.integer;
3943
0
        else if (XS_NUMBER_KIND == slot->kind) {
3944
0
          offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number == mxStack->value.number);
3945
0
          mxFloatingPointOp("equal");
3946
0
        }
3947
0
        else if ((XS_STRING_KIND == slot->kind) || (XS_STRING_X_KIND == slot->kind))
3948
0
          offset = c_strcmp(slot->value.string, mxStack->value.string) == 0;
3949
0
        else if (XS_SYMBOL_KIND == slot->kind)
3950
0
          offset = slot->value.symbol == mxStack->value.symbol;
3951
0
        else if (XS_REFERENCE_KIND == slot->kind)
3952
0
          offset = fxIsSameReference(the, slot, mxStack);
3953
      #if mxHostFunctionPrimitive
3954
        else if (XS_HOST_FUNCTION_KIND == slot->kind)
3955
          offset = slot->value.hostFunction.builder == mxStack->value.hostFunction.builder;
3956
      #endif
3957
0
        else if ((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind))
3958
0
          offset = gxTypeBigInt.compare(the, 0, 1, 0, slot, mxStack);
3959
0
        else
3960
0
                    offset = 0;
3961
0
      }
3962
0
      else if ((XS_INTEGER_KIND == slot->kind) && (XS_NUMBER_KIND == mxStack->kind)) {
3963
0
        offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) == stack->value.number);
3964
0
        mxFloatingPointOp("equal");
3965
0
      }
3966
0
      else if ((XS_NUMBER_KIND == slot->kind) && (XS_INTEGER_KIND == mxStack->kind)) {
3967
0
        offset = (!c_isnan(slot->value.number)) && (slot->value.number == (txNumber)(mxStack->value.integer));
3968
0
        mxFloatingPointOp("equal");
3969
0
      }
3970
0
      else if ((XS_STRING_KIND == slot->kind) && (XS_STRING_X_KIND == mxStack->kind))
3971
0
        offset = c_strcmp(slot->value.string, mxStack->value.string) == 0;
3972
0
      else if ((XS_STRING_X_KIND == slot->kind) && (XS_STRING_KIND == mxStack->kind))
3973
0
        offset = c_strcmp(slot->value.string, mxStack->value.string) == 0;
3974
0
      else if (XS_CODE_EQUAL == byte) {
3975
0
        if ((slot->kind == XS_UNDEFINED_KIND) && (mxStack->kind == XS_NULL_KIND))
3976
0
          offset = 1;
3977
0
        else if ((slot->kind == XS_NULL_KIND) && (mxStack->kind == XS_UNDEFINED_KIND))
3978
0
          offset = 1;
3979
0
        else if (((XS_INTEGER_KIND == slot->kind) || (XS_NUMBER_KIND == slot->kind)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) {
3980
0
          mxToNumber(mxStack); 
3981
0
          goto XS_CODE_EQUAL_AGAIN;
3982
0
        }
3983
0
        else if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == mxStack->kind) || (XS_NUMBER_KIND == mxStack->kind))) {
3984
0
          mxToNumber(slot);
3985
0
          goto XS_CODE_EQUAL_AGAIN;
3986
0
        }
3987
0
        else if (XS_BOOLEAN_KIND == slot->kind) {
3988
0
          mxToNumber(slot);
3989
0
          goto XS_CODE_EQUAL_AGAIN;
3990
0
        }
3991
0
        else if (XS_BOOLEAN_KIND == mxStack->kind) {
3992
0
          mxToNumber(mxStack);
3993
0
          goto XS_CODE_EQUAL_AGAIN;
3994
0
        }
3995
0
        else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (slot->kind == XS_SYMBOL_KIND) || (slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) && mxIsReference(mxStack)) {
3996
0
          mxSaveState;
3997
0
          fxToPrimitive(the, mxStack, XS_NO_HINT);
3998
0
          mxRestoreState;
3999
0
          goto XS_CODE_EQUAL_AGAIN;
4000
0
        }
4001
0
        else if (mxIsReference(slot) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_SYMBOL_KIND) || (mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))) {
4002
0
          mxSaveState;
4003
0
          fxToPrimitive(the, slot, XS_NO_HINT);
4004
0
          mxRestoreState;
4005
0
          goto XS_CODE_EQUAL_AGAIN;
4006
0
        }
4007
0
        else if (((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) {
4008
0
          mxSaveState;
4009
0
          offset = gxTypeBigInt.compare(the, 0, 1, 0, slot, mxStack);
4010
0
          mxRestoreState;
4011
0
        }
4012
0
        else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_BIGINT_KIND == mxStack->kind) || (XS_BIGINT_X_KIND == mxStack->kind))) {
4013
0
          mxSaveState;
4014
0
          offset = gxTypeBigInt.compare(the, 0, 1, 0, mxStack, slot);
4015
0
          mxRestoreState;
4016
0
        }
4017
0
                else
4018
0
                    offset = 0;
4019
0
      }
4020
0
      else 
4021
0
        offset = 0;
4022
0
      slot->kind = XS_BOOLEAN_KIND;
4023
0
      slot->value.boolean = offset;
4024
0
      mxStack++;
4025
0
      mxNextCode(1);
4026
0
      mxBreak;
4027
0
    mxCase(XS_CODE_NOT_EQUAL)
4028
0
    mxCase(XS_CODE_STRICT_NOT_EQUAL)
4029
0
      slot = mxStack + 1;
4030
0
    XS_CODE_NOT_EQUAL_AGAIN:
4031
0
      if (slot->kind == mxStack->kind) {
4032
0
        if ((XS_UNDEFINED_KIND == slot->kind) || (XS_NULL_KIND == slot->kind))
4033
0
          offset = 0;
4034
0
        else if (XS_BOOLEAN_KIND == slot->kind)
4035
0
          offset = slot->value.boolean != stack->value.boolean;
4036
0
        else if (XS_INTEGER_KIND == slot->kind)
4037
0
          offset = slot->value.integer != stack->value.integer;
4038
0
        else if (XS_NUMBER_KIND == slot->kind) {
4039
0
          offset = (c_isnan(slot->value.number)) || (c_isnan(mxStack->value.number)) || (slot->value.number != mxStack->value.number);
4040
0
          mxFloatingPointOp("not equal");
4041
0
        }
4042
0
        else if ((XS_STRING_KIND == slot->kind) || (XS_STRING_X_KIND == slot->kind))
4043
0
          offset = c_strcmp(slot->value.string, mxStack->value.string) != 0;
4044
0
        else if (XS_SYMBOL_KIND == slot->kind)
4045
0
          offset = slot->value.symbol != mxStack->value.symbol;
4046
0
        else if (XS_REFERENCE_KIND == slot->kind)
4047
0
          offset = !fxIsSameReference(the, slot, mxStack);
4048
      #if mxHostFunctionPrimitive
4049
        else if (XS_HOST_FUNCTION_KIND == slot->kind)
4050
          offset = slot->value.hostFunction.builder != mxStack->value.hostFunction.builder;
4051
      #endif
4052
0
        else if ((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind))
4053
0
          offset = gxTypeBigInt.compare(the, 1, 0, 1, slot, mxStack);
4054
0
                else
4055
0
                  offset = 1;
4056
0
      }
4057
0
      else if ((XS_INTEGER_KIND == slot->kind) && (XS_NUMBER_KIND == mxStack->kind)) {
4058
0
        offset = (c_isnan(mxStack->value.number)) || ((txNumber)(slot->value.integer) != stack->value.number);
4059
0
        mxFloatingPointOp("not equal");
4060
0
      }
4061
0
      else if ((XS_NUMBER_KIND == slot->kind) && (XS_INTEGER_KIND == mxStack->kind)) {
4062
0
        offset = (c_isnan(slot->value.number)) || (slot->value.number != (txNumber)(mxStack->value.integer));
4063
0
        mxFloatingPointOp("not equal");
4064
0
      }
4065
0
      else if ((XS_STRING_KIND == slot->kind) && (XS_STRING_X_KIND == mxStack->kind))
4066
0
        offset = c_strcmp(slot->value.string, mxStack->value.string) != 0;
4067
0
      else if ((XS_STRING_X_KIND == slot->kind) && (XS_STRING_KIND == mxStack->kind))
4068
0
        offset = c_strcmp(slot->value.string, mxStack->value.string) != 0;
4069
0
      else if (XS_CODE_NOT_EQUAL == byte) {
4070
0
        if ((slot->kind == XS_UNDEFINED_KIND) && (mxStack->kind == XS_NULL_KIND))
4071
0
          offset = 0;
4072
0
        else if ((slot->kind == XS_NULL_KIND) && (mxStack->kind == XS_UNDEFINED_KIND))
4073
0
          offset = 0;
4074
0
        else if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == mxStack->kind) || (XS_NUMBER_KIND == mxStack->kind))) {
4075
0
          mxToNumber(slot);
4076
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4077
0
        }
4078
0
        else if (((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == slot->kind) || (XS_NUMBER_KIND == slot->kind))) {
4079
0
          mxToNumber(mxStack); 
4080
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4081
0
        }
4082
0
        else if (XS_BOOLEAN_KIND == slot->kind) {
4083
0
          mxToNumber(slot);
4084
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4085
0
        }
4086
0
        else if (XS_BOOLEAN_KIND == mxStack->kind) {
4087
0
          mxToNumber(mxStack);
4088
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4089
0
        }
4090
0
        else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (slot->kind == XS_SYMBOL_KIND) || (slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) && mxIsReference(mxStack)) {
4091
0
          mxSaveState;
4092
0
          fxToPrimitive(the, mxStack, XS_NO_HINT);
4093
0
          mxRestoreState;
4094
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4095
0
        }
4096
0
        else if (mxIsReference(slot) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_SYMBOL_KIND) || (mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))) {
4097
0
          mxSaveState;
4098
0
          fxToPrimitive(the, slot, XS_NO_HINT);
4099
0
          mxRestoreState;
4100
0
          goto XS_CODE_NOT_EQUAL_AGAIN;
4101
0
        }
4102
0
        else if (((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) {
4103
0
          mxSaveState;
4104
0
          offset = gxTypeBigInt.compare(the, 1, 0, 1, slot, mxStack);
4105
0
          mxRestoreState;
4106
0
        }
4107
0
        else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_BIGINT_KIND == mxStack->kind) || (XS_BIGINT_X_KIND == mxStack->kind))) {
4108
0
          mxSaveState;
4109
0
          offset = gxTypeBigInt.compare(the, 1, 0, 1, mxStack, slot);
4110
0
          mxRestoreState;
4111
0
        }
4112
0
                else
4113
0
                offset = 1;
4114
0
      }
4115
0
      else 
4116
0
        offset = 1;
4117
0
      slot->kind = XS_BOOLEAN_KIND;
4118
0
      slot->value.boolean = offset;
4119
0
      mxStack++;
4120
0
      mxNextCode(1);
4121
0
      mxBreak;
4122
      
4123
0
    mxCase(XS_CODE_FOR_AWAIT_OF)
4124
0
      mxNextCode(1);
4125
0
      mxSaveState;
4126
0
      gxDefaults.runForAwaitOf(the);
4127
0
      mxRestoreState;
4128
0
      mxBreak;
4129
0
    mxCase(XS_CODE_FOR_IN)
4130
0
      mxSkipCode(1);
4131
      /* FUNCTION */
4132
0
      mxAllocStack(1);
4133
0
      *mxStack = mxEnumeratorFunction;
4134
0
      slot = fxGetInstance(the, mxStack);
4135
      /* RESULT */
4136
0
      mxPushKind(XS_UNDEFINED_KIND);
4137
0
      mxPushKind(XS_UNDEFINED_KIND);
4138
0
      offset = 0;
4139
0
      goto XS_CODE_RUN_ALL;
4140
4141
0
    mxCase(XS_CODE_FOR_OF)
4142
0
      mxNextCode(1);
4143
0
      mxSaveState;
4144
0
      fxRunForOf(the);
4145
0
      mxRestoreState;
4146
0
      mxBreak;
4147
      
4148
0
    mxCase(XS_CODE_IN)
4149
0
      mxNextCode(1);
4150
0
      if (!mxIsReference(mxStack))
4151
0
        mxRunDebug(XS_TYPE_ERROR, "in: not an object");
4152
0
      mxSaveState;
4153
0
      fxRunIn(the);
4154
0
      mxRestoreState;
4155
0
      mxBreak;
4156
0
    mxCase(XS_CODE_INSTANCEOF)
4157
0
      mxNextCode(1);
4158
0
      mxSaveState;
4159
0
      fxRunInstanceOf(the);
4160
0
      mxRestoreState;
4161
0
      mxBreak;
4162
0
    mxCase(XS_CODE_TYPEOF)
4163
0
      byte = mxStack->kind;
4164
0
      if (XS_UNDEFINED_KIND == byte)
4165
0
        *mxStack = mxUndefinedString;
4166
0
      else if (XS_NULL_KIND == byte)
4167
0
        *mxStack = mxObjectString;
4168
0
      else if (XS_BOOLEAN_KIND == byte)
4169
0
        *mxStack = mxBooleanString;
4170
0
      else if ((XS_INTEGER_KIND == byte) || (XS_NUMBER_KIND == byte))
4171
0
        *mxStack = mxNumberString;
4172
0
      else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte))
4173
0
        *mxStack = mxStringString;
4174
0
      else if (XS_SYMBOL_KIND == byte)
4175
0
        *mxStack = mxSymbolString;
4176
0
      else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte))
4177
0
        *mxStack = mxBigIntString;
4178
0
      else if (XS_REFERENCE_KIND == byte) {
4179
0
        slot = fxGetInstance(the, mxStack);
4180
0
        if (slot->flag & XS_CAN_CALL_FLAG)
4181
0
          *mxStack = mxFunctionString;
4182
0
        else
4183
0
          *mxStack = mxObjectString;
4184
0
      }
4185
    #if mxHostFunctionPrimitive
4186
      else if (XS_HOST_FUNCTION_KIND == byte)
4187
        *mxStack = mxFunctionString;
4188
    #endif
4189
0
      mxNextCode(1);
4190
0
      mxBreak;
4191
0
    mxCase(XS_CODE_VOID)
4192
0
      mxNextCode(1);
4193
0
      mxStack->kind = XS_UNDEFINED_KIND;
4194
0
      mxBreak;
4195
4196
  /* DEBUG */    
4197
0
    mxCase(XS_CODE_DEBUGGER)
4198
0
      mxNextCode(1);
4199
0
    #ifdef mxDebug
4200
0
      if (!the->debugEval) {
4201
0
        mxSaveState;
4202
0
        fxDebugLoop(the, C_NULL, 0, "debugger");
4203
0
        mxRestoreState;
4204
0
      }
4205
0
    #endif
4206
0
      mxBreak;
4207
0
    mxCase(XS_CODE_FILE)
4208
0
    #ifdef mxDebug
4209
0
      count = mxRunID(1);
4210
#ifdef mxTrace
4211
      if (gxDoTrace) fxTraceID(the, count, 0);
4212
#endif
4213
0
      mxEnvironment->ID = count;
4214
0
      mxEnvironment->value.environment.line = 0;
4215
0
    #endif
4216
0
      mxNextCode(1 + sizeof(txID));
4217
0
      mxBreak;
4218
0
    mxCase(XS_CODE_LINE)
4219
0
    #ifdef mxDebug
4220
0
      count = mxRunS2(1);
4221
#ifdef mxTrace
4222
      if (gxDoTrace) fxTraceInteger(the, count);
4223
#endif
4224
0
      if (count == 0) {
4225
0
        count = mxFunctionInstanceCode(mxFrameFunction->value.reference)->ID;
4226
0
        if ((mxEnvironment->ID != XS_NO_ID) && (count != XS_NO_ID) && mxBreakpoints.value.list.first) {
4227
0
          mxSaveState;
4228
0
          fxDebugLine(the, mxEnvironment->ID, mxEnvironment->value.environment.line, count);
4229
0
          mxRestoreState;
4230
0
        }
4231
0
      }
4232
0
      else {
4233
0
        mxEnvironment->value.environment.line = count;
4234
0
        if (fxIsReadable(the)) {
4235
0
          mxSaveState;
4236
0
          fxDebugCommand(the);
4237
0
          mxRestoreState;
4238
0
        }
4239
0
        if ((mxEnvironment->ID != XS_NO_ID) && ((mxFrame->flag & XS_STEP_OVER_FLAG) || mxBreakpoints.value.list.first)) {
4240
0
          mxSaveState;
4241
0
          fxDebugLine(the, mxEnvironment->ID, mxEnvironment->value.environment.line, XS_NO_ID);
4242
0
          mxRestoreState;
4243
0
        }
4244
0
      }
4245
0
    #endif
4246
0
    #if defined(mxInstrument) || defined(mxProfile)
4247
0
      fxCheckProfiler(the, mxFrame);
4248
0
    #endif
4249
0
      mxNextCode(3);
4250
0
      mxBreak;
4251
4252
  /* MODULE */    
4253
0
    mxCase(XS_CODE_IMPORT)
4254
0
      slot = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
4255
0
      variable = mxModuleInstanceInternal(slot);
4256
0
      variable = variable->value.module.realm;
4257
0
      if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
4258
0
      mxSaveState;
4259
0
      gxDefaults.runImport(the, variable, slot);
4260
0
      mxRestoreState;
4261
0
      mxNextCode(1);
4262
0
      mxBreak;
4263
0
    mxCase(XS_CODE_IMPORT_META)
4264
0
      slot = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
4265
0
      mxSaveState;
4266
0
      fxRunImportMeta(the, slot);
4267
0
      mxRestoreState;
4268
0
      mxNextCode(1);
4269
0
      mxBreak;
4270
0
    mxCase(XS_CODE_TRANSFER)
4271
0
      mxSaveState;
4272
0
      fxPrepareTransfer(the, XS_NO_FLAG);
4273
0
      mxRestoreState;
4274
0
            mxNextCode(1);
4275
0
      mxBreak;
4276
0
    mxCase(XS_CODE_TRANSFER_JSON)
4277
0
      mxSaveState;
4278
0
      fxPrepareTransfer(the, XS_JSON_MODULE_FLAG);
4279
0
      mxRestoreState;
4280
0
            mxNextCode(1);
4281
0
      mxBreak;
4282
0
    mxCase(XS_CODE_MODULE)
4283
0
      byte = mxRunU1(1);
4284
0
      mxSaveState;
4285
0
      fxPrepareModule(the, byte);
4286
0
      mxRestoreState;
4287
0
            mxNextCode(2);
4288
0
      mxBreak;
4289
      
4290
  /* EVAL, PROGRAM & WITH */
4291
0
    mxCase(XS_CODE_EVAL)
4292
0
      offset = mxStack->value.integer;
4293
0
      slot = mxStack + 1 + offset + 2;
4294
0
      if (mxIsReference(slot) && mxIsFunction(slot->value.reference) && (mxFunctionInstanceCode(slot->value.reference)->value.callback.address == mxFunctionInstanceCode(mxEvalFunction.value.reference)->value.callback.address)) {
4295
0
        mxSaveState;
4296
0
        gxDefaults.runEval(the);
4297
0
        mxRestoreState;
4298
0
        mxNextCode(1);
4299
0
        mxBreak;
4300
0
      }
4301
0
      mxSkipCode(1);
4302
0
      mxStack++;
4303
0
      goto XS_CODE_RUN_ALL;
4304
0
    mxCase(XS_CODE_EVAL_TAIL)
4305
0
      offset = mxStack->value.integer;
4306
0
      slot = mxStack + 1 + offset + 2;
4307
0
      if (mxIsReference(slot) && mxIsFunction(slot->value.reference) && (mxFunctionInstanceCode(slot->value.reference)->value.callback.address == mxFunctionInstanceCode(mxEvalFunction.value.reference)->value.callback.address)) {
4308
0
        mxSaveState;
4309
0
        gxDefaults.runEval(the);
4310
0
        mxRestoreState;
4311
0
        mxNextCode(1);
4312
0
        mxBreak;
4313
0
      }
4314
0
      mxSkipCode(1);
4315
0
      mxStack++;
4316
0
      goto XS_CODE_RUN_TAIL_ALL;
4317
0
    mxCase(XS_CODE_EVAL_ENVIRONMENT)
4318
0
      mxNextCode(1);
4319
0
      mxSaveState;
4320
0
      gxDefaults.runEvalEnvironment(the);
4321
0
      mxRestoreState;
4322
0
      mxBreak;
4323
0
    mxCase(XS_CODE_EVAL_PRIVATE)
4324
0
      offset = mxRunID(1);
4325
    #ifdef mxTrace
4326
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
4327
    #endif
4328
0
      mxNextCode(1 + sizeof(txID));
4329
0
      variable = mxEnvironment;
4330
0
      if (variable->kind == XS_REFERENCE_KIND) {
4331
0
        variable = variable->value.reference;
4332
0
    XS_CODE_EVAL_PRIVATE_AGAIN:
4333
0
        if (variable) {
4334
0
          slot = mxBehaviorGetProperty(the, variable, (txID)offset, 0, XS_OWN);
4335
0
          if (slot) {
4336
0
            mxPushKind(slot->kind);
4337
0
            mxStack->value = slot->value;
4338
0
            mxBreak;
4339
0
          }
4340
0
          variable = variable->value.instance.prototype;
4341
0
          goto XS_CODE_EVAL_PRIVATE_AGAIN;
4342
0
        }
4343
0
      }
4344
0
      mxRunDebugID(XS_SYNTAX_ERROR, "eval %s: undefined private property", (txID)offset);
4345
0
      mxBreak;
4346
0
    mxCase(XS_CODE_EVAL_REFERENCE)
4347
0
      offset = mxRunID(1);
4348
    #ifdef mxTrace
4349
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
4350
    #endif
4351
0
      mxNextCode(1 + sizeof(txID));
4352
0
      variable = mxEnvironment;
4353
0
      if (variable->kind == XS_REFERENCE_KIND) {
4354
0
        variable = variable->value.reference;
4355
0
    XS_CODE_EVAL_REFERENCE_AGAIN:
4356
0
        if (variable->value.instance.prototype) {
4357
0
          slot = variable->next;
4358
0
          if (slot->kind == XS_REFERENCE_KIND) {
4359
0
            slot = slot->value.reference;
4360
0
            mxSaveState;
4361
0
            index = fxIsScopableSlot(the, slot, (txID)offset);
4362
0
            mxRestoreState;
4363
0
            if (index) {
4364
//              if (fxRunHas(the, slot, (txID)offset, 0)) {
4365
0
                if (XS_CODE_GET_THIS_VARIABLE == byte) {
4366
0
                  mxStack->kind = XS_REFERENCE_KIND;
4367
0
                  mxStack->value.reference = slot;
4368
0
                }
4369
0
                mxPushKind(XS_REFERENCE_KIND);
4370
0
                mxStack->value.reference = slot;
4371
0
                mxBreak;
4372
//              }
4373
0
            }
4374
0
          }
4375
0
          else if (mxBehaviorHasProperty(the, variable, (txID)offset, 0)) {
4376
0
            mxPushKind(XS_REFERENCE_KIND);
4377
0
            mxStack->value.reference = variable;
4378
0
            mxBreak;
4379
0
          }
4380
0
          variable = variable->value.instance.prototype;
4381
0
          goto XS_CODE_EVAL_REFERENCE_AGAIN;
4382
0
        }
4383
0
        if (mxBehaviorHasProperty(the, variable, (txID)offset, 0)) {
4384
0
          mxPushKind(XS_REFERENCE_KIND);
4385
0
          mxStack->value.reference = variable;
4386
0
          mxBreak;
4387
0
        }
4388
0
      }
4389
0
      mxPushKind(XS_REFERENCE_KIND);
4390
0
      variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
4391
0
      variable = mxModuleInstanceInternal(variable)->value.module.realm;
4392
0
      if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
4393
0
      mxStack->value.reference = mxRealmGlobal(variable)->value.reference;
4394
0
      mxBreak;
4395
0
    mxCase(XS_CODE_FUNCTION_ENVIRONMENT)  
4396
0
      variable = mxEnvironment;
4397
0
      mxPushKind(XS_UNDEFINED_KIND);
4398
0
      mxSaveState;
4399
0
      slot = fxNewEnvironmentInstance(the, variable);
4400
0
      mxRestoreState;
4401
0
      variable = mxFunctionInstanceCode((mxStack + 1)->value.reference);
4402
0
      variable->value.code.closures = slot;
4403
0
      mxNextCode(1);
4404
0
      mxBreak;
4405
0
    mxCase(XS_CODE_PROGRAM_ENVIRONMENT)
4406
0
      mxNextCode(1);
4407
0
      mxSaveState;
4408
0
      gxDefaults.runProgramEnvironment(the);
4409
0
      mxRestoreState;
4410
0
      mxBreak;
4411
0
    mxCase(XS_CODE_PROGRAM_REFERENCE)
4412
0
      offset = mxRunID(1);
4413
    #ifdef mxTrace
4414
      if (gxDoTrace) fxTraceID(the, (txID)offset, 0);
4415
    #endif
4416
0
      mxNextCode(1 + sizeof(txID));
4417
0
            variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module;
4418
0
            variable = mxModuleInstanceInternal(variable)->value.module.realm;
4419
0
            if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm;
4420
0
            slot = mxRealmClosures(variable)->value.reference;
4421
0
            if (mxBehaviorHasProperty(the, slot, (txID)offset, 0)) {
4422
0
                mxPushKind(XS_REFERENCE_KIND);
4423
0
                mxStack->value.reference = slot;
4424
0
                mxBreak;
4425
0
            }
4426
0
      mxPushKind(XS_REFERENCE_KIND);
4427
0
      mxStack->value.reference = mxRealmGlobal(variable)->value.reference;
4428
0
      mxBreak;
4429
0
    mxCase(XS_CODE_WITH)
4430
0
      variable = mxEnvironment;
4431
0
      mxSaveState;
4432
0
      slot = fxNewEnvironmentInstance(the, variable);
4433
0
      mxRestoreState;
4434
0
      variable->kind = XS_REFERENCE_KIND;
4435
0
      variable->value.reference = slot;
4436
0
      mxNextCode(1);
4437
0
      mxBreak;
4438
0
    mxCase(XS_CODE_WITHOUT)
4439
0
      variable = mxEnvironment;
4440
0
      slot = variable->value.reference->value.instance.prototype;
4441
0
      if (slot) {
4442
0
        variable->kind = XS_REFERENCE_KIND;
4443
0
        variable->value.reference = slot;
4444
0
      }
4445
0
      else
4446
0
        variable->kind = XS_NULL_KIND;
4447
0
      mxNextCode(1);
4448
0
      mxBreak;
4449
0
    }
4450
0
  }
4451
4452
0
STACK_OVERFLOW:
4453
0
  mxSaveState;
4454
0
  fxAbort(the, XS_JAVASCRIPT_STACK_OVERFLOW_EXIT);
4455
0
}
4456
4457
#ifdef mxMetering
4458
4459
void fxBeginMetering(txMachine* the, txBoolean (*callback)(txMachine*, txU8), txU8 interval)
4460
6.07k
{
4461
6.07k
  the->meterCallback = callback;
4462
6.07k
  the->meterCount = ((txU8)interval) << 16;
4463
6.07k
  the->meterIndex = 0;
4464
6.07k
  the->meterInterval = ((txU8)interval) << 16;
4465
6.07k
}
4466
4467
void fxEndMetering(txMachine* the)
4468
6.07k
{
4469
6.07k
  the->meterCallback = C_NULL;
4470
6.07k
  the->meterIndex = 0;
4471
6.07k
  the->meterInterval = 0;
4472
6.07k
  the->meterCount = 0;
4473
6.07k
}
4474
4475
void fxCheckMetering(txMachine* the)
4476
0
{
4477
0
  txU8 interval = the->meterInterval;
4478
0
  the->meterInterval = 0;
4479
0
  if ((*the->meterCallback)(the, the->meterIndex >> 16)) {
4480
0
    the->meterCount = the->meterIndex + interval;
4481
0
    if (the->meterCount < the->meterIndex) {
4482
0
      the->meterIndex = 0;
4483
0
      the->meterCount = interval;
4484
0
    }
4485
0
    the->meterInterval = interval;
4486
0
  }
4487
0
  else {
4488
0
    fxAbort(the, XS_TOO_MUCH_COMPUTATION_EXIT);
4489
0
  }
4490
0
}
4491
#endif
4492
4493
void fxRunArguments(txMachine* the, txIndex offset)
4494
0
{
4495
0
  txSlot* array;
4496
0
  txIndex length = (txIndex)mxArgc;
4497
0
  txIndex index;
4498
0
  txSlot* address;
4499
0
  mxPush(mxArrayPrototype);
4500
0
  array = fxNewArrayInstance(the)->next;
4501
0
  if (offset < length) {
4502
0
    length -= offset;
4503
0
    fxSetIndexSize(the, array, length, XS_CHUNK);
4504
0
    index = 0;
4505
0
    address = array->value.array.address;
4506
0
    while (index < length) {
4507
0
      txSlot* property = mxArgv(offset + index);
4508
0
      *((txIndex*)address) = index;
4509
0
      address->ID = XS_NO_ID;
4510
0
      address->kind = property->kind;
4511
0
      address->value = property->value;
4512
0
      index++;
4513
0
      address++;
4514
0
    }
4515
0
  }
4516
0
}
4517
4518
void fxRunBase(txMachine* the)
4519
0
{
4520
0
  if (!mxHasTarget)
4521
0
    mxTypeError("call: class");
4522
0
  fxRunConstructor(the);
4523
0
}
4524
4525
void fxRunConstructor(txMachine* the)
4526
0
{
4527
0
  txSlot* target;
4528
0
  txSlot* prototype;
4529
0
  target = mxTarget;
4530
0
  mxPushUndefined();
4531
0
  prototype = the->stack;
4532
0
  fxBeginHost(the);
4533
0
  mxPushSlot(target);
4534
0
  fxGetPrototypeFromConstructor(the, &mxObjectPrototype);
4535
0
  *prototype = *the->stack;
4536
0
  fxEndHost(the);
4537
0
  fxNewHostInstance(the);
4538
0
  mxPullSlot(mxThis);
4539
0
}
4540
4541
txBoolean fxRunDefine(txMachine* the, txSlot* instance, txSlot* check, txID id, txIndex index, txSlot* slot, txFlag mask) 
4542
0
{
4543
0
  txBoolean result;
4544
0
  if (check) {
4545
0
    result = gxDefaults.definePrivateProperty(the, instance, check, id, slot, mask);
4546
0
  }
4547
0
  else {
4548
0
    fxBeginHost(the);
4549
0
    mxCheck(the, instance->kind == XS_INSTANCE_KIND);
4550
0
    result = mxBehaviorDefineOwnProperty(the, instance, id, index, slot, mask);
4551
0
    fxEndHost(the);
4552
0
  }
4553
0
  return result;
4554
0
}
4555
4556
4557
txBoolean fxRunDelete(txMachine* the, txSlot* instance, txID id, txIndex index) 
4558
0
{
4559
0
  txBoolean result;
4560
0
  fxBeginHost(the);
4561
0
  mxCheck(the, instance->kind == XS_INSTANCE_KIND);
4562
0
  result = mxBehaviorDeleteProperty(the, instance, id, index);
4563
0
  fxEndHost(the);
4564
0
  return result;
4565
0
}
4566
4567
void fxRunDerived(txMachine* the)
4568
0
{
4569
0
  txSlot* slot;
4570
0
  if (!mxHasTarget)
4571
0
    mxTypeError("call: class");
4572
0
  slot = fxNewSlot(the);
4573
0
  slot->kind = XS_UNINITIALIZED_KIND;
4574
0
  mxPushClosure(slot);
4575
0
  mxPullSlot(mxThis);
4576
0
}
4577
4578
void fxRunExtends(txMachine* the)
4579
0
{
4580
0
  txSlot* constructor;
4581
0
  txSlot* prototype;
4582
  
4583
0
  constructor = fxGetInstance(the, the->stack);
4584
0
  if (!mxIsConstructor(constructor))
4585
0
    mxTypeError("extends: class is not a constructor");
4586
0
  mxPushUndefined();
4587
0
  prototype = the->stack;
4588
0
  fxBeginHost(the);
4589
0
  mxPushReference(constructor);
4590
0
  mxGetID(mxID(_prototype));
4591
0
  *prototype = *the->stack;
4592
0
  fxEndHost(the);
4593
0
  if (the->stack->kind == XS_NULL_KIND) {
4594
0
    mxPop();
4595
0
    fxNewInstance(the);
4596
0
  }
4597
0
  else if (the->stack->kind == XS_REFERENCE_KIND) {
4598
0
    if (the->stack->value.reference->value.instance.prototype == mxGeneratorPrototype.value.reference)
4599
0
      mxTypeError("extends: class is a generator");
4600
0
    fxNewHostInstance(the);
4601
0
  }
4602
0
  else
4603
0
    mxTypeError("extends: class prototype is not an object");
4604
0
}
4605
4606
void fxRunEval(txMachine* the)
4607
0
{ 
4608
0
  txStringStream aStream;
4609
0
  txUnsigned flags;
4610
0
  txSlot* function;
4611
0
  txSlot* home;
4612
0
  txSlot* closures;
4613
0
  if (the->stack->value.integer == 0)
4614
0
    the->stack->kind = XS_UNDEFINED_KIND;
4615
0
  else
4616
0
    the->stack += the->stack->value.integer;
4617
0
  the->stack[4] = the->stack[0];
4618
0
  the->stack += 4;
4619
0
  if ((the->stack->kind == XS_STRING_KIND) || (the->stack->kind == XS_STRING_X_KIND)) {
4620
0
    aStream.slot = the->stack;
4621
0
    aStream.offset = 0;
4622
0
    aStream.size = mxStringLength(fxToString(the, aStream.slot));
4623
0
    flags = mxProgramFlag | mxEvalFlag;
4624
0
    if (the->frame->flag & XS_STRICT_FLAG)
4625
0
      flags |= mxStrictFlag;
4626
0
    if (the->frame->flag & XS_FIELD_FLAG)
4627
0
      flags |= mxFieldFlag;
4628
0
    function = mxFunction->value.reference;
4629
0
    if (function->flag & XS_CAN_CONSTRUCT_FLAG)
4630
0
      flags |= mxTargetFlag;
4631
0
    home = mxFunctionInstanceHome(function);
4632
0
    if (home->value.home.object)
4633
0
      flags |= mxSuperFlag;
4634
0
    closures = mxFrameToEnvironment(the->frame);
4635
0
    if (closures->kind == XS_REFERENCE_KIND)
4636
0
      closures = closures->value.reference;
4637
0
    else
4638
0
      closures = C_NULL;
4639
0
    fxRunScript(the, fxParseScript(the, &aStream, fxStringGetter, flags), mxThis, mxHasTarget ? mxTarget : C_NULL, closures, home->value.home.object, home->value.home.module);
4640
0
    aStream.slot->kind = the->stack->kind;
4641
0
    aStream.slot->value = the->stack->value;
4642
0
    mxPop();
4643
0
  }
4644
0
}
4645
4646
void fxRunForAwaitOf(txMachine* the)
4647
0
{
4648
0
  txSlot* slot = the->stack;
4649
0
  fxBeginHost(the);
4650
0
  mxPushSlot(slot);
4651
0
  mxDub();
4652
0
  mxGetID(mxID(_Symbol_asyncIterator));
4653
0
  if (mxIsUndefined(the->stack) || mxIsNull(the->stack)) {
4654
0
    mxPop();
4655
0
    mxPop();
4656
0
    fxGetIterator(the, slot, the->stack, C_NULL, 0);
4657
0
    fxNewAsyncFromSyncIteratorInstance(the);
4658
0
  }
4659
0
  else {
4660
0
    mxCall();
4661
0
    mxRunCount(0);
4662
0
  }
4663
0
  mxPullSlot(slot);
4664
0
  fxEndHost(the);
4665
0
}
4666
4667
void fxRunForOf(txMachine* the)
4668
0
{
4669
0
  txSlot* slot = the->stack;
4670
0
  fxBeginHost(the);
4671
0
  fxGetIterator(the, slot, slot, C_NULL, 0);
4672
0
  fxEndHost(the);
4673
0
}
4674
4675
txBoolean fxRunHas(txMachine* the, txSlot* instance, txID id, txIndex index)
4676
0
{
4677
0
  txBoolean result;
4678
0
  fxBeginHost(the);
4679
0
  result = mxBehaviorHasProperty(the, instance, id, index);
4680
0
  fxEndHost(the);
4681
0
  return result;
4682
0
}
4683
4684
void fxRunIn(txMachine* the)
4685
0
{
4686
0
  txSlot* left = the->stack + 1;
4687
0
  txSlot* right = the->stack;
4688
0
  fxBeginHost(the);
4689
0
  mxPushSlot(right);
4690
0
  mxPushSlot(left);
4691
0
  left->value.boolean = fxHasAt(the);
4692
0
  left->kind = XS_BOOLEAN_KIND;
4693
0
  fxEndHost(the);
4694
0
  mxPop();
4695
0
}
4696
4697
void fxRunInstanceOf(txMachine* the)
4698
0
{
4699
0
  txSlot* left = the->stack + 1;
4700
0
  txSlot* right = the->stack;
4701
0
  fxBeginHost(the);
4702
0
  mxPushSlot(right);
4703
0
  mxDub();
4704
0
  mxGetID(mxID(_Symbol_hasInstance));
4705
0
  mxCall();
4706
0
  mxPushSlot(left);
4707
0
  mxRunCount(1);
4708
0
  fxToBoolean(the, the->stack);
4709
0
  mxPullSlot(left);
4710
0
  fxEndHost(the);
4711
0
  mxPop();
4712
0
}
4713
4714
void fxRunInstantiate(txMachine* the)
4715
0
{
4716
0
  if (the->stack->kind == XS_NULL_KIND) {
4717
0
    mxPop();
4718
0
    fxNewInstance(the);
4719
0
  }
4720
0
  else if (the->stack->kind == XS_REFERENCE_KIND) {
4721
0
    fxNewHostInstance(the);
4722
0
  }
4723
0
  else {
4724
0
    mxPop();
4725
0
    mxPush(mxObjectPrototype);
4726
0
    fxNewObjectInstance(the);
4727
0
  }
4728
0
}
4729
4730
void fxRunProxy(txMachine* the, txSlot* instance)
4731
0
{
4732
0
  txSlot* array;
4733
0
  txIndex length = (txIndex)mxArgc;
4734
0
  txIndex index;
4735
0
  txSlot* address;
4736
0
  mxPush(mxArrayPrototype);
4737
0
  array = fxNewArrayInstance(the)->next;
4738
0
  fxSetIndexSize(the, array, length, XS_CHUNK);
4739
0
  index = 0;
4740
0
  address = array->value.array.address;
4741
0
  while (index < length) {
4742
0
    txSlot* property = mxArgv(index);
4743
0
    *((txIndex*)address) = index;
4744
0
    address->ID = XS_NO_ID;
4745
0
    address->kind = property->kind;
4746
0
    address->value = property->value;
4747
0
    index++;
4748
0
    address++;
4749
0
  }
4750
0
  if (!mxHasTarget)
4751
0
    mxBehaviorCall(the, instance, mxThis, the->stack);
4752
0
  else if (instance->flag & XS_CAN_CONSTRUCT_FLAG)
4753
0
    mxBehaviorConstruct(the, instance, the->stack, mxTarget);
4754
0
  else
4755
0
    mxTypeError("new: proxy is not a constructor");
4756
0
  mxPop();
4757
0
}
4758
4759
txBoolean fxIsSameReference(txMachine* the, txSlot* a, txSlot* b)
4760
0
{ 
4761
0
  a = a->value.reference;
4762
0
  b = b->value.reference;
4763
0
  if (a == b)
4764
0
    return 1;
4765
#if mxAliasInstance
4766
  if (a->ID) {
4767
    txSlot* alias = the->aliasArray[a->ID];
4768
    if (alias) {
4769
      a = alias;
4770
      if (a == b)
4771
        return 1;
4772
    }
4773
  }
4774
  if (b->ID) {
4775
    txSlot* alias = the->aliasArray[b->ID];
4776
    if (alias) {
4777
      b = alias;
4778
      if (a == b)
4779
        return 1;
4780
    }
4781
  }
4782
#endif
4783
0
  return 0;
4784
0
}
4785
4786
txBoolean fxIsSameSlot(txMachine* the, txSlot* a, txSlot* b)
4787
0
{ 
4788
0
  txBoolean result = 0;
4789
0
  if (a->kind == b->kind) {
4790
0
    if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind))
4791
0
      result = 1;
4792
0
    else if (XS_BOOLEAN_KIND == a->kind)
4793
0
      result = a->value.boolean == b->value.boolean;
4794
0
    else if (XS_INTEGER_KIND == a->kind)
4795
0
      result = a->value.integer == b->value.integer;
4796
0
        else if (XS_NUMBER_KIND == a->kind) {
4797
0
      result = (!c_isnan(a->value.number)) && (!c_isnan(b->value.number)) && (a->value.number == b->value.number);
4798
0
      mxFloatingPointOp("same slot");
4799
0
    }
4800
0
    else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind))
4801
0
      result = c_strcmp(a->value.string, b->value.string) == 0;
4802
0
    else if (XS_SYMBOL_KIND == a->kind)
4803
0
      result = a->value.symbol == b->value.symbol;
4804
0
    else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind))
4805
0
      result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4806
0
    else if (XS_REFERENCE_KIND == a->kind)
4807
0
      result = fxIsSameReference(the, a, b);
4808
0
  }
4809
0
  else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) {
4810
0
    result = (!c_isnan(b->value.number)) && ((txNumber)(a->value.integer) == b->value.number);
4811
0
    mxFloatingPointOp("same slot");
4812
0
  }
4813
0
  else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) {
4814
0
    result = (!c_isnan(a->value.number)) && (a->value.number == (txNumber)(b->value.integer));
4815
0
    mxFloatingPointOp("same slot");
4816
0
  }
4817
0
  else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind))
4818
0
    result = c_strcmp(a->value.string, b->value.string) == 0;
4819
0
  else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind))
4820
0
    result = c_strcmp(a->value.string, b->value.string) == 0;
4821
0
  else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind))
4822
0
    result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4823
0
  else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind))
4824
0
    result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4825
0
  return result;
4826
0
}
4827
4828
txBoolean fxIsSameValue(txMachine* the, txSlot* a, txSlot* b, txBoolean zero)
4829
0
{
4830
0
  txBoolean result = 0;
4831
0
  if (a->kind == b->kind) {
4832
0
    if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind))
4833
0
      result = 1;
4834
0
    else if (XS_BOOLEAN_KIND == a->kind)
4835
0
      result = a->value.boolean == b->value.boolean;
4836
0
    else if (XS_INTEGER_KIND == a->kind)
4837
0
      result = a->value.integer == b->value.integer;
4838
0
        else if (XS_NUMBER_KIND == a->kind) {
4839
0
      result = ((c_isnan(a->value.number) && c_isnan(b->value.number)) || ((a->value.number == b->value.number) && (zero || (c_signbit(a->value.number) == c_signbit(b->value.number)))));
4840
0
      mxFloatingPointOp("same value");
4841
0
    }
4842
0
    else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind))
4843
0
      result = c_strcmp(a->value.string, b->value.string) == 0;
4844
0
    else if (XS_SYMBOL_KIND == a->kind)
4845
0
      result = a->value.symbol == b->value.symbol;
4846
0
    else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind))
4847
0
      result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4848
0
    else if (XS_REFERENCE_KIND == a->kind)
4849
0
      result = fxIsSameReference(the, a, b);
4850
0
  }
4851
0
  else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) {
4852
0
    txNumber aNumber = a->value.integer;
4853
0
    result = (aNumber == b->value.number) && (zero || (signbit(aNumber) == signbit(b->value.number)));
4854
0
    mxFloatingPointOp("same value");
4855
0
  }
4856
0
  else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) {
4857
0
    txNumber bNumber = b->value.integer;
4858
0
    result = (a->value.number == bNumber) && (zero || (signbit(a->value.number) == signbit(bNumber)));
4859
0
    mxFloatingPointOp("same value");
4860
0
  }
4861
0
  else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind))
4862
0
    result = c_strcmp(a->value.string, b->value.string) == 0;
4863
0
  else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind))
4864
0
    result = c_strcmp(a->value.string, b->value.string) == 0;
4865
0
  else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind))
4866
0
    result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4867
0
  else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind))
4868
0
    result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4869
0
  return result;
4870
0
}
4871
4872
txBoolean fxIsScopableSlot(txMachine* the, txSlot* instance, txID id)
4873
0
{ 
4874
0
  txBoolean result;
4875
0
  fxBeginHost(the);
4876
0
  mxPushReference(instance);
4877
0
  result = mxHasID(id);
4878
0
  if (result) {
4879
0
    mxPushReference(instance);
4880
0
    mxGetID(mxID(_Symbol_unscopables));
4881
0
    if (mxIsReference(the->stack)) {
4882
0
      mxGetID(id);
4883
0
      result = fxToBoolean(the, the->stack) ? 0 : 1;
4884
0
    }
4885
0
    mxPop();
4886
0
  }
4887
0
  fxEndHost(the);
4888
0
  return result;
4889
0
}
4890
4891
void fxRemapIDs(txMachine* the, txByte* codeBuffer, txSize codeSize, txID* theIDs)
4892
0
{
4893
0
  register const txS1* bytes = gxCodeSizes;
4894
0
  register txByte* p = codeBuffer;
4895
0
  register txByte* q = codeBuffer + codeSize;
4896
0
  register txS1 offset;
4897
0
  txID id;
4898
0
  while (p < q) {
4899
    //fprintf(stderr, "%s", gxCodeNames[*((txU1*)p)]);
4900
0
    offset = (txS1)c_read8(bytes + c_read8(p));
4901
0
    if (0 < offset)
4902
0
      p += offset;
4903
0
    else if (0 == offset) {
4904
0
      p++;
4905
0
      mxDecodeID(p, id);
4906
0
      if (id != XS_NO_ID) {
4907
0
        id = theIDs[id];
4908
0
        p -= sizeof(txID);
4909
0
        mxEncodeID(p, id);
4910
0
      }
4911
0
    }
4912
0
    else if (-1 == offset) {
4913
0
      txU1 index;
4914
0
      p++;
4915
0
      index = *((txU1*)p);
4916
0
      p += 1 + index;
4917
0
    }
4918
0
        else if (-2 == offset) {
4919
0
      txU2 index;
4920
0
            p++;
4921
0
            mxDecode2(p, index);
4922
0
            p += index;
4923
0
        }
4924
0
        else if (-4 == offset) {
4925
0
      txS4 index;
4926
0
            p++;
4927
0
            mxDecode4(p, index);
4928
0
            p += index;
4929
0
        }
4930
    //fprintf(stderr, "\n");
4931
0
  }
4932
0
}
4933
4934
void fxRemapScript(txMachine* the, txScript* script)
4935
0
{
4936
0
  mxPushUndefined();
4937
0
  if (script->symbolsBuffer) {
4938
0
    txByte* p = script->symbolsBuffer;
4939
0
    txID c, i;
4940
0
    mxDecodeID(p, c);
4941
0
    the->stack->value.callback.address = C_NULL;
4942
0
    the->stack->value.IDs = (txID*)fxNewChunk(the, c * sizeof(txID));
4943
0
    the->stack->kind = XS_IDS_KIND;
4944
0
    the->stack->value.IDs[0] = XS_NO_ID;
4945
0
    for (i = 1; i < c; i++) {
4946
0
      txID id = fxNewNameC(the, (txString)p);
4947
0
      the->stack->value.IDs[i] = id;
4948
0
      p += mxStringLength((char*)p) + 1;
4949
0
    }
4950
0
    fxRemapIDs(the, script->codeBuffer, script->codeSize, the->stack->value.IDs);
4951
0
    the->stack->value.IDs = C_NULL;
4952
0
  } 
4953
0
  else {
4954
0
    the->stack->value.IDs = C_NULL;
4955
0
    the->stack->kind = XS_IDS_KIND;
4956
0
  }
4957
0
}
4958
4959
txBoolean fxToNumericInteger(txMachine* the, txSlot* theSlot)
4960
0
{
4961
0
  if (theSlot->kind == XS_REFERENCE_KIND)
4962
0
    fxToPrimitive(the, theSlot, XS_NUMBER_HINT);
4963
0
  if ((theSlot->kind == XS_BIGINT_KIND) || (theSlot->kind == XS_BIGINT_X_KIND))
4964
0
    return 0;
4965
0
  fxToInteger(the, theSlot);
4966
0
  return 1;
4967
0
}
4968
4969
txBoolean fxToNumericIntegerUnary(txMachine* the, txSlot* a, txBigIntUnary op)
4970
0
{
4971
0
  if (fxToNumericInteger(the, a))
4972
0
    return 1;
4973
0
  a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint);
4974
0
  a->kind = XS_BIGINT_KIND;
4975
0
  the->stack = a;
4976
0
  return 0;   
4977
0
}
4978
4979
txBoolean fxToNumericIntegerBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op)
4980
0
{
4981
0
  txBoolean ra = fxToNumericInteger(the, a);
4982
0
  txBoolean rb = fxToNumericInteger(the, b);
4983
0
  if (ra) {
4984
0
    if (rb)
4985
0
      return 1;
4986
0
    mxTypeError("cannot coerce left operand to bigint");
4987
0
  }
4988
0
  else if (rb)
4989
0
    mxTypeError("cannot coerce right operand to bigint");
4990
0
  a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint, &b->value.bigint);
4991
0
  a->kind = XS_BIGINT_KIND;
4992
0
  the->stack = b;
4993
0
  return 0;   
4994
0
}
4995
4996
txBoolean fxToNumericNumber(txMachine* the, txSlot* theSlot)
4997
0
{
4998
0
  if (theSlot->kind == XS_REFERENCE_KIND)
4999
0
    fxToPrimitive(the, theSlot, XS_NUMBER_HINT);
5000
0
  if ((theSlot->kind == XS_BIGINT_KIND) || (theSlot->kind == XS_BIGINT_X_KIND))
5001
0
    return 0;
5002
0
  fxToNumber(the, theSlot);
5003
0
  return 1;
5004
0
}
5005
5006
txBoolean fxToNumericNumberUnary(txMachine* the, txSlot* a, txBigIntUnary op)
5007
0
{
5008
0
  if (fxToNumericNumber(the, a))
5009
0
    return 1;
5010
0
  a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint);
5011
0
  a->kind = XS_BIGINT_KIND;
5012
0
  the->stack = a;
5013
0
  return 0;   
5014
0
}
5015
5016
txBoolean fxToNumericNumberBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op)
5017
0
{
5018
0
  txBoolean ra = fxToNumericNumber(the, a);
5019
0
  txBoolean rb = fxToNumericNumber(the, b);
5020
0
  if (ra) {
5021
0
    if (rb)
5022
0
      return 1;
5023
0
    mxTypeError("cannot coerce left operand to bigint");
5024
0
  }
5025
0
  else if (rb)
5026
0
    mxTypeError("cannot coerce right operand to bigint");
5027
0
  a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint, &b->value.bigint);
5028
0
  a->kind = XS_BIGINT_KIND;
5029
0
  the->stack = b;
5030
0
  return 0;   
5031
0
}
5032
5033
void fxRunScript(txMachine* the, txScript* script, txSlot* _this, txSlot* _target, txSlot* closures, txSlot* object, txSlot* module)
5034
0
{
5035
0
  if (script) {
5036
0
    mxTry(the) {
5037
0
      txSlot* instance;
5038
0
      txSlot* property;
5039
0
      __JUMP__.code = C_NULL;
5040
0
      fxRemapScript(the, script);
5041
0
      if (script->callback) {
5042
0
        property = the->stack;
5043
        /* THIS */
5044
0
        if (_this)
5045
0
          mxPushSlot(_this);
5046
0
        else
5047
0
          mxPushUndefined();
5048
0
        the->stack->ID = XS_NO_ID;
5049
        /* FUNCTION */
5050
0
        mxPush(mxFunctionPrototype);
5051
0
        instance = fxNewFunctionInstance(the, closures ? mxID(_eval) : XS_NO_ID);
5052
0
        instance->next->kind = XS_CALLBACK_KIND;
5053
0
        instance->next->value.callback.address = script->callback;
5054
0
        instance->next->value.callback.closures = C_NULL;
5055
0
        property = mxFunctionInstanceHome(instance);
5056
0
        property->value.home.object = object;
5057
0
        property->value.home.module = module;
5058
        /* RESULT */
5059
0
        mxPushUndefined();
5060
        /* FRAME */
5061
0
        mxPushUninitialized();
5062
0
        mxRunCount(0);
5063
0
      }
5064
0
      else {
5065
0
        mxPushUndefined();
5066
0
      }
5067
0
      mxPull(mxHosts);
5068
0
      mxPop();
5069
5070
      /* TARGET */
5071
0
      if (_target)
5072
0
        mxPushSlot(_target);
5073
      /* THIS */
5074
0
      if (_this)
5075
0
        mxPushSlot(_this);
5076
0
      else
5077
0
        mxPushUndefined();
5078
0
      the->stack->ID = XS_NO_ID;
5079
      /* FUNCTION */
5080
0
      mxPush(mxFunctionPrototype);
5081
0
      instance = fxNewFunctionInstance(the, XS_NO_ID);
5082
0
      instance->next->kind = XS_CODE_X_KIND;
5083
0
      instance->next->value.code.address = script->codeBuffer;
5084
0
      instance->next->value.code.closures = closures;
5085
0
      property = mxFunctionInstanceHome(instance);
5086
0
      property->ID = fxGenerateProfileID(the);
5087
0
      property->value.home.object = object;
5088
0
      property->value.home.module = module;
5089
      /* RESULT */
5090
0
            mxPushUndefined();
5091
      /* FRAME */
5092
0
      mxPushUninitialized();
5093
0
      if (_target)
5094
0
        the->stack->flag |= XS_TARGET_FLAG;
5095
0
      mxRunCount(0);
5096
5097
0
      mxPushUndefined();
5098
0
      mxPull(mxHosts);
5099
0
      if (script->symbolsBuffer)
5100
0
        fxDeleteScript(script);
5101
0
    }
5102
0
    mxCatch(the) {
5103
0
      if (script->symbolsBuffer)
5104
0
        fxDeleteScript(script);
5105
0
      fxJump(the);
5106
0
    }
5107
0
  }
5108
0
  else {
5109
0
    mxSyntaxError("invalid script");
5110
0
  }
5111
0
}
5112
5113
void fxRunUsed(txMachine* the, txSlot* selector)
5114
0
{
5115
0
#if mxExplicitResourceManagement
5116
0
  txSlot* exception = selector + 1;
5117
0
  fxBeginHost(the);
5118
0
  {
5119
0
    if (selector->value.integer == 0) {
5120
0
      mxPush(mxSuppressedErrorConstructor);
5121
0
      mxNew();
5122
0
      mxPush(mxException);
5123
0
      mxPushSlot(exception);
5124
0
      mxRunCount(2);
5125
0
      mxPullSlot(exception);
5126
0
    }
5127
0
    else {
5128
0
      *exception = mxException;
5129
0
      selector->value.integer = 0;
5130
0
    }
5131
0
    mxException = mxUndefined;
5132
0
  }
5133
0
  fxEndHost(the);
5134
#else
5135
  mxTypeError("using: unavailable feature");
5136
#endif
5137
0
}
5138
5139
void fxRunUsing(txMachine* the)
5140
0
{
5141
0
#if mxExplicitResourceManagement
5142
0
  txSlot* resource = the->stack;
5143
0
  fxBeginHost(the);
5144
0
  mxPushSlot(resource);
5145
0
  if (!mxIsNull(resource) && !mxIsUndefined(resource)) {
5146
0
    mxGetID(mxID(_Symbol_dispose));
5147
0
    if (!fxIsCallable(the, the->stack))
5148
0
      mxTypeError("using: [Symbol.dispose] is not a function");
5149
0
  }
5150
0
  else
5151
0
    the->stack->kind = XS_NULL_KIND;
5152
0
  mxPullSlot(resource);
5153
0
  fxEndHost(the);
5154
#else
5155
  mxTypeError("using: unavailable feature");
5156
#endif
5157
0
}
5158
5159
void fxRunUsingAsync(txMachine* the)
5160
0
{
5161
0
#if mxExplicitResourceManagement
5162
0
  txSlot* resource = the->stack;
5163
0
  fxBeginHost(the);
5164
0
  mxPushSlot(resource);
5165
0
  if (!mxIsNull(resource) && !mxIsUndefined(resource)) {
5166
0
    mxGetID(mxID(_Symbol_asyncDispose));
5167
0
    if (!fxIsCallable(the, the->stack)) {
5168
0
      mxPop();
5169
0
      mxPushSlot(resource);
5170
0
      mxGetID(mxID(_Symbol_dispose));
5171
0
    }
5172
0
    if (!fxIsCallable(the, the->stack))
5173
0
      mxTypeError("using: neither [Symbol.asyncDispose] nor [Symbol.dispose] are function");
5174
0
  }
5175
0
  else
5176
0
    the->stack->kind = XS_NULL_KIND;
5177
0
  mxPullSlot(resource);
5178
0
  fxEndHost(the);
5179
#else
5180
  mxTypeError("using: unavailable feature");
5181
#endif
5182
0
}
5183
5184
#ifdef mxMetering
5185
void fxCheckMeter(void* console)
5186
0
{
5187
0
  txMachine* the = console;
5188
0
  if (the->meterInterval && (the->meterIndex > the->meterCount)) {
5189
0
    fxCheckMetering(the);
5190
0
  }
5191
0
}
5192
void fxMeterSome(void* console, txU4 count)
5193
0
{
5194
0
  txMachine* the = console;
5195
0
  the->meterIndex += count * XS_PARSE_CODE_METERING;
5196
0
}
5197
#endif
5198
5199
5200
5201
5202
5203
5204
5205