interpreter: exec exit actions
This commit is contained in:
parent
b9327d2eb0
commit
2b73da9387
2 changed files with 37 additions and 11 deletions
|
|
@ -22,7 +22,8 @@ text.highlight {
|
||||||
}
|
}
|
||||||
|
|
||||||
.selecting {
|
.selecting {
|
||||||
fill: rgba(0, 0, 255, 0.2);
|
fill: blue;
|
||||||
|
fill-opacity: 0.2;
|
||||||
stroke-width: 1px;
|
stroke-width: 1px;
|
||||||
stroke:black;
|
stroke:black;
|
||||||
stroke-dasharray: 7 6;
|
stroke-dasharray: 7 6;
|
||||||
|
|
@ -36,7 +37,7 @@ text.highlight {
|
||||||
}
|
}
|
||||||
|
|
||||||
.rountangle:hover {
|
.rountangle:hover {
|
||||||
/* stroke: darkcyan; */
|
/* stroke: blue; */
|
||||||
/* stroke-opacity: 0.2; */
|
/* stroke-opacity: 0.2; */
|
||||||
/* fill: #eee; */
|
/* fill: #eee; */
|
||||||
/* stroke-width: 4px; */
|
/* stroke-width: 4px; */
|
||||||
|
|
@ -67,7 +68,7 @@ text.highlight {
|
||||||
stroke-width: 16px;
|
stroke-width: 16px;
|
||||||
}
|
}
|
||||||
.lineHelper:hover {
|
.lineHelper:hover {
|
||||||
stroke: darkcyan;
|
stroke: blue;
|
||||||
stroke-opacity: 0.2;
|
stroke-opacity: 0.2;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +79,7 @@ text.highlight {
|
||||||
stroke-width: 16px;
|
stroke-width: 16px;
|
||||||
}
|
}
|
||||||
.pathHelper:hover {
|
.pathHelper:hover {
|
||||||
stroke: darkcyan;
|
stroke: blue;
|
||||||
stroke-opacity: 0.2;
|
stroke-opacity: 0.2;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +89,7 @@ text.highlight {
|
||||||
fill: rgba(0, 0, 0, 0);
|
fill: rgba(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
.circleHelper:hover {
|
.circleHelper:hover {
|
||||||
fill: darkcyan;
|
fill: blue;
|
||||||
fill-opacity: 0.2;
|
fill-opacity: 0.2;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +137,7 @@ text.selected, text.selected:hover {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
text:hover {
|
text:hover {
|
||||||
fill: darkcyan;
|
fill: blue;
|
||||||
/* cursor: grab; */
|
/* cursor: grab; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,25 @@ type ActionScope = {
|
||||||
raised: RaisedEvents,
|
raised: RaisedEvents,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function enter(state: ConcreteState, rt: ActionScope): ({mode: Mode} & ActionScope) {
|
type EnteredScope = { mode: Mode } & ActionScope;
|
||||||
|
|
||||||
|
export function enter(state: ConcreteState, rt: ActionScope): EnteredScope {
|
||||||
let {environment, raised} = rt;
|
let {environment, raised} = rt;
|
||||||
|
|
||||||
|
// execute entry actions
|
||||||
for (const action of state.entryActions) {
|
for (const action of state.entryActions) {
|
||||||
({environment, raised} = execAction(action, {environment, raised}));
|
({environment, raised} = execAction(action, {environment, raised}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// enter children...
|
||||||
|
const mode: {[uid:string]: Mode} = {};
|
||||||
if (state.kind === "and") {
|
if (state.kind === "and") {
|
||||||
const mode: {[uid:string]: Mode} = {};
|
|
||||||
for (const child of state.children) {
|
for (const child of state.children) {
|
||||||
let childMode;
|
let childMode;
|
||||||
({mode: childMode, environment, raised} = enter(child, {environment, raised}));
|
({mode: childMode, environment, raised} = enter(child, {environment, raised}));
|
||||||
mode[child.uid] = childMode;
|
mode[child.uid] = childMode;
|
||||||
}
|
}
|
||||||
return { mode, environment, raised };
|
|
||||||
}
|
}
|
||||||
else if (state.kind === "or") {
|
else if (state.kind === "or") {
|
||||||
const mode: {[uid:string]: Mode} = {};
|
const mode: {[uid:string]: Mode} = {};
|
||||||
|
|
@ -41,10 +47,29 @@ export function enter(state: ConcreteState, rt: ActionScope): ({mode: Mode} & Ac
|
||||||
let childMode;
|
let childMode;
|
||||||
({mode: childMode, environment, raised} = enter(child, {environment, raised}));
|
({mode: childMode, environment, raised} = enter(child, {environment, raised}));
|
||||||
mode[child.uid] = childMode;
|
mode[child.uid] = childMode;
|
||||||
return { mode, environment, raised };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error("should never reach here");
|
|
||||||
|
return { mode, environment, raised };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function exit(state: ConcreteState, rt: EnteredScope): ActionScope {
|
||||||
|
let {mode, environment, raised} = rt;
|
||||||
|
|
||||||
|
// exit all active children...
|
||||||
|
for (const [childUid, childMode] of Object.entries(mode)) {
|
||||||
|
const child = state.children.find(child => child.uid === childUid);
|
||||||
|
if (child) {
|
||||||
|
({environment, raised} = exit(child, {mode: childMode, environment, raised}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute exit actions
|
||||||
|
for (const action of state.exitActions) {
|
||||||
|
({environment, raised} = execAction(action, {environment, raised}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return {environment, raised};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function execAction(action: Action, rt: ActionScope): ActionScope {
|
export function execAction(action: Action, rt: ActionScope): ActionScope {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue