< prev index next >

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

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.comp;
  27 

  28 import com.sun.tools.javac.tree.JCTree;
  29 import com.sun.tools.javac.util.*;
  30 import com.sun.tools.javac.code.*;
  31 import com.sun.tools.javac.code.Scope.WriteableScope;
  32 
  33 /** Contains information specific to the attribute and enter
  34  *  passes, to be used in place of the generic field in environments.
  35  *
  36  *  <p><b>This is NOT part of any supported API.
  37  *  If you write code that depends on this, you do so at your own risk.
  38  *  This code and its internal interfaces are subject to change or
  39  *  deletion without notice.</b>
  40  */
  41 public class AttrContext {
  42 
  43     /** The scope of local symbols.
  44      */
  45     WriteableScope scope = null;
  46 
  47     /** The number of enclosing `static' modifiers.


 100      * (set by Attr.visitMethod and Attr.visitLambda)
 101      */
 102     Attr.ResultInfo returnResult = null;
 103 
 104     /** ResultInfo to be used for attributing 'break' statement expressions
 105      * (set by Attr.visitSwitchExpression)
 106      */
 107     Attr.ResultInfo breakResult = null;
 108 
 109     /** Symbol corresponding to the site of a qualified default super call
 110      */
 111     Type defaultSuperCallSite = null;
 112 
 113     /** Tree that when non null, is to be preferentially used in diagnostics.
 114      *  Usually Env<AttrContext>.tree is the tree to be referred to in messages,
 115      *  but this may not be true during the window a method is looked up in enclosing
 116      *  contexts (JDK-8145466)
 117      */
 118     JCTree preferredTreeForDiagnostics;
 119 


 120     /** Duplicate this context, replacing scope field and copying all others.
 121      */
 122     AttrContext dup(WriteableScope scope) {
 123         AttrContext info = new AttrContext();
 124         info.scope = scope;
 125         info.staticLevel = staticLevel;
 126         info.isSelfCall = isSelfCall;
 127         info.selectSuper = selectSuper;
 128         info.pendingResolutionPhase = pendingResolutionPhase;
 129         info.lint = lint;
 130         info.enclVar = enclVar;
 131         info.returnResult = returnResult;
 132         info.breakResult = breakResult;
 133         info.defaultSuperCallSite = defaultSuperCallSite;
 134         info.isSerializable = isSerializable;
 135         info.isLambda = isLambda;
 136         info.isSpeculative = isSpeculative;
 137         info.isAnonymousDiamond = isAnonymousDiamond;
 138         info.isNewClass = isNewClass;
 139         info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
 140         info.visitingServiceImplementation = visitingServiceImplementation;

 141         return info;
 142     }
 143 
 144     /** Duplicate this context, copying all fields.
 145      */
 146     AttrContext dup() {
 147         return dup(scope);
 148     }
 149 
 150     public Iterable<Symbol> getLocalElements() {
 151         if (scope == null)
 152             return List.nil();
 153         return scope.getSymbols();
 154     }
 155 
 156     boolean lastResolveVarargs() {
 157         return pendingResolutionPhase != null &&
 158                 pendingResolutionPhase.isVarargsRequired();
 159     }
 160 


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.comp;
  27 
  28 import com.sun.tools.javac.code.Symbol.MethodSymbol;
  29 import com.sun.tools.javac.tree.JCTree;
  30 import com.sun.tools.javac.util.*;
  31 import com.sun.tools.javac.code.*;
  32 import com.sun.tools.javac.code.Scope.WriteableScope;
  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.


 101      * (set by Attr.visitMethod and Attr.visitLambda)
 102      */
 103     Attr.ResultInfo returnResult = null;
 104 
 105     /** ResultInfo to be used for attributing 'break' statement expressions
 106      * (set by Attr.visitSwitchExpression)
 107      */
 108     Attr.ResultInfo breakResult = null;
 109 
 110     /** Symbol corresponding to the site of a qualified default super call
 111      */
 112     Type defaultSuperCallSite = null;
 113 
 114     /** Tree that when non null, is to be preferentially used in diagnostics.
 115      *  Usually Env<AttrContext>.tree is the tree to be referred to in messages,
 116      *  but this may not be true during the window a method is looked up in enclosing
 117      *  contexts (JDK-8145466)
 118      */
 119     JCTree preferredTreeForDiagnostics;
 120 
 121     MethodSymbol recordImplicitConstructor;
 122 
 123     /** Duplicate this context, replacing scope field and copying all others.
 124      */
 125     AttrContext dup(WriteableScope scope) {
 126         AttrContext info = new AttrContext();
 127         info.scope = scope;
 128         info.staticLevel = staticLevel;
 129         info.isSelfCall = isSelfCall;
 130         info.selectSuper = selectSuper;
 131         info.pendingResolutionPhase = pendingResolutionPhase;
 132         info.lint = lint;
 133         info.enclVar = enclVar;
 134         info.returnResult = returnResult;
 135         info.breakResult = breakResult;
 136         info.defaultSuperCallSite = defaultSuperCallSite;
 137         info.isSerializable = isSerializable;
 138         info.isLambda = isLambda;
 139         info.isSpeculative = isSpeculative;
 140         info.isAnonymousDiamond = isAnonymousDiamond;
 141         info.isNewClass = isNewClass;
 142         info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
 143         info.visitingServiceImplementation = visitingServiceImplementation;
 144         info.recordImplicitConstructor = recordImplicitConstructor;
 145         return info;
 146     }
 147 
 148     /** Duplicate this context, copying all fields.
 149      */
 150     AttrContext dup() {
 151         return dup(scope);
 152     }
 153 
 154     public Iterable<Symbol> getLocalElements() {
 155         if (scope == null)
 156             return List.nil();
 157         return scope.getSymbols();
 158     }
 159 
 160     boolean lastResolveVarargs() {
 161         return pendingResolutionPhase != null &&
 162                 pendingResolutionPhase.isVarargsRequired();
 163     }
 164 
< prev index next >