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

Thu, 01 Nov 2012 10:48:36 +0100

author
ohrstrom
date
Thu, 01 Nov 2012 10:48:36 +0100
changeset 1384
bf54daa9dcd8
parent 1347
1408af4cd8b0
child 1393
d7d932236fee
permissions
-rw-r--r--

7153951: Add new lint option -Xlint:auxiliaryclass
Reviewed-by: jjg, mcimadamore, forax

duke@1 1 /*
jjh@1305 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.javac.comp;
duke@1 27
duke@1 28 import com.sun.tools.javac.util.*;
duke@1 29 import com.sun.tools.javac.code.*;
duke@1 30
duke@1 31 /** Contains information specific to the attribute and enter
duke@1 32 * passes, to be used in place of the generic field in environments.
duke@1 33 *
jjg@581 34 * <p><b>This is NOT part of any supported API.
jjg@581 35 * If you write code that depends on this, you do so at your own risk.
duke@1 36 * This code and its internal interfaces are subject to change or
duke@1 37 * deletion without notice.</b>
duke@1 38 */
duke@1 39 public class AttrContext {
duke@1 40
duke@1 41 /** The scope of local symbols.
duke@1 42 */
duke@1 43 Scope scope = null;
duke@1 44
duke@1 45 /** The number of enclosing `static' modifiers.
duke@1 46 */
duke@1 47 int staticLevel = 0;
duke@1 48
duke@1 49 /** Is this an environment for a this(...) or super(...) call?
duke@1 50 */
duke@1 51 boolean isSelfCall = false;
duke@1 52
duke@1 53 /** Are we evaluating the selector of a `super' or type name?
duke@1 54 */
duke@1 55 boolean selectSuper = false;
duke@1 56
duke@1 57 /** Are arguments to current function applications boxed into an array for varargs?
duke@1 58 */
mcimadamore@1347 59 Resolve.MethodResolutionPhase pendingResolutionPhase = null;
duke@1 60
duke@1 61 /** A record of the lint/SuppressWarnings currently in effect
duke@1 62 */
duke@1 63 Lint lint;
duke@1 64
mcimadamore@94 65 /** The variable whose initializer is being attributed
mcimadamore@94 66 * useful for detecting self-references in variable initializers
mcimadamore@94 67 */
mcimadamore@94 68 Symbol enclVar = null;
mcimadamore@94 69
mcimadamore@1347 70 /** ResultInfo to be used for attributing 'return' statement expressions
mcimadamore@1347 71 * (set by Attr.visitMethod and Attr.visitLambda)
mcimadamore@1347 72 */
mcimadamore@1347 73 Attr.ResultInfo returnResult = null;
mcimadamore@1347 74
duke@1 75 /** Duplicate this context, replacing scope field and copying all others.
duke@1 76 */
duke@1 77 AttrContext dup(Scope scope) {
duke@1 78 AttrContext info = new AttrContext();
duke@1 79 info.scope = scope;
duke@1 80 info.staticLevel = staticLevel;
duke@1 81 info.isSelfCall = isSelfCall;
duke@1 82 info.selectSuper = selectSuper;
mcimadamore@1347 83 info.pendingResolutionPhase = pendingResolutionPhase;
duke@1 84 info.lint = lint;
mcimadamore@94 85 info.enclVar = enclVar;
mcimadamore@1347 86 info.returnResult = returnResult;
duke@1 87 return info;
duke@1 88 }
duke@1 89
duke@1 90 /** Duplicate this context, copying all fields.
duke@1 91 */
duke@1 92 AttrContext dup() {
duke@1 93 return dup(scope);
duke@1 94 }
duke@1 95
duke@1 96 public Iterable<Symbol> getLocalElements() {
duke@1 97 if (scope == null)
duke@1 98 return List.nil();
duke@1 99 return scope.getElements();
duke@1 100 }
duke@1 101
mcimadamore@1347 102 boolean lastResolveVarargs() {
mcimadamore@1347 103 return pendingResolutionPhase != null &&
mcimadamore@1347 104 pendingResolutionPhase.isVarargsRequired();
mcimadamore@1347 105 }
mcimadamore@1347 106
duke@1 107 public String toString() {
duke@1 108 return "AttrContext[" + scope.toString() + "]";
duke@1 109 }
duke@1 110 }

mercurial