|
|
|
@ -1,8 +1,5 @@
|
|
|
|
|
(function(tree) {
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// A function call node.
|
|
|
|
|
//
|
|
|
|
|
tree.Call = function Call(name, args, index) {
|
|
|
|
|
this.is = 'call';
|
|
|
|
|
|
|
|
|
@ -53,26 +50,49 @@ tree.Call.prototype = {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return this;
|
|
|
|
|
// return new tree.Anonymous(this.name +
|
|
|
|
|
// '(' + args.map(function(a) { return a.toString(); }).join(', ') + ')');
|
|
|
|
|
var fn = tree.Reference.mapnikFunction(this.name);
|
|
|
|
|
if (!fn) {
|
|
|
|
|
env.error({
|
|
|
|
|
message: 'unknown function ' + this.name,
|
|
|
|
|
index: this.index,
|
|
|
|
|
type: 'runtime',
|
|
|
|
|
filename: this.filename
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
is: 'undefined',
|
|
|
|
|
value: 'undefined'
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (fn[1] !== args.length) {
|
|
|
|
|
env.error({
|
|
|
|
|
message: 'function ' + this.name + ' takes ' +
|
|
|
|
|
fn[1] + ' arguments and was given ' + args.length,
|
|
|
|
|
index: this.index,
|
|
|
|
|
type: 'runtime',
|
|
|
|
|
filename: this.filename
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
is: 'undefined',
|
|
|
|
|
value: 'undefined'
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
// Save the evaluated versions of arguments
|
|
|
|
|
this.args = args;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toString: function(env, format) {
|
|
|
|
|
if (format === 'image-filter') {
|
|
|
|
|
if (this.args.length) {
|
|
|
|
|
return this.name + ':' + this.args.map(function(a) {
|
|
|
|
|
return a.eval(env);
|
|
|
|
|
}).join(',');
|
|
|
|
|
return this.name + ':' + this.args.join(',');
|
|
|
|
|
} else {
|
|
|
|
|
return this.name;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (this.args.length) {
|
|
|
|
|
return this.name + '(' + this.args.map(function(a) {
|
|
|
|
|
return a.eval(env);
|
|
|
|
|
}).join(',') + ')';
|
|
|
|
|
return this.name + '(' + this.args.join(',') + ')';
|
|
|
|
|
} else {
|
|
|
|
|
return this.name;
|
|
|
|
|
}
|
|
|
|
|