Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Soquet committed Apr 6, 2021
1 parent e9742b4 commit 5dab47a
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions xs/sources/xsRun.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
static void fxCheckMetering(txMachine* the);
#endif
extern void fxRemapIDs(txMachine* the, txByte* codeBuffer, txSize codeSize, txID* theIDs);
static void fxRunArguments(txMachine* the, txIndex offset);
static void fxRunBase(txMachine* the);
static void fxRunConstructor(txMachine* the);
static txBoolean fxRunDefine(txMachine* the, txSlot* instance, txSlot* check, txID id, txIndex index, txSlot* slot, txFlag mask);
Expand Down Expand Up @@ -1189,22 +1190,9 @@ void fxRunID(txMachine* the, txSlot* generator, txInteger count)
#ifdef mxTrace
if (gxDoTrace) fxTraceInteger(the, offset);
#endif
mxAllocStack(1);
*mxStack = mxArrayPrototype;
mxSaveState;
fxNewArrayInstance(the);
fxRunArguments(the, offset);
mxRestoreState;
count = mxFrameArgc;
if (offset < count) {
count -= offset;
variable = mxFrameArgv(offset);
for (offset = 0; offset < count; offset++) {
slot = mxBehaviorSetProperty(the, mxStack->value.reference, 0, offset, XS_OWN);
slot->kind = variable->kind;
slot->value = variable->value;
variable--;
}
}
mxNextCode(2);
mxBreak;
mxCase(XS_CODE_ARGUMENTS_SLOPPY)
Expand Down Expand Up @@ -4162,6 +4150,31 @@ void fxCheckMetering(txMachine* the)
}
#endif

void fxRunArguments(txMachine* the, txIndex offset)
{
txSlot* array;
txIndex length = (txIndex)mxArgc;
txIndex index;
txSlot* address;
mxPush(mxArrayPrototype);
array = fxNewArrayInstance(the)->next;
if (offset < length) {
length -= offset;
fxSetIndexSize(the, array, length);
index = 0;
address = array->value.array.address;
while (index < length) {
txSlot* property = mxArgv(offset + index);
*((txIndex*)address) = index;
address->ID = XS_NO_ID;
address->kind = property->kind;
address->value = property->value;
index++;
address++;
}
}
}

void fxRunBase(txMachine* the)
{
if (mxIsUndefined(mxTarget))
Expand Down

0 comments on commit 5dab47a

Please sign in to comment.