4 // A function call node.
6 tree.Call = function (name, args, index) {
11 tree.Call.prototype = {
13 // When evaluating a function call,
14 // we either find the function in `tree.functions` [1],
15 // in which case we call it, passing the evaluated arguments,
16 // or we simply print it out as it appeared originally [2].
18 // The *functions.js* file contains the built-in functions.
20 // The reason why we evaluate the arguments, is in the case where
21 // we try to pass a variable to a function, like: `saturate(@color)`.
22 // The function should receive the value, not the variable.
24 eval: function (env) {
25 var args = this.args.map(function (a) { return a.eval(env) });
27 if (this.name in tree.functions) { // 1.
29 return tree.functions[this.name].apply(tree.functions, args);
31 throw { message: "error evaluating function `" + this.name + "`",
35 return new(tree.Anonymous)(this.name +
36 "(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
40 toCSS: function (env) {
41 return this.eval(env).toCSS();
45 })(require('less/tree'));