< prev index next >

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

Print this page

192      *  This will create a fresh scope for local symbols of a class, referred
193      *  to by the environments info.scope field.
194      *  This scope will contain
195      *    - symbols for this and super
196      *    - symbols for any type parameters
197      *  In addition, it serves as an anchor for scopes of methods and initializers
198      *  which are nested in this scope via Scope.dup().
199      *  This scope should not be confused with the members scope of a class.
200      *
201      *  @param tree     The class definition.
202      *  @param env      The environment current outside of the class definition.
203      */
204     public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
205         Env<AttrContext> localEnv =
206             env.dup(tree, env.info.dup(WriteableScope.create(tree.sym)));
207         localEnv.enclClass = tree;
208         localEnv.outer = env;
209         localEnv.info.lint = null; // leave this to be filled in by Attr,
210                                    // when annotations have been processed
211         localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
212         localEnv.info.ctorPrologue = false;
213         return localEnv;
214     }
215 
216     /** Create a fresh environment for toplevels.
217      *  @param tree     The toplevel tree.
218      */
219     Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
220         Env<AttrContext> localEnv = new Env<>(tree, new AttrContext());
221         localEnv.toplevel = tree;
222         localEnv.enclClass = predefClassDef;
223         tree.toplevelScope = WriteableScope.create(tree.packge);
224         tree.namedImportScope = new NamedImportScope(tree.packge);
225         tree.starImportScope = new StarImportScope(tree.packge);
226         tree.moduleImportScope = new StarImportScope(tree.packge);
227         localEnv.info.scope = tree.toplevelScope;
228         localEnv.info.lint = lint;
229         return localEnv;
230     }
231 
232     public Env<AttrContext> getTopLevelEnv(JCCompilationUnit tree) {

192      *  This will create a fresh scope for local symbols of a class, referred
193      *  to by the environments info.scope field.
194      *  This scope will contain
195      *    - symbols for this and super
196      *    - symbols for any type parameters
197      *  In addition, it serves as an anchor for scopes of methods and initializers
198      *  which are nested in this scope via Scope.dup().
199      *  This scope should not be confused with the members scope of a class.
200      *
201      *  @param tree     The class definition.
202      *  @param env      The environment current outside of the class definition.
203      */
204     public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
205         Env<AttrContext> localEnv =
206             env.dup(tree, env.info.dup(WriteableScope.create(tree.sym)));
207         localEnv.enclClass = tree;
208         localEnv.outer = env;
209         localEnv.info.lint = null; // leave this to be filled in by Attr,
210                                    // when annotations have been processed
211         localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
212         localEnv.info.earlyContext = localEnv.info.earlyContext.nested(true);
213         return localEnv;
214     }
215 
216     /** Create a fresh environment for toplevels.
217      *  @param tree     The toplevel tree.
218      */
219     Env<AttrContext> topLevelEnv(JCCompilationUnit tree) {
220         Env<AttrContext> localEnv = new Env<>(tree, new AttrContext());
221         localEnv.toplevel = tree;
222         localEnv.enclClass = predefClassDef;
223         tree.toplevelScope = WriteableScope.create(tree.packge);
224         tree.namedImportScope = new NamedImportScope(tree.packge);
225         tree.starImportScope = new StarImportScope(tree.packge);
226         tree.moduleImportScope = new StarImportScope(tree.packge);
227         localEnv.info.scope = tree.toplevelScope;
228         localEnv.info.lint = lint;
229         return localEnv;
230     }
231 
232     public Env<AttrContext> getTopLevelEnv(JCCompilationUnit tree) {
< prev index next >