From 01de3b8d6b585fd119640539545cbf6e5a937e1b Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 3 Feb 2022 17:14:03 -0600 Subject: [PATCH] ecs: local system --- src/common/ecs/compiler.ts | 8 +++++--- src/common/ecs/ecs.ts | 11 ----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/common/ecs/compiler.ts b/src/common/ecs/compiler.ts index 7e20c26f..b2220f0b 100644 --- a/src/common/ecs/compiler.ts +++ b/src/common/ecs/compiler.ts @@ -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; diff --git a/src/common/ecs/ecs.ts b/src/common/ecs/ecs.ts index 7e489bc2..a5d1519e 100644 --- a/src/common/ecs/ecs.ts +++ b/src/common/ecs/ecs.ts @@ -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?