uae-dap
Version:
Debug Adapter Protocol for Amiga development with FS-UAE or WinUAE
61 lines • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.disassembledFileFromPath = exports.isDisassembledFile = exports.disassembledFileToPath = void 0;
/**
* Create file path for DisassembledFile
*/
function disassembledFileToPath(file) {
const address = file.memoryReference;
if (file.segmentId !== undefined) {
return `seg_${file.segmentId}.dbgasm`;
}
if (file.copper) {
return `copper_${address}__${file.instructionCount}.dbgasm`;
}
return `${file.stackFrameIndex}__${address}__${file.instructionCount}.dbgasm`;
}
exports.disassembledFileToPath = disassembledFileToPath;
/**
* Check if path is for a disassembled file
*/
function isDisassembledFile(path) {
return path.endsWith(".dbgasm");
}
exports.isDisassembledFile = isDisassembledFile;
/**
* Create a DisassembledFile from a path string
*
* Extracts properties from tokens in filename.
*/
function disassembledFileFromPath(path) {
const segMatch = path.match(/^(?<path>.+\/)?seg_(?<segmentId>[^_]+).dbgasm$/);
if (segMatch?.groups) {
const { segmentId } = segMatch.groups;
return {
segmentId: parseInt(segmentId),
copper: false,
};
}
const copperMatch = path.match(/^(?<path>.+\/)?copper_(?<memoryReference>[^_]+)__(?<instructionCount>[^_]+).dbgasm$/);
if (copperMatch?.groups) {
const { memoryReference, instructionCount } = copperMatch.groups;
return {
memoryReference,
instructionCount: parseInt(instructionCount),
copper: true,
};
}
const addressMatch = path.match(/^(?<path>.+\/)?(?<frame>[^_]+)__(?<memoryReference>[^_]+)__(?<instructionCount>[^_]+).dbgasm$/);
if (addressMatch?.groups) {
const { frame, memoryReference, instructionCount } = addressMatch.groups;
return {
stackFrameIndex: parseInt(frame),
memoryReference,
instructionCount: parseInt(instructionCount),
copper: false,
};
}
throw new Error("Unrecognised filename format " + path);
}
exports.disassembledFileFromPath = disassembledFileFromPath;
//# sourceMappingURL=disassembledFile.js.map