Skip to content

Commit

Permalink
XS: MODDEF_XS_TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Soquet committed Jan 7, 2022
1 parent 723418d commit 8074d4e
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 56 deletions.
6 changes: 3 additions & 3 deletions tools/test262/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
]
},
"strip": [],
"defines": {
"XS_TEST": 1
},
"platforms": {
"esp": {
"error": "test262 is unsupported on esp8266"
},
"esp32": {
"defines": {
"XS_TEST": 1
},
"modules": {
"*": [
"$(MODULES)/base/timer/*",
Expand Down
6 changes: 3 additions & 3 deletions tools/testmc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@
"http"
],
"strip": [],
"defines": {
"XS_TEST": 1
},
"platforms": {
"esp": {
"error": "testmc is unsupported on esp8266"
},
"esp32": {
"defines": {
"XS_TEST": 1
},
"include": [
"$(MODULES)/base/worker/manifest.json",
"$(MODULES)/files/flash/manifest.json"
Expand Down
4 changes: 4 additions & 0 deletions xs/platforms/lin_xs.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,9 @@ extern void fxQueueWorkerJob(void* machine, void* job);
GMutex workerMutex; \
txWorkerJob* workerQueue; \
void* demarshall;

#ifdef mxDebug
#define MODDEF_XS_TEST 1
#endif

#endif /* __LINUX_XS__ */
3 changes: 3 additions & 0 deletions xs/platforms/mac_xs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,8 @@ extern void fxQueueWorkerJob(void* machine, void* job);
CFRunLoopSourceRef workerSource; \
void* demarshall;

#ifdef mxDebug
#define MODDEF_XS_TEST 1
#endif

#endif /* __MAC_XS__ */
4 changes: 4 additions & 0 deletions xs/platforms/win_xs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,9 @@ extern void fxQueueWorkerJob(void* machine, void* job);
#define WM_XSBUG WM_USER + 2
#define WM_CALLBACK WM_USER + 3
#define WM_WORKER WM_USER + 4

#ifdef mxDebug
#define MODDEF_XS_TEST 1
#endif

#endif /* __WIN_XS__ */
108 changes: 60 additions & 48 deletions xs/sources/xsDebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,15 @@ void fxDebugCommand(txMachine* the)
}
mxHostInspectors.value.list.first = C_NULL;
mxHostInspectors.value.list.last = C_NULL;
#if MODDEF_XS_TEST
if (the->debugTag == XS_IMPORT_TAG)
fxQueueJob(the, 2, C_NULL);
else if (the->debugTag == XS_SCRIPT_TAG)
fxQueueJob(the, 4, C_NULL);
#endif
}

#if MODDEF_XS_TEST
void fxDebugImport(txMachine* the, txSlot* module, txString path)
{
if (!fxIsConnected(the))
Expand All @@ -242,6 +245,7 @@ void fxDebugImport(txMachine* the, txSlot* module, txString path)
mxPop();
}
}
#endif

void fxDebugLine(txMachine* the, txID id, txInteger line)
{
Expand Down Expand Up @@ -610,14 +614,8 @@ void fxDebugParseTag(txMachine* the, txString name)
the->debugTag = XS_CLEAR_BREAKPOINTS_TAG;
else if (!c_strcmp(name, "go"))
the->debugTag = XS_GO_TAG;
else if (!c_strcmp(name, "import"))
the->debugTag = XS_IMPORT_TAG;
else if (!c_strcmp(name, "logout"))
the->debugTag = XS_LOGOUT_TAG;
else if (!c_strcmp(name, "module"))
the->debugTag = XS_MODULE_TAG;
else if (!c_strcmp(name, "script"))
the->debugTag = XS_SCRIPT_TAG;
else if (!c_strcmp(name, "select"))
the->debugTag = XS_SELECT_TAG;
else if (!c_strcmp(name, "set-all-breakpoints"))
Expand All @@ -632,6 +630,14 @@ void fxDebugParseTag(txMachine* the, txString name)
the->debugTag = XS_STEP_OUTSIDE_TAG;
else if (!c_strcmp(name, "toggle"))
the->debugTag = XS_TOGGLE_TAG;
#if MODDEF_XS_TEST
else if (!c_strcmp(name, "import"))
the->debugTag = XS_IMPORT_TAG;
else if (!c_strcmp(name, "module"))
the->debugTag = XS_MODULE_TAG;
else if (!c_strcmp(name, "script"))
the->debugTag = XS_SCRIPT_TAG;
#endif
else
the->debugTag = XS_UNKNOWN_TAG;
}
Expand All @@ -653,18 +659,9 @@ void fxDebugPopTag(txMachine* the)
case XS_GO_TAG:
the->debugExit |= 2;
break;
case XS_IMPORT_TAG:
the->debugExit |= 2;
break;
case XS_LOGOUT_TAG:
the->debugExit |= 2;
break;
case XS_MODULE_TAG:
case XS_SCRIPT_TAG:
mxPop();
mxPop();
the->debugExit |= 2;
break;
case XS_SELECT_TAG:
break;
case XS_SET_ALL_BREAKPOINTS_TAG:
Expand All @@ -684,6 +681,17 @@ void fxDebugPopTag(txMachine* the)
break;
case XS_TOGGLE_TAG:
break;
#if MODDEF_XS_TEST
case XS_IMPORT_TAG:
the->debugExit |= 2;
break;
case XS_MODULE_TAG:
case XS_SCRIPT_TAG:
mxPop();
mxPop();
the->debugExit |= 2;
break;
#endif
}
}

Expand All @@ -707,43 +715,10 @@ void fxDebugPushTag(txMachine* the)
case XS_GO_TAG:
fxGo(the);
break;
case XS_IMPORT_TAG:
/* THIS */
mxPushUndefined();
/* FUNCTION */
mxPush(mxGlobal);
mxGetID(fxID(the, "<xsbug:import>"));
mxCall();
mxPushStringC("xsbug://");
fxConcatStringC(the, the->stack, the->pathValue);
mxPushInteger(the->lineValue);
break;
case XS_LOGOUT_TAG:
fxLogout(the);
fxGo(the);
break;
case XS_MODULE_TAG:
case XS_SCRIPT_TAG:
/* THIS */
mxPushUndefined();
/* FUNCTION */
mxPush(mxGlobal);
if (the->debugTag == XS_MODULE_TAG)
mxGetID(fxID(the, "<xsbug:module>"));
else
mxGetID(mxID(__xsbug_script_));
mxCall();
if (the->debugModule)
mxPushSlot(the->debugModule);
else
mxPushUndefined();
mxPushUndefined();
fxStringBuffer(the, the->stack, C_NULL, 256);
mxPushStringC(the->pathValue);
mxPushInteger(the->lineValue);
mxPushInteger(256);
mxPushInteger(0);
break;
case XS_SELECT_TAG:
fxSelect(the, (txSlot*)the->idValue);
fxEchoStart(the);
Expand Down Expand Up @@ -774,11 +749,47 @@ void fxDebugPushTag(txMachine* the)
fxListModules(the);
fxEchoStop(the);
break;
#if MODDEF_XS_TEST
case XS_IMPORT_TAG:
/* THIS */
mxPushUndefined();
/* FUNCTION */
mxPush(mxGlobal);
mxGetID(fxID(the, "<xsbug:import>"));
mxCall();
mxPushStringC("xsbug://");
fxConcatStringC(the, the->stack, the->pathValue);
mxPushInteger(the->lineValue);
break;
case XS_MODULE_TAG:
case XS_SCRIPT_TAG:
/* THIS */
mxPushUndefined();
/* FUNCTION */
mxPush(mxGlobal);
if (the->debugTag == XS_MODULE_TAG)
mxGetID(fxID(the, "<xsbug:module>"));
else
mxGetID(mxID(__xsbug_script_));
mxCall();
if (the->debugModule)
mxPushSlot(the->debugModule);
else
mxPushUndefined();
mxPushUndefined();
fxStringBuffer(the, the->stack, C_NULL, 256);
mxPushStringC(the->pathValue);
mxPushInteger(the->lineValue);
mxPushInteger(256);
mxPushInteger(0);
break;
#endif
}
}

void fxDebugScriptCDATA(txMachine* the, char c)
{
#if MODDEF_XS_TEST
if ((the->debugTag == XS_MODULE_TAG) || (the->debugTag == XS_SCRIPT_TAG)) {
txString string = the->stack[4].value.string;
txInteger size = the->stack[1].value.integer;
Expand All @@ -796,6 +807,7 @@ void fxDebugScriptCDATA(txMachine* the, char c)
string[offset++] = c;
the->stack[0].value.integer = offset;
}
#endif
}

void fxDebugThrow(txMachine* the, txString path, txInteger line, txString message)
Expand Down
11 changes: 9 additions & 2 deletions xs/sources/xsPlatforms.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot)
{
txPreparation* preparation = the->preparation;
char name[C_PATH_MAX];
#if MODDEF_XS_TEST
char extension[5] = "";
#endif
char buffer[C_PATH_MAX];
txInteger dot = 0;
txString slash;
Expand Down Expand Up @@ -168,7 +170,9 @@ txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot)
slash = name;
slash = c_strrchr(slash, '.');
if (slash && (!c_strcmp(slash, ".js") || !c_strcmp(slash, ".mjs"))) {
#if MODDEF_XS_TEST
c_strcpy(extension, slash);
#endif
*slash = 0;
}
if (dot) {
Expand Down Expand Up @@ -204,7 +208,7 @@ txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot)
script++;
}
}
#ifdef mxDebug
#if MODDEF_XS_TEST
if (!c_strncmp(path, "xsbug://", 8)) {
c_strcat(path, extension);
return fxNewNameC(the, path);
Expand All @@ -217,7 +221,10 @@ txID fxFindModule(txMachine* the, txSlot* realm, txID moduleID, txSlot* slot)

#if mxUseDefaultLoadModule

#if MODDEF_XS_TEST
extern void fxDebugImport(txMachine* the, txSlot* module, txString path);
#endif

void fxLoadModule(txMachine* the, txSlot* module, txID moduleID)
{
txString path = fxGetKeyName(the, moduleID);
Expand Down Expand Up @@ -255,7 +262,7 @@ void fxLoadModule(txMachine* the, txSlot* module, txID moduleID)
}
}
}
#ifdef mxDebug
#if MODDEF_XS_TEST
if (!c_strncmp(path, "xsbug://", 8)) {
fxDebugImport(the, module, path);
return;
Expand Down

0 comments on commit 8074d4e

Please sign in to comment.