mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
New linter fixes
This commit is contained in:
parent
d67f3d8086
commit
fe955fba41
@ -61,7 +61,7 @@ class LineBuffer implements IterableIterator<string> {
|
|||||||
return new LineBuffer(this.line, this.curChar);
|
return new LineBuffer(this.line, this.curChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
next(): IteratorResult<string> {
|
next(): IteratorResult<string, string | undefined> {
|
||||||
if (this.atEnd()) {
|
if (this.atEnd()) {
|
||||||
return { done: true, value: undefined };
|
return { done: true, value: undefined };
|
||||||
}
|
}
|
||||||
@ -123,8 +123,6 @@ class LineBuffer implements IterableIterator<string> {
|
|||||||
export default class ApplesoftCompiler {
|
export default class ApplesoftCompiler {
|
||||||
private lines: Map<number, byte[]> = new Map();
|
private lines: Map<number, byte[]> = new Map();
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an AppleSoft BASIC program into memory.
|
* Loads an AppleSoft BASIC program into memory.
|
||||||
*
|
*
|
||||||
@ -197,7 +195,7 @@ export default class ApplesoftCompiler {
|
|||||||
// Backup to before the token
|
// Backup to before the token
|
||||||
lineBuffer.backup();
|
lineBuffer.backup();
|
||||||
// and emit the 'A' (upper- or lower-case)
|
// and emit the 'A' (upper- or lower-case)
|
||||||
return lineBuffer.next().value.charCodeAt(0);
|
return lineBuffer.next().value?.charCodeAt(0) ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return STRING_TO_TOKEN[possibleToken];
|
return STRING_TO_TOKEN[possibleToken];
|
||||||
@ -205,7 +203,7 @@ export default class ApplesoftCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not a token, output the character upper-cased
|
// If not a token, output the character upper-cased
|
||||||
return lineBuffer.next().value.toUpperCase().charCodeAt(0);
|
return lineBuffer.next().value?.toUpperCase().charCodeAt(0) ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private compileLine(line: string | null | undefined) {
|
private compileLine(line: string | null | undefined) {
|
||||||
@ -306,7 +304,7 @@ export default class ApplesoftCompiler {
|
|||||||
const lineNumbers = [...this.lines.keys()].sort();
|
const lineNumbers = [...this.lines.keys()].sort();
|
||||||
|
|
||||||
for (const lineNo of lineNumbers) {
|
for (const lineNo of lineNumbers) {
|
||||||
const lineBytes = this.lines.get(lineNo)!;
|
const lineBytes = this.lines.get(lineNo) || [];
|
||||||
const nextLineAddr = programStart + result.length + 4
|
const nextLineAddr = programStart + result.length + 4
|
||||||
+ lineBytes.length + 1; // +1 for the zero at end of line
|
+ lineBytes.length + 1; // +1 for the zero at end of line
|
||||||
result.push(nextLineAddr & 0xff, nextLineAddr >> 8);
|
result.push(nextLineAddr & 0xff, nextLineAddr >> 8);
|
||||||
|
@ -79,12 +79,12 @@ export default class ApplesoftDecompiler {
|
|||||||
let offset = 0;
|
let offset = 0;
|
||||||
let nextLineAddr = this.wordAt(offset);
|
let nextLineAddr = this.wordAt(offset);
|
||||||
let nextLineNo = this.wordAt(offset + 2);
|
let nextLineNo = this.wordAt(offset + 2);
|
||||||
while (nextLineAddr != 0 && nextLineNo < from) {
|
while (nextLineAddr !== 0 && nextLineNo < from) {
|
||||||
offset = nextLineAddr;
|
offset = nextLineAddr;
|
||||||
nextLineAddr = this.wordAt(offset);
|
nextLineAddr = this.wordAt(offset);
|
||||||
nextLineNo = this.wordAt(offset + 2);
|
nextLineNo = this.wordAt(offset + 2);
|
||||||
}
|
}
|
||||||
while (nextLineAddr != 0 && nextLineNo <= to) {
|
while (nextLineAddr !== 0 && nextLineNo <= to) {
|
||||||
callback(offset + 2);
|
callback(offset + 2);
|
||||||
offset = nextLineAddr - this.base;
|
offset = nextLineAddr - this.base;
|
||||||
nextLineAddr = this.wordAt(offset);
|
nextLineAddr = this.wordAt(offset);
|
||||||
@ -105,14 +105,14 @@ export default class ApplesoftDecompiler {
|
|||||||
if (options.apple2 === 'e') {
|
if (options.apple2 === 'e') {
|
||||||
line += ' '; // D6F9: JSR SPCLIN
|
line += ' '; // D6F9: JSR SPCLIN
|
||||||
}
|
}
|
||||||
line += lineNo + ' '; // D6FC, always 1 space after line number
|
line += `${lineNo} `; // D6FC, always 1 space after line number
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
// In the original ROM, the line length is checked immediately
|
// In the original ROM, the line length is checked immediately
|
||||||
// after the line number is printed. For simplicity, this method
|
// after the line number is printed. For simplicity, this method
|
||||||
// always assumes that there is space for one token—which would
|
// always assumes that there is space for one token—which would
|
||||||
// have been the case on a realy Apple.
|
// have been the case on a realy Apple.
|
||||||
while (this.program[offset] != 0) {
|
while (this.program[offset] !== 0) {
|
||||||
const token = this.program[offset];
|
const token = this.program[offset];
|
||||||
if (token >= 0x80 && token <= 0xea) {
|
if (token >= 0x80 && token <= 0xea) {
|
||||||
line += ' '; // D750, always put a space in front of token
|
line += ' '; // D750, always put a space in front of token
|
||||||
@ -193,7 +193,7 @@ export default class ApplesoftDecompiler {
|
|||||||
spaceIf = (nextToken: string) => /^\d/.test(nextToken);
|
spaceIf = (nextToken: string) => /^\d/.test(nextToken);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
while (this.program[offset] != 0) {
|
while (this.program[offset] !== 0) {
|
||||||
const token = this.program[offset];
|
const token = this.program[offset];
|
||||||
let tokenString: string;
|
let tokenString: string;
|
||||||
if (token >= 0x80 && token <= 0xea) {
|
if (token >= 0x80 && token <= 0xea) {
|
||||||
@ -235,10 +235,10 @@ export default class ApplesoftDecompiler {
|
|||||||
let spaceIf: (char: byte) => boolean = () => false;
|
let spaceIf: (char: byte) => boolean = () => false;
|
||||||
|
|
||||||
const lineNo = this.wordAt(offset);
|
const lineNo = this.wordAt(offset);
|
||||||
result += lineNo + ' ';
|
result += `${lineNo} `;
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
while (this.program[offset] != 0) {
|
while (this.program[offset] !== 0) {
|
||||||
const token = this.program[offset];
|
const token = this.program[offset];
|
||||||
let tokenString: string;
|
let tokenString: string;
|
||||||
if (token >= 0x80 && token <= 0xea) {
|
if (token >= 0x80 && token <= 0xea) {
|
||||||
|
Loading…
Reference in New Issue
Block a user