debugger stuff

This commit is contained in:
LenAnderson
2024-06-20 13:06:58 -04:00
parent 02e1ef7606
commit 538724739b
5 changed files with 264 additions and 20 deletions

View File

@@ -97,7 +97,7 @@ export class SlashCommandClosure {
/**
*
* @returns Promise<SlashCommandClosureResult>
* @returns {Promise<SlashCommandClosureResult>}
*/
async execute() {
const closure = this.getCopy();
@@ -124,6 +124,7 @@ export class SlashCommandClosure {
}
async * executeDirect() {
this.debugController?.down(this);
// closure arguments
for (const arg of this.argumentList) {
let v = arg.value;
@@ -305,10 +306,12 @@ export class SlashCommandClosure {
// if execution has returned a closure result, return that (should only happen on abort)
if (step.value instanceof SlashCommandClosureResult) {
this.debugController?.up();
return step.value;
}
/**@type {SlashCommandClosureResult} */
const result = Object.assign(new SlashCommandClosureResult(), { pipe: this.scope.pipe });
this.debugController?.up();
return result;
}
async * executeStep() {

View File

@@ -2,6 +2,7 @@ import { SlashCommandClosure } from './SlashCommandClosure.js';
import { SlashCommandExecutor } from './SlashCommandExecutor.js';
export class SlashCommandDebugController {
/**@type {SlashCommandClosure[]} */ stack = [];
/**@type {boolean} */ isStepping = false;
/**@type {boolean} */ isSteppingInto = false;
@@ -12,6 +13,16 @@ export class SlashCommandDebugController {
down(closure) {
this.stack.push(closure);
}
up() {
this.stack.pop();
}
resume() {
this.continueResolver?.(false);
this.continuePromise = null;