mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-26 07:29:22 +00:00
ecs: local system
This commit is contained in:
parent
51f0f6ffea
commit
01de3b8d6b
@ -294,7 +294,7 @@ export class ECSCompiler extends Tokenizer {
|
|||||||
scope.filePath = this.path;
|
scope.filePath = this.path;
|
||||||
this.currentScope = scope;
|
this.currentScope = scope;
|
||||||
let cmd;
|
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') {
|
if (cmd == 'using') {
|
||||||
this.parseScopeUsing();
|
this.parseScopeUsing();
|
||||||
}
|
}
|
||||||
@ -307,8 +307,10 @@ export class ECSCompiler extends Tokenizer {
|
|||||||
if (cmd == 'comment') {
|
if (cmd == 'comment') {
|
||||||
this.expectTokenTypes([ECSTokenType.CodeFragment]);
|
this.expectTokenTypes([ECSTokenType.CodeFragment]);
|
||||||
}
|
}
|
||||||
if (cmd == 'on') {
|
if (cmd == 'system') {
|
||||||
this.currentScope.addAction(this.annotate(() => this.parseAction()));
|
let sys = this.annotate(() => this.parseSystem());
|
||||||
|
this.em.defineSystem(sys);
|
||||||
|
this.currentScope.addUsingSystem(sys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.currentScope = scope.parent || null;
|
this.currentScope = scope.parent || null;
|
||||||
|
@ -801,7 +801,6 @@ export class EntityScope implements SourceLocated {
|
|||||||
childScopes: EntityScope[] = [];
|
childScopes: EntityScope[] = [];
|
||||||
systems: System[] = [];
|
systems: System[] = [];
|
||||||
entities: Entity[] = [];
|
entities: Entity[] = [];
|
||||||
events: Action[] = [];
|
|
||||||
bss = new DataSegment();
|
bss = new DataSegment();
|
||||||
rodata = new DataSegment();
|
rodata = new DataSegment();
|
||||||
code = new CodeSegment();
|
code = new CodeSegment();
|
||||||
@ -837,9 +836,6 @@ export class EntityScope implements SourceLocated {
|
|||||||
addUsingSystem(system: System) {
|
addUsingSystem(system: System) {
|
||||||
this.systems.push(system);
|
this.systems.push(system);
|
||||||
}
|
}
|
||||||
addAction(action: Action) {
|
|
||||||
this.events.push(action);
|
|
||||||
}
|
|
||||||
getEntityByName(name: string) {
|
getEntityByName(name: string) {
|
||||||
return this.entities.find(e => e.name == name);
|
return this.entities.find(e => e.name == name);
|
||||||
}
|
}
|
||||||
@ -1087,18 +1083,11 @@ export class EntityScope implements SourceLocated {
|
|||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
analyzeEntities() {
|
analyzeEntities() {
|
||||||
this.buildLocalSystem();
|
|
||||||
this.buildSegments();
|
this.buildSegments();
|
||||||
this.allocateSegment(this.bss, false);
|
this.allocateSegment(this.bss, false);
|
||||||
this.allocateSegment(this.rodata, true);
|
this.allocateSegment(this.rodata, true);
|
||||||
this.allocateROData(this.rodata);
|
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() {
|
generateCode() {
|
||||||
this.tempOffset = this.maxTempBytes = 0;
|
this.tempOffset = this.maxTempBytes = 0;
|
||||||
// TODO: main scope?
|
// TODO: main scope?
|
||||||
|
Loading…
Reference in New Issue
Block a user