@powerlang/egg-js
Version:
A Smalltalk VM that runs on top of JavaScript
66 lines (53 loc) • 1.16 kB
JavaScript
import SBinding from './SBinding.js';
let SDynamicBinding = class extends SBinding {
constructor() {
super();
this._name = nil;
this._cache = nil;
}
static decodeUsing_(aTreecodeDecoder) {
return aTreecodeDecoder.decodeDynamicVar();
}
assign_within_ifUnbound_(value, anEvaluationContext, aClosure) {
if (nil === this._cache)
{
this.lookupWithin_(anEvaluationContext)
}
;
if (nil === this._cache)
{
return aClosure.value()
}
;
this._cache.assign_within_(value, anEvaluationContext);
return this;
}
isDynamic() {
return true;
}
lookupWithin_(anEvaluationContext) {
this._cache = anEvaluationContext.staticBindingFor_(this._name);
return this;
}
name() {
return this._name;
}
name_(aSymbol) {
this._name = aSymbol;
return this;
}
valueWithin_ifUnbound_(anEvaluationContext, aClosure) {
if (nil === this._cache)
{
this.lookupWithin_(anEvaluationContext)
}
;
if (nil === this._cache)
{
return aClosure.value()
}
;
return this._cache.valueWithin_(anEvaluationContext);
}
}
export default SDynamicBinding