1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-17 03:29:55 +00:00

ecs: worker tool

This commit is contained in:
Steven Hugg 2022-01-29 11:34:26 -06:00
parent 8b96c746a2
commit 3f241bfcc2
5 changed files with 43 additions and 2 deletions

View File

@ -431,6 +431,7 @@ export function getToolForFilename_6502(fn:string) : string {
if (fn.endsWith(".dasm")) return "dasm";
if (fn.endsWith(".acme")) return "acme";
if (fn.endsWith(".wiz")) return "wiz";
if (fn.endsWith(".ecs")) return "ecs";
return "dasm"; // .a
}

View File

@ -69,7 +69,7 @@ export class ECSCompiler extends Tokenizer {
parseComponentField(): DataField {
let name = this.expectIdent();
this.expectToken(':');
this.expectToken(':', 'I expected either a ":" or "end" here.'); // TODO
let type = this.parseDataType();
return { name: name.str, ...type };
}
@ -260,4 +260,10 @@ export class ECSCompiler extends Tokenizer {
scope.dump(src);
}
}
export() {
let src = new SourceFileExport();
this.exportToFile(src);
return src.toString();
}
}

View File

@ -60,6 +60,7 @@ function getToolForFilename_vcs(fn: string) {
if (fn.endsWith(".wiz")) return "wiz";
if (fn.endsWith(".bb") || fn.endsWith(".bas")) return "bataribasic";
if (fn.endsWith(".ca65")) return "ca65";
if (fn.endsWith(".ecs")) return "ecs";
return "dasm";
}

30
src/worker/tools/ecs.ts Normal file
View File

@ -0,0 +1,30 @@
import { ECSCompiler } from "../../common/ecs/compiler";
import { CompileError } from "../../common/tokenizer";
import { CodeListingMap } from "../../common/workertypes";
import { BuildStep, BuildStepResult, gatherFiles, getWorkFileAsString, putWorkFile, staleFiles } from "../workermain";
export function assembleECS(step: BuildStep): BuildStepResult {
let compiler = new ECSCompiler();
gatherFiles(step, { mainFilePath: "main.ecs" });
var destpath = step.prefix + '.ca65';
if (staleFiles(step, [destpath])) {
let code = getWorkFileAsString(step.path);
try {
compiler.parseFile(code, step.path);
} catch (e) {
if (e instanceof CompileError) {
return { errors: compiler.errors };
} else {
throw e;
}
}
//var listings: CodeListingMap = {};
putWorkFile(destpath, compiler.export().toString());
}
return {
nexttool: "ca65",
path: destpath,
args: [destpath],
files: [destpath, 'vcs-ca65.h'], //TODO
};
}

View File

@ -1063,6 +1063,7 @@ import * as z80 from './tools/z80'
import * as x86 from './tools/x86'
import * as arm from './tools/arm'
import * as script from './tools/script'
import * as ecs from './tools/ecs'
var TOOLS = {
'dasm': dasm.assembleDASM,
@ -1098,7 +1099,8 @@ var TOOLS = {
'wiz': misc.compileWiz,
'armips': arm.assembleARMIPS,
'vasmarm': arm.assembleVASMARM,
'js': script.runJavascript,
//'js': script.runJavascript,
'ecs': ecs.assembleECS,
}
var TOOL_PRELOADFS = {
@ -1125,6 +1127,7 @@ var TOOL_PRELOADFS = {
'fastbasic': '65-atari8',
'silice': 'Silice',
'wiz': 'wiz',
'ecs': '65-none', // TODO: support multiple platforms
}
//const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay)); // for testing