< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java

Print this page

 32 import com.sun.tools.javac.comp.DeferredAttr.AttributionMode;
 33 
 34 /** Contains information specific to the attribute and enter
 35  *  passes, to be used in place of the generic field in environments.
 36  *
 37  *  <p><b>This is NOT part of any supported API.
 38  *  If you write code that depends on this, you do so at your own risk.
 39  *  This code and its internal interfaces are subject to change or
 40  *  deletion without notice.</b>
 41  */
 42 public class AttrContext {
 43 
 44     /** The scope of local symbols.
 45      */
 46     WriteableScope scope = null;
 47 
 48     /** The number of enclosing `static' modifiers.
 49      */
 50     int staticLevel = 0;
 51 
 52     /** Is this an environment for a this(...) or super(...) call?
 53      */
 54     boolean isSelfCall = false;
 55 
 56     /** are we analyzing the arguments for a constructor invocation?
 57      */
 58     boolean constructorArgs = false;
 59 
 60     /** Are we evaluating the selector of a `super' or type name?
 61      */
 62     boolean selectSuper = false;
 63 
 64     /** Is the current target of lambda expression or method reference serializable or is this a
 65      *  serializable class?
 66      */
 67     boolean isSerializable = false;
 68 
 69     /** Is this a serializable lambda?
 70      */
 71     boolean isSerializableLambda = false;
 72 
 73     /** Is this a lambda environment?
 74      */
 75     boolean isLambda = false;
 76 
 77     /** Is this a speculative attribution environment?
 78      */

113      * (set by Attr.visitMethod and Attr.visitLambda)
114      */
115     Attr.ResultInfo returnResult = null;
116 
117     /** ResultInfo to be used for attributing 'yield' statement expressions
118      * (set by Attr.visitSwitchExpression)
119      */
120     Attr.ResultInfo yieldResult = null;
121 
122     /** Symbol corresponding to the site of a qualified default super call
123      */
124     Type defaultSuperCallSite = null;
125 
126     /** Tree that when non null, is to be preferentially used in diagnostics.
127      *  Usually Env<AttrContext>.tree is the tree to be referred to in messages,
128      *  but this may not be true during the window a method is looked up in enclosing
129      *  contexts (JDK-8145466)
130      */
131     JCTree preferredTreeForDiagnostics;
132 


133     /** Duplicate this context, replacing scope field and copying all others.
134      */
135     AttrContext dup(WriteableScope scope) {
136         AttrContext info = new AttrContext();
137         info.scope = scope;
138         info.staticLevel = staticLevel;
139         info.isSelfCall = isSelfCall;
140         info.constructorArgs = constructorArgs;
141         info.selectSuper = selectSuper;
142         info.pendingResolutionPhase = pendingResolutionPhase;
143         info.lint = lint;
144         info.enclVar = enclVar;
145         info.returnResult = returnResult;
146         info.yieldResult = yieldResult;
147         info.defaultSuperCallSite = defaultSuperCallSite;
148         info.isSerializable = isSerializable;
149         info.isLambda = isLambda;
150         info.isSerializableLambda = isSerializableLambda;
151         info.attributionMode = attributionMode;
152         info.isAnonymousDiamond = isAnonymousDiamond;
153         info.isNewClass = isNewClass;
154         info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
155         info.visitingServiceImplementation = visitingServiceImplementation;
156         info.allowProtectedAccess = allowProtectedAccess;

157         return info;
158     }
159 
160     /** Duplicate this context, copying all fields.
161      */
162     AttrContext dup() {
163         return dup(scope);
164     }
165 
166     public Iterable<Symbol> getLocalElements() {
167         if (scope == null)
168             return List.nil();
169         return scope.getSymbols();
170     }
171 
172     boolean lastResolveVarargs() {
173         return pendingResolutionPhase != null &&
174                 pendingResolutionPhase.isVarargsRequired();
175     }
176 

 32 import com.sun.tools.javac.comp.DeferredAttr.AttributionMode;
 33 
 34 /** Contains information specific to the attribute and enter
 35  *  passes, to be used in place of the generic field in environments.
 36  *
 37  *  <p><b>This is NOT part of any supported API.
 38  *  If you write code that depends on this, you do so at your own risk.
 39  *  This code and its internal interfaces are subject to change or
 40  *  deletion without notice.</b>
 41  */
 42 public class AttrContext {
 43 
 44     /** The scope of local symbols.
 45      */
 46     WriteableScope scope = null;
 47 
 48     /** The number of enclosing `static' modifiers.
 49      */
 50     int staticLevel = 0;
 51 
 52     /** Are we in the 'prologue' part of a constructor, prior to an explicit this()/super()?
 53      */
 54     boolean ctorPrologue = false;




 55 
 56     /** Are we evaluating the selector of a `super' or type name?
 57      */
 58     boolean selectSuper = false;
 59 
 60     /** Is the current target of lambda expression or method reference serializable or is this a
 61      *  serializable class?
 62      */
 63     boolean isSerializable = false;
 64 
 65     /** Is this a serializable lambda?
 66      */
 67     boolean isSerializableLambda = false;
 68 
 69     /** Is this a lambda environment?
 70      */
 71     boolean isLambda = false;
 72 
 73     /** Is this a speculative attribution environment?
 74      */

109      * (set by Attr.visitMethod and Attr.visitLambda)
110      */
111     Attr.ResultInfo returnResult = null;
112 
113     /** ResultInfo to be used for attributing 'yield' statement expressions
114      * (set by Attr.visitSwitchExpression)
115      */
116     Attr.ResultInfo yieldResult = null;
117 
118     /** Symbol corresponding to the site of a qualified default super call
119      */
120     Type defaultSuperCallSite = null;
121 
122     /** Tree that when non null, is to be preferentially used in diagnostics.
123      *  Usually Env<AttrContext>.tree is the tree to be referred to in messages,
124      *  but this may not be true during the window a method is looked up in enclosing
125      *  contexts (JDK-8145466)
126      */
127     JCTree preferredTreeForDiagnostics;
128 
129     boolean instanceInitializerBlock = false;
130 
131     /** Duplicate this context, replacing scope field and copying all others.
132      */
133     AttrContext dup(WriteableScope scope) {
134         AttrContext info = new AttrContext();
135         info.scope = scope;
136         info.staticLevel = staticLevel;
137         info.ctorPrologue = ctorPrologue;

138         info.selectSuper = selectSuper;
139         info.pendingResolutionPhase = pendingResolutionPhase;
140         info.lint = lint;
141         info.enclVar = enclVar;
142         info.returnResult = returnResult;
143         info.yieldResult = yieldResult;
144         info.defaultSuperCallSite = defaultSuperCallSite;
145         info.isSerializable = isSerializable;
146         info.isLambda = isLambda;
147         info.isSerializableLambda = isSerializableLambda;
148         info.attributionMode = attributionMode;
149         info.isAnonymousDiamond = isAnonymousDiamond;
150         info.isNewClass = isNewClass;
151         info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
152         info.visitingServiceImplementation = visitingServiceImplementation;
153         info.allowProtectedAccess = allowProtectedAccess;
154         info.instanceInitializerBlock = instanceInitializerBlock;
155         return info;
156     }
157 
158     /** Duplicate this context, copying all fields.
159      */
160     AttrContext dup() {
161         return dup(scope);
162     }
163 
164     public Iterable<Symbol> getLocalElements() {
165         if (scope == null)
166             return List.nil();
167         return scope.getSymbols();
168     }
169 
170     boolean lastResolveVarargs() {
171         return pendingResolutionPhase != null &&
172                 pendingResolutionPhase.isVarargsRequired();
173     }
174 
< prev index next >