src/share/classes/com/sun/tools/javac/tree/JCTree.java

changeset 1142
c896d95e7469
parent 1138
7375d4979bd3
child 1143
ec59a2ce9114
     1.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Sat Nov 19 15:54:04 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Nov 24 13:36:20 2011 +0000
     1.3 @@ -41,6 +41,7 @@
     1.4  import com.sun.tools.javac.code.Symbol.*;
     1.5  import com.sun.tools.javac.parser.EndPosTable;
     1.6  import com.sun.source.tree.*;
     1.7 +import com.sun.source.tree.LambdaExpressionTree.BodyKind;
     1.8  
     1.9  import static com.sun.tools.javac.code.BoundKind.*;
    1.10  import static com.sun.tools.javac.tree.JCTree.Tag.*;
    1.11 @@ -198,6 +199,10 @@
    1.12           */
    1.13          NEWARRAY,
    1.14  
    1.15 +        /** Lambda expression, of type Lambda.
    1.16 +         */
    1.17 +        LAMBDA,
    1.18 +
    1.19          /** Parenthesized subexpressions, of type Parens.
    1.20           */
    1.21          PARENS,
    1.22 @@ -1487,6 +1492,56 @@
    1.23      }
    1.24  
    1.25      /**
    1.26 +     * A lambda expression.
    1.27 +     */
    1.28 +    public static class JCLambda extends JCExpression implements LambdaExpressionTree {
    1.29 +
    1.30 +        public List<JCVariableDecl> params;
    1.31 +        public JCTree body;
    1.32 +        public Type targetType;
    1.33 +        public boolean canCompleteNormally = true;
    1.34 +        public List<Type> inferredThrownTypes;
    1.35 +
    1.36 +        public JCLambda(List<JCVariableDecl> params,
    1.37 +                        JCTree body) {
    1.38 +            this.params = params;
    1.39 +            this.body = body;
    1.40 +        }
    1.41 +        @Override
    1.42 +        public Tag getTag() {
    1.43 +            return LAMBDA;
    1.44 +        }
    1.45 +        @Override
    1.46 +        public void accept(Visitor v) {
    1.47 +            v.visitLambda(this);
    1.48 +        }
    1.49 +        @Override
    1.50 +        public <R, D> R accept(TreeVisitor<R, D> v, D d) {
    1.51 +            return v.visitLambdaExpression(this, d);
    1.52 +        }
    1.53 +        public Kind getKind() {
    1.54 +            return Kind.LAMBDA_EXPRESSION;
    1.55 +        }
    1.56 +        public JCTree getBody() {
    1.57 +            return body;
    1.58 +        }
    1.59 +        public java.util.List<? extends VariableTree> getParameters() {
    1.60 +            return params;
    1.61 +        }
    1.62 +        @Override
    1.63 +        public JCLambda setType(Type type) {
    1.64 +            super.setType(type);
    1.65 +            return this;
    1.66 +        }
    1.67 +        @Override
    1.68 +        public BodyKind getBodyKind() {
    1.69 +            return body.hasTag(BLOCK) ?
    1.70 +                    BodyKind.STATEMENT :
    1.71 +                    BodyKind.EXPRESSION;
    1.72 +        }
    1.73 +    }
    1.74 +
    1.75 +    /**
    1.76       * A parenthesized subexpression ( ... )
    1.77       */
    1.78      public static class JCParens extends JCExpression implements ParenthesizedTree {
    1.79 @@ -2271,6 +2326,7 @@
    1.80          public void visitApply(JCMethodInvocation that)      { visitTree(that); }
    1.81          public void visitNewClass(JCNewClass that)           { visitTree(that); }
    1.82          public void visitNewArray(JCNewArray that)           { visitTree(that); }
    1.83 +        public void visitLambda(JCLambda that)               { visitTree(that); }
    1.84          public void visitParens(JCParens that)               { visitTree(that); }
    1.85          public void visitAssign(JCAssign that)               { visitTree(that); }
    1.86          public void visitAssignop(JCAssignOp that)           { visitTree(that); }

mercurial