Skip to content

Commit 6f5e4b5

Browse files
committed
Fix #207 uppercaseOnly BASIC dialects
uppercaseOnly BASIC dialects will remain uppercase only even when loaded with compile errors.
1 parent 2baf368 commit 6f5e4b5

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/common/workertypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export interface WorkerUnchangedResult {
138138
export interface WorkerErrorResult {
139139
errors: WorkerError[]
140140
listings?: CodeListingMap
141+
uppercaseOnly?: boolean
141142
}
142143

143144
export interface WorkerOutputResult<T> {
@@ -147,6 +148,7 @@ export interface WorkerOutputResult<T> {
147148
params?: {}
148149
segments?: Segment[]
149150
debuginfo?: {} // optional info
151+
uppercaseOnly?: boolean
150152
}
151153

152154
export function isUnchanged(result: WorkerResult) : result is WorkerUnchangedResult {

src/ide/ui.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Toolbar } from "./toolbar";
2121
import { AssetEditorView } from "./views/asseteditor";
2222
import { isMobileDevice } from "./views/baseviews";
2323
import { AddressHeatMapView, BinaryFileView, MemoryMapView, MemoryView, ProbeLogView, ProbeSymbolView, RasterStackMapView, ScanlineIOView, VRAMMemoryView } from "./views/debugviews";
24-
import { DisassemblerView, ListingView, PC_LINE_LOOKAHEAD, SourceEditor } from "./views/editors";
24+
import { DisassemblerView, ListingView, PC_LINE_LOOKAHEAD, SourceEditor, setUppercaseOnly } from "./views/editors";
2525
import { CallStackView, DebugBrowserView } from "./views/treeviews";
2626
import { ProjectWindows } from "./windows";
2727
import Split = require('split.js');
@@ -908,6 +908,9 @@ function showExceptionAsError(err, msg: string) {
908908
}
909909

910910
async function setCompileOutput(data: WorkerResult) {
911+
if ('uppercaseOnly' in data) {
912+
setUppercaseOnly(data.uppercaseOnly);
913+
}
911914
// errors? mark them in editor
912915
if ('errors' in data && data.errors.length > 0) {
913916
toolbar.addClass("has-errors");

src/ide/views/editors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export var textMapFunctions = {
5959
input: null as ((text: string) => string) | null
6060
};
6161

62+
export function setUppercaseOnly(uppercaseOnly: boolean) {
63+
textMapFunctions.input = uppercaseOnly ? (s) => s.toUpperCase() : null;
64+
}
65+
6266
export class SourceEditor implements ProjectView {
6367
constructor(path: string, mode: string) {
6468
this.path = path;

src/platform/basic.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
import { Platform, BreakpointCallback, DebugCondition, DebugEvalCondition } from "../common/baseplatform";
33
import { PLATFORMS, AnimationTimer, EmuHalt } from "../common/emu";
4-
import * as editors from "../ide/views/editors";
54
import { BASICRuntime } from "../common/basic/runtime";
65
import { BASICProgram } from "../common/basic/compiler";
76
import { TeleTypeWithKeyboard } from "../common/teletype";
@@ -133,8 +132,6 @@ class BASICPlatform implements Platform {
133132
this.program = data;
134133
var resumePC = this.runtime.load(data);
135134
this.tty.uppercaseOnly = true; // this.program.opts.uppercaseOnly; //TODO?
136-
// map editor to uppercase-only if need be
137-
editors.textMapFunctions.input = this.program.opts.uppercaseOnly ? (s) => s.toUpperCase() : null;
138135
// only reset if we exited, or couldn't restart at label (PC reset to 0)
139136
if (!this.hotReload || didExit || !resumePC)
140137
this.reset();

src/worker/tools/misc.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,15 @@ export function compileBASIC(step: BuildStep): WorkerResult {
128128
if (parser.errors.length == 0) throw e;
129129
}
130130
if (parser.errors.length) {
131-
return { errors: parser.errors };
131+
return { errors: parser.errors, uppercaseOnly: parser.opts.uppercaseOnly };
132132
}
133133
// put AST into JSON (sans source locations) to see if it has changed
134134
var json = JSON.stringify(ast, (key, value) => { return (key == '$loc' ? undefined : value) });
135135
putWorkFile(jsonpath, json);
136136
if (anyTargetChanged(step, [jsonpath])) return {
137137
output: ast,
138138
listings: parser.getListings(),
139+
uppercaseOnly: parser.opts.uppercaseOnly,
139140
};
140141
}
141142
}

0 commit comments

Comments
 (0)