Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
christo committed Dec 21, 2024
1 parent 4b93e0d commit 2c75a5e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/src/machine/asm/Disassembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Disassembler {
this.currentIndex = index;
this.fb = fb;
this.segmentBaseAddress = dm.baseAddress(fb);
this.predefLc = dm.getJumpTargets(fb);
this.predefLc = dm.resolveSymbols(fb);
this.disMeta = dm;
this.symbolDefinitions = new Map<string, SymDef>();
this.stats = new Map<string, number>();
Expand Down
2 changes: 1 addition & 1 deletion client/src/machine/asm/DisassemblyMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface DisassemblyMeta {
/**
* Return a list of address + LabelsComments to use for address aliases
*/
getJumpTargets(fb: FileBlob): [Addr, LabelsComments][];
resolveSymbols(fb: FileBlob): [Addr, LabelsComments][];

/**
* Based on the known machine.
Expand Down
14 changes: 7 additions & 7 deletions client/src/machine/asm/DisassemblyMetaImpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {EMPTY_JUMP_TARGET_FETCHER, JumpTargetFetcher, LabelsComments, SymbolTable} from "./asm.ts";
import {EMPTY_JUMP_TARGET_FETCHER, SymbolResolver, LabelsComments, SymbolTable} from "./asm.ts";
import {Addr, hex16} from "../core.ts";
import {FileBlob} from "../FileBlob.ts";
import {Edict, InstructionLike} from "./instructions.ts";
Expand All @@ -18,7 +18,7 @@ class DisassemblyMetaImpl implements DisassemblyMeta {
private readonly _resetVectorOffset: number;
private readonly _contentStartOffset: number;
private readonly edicts: { [id: number]: Edict<InstructionLike>; };
private readonly jumpTargetFetcher: JumpTargetFetcher;
private readonly symbolResolver: SymbolResolver;
private readonly symbolTable: SymbolTable;

/**
Expand All @@ -28,15 +28,15 @@ class DisassemblyMetaImpl implements DisassemblyMeta {
* @param resetVectorOffset reset vector, defaults to baseAddressOffset
* @param contentStartOffset start of content, defaults to baseAddressOffset
* @param edicts any predefined edicts for disassembly, defaults to empty, only one per address.
* @param getJumpTargets do find externally defined symbols, defaults to empty.
* @param symbolResolver do find externally defined symbols, defaults to empty.
* @param symbolTable predefined symbol table (defaults to empty).
*/
constructor(
baseAddressOffset: number = 0,
resetVectorOffset: number = baseAddressOffset,
contentStartOffset: number = baseAddressOffset,
edicts: Edict<InstructionLike>[] = [],
getJumpTargets: JumpTargetFetcher = EMPTY_JUMP_TARGET_FETCHER,
symbolResolver: SymbolResolver = EMPTY_JUMP_TARGET_FETCHER,
symbolTable: SymbolTable = new SymbolTable("default")
) {

Expand All @@ -51,7 +51,7 @@ class DisassemblyMetaImpl implements DisassemblyMeta {
const edict = edicts[i];
this.edicts[edict.offset] = edict;
}
this.jumpTargetFetcher = getJumpTargets;
this.symbolResolver = symbolResolver;
}

baseAddress(fb: FileBlob): number {
Expand Down Expand Up @@ -88,8 +88,8 @@ class DisassemblyMetaImpl implements DisassemblyMeta {
return this.edicts[address];
}

getJumpTargets(fb: FileBlob): [Addr, LabelsComments][] {
return this.jumpTargetFetcher(fb);
resolveSymbols(fb: FileBlob): [Addr, LabelsComments][] {
return this.symbolResolver(fb);
}

getSymbolTable(): SymbolTable {
Expand Down
8 changes: 5 additions & 3 deletions client/src/machine/asm/asm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ export class LabelsComments {
* destinations for jump or branch. Addr is derived from the contents of the
* {@link FileBlob}.
*/
type JumpTargetFetcher = (fb: FileBlob) => Array<[Addr, LabelsComments]>;
const EMPTY_JUMP_TARGET_FETCHER: JumpTargetFetcher = (_fb) => []
type SymbolResolver = (fb: FileBlob) => Array<[Addr, LabelsComments]>;

const EMPTY_JUMP_TARGET_FETCHER: SymbolResolver = (_fb) => []

export {
Environment,
Section,
Expand All @@ -243,5 +245,5 @@ export {
EMPTY_JUMP_TARGET_FETCHER
};
export type {
JumpTargetFetcher
SymbolResolver
};
4 changes: 2 additions & 2 deletions client/src/machine/cbm/c64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Petscii} from "./petscii.ts";
import {DisassemblyMetaImpl} from "../asm/DisassemblyMetaImpl.ts";
import {BlobType} from "../BlobType.ts";
import {ByteDefinitionEdict, VectorDefinitionEdict} from "../asm/instructions.ts";
import {JumpTargetFetcher, LabelsComments, mkLabels, SymbolTable} from "../asm/asm.ts";
import {SymbolResolver, LabelsComments, mkLabels, SymbolTable} from "../asm/asm.ts";
import {ArrayMemory} from "../Memory.ts";

class C64 extends Computer {
Expand Down Expand Up @@ -69,7 +69,7 @@ const C64_CART_MAGIC = new ByteDefinitionEdict(MAGIC_OFFSET, CBM80.length, new L
const C64_CART_NMI_VECTOR = new VectorDefinitionEdict(C64_COLD_VECTOR_OFFSET, mkLabels("resetVector"));
const C64_CART_RESET_VECTOR = new VectorDefinitionEdict(C64_WARM_VECTOR_OFFSET, mkLabels("nmiVector"));

const jumpTargetFetcher: JumpTargetFetcher = (fb: FileBlob) => [
const jumpTargetFetcher: SymbolResolver = (fb: FileBlob) => [
[fb.read16(C64_COLD_VECTOR_OFFSET), mkLabels("reset")],
[fb.read16(C64_WARM_VECTOR_OFFSET), mkLabels("nmi")]
]
Expand Down
4 changes: 2 additions & 2 deletions client/src/machine/cbm/vic20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {KB_64, LE, lsb, msb} from "../core";
import {FileBlob} from "../FileBlob";
import {Mos6502} from "../mos6502";
import {DisassemblyMetaImpl} from "../asm/DisassemblyMetaImpl";
import {JumpTargetFetcher, LabelsComments, mkLabels, SymbolTable} from "../asm/asm.ts";
import {SymbolResolver, LabelsComments, mkLabels, SymbolTable} from "../asm/asm.ts";
import {ByteDefinitionEdict, VectorDefinitionEdict} from "../asm/instructions.ts";
import {DisassemblyMeta} from "../asm/DisassemblyMeta.ts";
import {BlobSniffer} from "../BlobSniffer.ts";
Expand Down Expand Up @@ -84,7 +84,7 @@ const VIC20_CART_COLD_VECTOR_OFFSET = 2;
/** The warm reset vector (NMI) is stored at this offset. */
const VIC20_CART_WARM_VECTOR_OFFSET = 4;

const jumpTargetFetcher: JumpTargetFetcher = (fb: FileBlob) => [
const jumpTargetFetcher: SymbolResolver = (fb: FileBlob) => [
[fb.readVector(VIC20_CART_COLD_VECTOR_OFFSET), new LabelsComments("reset", "main entry point")],
[fb.readVector(VIC20_CART_WARM_VECTOR_OFFSET), new LabelsComments("nmi", "jump target on restore key")]
];
Expand Down

0 comments on commit 2c75a5e

Please sign in to comment.