-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstate.js
More file actions
25 lines (22 loc) · 753 Bytes
/
Copy pathstate.js
File metadata and controls
25 lines (22 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { debug, error } from './utils';
// the state type that wraps up Stmt x Environment x Store x Kont
export class State {
constructor(stmt, fp, store, kont) {
if (!stmt || !stmt.type) error('State.stmt must be an ast node');
this.stmt = stmt;
this.fp = fp;
this.store = store;
this.kont = kont;
}
next() {
let kont_stack = '';
let k = this.kont;
while (k) {
kont_stack += k.toString() + ' ';
k = k.next;
}
debug(`State.next called, current stmt = ${this.stmt.type}, kont stack = ${kont_stack}`);
return this.stmt.step(this.fp, this.store, this.kont);
}
toString() { return `State(${this.stmt.type})`; }
}