Coverage Report

Created: 2026-01-09 07:15

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