Allow an onDone listener to be associated with a slot

This commit is contained in:
Patrick Steele-Idem 2015-12-16 21:35:52 -07:00
parent 6465b81d2d
commit 86f7f406e4

View File

@ -5,22 +5,25 @@ var Node = require('./Node');
class Slot extends Node {
constructor(def) {
super('Slot');
this.onDone = def.onDone;
this.generatorSlot = null;
}
generateCode(generator) {
if (this.onDone) {
generator.onDone((generator) => {
this.onDone(this, generator);
});
}
// At the time the code for this node is to be generated we instead
// create a slot. A slot is just a marker in the output code stream
// that we can later inject code into. The injection happens after
// the entire tree has been walked.
this.generatorSlot = generator.createSlot();
this.generatorSlot = generator.beginSlot(this);
}
setContent(content) {
this.generatorSlot.setContent(content, {
statement: this.statement
});
this.generatorSlot.setContent(content);
}
toJSON() {