diff --git a/src/ol/expression/expressions.js b/src/ol/expression/expressions.js index 98a608ca2c..44c4435b5d 100644 --- a/src/ol/expression/expressions.js +++ b/src/ol/expression/expressions.js @@ -47,17 +47,17 @@ ol.expression.Expression.prototype.evaluate = goog.abstractMethod; * * @constructor * @extends {ol.expression.Expression} - * @param {ol.expression.Expression} expr An expression that resolves to a + * @param {ol.expression.Expression} callee An expression that resolves to a * function. * @param {Array.} args Arguments. */ -ol.expression.Call = function(expr, args) { +ol.expression.Call = function(callee, args) { /** * @type {ol.expression.Expression} * @private */ - this.expr_ = expr; + this.callee_ = callee; /** * @type {Array.} @@ -74,7 +74,7 @@ goog.inherits(ol.expression.Call, ol.expression.Expression); */ ol.expression.Call.prototype.evaluate = function(opt_scope, opt_fns, opt_this) { var fnScope = goog.isDefAndNotNull(opt_fns) ? opt_fns : opt_scope; - var fn = this.expr_.evaluate(fnScope); + var fn = this.callee_.evaluate(fnScope); if (!fn || !goog.isFunction(fn)) { throw new Error('Expected function but found ' + fn); } @@ -89,6 +89,24 @@ ol.expression.Call.prototype.evaluate = function(opt_scope, opt_fns, opt_this) { }; +/** + * Get the argument list. + * @return {Array.} The argument. + */ +ol.expression.Call.prototype.getArgs = function() { + return this.args_; +}; + + +/** + * Get the callee expression. + * @return {ol.expression.Expression} The callee expression. + */ +ol.expression.Call.prototype.getCallee = function() { + return this.callee_; +}; + + /** * @enum {string} */ diff --git a/test/spec/ol/expression/expressions.test.js b/test/spec/ol/expression/expressions.test.js index 1e924fd8e7..7d589f7bae 100644 --- a/test/spec/ol/expression/expressions.test.js +++ b/test/spec/ol/expression/expressions.test.js @@ -67,6 +67,22 @@ describe('ol.expression.Call', function() { }); + var callee = new ol.expression.Identifier('sqrt'); + var args = [new ol.expression.Literal(42)]; + var expr = new ol.expression.Call(callee, args); + + describe('#getArgs()', function() { + it('gets the callee expression', function() { + expect(expr.getArgs()).to.be(args); + }); + }); + + describe('#getCallee()', function() { + it('gets the callee expression', function() { + expect(expr.getCallee()).to.be(callee); + }); + }); + });