2011-01-18 03:46:22 +08:00
|
|
|
(function(tree) {
|
2010-03-02 04:32:21 +08:00
|
|
|
|
2011-01-26 00:56:07 +08:00
|
|
|
tree.Variable = function Variable(name, index) {
|
2011-01-22 02:07:50 +08:00
|
|
|
this.name = name;
|
|
|
|
this.index = index;
|
|
|
|
};
|
2010-03-02 04:32:21 +08:00
|
|
|
tree.Variable.prototype = {
|
2011-01-18 03:46:22 +08:00
|
|
|
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
|
|
|
|
2011-01-25 04:08:47 +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 {
|
2011-01-18 08:08:33 +08:00
|
|
|
env.error({
|
2011-01-22 02:07:50 +08:00
|
|
|
message: 'variable ' + this.name + ' is undefined',
|
2011-01-18 08:08:33 +08:00
|
|
|
index: this.index
|
|
|
|
});
|
2010-02-24 02:39:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-06 03:23:28 +08:00
|
|
|
})(require('mess/tree'));
|