< prev index next >

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

Print this page

 783         /**
 784          * A poly expression can only be truly 'poly' in certain contexts
 785          */
 786         public enum PolyKind {
 787             /** poly expression to be treated as a standalone expression */
 788             STANDALONE,
 789             /** true poly expression */
 790             POLY
 791         }
 792 
 793         /** is this poly expression a 'true' poly expression? */
 794         public PolyKind polyKind;
 795 
 796         @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
 797         @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
 798     }
 799 
 800     /**
 801      * Common supertype for all functional expression trees (lambda and method references)
 802      */
 803     public abstract static class JCFunctionalExpression extends JCPolyExpression {

 804 
 805         public JCFunctionalExpression() {
 806             //a functional expression is always a 'true' poly
 807             polyKind = PolyKind.POLY;
 808         }
 809 
 810         /** list of target types inferred for this functional expression. */
 811         public Type target;
 812         /** The owner of this functional expression. */
 813         public Symbol owner;


 814 
 815         public Type getDescriptorType(Types types) {
 816             return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
 817         }


 818     }
 819 
 820     /**
 821      * A class definition.
 822      */
 823     public static class JCClassDecl extends JCStatement implements ClassTree {
 824         /** the modifiers */
 825         public JCModifiers mods;
 826         /** the name of the class */
 827         public Name name;
 828         /** formal class parameters */
 829         public List<JCTypeParameter> typarams;
 830         /** the classes this class extends */
 831         public JCExpression extending;
 832         /** the interfaces implemented by this class */
 833         public List<JCExpression> implementing;
 834         /** the subclasses allowed to extend this class, if sealed */
 835         public List<JCExpression> permitting;
 836         /** all variables and methods defined in this class */
 837         public List<JCTree> defs;

1997         }
1998         @Override
1999         public Tag getTag() {
2000             return NEWARRAY;
2001         }
2002 
2003         @Override @DefinedBy(Api.COMPILER_TREE)
2004         public List<JCAnnotation> getAnnotations() {
2005             return annotations;
2006         }
2007 
2008         @Override @DefinedBy(Api.COMPILER_TREE)
2009         public List<List<JCAnnotation>> getDimAnnotations() {
2010             return dimAnnotations;
2011         }
2012     }
2013 
2014     /**
2015      * A lambda expression.
2016      */
2017     public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2018 
2019         public enum ParameterKind {
2020             IMPLICIT,
2021             EXPLICIT
2022         }
2023 
2024         public List<JCVariableDecl> params;
2025         public JCTree body;
2026         public boolean canCompleteNormally = true;
2027         public ParameterKind paramKind;
2028         public boolean wasMethodReference;
2029 
2030         public JCLambda(List<JCVariableDecl> params,
2031                         JCTree body) {
2032             this.params = params;
2033             this.body = body;
2034             if (params.isEmpty() ||
2035                 params.head.vartype != null) {
2036                 paramKind = ParameterKind.EXPLICIT;
2037             } else {

2586 
2587         @DefinedBy(Api.COMPILER_TREE)
2588         public Kind getKind() { return Kind.MEMBER_SELECT; }
2589         @DefinedBy(Api.COMPILER_TREE)
2590         public JCExpression getExpression() { return selected; }
2591         @Override @DefinedBy(Api.COMPILER_TREE)
2592         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2593             return v.visitMemberSelect(this, d);
2594         }
2595         @DefinedBy(Api.COMPILER_TREE)
2596         public Name getIdentifier() { return name; }
2597         @Override
2598         public Tag getTag() {
2599             return SELECT;
2600         }
2601     }
2602 
2603     /**
2604      * Selects a member expression.
2605      */
2606     public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2607 
2608         public ReferenceMode mode;
2609         public ReferenceKind kind;
2610         public Name name;
2611         public JCExpression expr;
2612         public List<JCExpression> typeargs;
2613         public Symbol sym;
2614         public Type varargsElement;
2615         public PolyKind refPolyKind;
2616         public boolean ownerAccessible;
2617         private OverloadKind overloadKind;
2618         public Type referentType;
2619 
2620         public enum OverloadKind {
2621             OVERLOADED,
2622             UNOVERLOADED,
2623             ERROR
2624         }
2625 
2626         /**

 783         /**
 784          * A poly expression can only be truly 'poly' in certain contexts
 785          */
 786         public enum PolyKind {
 787             /** poly expression to be treated as a standalone expression */
 788             STANDALONE,
 789             /** true poly expression */
 790             POLY
 791         }
 792 
 793         /** is this poly expression a 'true' poly expression? */
 794         public PolyKind polyKind;
 795 
 796         @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
 797         @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
 798     }
 799 
 800     /**
 801      * Common supertype for all functional expression trees (lambda and method references)
 802      */
 803     public abstract static sealed class JCFunctionalExpression extends JCPolyExpression
 804                                                                permits JCLambda, JCMemberReference {
 805 
 806         public JCFunctionalExpression() {
 807             //a functional expression is always a 'true' poly
 808             polyKind = PolyKind.POLY;
 809         }
 810 
 811         /** list of target types inferred for this functional expression. */
 812         public Type target;
 813         /** The owner of this functional expression. */
 814         public Symbol owner;
 815         /** code reflection specific metadata. */
 816         public CodeReflectionInfo codeReflectionInfo;
 817 
 818         public Type getDescriptorType(Types types) {
 819             return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
 820         }
 821 
 822         public record CodeReflectionInfo(MethodSymbol codeModel, Type reflectableLambdaMetafactory) { }
 823     }
 824 
 825     /**
 826      * A class definition.
 827      */
 828     public static class JCClassDecl extends JCStatement implements ClassTree {
 829         /** the modifiers */
 830         public JCModifiers mods;
 831         /** the name of the class */
 832         public Name name;
 833         /** formal class parameters */
 834         public List<JCTypeParameter> typarams;
 835         /** the classes this class extends */
 836         public JCExpression extending;
 837         /** the interfaces implemented by this class */
 838         public List<JCExpression> implementing;
 839         /** the subclasses allowed to extend this class, if sealed */
 840         public List<JCExpression> permitting;
 841         /** all variables and methods defined in this class */
 842         public List<JCTree> defs;

2002         }
2003         @Override
2004         public Tag getTag() {
2005             return NEWARRAY;
2006         }
2007 
2008         @Override @DefinedBy(Api.COMPILER_TREE)
2009         public List<JCAnnotation> getAnnotations() {
2010             return annotations;
2011         }
2012 
2013         @Override @DefinedBy(Api.COMPILER_TREE)
2014         public List<List<JCAnnotation>> getDimAnnotations() {
2015             return dimAnnotations;
2016         }
2017     }
2018 
2019     /**
2020      * A lambda expression.
2021      */
2022     public static final class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2023 
2024         public enum ParameterKind {
2025             IMPLICIT,
2026             EXPLICIT
2027         }
2028 
2029         public List<JCVariableDecl> params;
2030         public JCTree body;
2031         public boolean canCompleteNormally = true;
2032         public ParameterKind paramKind;
2033         public boolean wasMethodReference;
2034 
2035         public JCLambda(List<JCVariableDecl> params,
2036                         JCTree body) {
2037             this.params = params;
2038             this.body = body;
2039             if (params.isEmpty() ||
2040                 params.head.vartype != null) {
2041                 paramKind = ParameterKind.EXPLICIT;
2042             } else {

2591 
2592         @DefinedBy(Api.COMPILER_TREE)
2593         public Kind getKind() { return Kind.MEMBER_SELECT; }
2594         @DefinedBy(Api.COMPILER_TREE)
2595         public JCExpression getExpression() { return selected; }
2596         @Override @DefinedBy(Api.COMPILER_TREE)
2597         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2598             return v.visitMemberSelect(this, d);
2599         }
2600         @DefinedBy(Api.COMPILER_TREE)
2601         public Name getIdentifier() { return name; }
2602         @Override
2603         public Tag getTag() {
2604             return SELECT;
2605         }
2606     }
2607 
2608     /**
2609      * Selects a member expression.
2610      */
2611     public static non-sealed class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2612 
2613         public ReferenceMode mode;
2614         public ReferenceKind kind;
2615         public Name name;
2616         public JCExpression expr;
2617         public List<JCExpression> typeargs;
2618         public Symbol sym;
2619         public Type varargsElement;
2620         public PolyKind refPolyKind;
2621         public boolean ownerAccessible;
2622         private OverloadKind overloadKind;
2623         public Type referentType;
2624 
2625         public enum OverloadKind {
2626             OVERLOADED,
2627             UNOVERLOADED,
2628             ERROR
2629         }
2630 
2631         /**
< prev index next >