Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BlockExprResolve |
|
| 0.0;0 | ||||
BlockExprResolve$1 |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 | * | |
5 | * This code is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License version 2 only, as | |
7 | * published by the Free Software Foundation. Sun designates this | |
8 | * particular file as subject to the "Classpath" exception as provided | |
9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
22 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
23 | * have any questions. | |
24 | */ | |
25 | ||
26 | package com.sun.tools.javafx.comp; | |
27 | ||
28 | import com.sun.tools.javac.util.*; | |
29 | import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; | |
30 | import com.sun.tools.javac.code.*; | |
31 | import com.sun.tools.javac.jvm.*; | |
32 | import com.sun.tools.javac.tree.*; | |
33 | ||
34 | import com.sun.tools.javac.code.Type.*; | |
35 | import com.sun.tools.javac.code.Symbol.*; | |
36 | import com.sun.tools.javac.comp.MemberEnter; | |
37 | import com.sun.tools.javac.comp.Resolve; | |
38 | import com.sun.tools.javac.tree.JCTree.*; | |
39 | ||
40 | import static com.sun.tools.javac.code.Flags.*; | |
41 | import static com.sun.tools.javac.code.Kinds.*; | |
42 | import static com.sun.tools.javac.code.TypeTags.*; | |
43 | ||
44 | /** Helper class for name resolution, used mostly by the attribution phase. | |
45 | * | |
46 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If | |
47 | * you write code that depends on this, you do so at your own risk. | |
48 | * This code and its internal interfaces are subject to change or | |
49 | * deletion without notice.</b> | |
50 | */ | |
51 | public class BlockExprResolve extends Resolve { | |
52 | BlockExprMemberEnter memberEnter; | |
53 | 399 | String interfaceNameSuffix = "$Intf"; |
54 | public static Resolve instance0(Context context) { | |
55 | 0 | Resolve instance = context.get(resolveKey); |
56 | 0 | if (instance == null) |
57 | 0 | instance = new BlockExprResolve(context); |
58 | 0 | return instance; |
59 | } | |
60 | ||
61 | public static void preRegister(final Context context) { | |
62 | 798 | context.put(resolveKey, new Context.Factory<Resolve>() { |
63 | public Resolve make() { | |
64 | 399 | return new BlockExprResolve(context); |
65 | } | |
66 | }); | |
67 | 399 | } |
68 | ||
69 | protected BlockExprResolve(Context context) { | |
70 | 399 | super(context); |
71 | 399 | memberEnter = (BlockExprMemberEnter)BlockExprMemberEnter.instance(context); |
72 | 399 | } |
73 | ||
74 | /** If `sym' is a bad symbol: report error and return errSymbol | |
75 | * else pass through unchanged, | |
76 | * additional arguments duplicate what has been used in trying to find the | |
77 | * symbol (--> flyweight pattern). This improves performance since we | |
78 | * expect misses to happen frequently. | |
79 | * | |
80 | * @param sym The symbol that was found, or a ResolveError. | |
81 | * @param pos The position to use for error reporting. | |
82 | * @param site The original type from where the selection took place. | |
83 | * @param name The symbol's name. | |
84 | * @param argtypes The invocation's value arguments, | |
85 | * if we looked for a method. | |
86 | * @param typeargtypes The invocation's type arguments, | |
87 | * if we looked for a method. | |
88 | */ | |
89 | public Symbol access(Symbol sym, | |
90 | DiagnosticPosition pos, | |
91 | Type site, | |
92 | Name name, | |
93 | boolean qualified, | |
94 | List<Type> argtypes, | |
95 | List<Type> typeargtypes) { | |
96 | 4188 | if (sym.kind >= AMBIGUOUS) { |
97 | // printscopes(site.tsym.members());//DEBUG | |
98 | 10 | if (!site.isErroneous() && |
99 | !Type.isErroneous(argtypes) && | |
100 | (typeargtypes==null || !Type.isErroneous(typeargtypes))) | |
101 | 8 | if (!(memberEnter.resolvingImport && name.toString().endsWith(interfaceNameSuffix))) { |
102 | 8 | ((ResolveError)sym).report(log, pos, site, name, argtypes, typeargtypes); |
103 | } | |
104 | do { | |
105 | 10 | sym = ((ResolveError)sym).sym; |
106 | 10 | } while (sym.kind >= AMBIGUOUS); |
107 | 10 | if (sym == syms.errSymbol // preserve the symbol name through errors |
108 | || ((sym.kind & ERRONEOUS) == 0 // make sure an error symbol is returned | |
109 | && (sym.kind & TYP) != 0)) | |
110 | 9 | sym = new ErrorType(name, qualified?site.tsym:syms.noSymbol).tsym; |
111 | } | |
112 | 4188 | return sym; |
113 | } | |
114 | } |