mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-18 00:30:43 +00:00
ecs: unroll keyword
This commit is contained in:
parent
3fe2a151da
commit
479c2f24b8
@ -72,7 +72,7 @@ export interface SystemInstance extends SourceLocated {
|
|||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SELECT_TYPE = ['once', 'foreach', 'join', 'with', 'if', 'select'] as const;
|
export const SELECT_TYPE = ['once', 'foreach', 'join', 'with', 'if', 'select', 'unroll'] as const;
|
||||||
|
|
||||||
export type SelectType = typeof SELECT_TYPE[number];
|
export type SelectType = typeof SELECT_TYPE[number];
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ export interface ActionOnce extends ActionBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ActionWithQuery extends ActionBase {
|
export interface ActionWithQuery extends ActionBase {
|
||||||
select: 'foreach' | 'join' | 'with' | 'if' | 'select'
|
select: 'foreach' | 'join' | 'with' | 'if' | 'select' | 'unroll'
|
||||||
query: Query
|
query: Query
|
||||||
direction?: 'asc' | 'desc'
|
direction?: 'asc' | 'desc'
|
||||||
}
|
}
|
||||||
@ -647,6 +647,7 @@ class ActionEval {
|
|||||||
state.xreg = state.yreg = null;
|
state.xreg = state.yreg = null;
|
||||||
break;
|
break;
|
||||||
case 'foreach':
|
case 'foreach':
|
||||||
|
case 'unroll':
|
||||||
if (state.xreg && state.yreg) throw new ECSError('no more index registers', this.action);
|
if (state.xreg && state.yreg) throw new ECSError('no more index registers', this.action);
|
||||||
if (state.xreg) state.yreg = new IndexRegister(this.scope, this.qr);
|
if (state.xreg) state.yreg = new IndexRegister(this.scope, this.qr);
|
||||||
else state.xreg = new IndexRegister(this.scope, this.qr);
|
else state.xreg = new IndexRegister(this.scope, this.qr);
|
||||||
@ -689,7 +690,7 @@ class ActionEval {
|
|||||||
this.scope.state = this.oldState;
|
this.scope.state = this.oldState;
|
||||||
}
|
}
|
||||||
codeToString(): string {
|
codeToString(): string {
|
||||||
const allowEmpty = ['if','foreach','join'];
|
const allowEmpty = ['if','foreach','unroll','join'];
|
||||||
if (this.entities.length == 0 && allowEmpty.includes(this.action.select))
|
if (this.entities.length == 0 && allowEmpty.includes(this.action.select))
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
@ -746,6 +747,9 @@ class ActionEval {
|
|||||||
if (action.select == 'foreach' && entities.length > 1) {
|
if (action.select == 'foreach' && entities.length > 1) {
|
||||||
code = this.wrapCodeInLoop(code, action, this.qr.entities);
|
code = this.wrapCodeInLoop(code, action, this.qr.entities);
|
||||||
}
|
}
|
||||||
|
if (action.select == 'unroll' && entities.length > 1) {
|
||||||
|
throw new ECSError('unroll is not yet implemented');
|
||||||
|
}
|
||||||
// define properties
|
// define properties
|
||||||
props['%elo'] = entities[0].id.toString();
|
props['%elo'] = entities[0].id.toString();
|
||||||
props['%ehi'] = entities[entities.length - 1].id.toString();
|
props['%ehi'] = entities[entities.length - 1].id.toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user