You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/18 16:12:49 UTC
svn commit: r1504483 - in /tomcat/trunk/java/org/apache/el/parser:
AstFunction.java AstLambdaExpression.java
Author: markt
Date: Thu Jul 18 14:12:49 2013
New Revision: 1504483
URL: http://svn.apache.org/r1504483
Log:
Simplify. Update comments.
Modified:
tomcat/trunk/java/org/apache/el/parser/AstFunction.java
tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
Modified: tomcat/trunk/java/org/apache/el/parser/AstFunction.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstFunction.java?rev=1504483&r1=1504482&r2=1504483&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstFunction.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstFunction.java Thu Jul 18 14:12:49 2013
@@ -97,14 +97,11 @@ public final class AstFunction extends S
if (obj instanceof LambdaExpression) {
// Build arguments
int i = 0;
- while (obj instanceof LambdaExpression && i < this.jjtGetNumChildren()) {
- Node parameters = jjtGetChild(i);
- int numArgs = parameters.jjtGetNumChildren();
- Object[] args = new Object[numArgs];
- for (int j = 0; j < numArgs; j++) {
- args[j] = parameters.jjtGetChild(j).getValue(ctx);
- }
- obj = ((LambdaExpression) obj).invoke(args);
+ while (obj instanceof LambdaExpression &&
+ i < this.jjtGetNumChildren()) {
+ Node args = jjtGetChild(i);
+ obj = ((LambdaExpression) obj).invoke(
+ ((AstMethodParameters) args).getParameters(ctx));
i++;
}
return obj;
Modified: tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java?rev=1504483&r1=1504482&r2=1504483&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstLambdaExpression.java Thu Jul 18 14:12:49 2013
@@ -29,8 +29,6 @@ import org.apache.el.util.MessageFactory
public class AstLambdaExpression extends SimpleNode {
- private int methodParameterIndex = 0;
-
public AstLambdaExpression(int id) {
super(id);
}
@@ -76,23 +74,21 @@ public class AstLambdaExpression extends
le.setELContext(ctx);
if (jjtGetNumChildren() == 2) {
- if (formalParameters.isEmpty() && !(parent instanceof AstLambdaExpression)) {
- // No formal parameters or method parameters so invoke the
- // expression. If this is a nested expression inform the outer
- // expression that an invocation has occurred so the correct set
- // of method parameters are used for the next invocation.
- incMethodParameterIndex();
+ if (formalParameters.isEmpty() &&
+ !(parent instanceof AstLambdaExpression)) {
+ // No formal parameters or method parameters and not a nested
+ // expression so invoke the expression.
return le.invoke(ctx, (Object[]) null);
} else {
- // Has formal parameters but no method parameters so return the
- // expression for later evaluation
+ // Has formal parameters but no method parameters or is a nested
+ // expression so return the expression for later evaluation
return le;
}
}
// Always have to invoke the outer-most expression
- methodParameterIndex = 2;
+ int methodParameterIndex = 2;
Object result = le.invoke(((AstMethodParameters)
children[methodParameterIndex]).getParameters(ctx));
methodParameterIndex++;
@@ -111,11 +107,6 @@ public class AstLambdaExpression extends
* If the inner most expression(s) do not require parameters then a
* value will be returned once the outermost expression that does
* require a parameter has been evaluated.
- *
- * When invoking an expression if it has nested expressions that do not
- * have formal parameters then they will be evaluated as as part of that
- * invocation. In this case the method parameters associated with those
- * nested expressions need to be skipped.
*/
while (result instanceof LambdaExpression &&
methodParameterIndex < jjtGetNumChildren()) {
@@ -128,17 +119,6 @@ public class AstLambdaExpression extends
}
- public void incMethodParameterIndex() {
- Node parent = jjtGetParent();
- if (parent instanceof LambdaExpression) {
- // Method parameter index is maintained by outermost lambda
- // expressions as that is where the parameters are
- ((AstLambdaExpression) parent).incMethodParameterIndex();
- } else {
- methodParameterIndex++;
- }
- }
-
@Override
public String toString() {
// Purely for debug purposes. May not be complete or correct. Certainly
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org