carto/lib/mess/tree/variable.js

31 lines
700 B
JavaScript
Raw Normal View History

(function(tree) {
tree.Variable = function Variable(name, index) {
2011-01-22 02:07:50 +08:00
this.name = name;
this.index = index;
};
tree.Variable.prototype = {
eval: function(env) {
2011-01-22 02:07:50 +08:00
var variable,
v,
that = this;
name = this.name;
if (this._css) return this._css;
2010-02-24 02:39:05 +08:00
var thisframe = env.frames.filter(function(f) {
return f.name == this.name;
});
if (thisframe.length) {
return thisframe[0].value.eval(env);
2011-01-22 02:07:50 +08:00
} else {
env.error({
2011-01-22 02:07:50 +08:00
message: 'variable ' + this.name + ' is undefined',
index: this.index
});
2010-02-24 02:39:05 +08:00
}
}
};
2011-01-06 03:23:28 +08:00
})(require('mess/tree'));