mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
27 lines
788 B
JavaScript
27 lines
788 B
JavaScript
(function (tree) {
|
|
|
|
tree.Variable = function (name, index, file) { this.name = name, this.index = index, this.file = file };
|
|
tree.Variable.prototype = {
|
|
eval: function (env) {
|
|
var variable, v, name = this.name;
|
|
|
|
if (name.indexOf('@@') == 0) {
|
|
name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
|
|
}
|
|
|
|
if (variable = tree.find(env.frames, function (frame) {
|
|
if (v = frame.variable(name)) {
|
|
return v.value.eval(env);
|
|
}
|
|
})) { return variable }
|
|
else {
|
|
throw { type: 'Name',
|
|
message: "variable " + name + " is undefined",
|
|
filename: this.file,
|
|
index: this.index };
|
|
}
|
|
}
|
|
};
|
|
|
|
})(require('../tree'));
|