Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var CodeRef = require('./code-ref.js'); | ||
class CodeRefWithStateVars extends CodeRef { | ||
freshBlock() { | ||
return this.closureTemplate(); | ||
} | ||
|
||
$$clone() { | ||
var clone = new CodeRefWithStateVars(this.name, undefined); | ||
clone.$$call = this.freshBlock(); | ||
clone.codeObj = this.codeObj; | ||
clone.staticCode = this.staticCode; | ||
clone.closureTemplate = this.closureTemplate; | ||
clone.outerCtx = this.outerCtx; | ||
return clone; | ||
} | ||
|
||
closure(block) { | ||
/* TODO cloning won't work with a closureTemplate */ | ||
throw 'CodeRefWithStateVars.closure NYI'; | ||
} | ||
|
||
closureCtx(outerCtx) { | ||
var closure = new CodeRefWithStateVars(this.name, this.cuid); | ||
closure.codeObj = this.codeObj; | ||
closure.$$call = this.freshBlock(); | ||
closure.closureTemplate = this.closureTemplate; | ||
closure.staticCode = this; | ||
|
||
closure.outerCtx = outerCtx; | ||
|
||
return closure; | ||
} | ||
}; | ||
module.exports = CodeRefWithStateVars; |