1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-25 15:30:03 +00:00

ecs: local system

This commit is contained in:
Steven Hugg 2022-02-03 17:14:03 -06:00
parent 51f0f6ffea
commit 01de3b8d6b
2 changed files with 5 additions and 14 deletions

View File

@ -294,7 +294,7 @@ export class ECSCompiler extends Tokenizer {
scope.filePath = this.path;
this.currentScope = scope;
let cmd;
while ((cmd = this.expectTokens(['end', 'using', 'entity', 'scope', 'comment', 'on']).str) != 'end') {
while ((cmd = this.expectTokens(['end', 'using', 'entity', 'scope', 'comment', 'system']).str) != 'end') {
if (cmd == 'using') {
this.parseScopeUsing();
}
@ -307,8 +307,10 @@ export class ECSCompiler extends Tokenizer {
if (cmd == 'comment') {
this.expectTokenTypes([ECSTokenType.CodeFragment]);
}
if (cmd == 'on') {
this.currentScope.addAction(this.annotate(() => this.parseAction()));
if (cmd == 'system') {
let sys = this.annotate(() => this.parseSystem());
this.em.defineSystem(sys);
this.currentScope.addUsingSystem(sys);
}
}
this.currentScope = scope.parent || null;

View File

@ -801,7 +801,6 @@ export class EntityScope implements SourceLocated {
childScopes: EntityScope[] = [];
systems: System[] = [];
entities: Entity[] = [];
events: Action[] = [];
bss = new DataSegment();
rodata = new DataSegment();
code = new CodeSegment();
@ -837,9 +836,6 @@ export class EntityScope implements SourceLocated {
addUsingSystem(system: System) {
this.systems.push(system);
}
addAction(action: Action) {
this.events.push(action);
}
getEntityByName(name: string) {
return this.entities.find(e => e.name == name);
}
@ -1087,18 +1083,11 @@ export class EntityScope implements SourceLocated {
return symbol;
}
analyzeEntities() {
this.buildLocalSystem();
this.buildSegments();
this.allocateSegment(this.bss, false);
this.allocateSegment(this.rodata, true);
this.allocateROData(this.rodata);
}
buildLocalSystem() {
if (this.events.length) {
let sys : System = { name: this.name, actions: this.events };
this.addUsingSystem(this.em.defineSystem(sys));
}
}
generateCode() {
this.tempOffset = this.maxTempBytes = 0;
// TODO: main scope?