author | briangoetz |
Wed, 18 Dec 2013 16:05:18 -0500 | |
changeset 22163 | 3651128c74eb |
parent 18646 | e628560a86d1 |
child 22442 | 8fd30fc4e3a3 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15356
cf312dc54c60
8006119: update javac to follow latest spec for repeatable annotations
jjg
parents:
14539
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.code; |
|
27 |
||
28 |
import java.util.*; |
|
29 |
||
14258 | 30 |
import javax.lang.model.element.ElementVisitor; |
31 |
||
10 | 32 |
import com.sun.tools.javac.code.Symbol.*; |
33 |
import com.sun.tools.javac.code.Type.*; |
|
34 |
import com.sun.tools.javac.jvm.*; |
|
14258 | 35 |
import com.sun.tools.javac.util.*; |
36 |
import com.sun.tools.javac.util.List; |
|
37 |
import static com.sun.tools.javac.code.Flags.*; |
|
10 | 38 |
import static com.sun.tools.javac.jvm.ByteCodes.*; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
39 |
import static com.sun.tools.javac.code.TypeTag.*; |
10 | 40 |
|
41 |
/** A class that defines all predefined constants and operators |
|
42 |
* as well as special classes such as java.lang.Object, which need |
|
43 |
* to be known to the compiler. All symbols are held in instance |
|
44 |
* fields. This makes it possible to work in multiple concurrent |
|
45 |
* projects, which might use different class files for library classes. |
|
46 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
47 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
48 |
* If you write code that depends on this, you do so at your own risk. |
10 | 49 |
* This code and its internal interfaces are subject to change or |
50 |
* deletion without notice.</b> |
|
51 |
*/ |
|
52 |
public class Symtab { |
|
53 |
/** The context key for the symbol table. */ |
|
22163 | 54 |
protected static final Context.Key<Symtab> symtabKey = new Context.Key<>(); |
10 | 55 |
|
56 |
/** Get the symbol table instance. */ |
|
57 |
public static Symtab instance(Context context) { |
|
58 |
Symtab instance = context.get(symtabKey); |
|
59 |
if (instance == null) |
|
60 |
instance = new Symtab(context); |
|
61 |
return instance; |
|
62 |
} |
|
63 |
||
64 |
/** Builtin types. |
|
65 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
66 |
public final JCPrimitiveType byteType = new JCPrimitiveType(BYTE, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
67 |
public final JCPrimitiveType charType = new JCPrimitiveType(CHAR, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
68 |
public final JCPrimitiveType shortType = new JCPrimitiveType(SHORT, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
69 |
public final JCPrimitiveType intType = new JCPrimitiveType(INT, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
70 |
public final JCPrimitiveType longType = new JCPrimitiveType(LONG, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
71 |
public final JCPrimitiveType floatType = new JCPrimitiveType(FLOAT, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
72 |
public final JCPrimitiveType doubleType = new JCPrimitiveType(DOUBLE, null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
73 |
public final JCPrimitiveType booleanType = new JCPrimitiveType(BOOLEAN, null); |
10 | 74 |
public final Type botType = new BottomType(); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
75 |
public final JCVoidType voidType = new JCVoidType(); |
10 | 76 |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1257
diff
changeset
|
77 |
private final Names names; |
10 | 78 |
private final ClassReader reader; |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
79 |
private final Target target; |
10 | 80 |
|
81 |
/** A symbol for the root package. |
|
82 |
*/ |
|
83 |
public final PackageSymbol rootPackage; |
|
84 |
||
85 |
/** A symbol for the unnamed package. |
|
86 |
*/ |
|
87 |
public final PackageSymbol unnamedPackage; |
|
88 |
||
89 |
/** A symbol that stands for a missing symbol. |
|
90 |
*/ |
|
91 |
public final TypeSymbol noSymbol; |
|
92 |
||
93 |
/** The error symbol. |
|
94 |
*/ |
|
95 |
public final ClassSymbol errSymbol; |
|
96 |
||
6594
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
97 |
/** The unknown symbol. |
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
98 |
*/ |
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
99 |
public final ClassSymbol unknownSymbol; |
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
100 |
|
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1037
diff
changeset
|
101 |
/** A value for the errType, with a originalType of noType */ |
10 | 102 |
public final Type errType; |
103 |
||
104 |
/** A value for the unknown type. */ |
|
105 |
public final Type unknownType; |
|
106 |
||
107 |
/** The builtin type of all arrays. */ |
|
108 |
public final ClassSymbol arrayClass; |
|
109 |
public final MethodSymbol arrayCloneMethod; |
|
110 |
||
111 |
/** VGJ: The (singleton) type of all bound types. */ |
|
112 |
public final ClassSymbol boundClass; |
|
113 |
||
114 |
/** The builtin type of all methods. */ |
|
115 |
public final ClassSymbol methodClass; |
|
116 |
||
117 |
/** Predefined types. |
|
118 |
*/ |
|
119 |
public final Type objectType; |
|
120 |
public final Type classType; |
|
121 |
public final Type classLoaderType; |
|
122 |
public final Type stringType; |
|
123 |
public final Type stringBufferType; |
|
124 |
public final Type stringBuilderType; |
|
125 |
public final Type cloneableType; |
|
126 |
public final Type serializableType; |
|
16300 | 127 |
public final Type serializedLambdaType; |
2723
b659ca23d5f5
6829189: Java programming with JSR 292 needs language support
jrose
parents:
1471
diff
changeset
|
128 |
public final Type methodHandleType; |
14365
20f388573215
8000694: Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods
rfield
parents:
14359
diff
changeset
|
129 |
public final Type methodHandleLookupType; |
14046
8ef5d5b19998
7194586: Add back-end support for invokedynamic
mcimadamore
parents:
13844
diff
changeset
|
130 |
public final Type methodTypeType; |
12213
516b112d6c68
7150368: javac should include basic ability to generate native headers
jjg
parents:
9082
diff
changeset
|
131 |
public final Type nativeHeaderType; |
10 | 132 |
public final Type throwableType; |
133 |
public final Type errorType; |
|
9076
45c73da050e9
7027157: Project Coin: javac warnings for AutoCloseable.close throwing InterruptedException
mcimadamore
parents:
8621
diff
changeset
|
134 |
public final Type interruptedExceptionType; |
10 | 135 |
public final Type illegalArgumentExceptionType; |
136 |
public final Type exceptionType; |
|
137 |
public final Type runtimeExceptionType; |
|
138 |
public final Type classNotFoundExceptionType; |
|
139 |
public final Type noClassDefFoundErrorType; |
|
140 |
public final Type noSuchFieldErrorType; |
|
141 |
public final Type assertionErrorType; |
|
142 |
public final Type cloneNotSupportedExceptionType; |
|
143 |
public final Type annotationType; |
|
144 |
public final TypeSymbol enumSym; |
|
145 |
public final Type listType; |
|
146 |
public final Type collectionsType; |
|
147 |
public final Type comparableType; |
|
16333 | 148 |
public final Type comparatorType; |
10 | 149 |
public final Type arraysType; |
150 |
public final Type iterableType; |
|
151 |
public final Type iteratorType; |
|
152 |
public final Type annotationTargetType; |
|
153 |
public final Type overrideType; |
|
154 |
public final Type retentionType; |
|
155 |
public final Type deprecatedType; |
|
156 |
public final Type suppressWarningsType; |
|
157 |
public final Type inheritedType; |
|
15724 | 158 |
public final Type profileType; |
10 | 159 |
public final Type proprietaryType; |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
160 |
public final Type systemType; |
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
161 |
public final Type autoCloseableType; |
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
6709
diff
changeset
|
162 |
public final Type trustMeType; |
14365
20f388573215
8000694: Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods
rfield
parents:
14359
diff
changeset
|
163 |
public final Type lambdaMetafactory; |
15356
cf312dc54c60
8006119: update javac to follow latest spec for repeatable annotations
jjg
parents:
14539
diff
changeset
|
164 |
public final Type repeatableType; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
12335
diff
changeset
|
165 |
public final Type documentedType; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
12335
diff
changeset
|
166 |
public final Type elementTypeType; |
15361
01f1828683e6
8005299: Add FunctionalInterface checking to javac
mcimadamore
parents:
15356
diff
changeset
|
167 |
public final Type functionalInterfaceType; |
10 | 168 |
|
169 |
/** The symbol representing the length field of an array. |
|
170 |
*/ |
|
171 |
public final VarSymbol lengthVar; |
|
172 |
||
173 |
/** The null check operator. */ |
|
174 |
public final OperatorSymbol nullcheck; |
|
175 |
||
176 |
/** The symbol representing the final finalize method on enums */ |
|
177 |
public final MethodSymbol enumFinalFinalize; |
|
178 |
||
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
179 |
/** The symbol representing the close method on TWR AutoCloseable type */ |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
180 |
public final MethodSymbol autoCloseableClose; |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
181 |
|
10 | 182 |
/** The predefined type that belongs to a tag. |
183 |
*/ |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
184 |
public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()]; |
10 | 185 |
|
186 |
/** The name of the class that belongs to a basix type tag. |
|
187 |
*/ |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
188 |
public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()]; |
10 | 189 |
|
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
190 |
/** A set containing all operator names. |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
191 |
*/ |
22163 | 192 |
public final Set<Name> operatorNames = new HashSet<>(); |
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
193 |
|
10 | 194 |
/** A hashtable containing the encountered top-level and member classes, |
195 |
* indexed by flat names. The table does not contain local classes. |
|
196 |
* It should be updated from the outside to reflect classes defined |
|
197 |
* by compiled source files. |
|
198 |
*/ |
|
22163 | 199 |
public final Map<Name, ClassSymbol> classes = new HashMap<>(); |
10 | 200 |
|
201 |
/** A hashtable containing the encountered packages. |
|
202 |
* the table should be updated from outside to reflect packages defined |
|
203 |
* by compiled source files. |
|
204 |
*/ |
|
22163 | 205 |
public final Map<Name, PackageSymbol> packages = new HashMap<>(); |
10 | 206 |
|
207 |
public void initType(Type type, ClassSymbol c) { |
|
208 |
type.tsym = c; |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
209 |
typeOfTag[type.getTag().ordinal()] = type; |
10 | 210 |
} |
211 |
||
212 |
public void initType(Type type, String name) { |
|
213 |
initType( |
|
214 |
type, |
|
215 |
new ClassSymbol( |
|
216 |
PUBLIC, names.fromString(name), type, rootPackage)); |
|
217 |
} |
|
218 |
||
219 |
public void initType(Type type, String name, String bname) { |
|
220 |
initType(type, name); |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
221 |
boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname); |
10 | 222 |
} |
223 |
||
224 |
/** The class symbol that owns all predefined symbols. |
|
225 |
*/ |
|
226 |
public final ClassSymbol predefClass; |
|
227 |
||
228 |
/** Enter a constant into symbol table. |
|
229 |
* @param name The constant's name. |
|
230 |
* @param type The constant's type. |
|
231 |
*/ |
|
232 |
private VarSymbol enterConstant(String name, Type type) { |
|
233 |
VarSymbol c = new VarSymbol( |
|
234 |
PUBLIC | STATIC | FINAL, |
|
235 |
names.fromString(name), |
|
236 |
type, |
|
237 |
predefClass); |
|
238 |
c.setData(type.constValue()); |
|
239 |
predefClass.members().enter(c); |
|
240 |
return c; |
|
241 |
} |
|
242 |
||
243 |
/** Enter a binary operation into symbol table. |
|
244 |
* @param name The name of the operator. |
|
245 |
* @param left The type of the left operand. |
|
246 |
* @param right The type of the left operand. |
|
247 |
* @param res The operation's result type. |
|
248 |
* @param opcode The operation's bytecode instruction. |
|
249 |
*/ |
|
250 |
private void enterBinop(String name, |
|
251 |
Type left, Type right, Type res, |
|
252 |
int opcode) { |
|
253 |
predefClass.members().enter( |
|
254 |
new OperatorSymbol( |
|
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
255 |
makeOperatorName(name), |
10 | 256 |
new MethodType(List.of(left, right), res, |
257 |
List.<Type>nil(), methodClass), |
|
258 |
opcode, |
|
259 |
predefClass)); |
|
260 |
} |
|
261 |
||
262 |
/** Enter a binary operation, as above but with two opcodes, |
|
13844 | 263 |
* which get encoded as |
264 |
* {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }. |
|
10 | 265 |
* @param opcode1 First opcode. |
266 |
* @param opcode2 Second opcode. |
|
267 |
*/ |
|
268 |
private void enterBinop(String name, |
|
269 |
Type left, Type right, Type res, |
|
270 |
int opcode1, int opcode2) { |
|
271 |
enterBinop( |
|
272 |
name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2); |
|
273 |
} |
|
274 |
||
275 |
/** Enter a unary operation into symbol table. |
|
276 |
* @param name The name of the operator. |
|
277 |
* @param arg The type of the operand. |
|
278 |
* @param res The operation's result type. |
|
279 |
* @param opcode The operation's bytecode instruction. |
|
280 |
*/ |
|
281 |
private OperatorSymbol enterUnop(String name, |
|
282 |
Type arg, |
|
283 |
Type res, |
|
284 |
int opcode) { |
|
285 |
OperatorSymbol sym = |
|
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
286 |
new OperatorSymbol(makeOperatorName(name), |
10 | 287 |
new MethodType(List.of(arg), |
288 |
res, |
|
289 |
List.<Type>nil(), |
|
290 |
methodClass), |
|
291 |
opcode, |
|
292 |
predefClass); |
|
293 |
predefClass.members().enter(sym); |
|
294 |
return sym; |
|
295 |
} |
|
296 |
||
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
297 |
/** |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
298 |
* Create a new operator name from corresponding String representation |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
299 |
* and add the name to the set of known operator names. |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
300 |
*/ |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
301 |
private Name makeOperatorName(String name) { |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
302 |
Name opName = names.fromString(name); |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
303 |
operatorNames.add(opName); |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
304 |
return opName; |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
305 |
} |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14046
diff
changeset
|
306 |
|
10 | 307 |
/** Enter a class into symbol table. |
14259 | 308 |
* @param s The name of the class. |
10 | 309 |
*/ |
310 |
private Type enterClass(String s) { |
|
311 |
return reader.enterClass(names.fromString(s)).type; |
|
312 |
} |
|
313 |
||
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
314 |
public void synthesizeEmptyInterfaceIfMissing(final Type type) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
315 |
final Completer completer = type.tsym.completer; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
316 |
if (completer != null) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
317 |
type.tsym.completer = new Completer() { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
318 |
public void complete(Symbol sym) throws CompletionFailure { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
319 |
try { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
320 |
completer.complete(sym); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
321 |
} catch (CompletionFailure e) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
322 |
sym.flags_field |= (PUBLIC | INTERFACE); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
323 |
((ClassType) sym.type).supertype_field = objectType; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
324 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
325 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
326 |
}; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
327 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
328 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
329 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
330 |
public void synthesizeBoxTypeIfMissing(final Type type) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
331 |
ClassSymbol sym = reader.enterClass(boxedName[type.getTag().ordinal()]); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
332 |
final Completer completer = sym.completer; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
333 |
if (completer != null) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
334 |
sym.completer = new Completer() { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
335 |
public void complete(Symbol sym) throws CompletionFailure { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
336 |
try { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
337 |
completer.complete(sym); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
338 |
} catch (CompletionFailure e) { |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
339 |
sym.flags_field |= PUBLIC; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
340 |
((ClassType) sym.type).supertype_field = objectType; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
341 |
Name n = target.boxWithConstructors() ? names.init : names.valueOf; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
342 |
MethodSymbol boxMethod = |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
343 |
new MethodSymbol(PUBLIC | STATIC, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
344 |
n, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
345 |
new MethodType(List.of(type), sym.type, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
346 |
List.<Type>nil(), methodClass), |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
347 |
sym); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
348 |
sym.members().enter(boxMethod); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
349 |
MethodSymbol unboxMethod = |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
350 |
new MethodSymbol(PUBLIC, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
351 |
type.tsym.name.append(names.Value), // x.intValue() |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
352 |
new MethodType(List.<Type>nil(), type, |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
353 |
List.<Type>nil(), methodClass), |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
354 |
sym); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
355 |
sym.members().enter(unboxMethod); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
356 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
357 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
358 |
}; |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
359 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
360 |
|
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
361 |
} |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
362 |
|
15724 | 363 |
// Enter a synthetic class that is used to mark classes in ct.sym. |
364 |
// This class does not have a class file. |
|
365 |
private Type enterSyntheticAnnotation(String name) { |
|
366 |
ClassType type = (ClassType)enterClass(name); |
|
367 |
ClassSymbol sym = (ClassSymbol)type.tsym; |
|
368 |
sym.completer = null; |
|
369 |
sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE; |
|
370 |
sym.erasure_field = type; |
|
371 |
sym.members_field = new Scope(sym); |
|
372 |
type.typarams_field = List.nil(); |
|
373 |
type.allparams_field = List.nil(); |
|
374 |
type.supertype_field = annotationType; |
|
375 |
type.interfaces_field = List.nil(); |
|
376 |
return type; |
|
377 |
} |
|
378 |
||
10 | 379 |
/** Constructor; enters all predefined identifiers and operators |
380 |
* into symbol table. |
|
381 |
*/ |
|
382 |
protected Symtab(Context context) throws CompletionFailure { |
|
383 |
context.put(symtabKey, this); |
|
384 |
||
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1257
diff
changeset
|
385 |
names = Names.instance(context); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
386 |
target = Target.instance(context); |
10 | 387 |
|
388 |
// Create the unknown type |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18414
diff
changeset
|
389 |
unknownType = new UnknownType(); |
10 | 390 |
|
391 |
// create the basic builtin symbols |
|
392 |
rootPackage = new PackageSymbol(names.empty, null); |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
393 |
final JavacMessages messages = JavacMessages.instance(context); |
10 | 394 |
unnamedPackage = new PackageSymbol(names.empty, rootPackage) { |
395 |
public String toString() { |
|
396 |
return messages.getLocalizedString("compiler.misc.unnamed.package"); |
|
397 |
} |
|
398 |
}; |
|
16967
79d444669f3f
7015104: use new subtype of TypeSymbol for type parameters
jfranck
parents:
16333
diff
changeset
|
399 |
noSymbol = new TypeSymbol(Kinds.NIL, 0, names.empty, Type.noType, rootPackage) { |
8621
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
400 |
public <R, P> R accept(ElementVisitor<R, P> v, P p) { |
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
401 |
return v.visitUnknown(this, p); |
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
402 |
} |
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
403 |
}; |
10 | 404 |
|
405 |
// create the error symbols |
|
406 |
errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage); |
|
8621
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
407 |
errType = new ErrorType(errSymbol, Type.noType); |
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
408 |
|
6594
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
409 |
unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage); |
8621
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
410 |
unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol); |
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
411 |
unknownSymbol.type = unknownType; |
10 | 412 |
|
413 |
// initialize builtin types |
|
414 |
initType(byteType, "byte", "Byte"); |
|
415 |
initType(shortType, "short", "Short"); |
|
416 |
initType(charType, "char", "Character"); |
|
417 |
initType(intType, "int", "Integer"); |
|
418 |
initType(longType, "long", "Long"); |
|
419 |
initType(floatType, "float", "Float"); |
|
420 |
initType(doubleType, "double", "Double"); |
|
421 |
initType(booleanType, "boolean", "Boolean"); |
|
422 |
initType(voidType, "void", "Void"); |
|
423 |
initType(botType, "<nulltype>"); |
|
424 |
initType(errType, errSymbol); |
|
6594
d43f068fba19
6970584: Flow.java should be more error-friendly
mcimadamore
parents:
6148
diff
changeset
|
425 |
initType(unknownType, unknownSymbol); |
10 | 426 |
|
427 |
// the builtin class of all arrays |
|
428 |
arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol); |
|
429 |
||
430 |
// VGJ |
|
431 |
boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol); |
|
8621
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
432 |
boundClass.members_field = new Scope.ErrorScope(boundClass); |
10 | 433 |
|
434 |
// the builtin class of all methods |
|
435 |
methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol); |
|
8621
ce0bce60cffc
7021183: 269: assertion failure getting enclosing element of an undefined name
jjg
parents:
8242
diff
changeset
|
436 |
methodClass.members_field = new Scope.ErrorScope(boundClass); |
10 | 437 |
|
438 |
// Create class to hold all predefined constants and operations. |
|
439 |
predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage); |
|
8242
3873b4aaf4a8
7007615: java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
mcimadamore
parents:
8241
diff
changeset
|
440 |
Scope scope = new Scope(predefClass); |
10 | 441 |
predefClass.members_field = scope; |
442 |
||
443 |
// Enter symbols for basic types. |
|
444 |
scope.enter(byteType.tsym); |
|
445 |
scope.enter(shortType.tsym); |
|
446 |
scope.enter(charType.tsym); |
|
447 |
scope.enter(intType.tsym); |
|
448 |
scope.enter(longType.tsym); |
|
449 |
scope.enter(floatType.tsym); |
|
450 |
scope.enter(doubleType.tsym); |
|
451 |
scope.enter(booleanType.tsym); |
|
452 |
scope.enter(errType.tsym); |
|
453 |
||
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1037
diff
changeset
|
454 |
// Enter symbol for the errSymbol |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1037
diff
changeset
|
455 |
scope.enter(errSymbol); |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1037
diff
changeset
|
456 |
|
10 | 457 |
classes.put(predefClass.fullname, predefClass); |
458 |
||
459 |
reader = ClassReader.instance(context); |
|
460 |
reader.init(this); |
|
461 |
||
462 |
// Enter predefined classes. |
|
463 |
objectType = enterClass("java.lang.Object"); |
|
464 |
classType = enterClass("java.lang.Class"); |
|
465 |
stringType = enterClass("java.lang.String"); |
|
466 |
stringBufferType = enterClass("java.lang.StringBuffer"); |
|
467 |
stringBuilderType = enterClass("java.lang.StringBuilder"); |
|
468 |
cloneableType = enterClass("java.lang.Cloneable"); |
|
469 |
throwableType = enterClass("java.lang.Throwable"); |
|
470 |
serializableType = enterClass("java.io.Serializable"); |
|
16300 | 471 |
serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda"); |
8241
4161b56e0d20
7017414: before the move of JSR 292 to package java.lang.invoke, javac must recognize the new package
mcimadamore
parents:
8036
diff
changeset
|
472 |
methodHandleType = enterClass("java.lang.invoke.MethodHandle"); |
14365
20f388573215
8000694: Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods
rfield
parents:
14359
diff
changeset
|
473 |
methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup"); |
14046
8ef5d5b19998
7194586: Add back-end support for invokedynamic
mcimadamore
parents:
13844
diff
changeset
|
474 |
methodTypeType = enterClass("java.lang.invoke.MethodType"); |
10 | 475 |
errorType = enterClass("java.lang.Error"); |
476 |
illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException"); |
|
9076
45c73da050e9
7027157: Project Coin: javac warnings for AutoCloseable.close throwing InterruptedException
mcimadamore
parents:
8621
diff
changeset
|
477 |
interruptedExceptionType = enterClass("java.lang.InterruptedException"); |
10 | 478 |
exceptionType = enterClass("java.lang.Exception"); |
479 |
runtimeExceptionType = enterClass("java.lang.RuntimeException"); |
|
480 |
classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException"); |
|
481 |
noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError"); |
|
482 |
noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError"); |
|
483 |
assertionErrorType = enterClass("java.lang.AssertionError"); |
|
484 |
cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException"); |
|
485 |
annotationType = enterClass("java.lang.annotation.Annotation"); |
|
486 |
classLoaderType = enterClass("java.lang.ClassLoader"); |
|
487 |
enumSym = reader.enterClass(names.java_lang_Enum); |
|
488 |
enumFinalFinalize = |
|
489 |
new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL, |
|
490 |
names.finalize, |
|
491 |
new MethodType(List.<Type>nil(), voidType, |
|
492 |
List.<Type>nil(), methodClass), |
|
493 |
enumSym); |
|
494 |
listType = enterClass("java.util.List"); |
|
495 |
collectionsType = enterClass("java.util.Collections"); |
|
496 |
comparableType = enterClass("java.lang.Comparable"); |
|
16333 | 497 |
comparatorType = enterClass("java.util.Comparator"); |
10 | 498 |
arraysType = enterClass("java.util.Arrays"); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
499 |
iterableType = target.hasIterable() |
10 | 500 |
? enterClass("java.lang.Iterable") |
501 |
: enterClass("java.util.Collection"); |
|
502 |
iteratorType = enterClass("java.util.Iterator"); |
|
503 |
annotationTargetType = enterClass("java.lang.annotation.Target"); |
|
504 |
overrideType = enterClass("java.lang.Override"); |
|
505 |
retentionType = enterClass("java.lang.annotation.Retention"); |
|
506 |
deprecatedType = enterClass("java.lang.Deprecated"); |
|
507 |
suppressWarningsType = enterClass("java.lang.SuppressWarnings"); |
|
508 |
inheritedType = enterClass("java.lang.annotation.Inherited"); |
|
15356
cf312dc54c60
8006119: update javac to follow latest spec for repeatable annotations
jjg
parents:
14539
diff
changeset
|
509 |
repeatableType = enterClass("java.lang.annotation.Repeatable"); |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
12335
diff
changeset
|
510 |
documentedType = enterClass("java.lang.annotation.Documented"); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
12335
diff
changeset
|
511 |
elementTypeType = enterClass("java.lang.annotation.ElementType"); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
512 |
systemType = enterClass("java.lang.System"); |
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
513 |
autoCloseableType = enterClass("java.lang.AutoCloseable"); |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
514 |
autoCloseableClose = new MethodSymbol(PUBLIC, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
515 |
names.close, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
516 |
new MethodType(List.<Type>nil(), voidType, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
517 |
List.of(exceptionType), methodClass), |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5857
diff
changeset
|
518 |
autoCloseableType.tsym); |
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
6709
diff
changeset
|
519 |
trustMeType = enterClass("java.lang.SafeVarargs"); |
14539
507556c4e622
8003412: javac needs to understand java.lang.annotation.Native
jjg
parents:
14365
diff
changeset
|
520 |
nativeHeaderType = enterClass("java.lang.annotation.Native"); |
14365
20f388573215
8000694: Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods
rfield
parents:
14359
diff
changeset
|
521 |
lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory"); |
15361
01f1828683e6
8005299: Add FunctionalInterface checking to javac
mcimadamore
parents:
15356
diff
changeset
|
522 |
functionalInterfaceType = enterClass("java.lang.FunctionalInterface"); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
523 |
|
9076
45c73da050e9
7027157: Project Coin: javac warnings for AutoCloseable.close throwing InterruptedException
mcimadamore
parents:
8621
diff
changeset
|
524 |
synthesizeEmptyInterfaceIfMissing(autoCloseableType); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
525 |
synthesizeEmptyInterfaceIfMissing(cloneableType); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
526 |
synthesizeEmptyInterfaceIfMissing(serializableType); |
14365
20f388573215
8000694: Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods
rfield
parents:
14359
diff
changeset
|
527 |
synthesizeEmptyInterfaceIfMissing(lambdaMetafactory); |
16300 | 528 |
synthesizeEmptyInterfaceIfMissing(serializedLambdaType); |
1037
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
529 |
synthesizeBoxTypeIfMissing(doubleType); |
c6b315a34dc6
6627362: javac generates code that uses array.clone, which is not available on JavaCard
jjg
parents:
10
diff
changeset
|
530 |
synthesizeBoxTypeIfMissing(floatType); |
3555
a6fd77fe81df
6390045: Unexpected error "cannot access java.lang.Void" with '-target cldc1.0' with -source >=1.5
mcimadamore
parents:
2723
diff
changeset
|
531 |
synthesizeBoxTypeIfMissing(voidType); |
10 | 532 |
|
5848
c5a4ce47e780
6960407: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5847
diff
changeset
|
533 |
// Enter a synthetic class that is used to mark internal |
10 | 534 |
// proprietary classes in ct.sym. This class does not have a |
535 |
// class file. |
|
15724 | 536 |
proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation"); |
537 |
||
538 |
// Enter a synthetic class that is used to provide profile info for |
|
539 |
// classes in ct.sym. This class does not have a class file. |
|
540 |
profileType = enterSyntheticAnnotation("jdk.Profile+Annotation"); |
|
541 |
MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym); |
|
542 |
profileType.tsym.members().enter(m); |
|
10 | 543 |
|
544 |
// Enter a class for arrays. |
|
545 |
// The class implements java.lang.Cloneable and java.io.Serializable. |
|
546 |
// It has a final length field and a clone method. |
|
547 |
ClassType arrayClassType = (ClassType)arrayClass.type; |
|
548 |
arrayClassType.supertype_field = objectType; |
|
549 |
arrayClassType.interfaces_field = List.of(cloneableType, serializableType); |
|
8242
3873b4aaf4a8
7007615: java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
mcimadamore
parents:
8241
diff
changeset
|
550 |
arrayClass.members_field = new Scope(arrayClass); |
10 | 551 |
lengthVar = new VarSymbol( |
552 |
PUBLIC | FINAL, |
|
553 |
names.length, |
|
554 |
intType, |
|
555 |
arrayClass); |
|
556 |
arrayClass.members().enter(lengthVar); |
|
557 |
arrayCloneMethod = new MethodSymbol( |
|
558 |
PUBLIC, |
|
559 |
names.clone, |
|
560 |
new MethodType(List.<Type>nil(), objectType, |
|
561 |
List.<Type>nil(), methodClass), |
|
562 |
arrayClass); |
|
563 |
arrayClass.members().enter(arrayCloneMethod); |
|
564 |
||
565 |
// Enter operators. |
|
18414
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
566 |
/* Internally we use +++, --- for unary +, - to reduce +, - operators |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
567 |
* overloading |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
568 |
*/ |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
569 |
enterUnop("+++", doubleType, doubleType, nop); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
570 |
enterUnop("+++", floatType, floatType, nop); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
571 |
enterUnop("+++", longType, longType, nop); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
572 |
enterUnop("+++", intType, intType, nop); |
10 | 573 |
|
18414
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
574 |
enterUnop("---", doubleType, doubleType, dneg); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
575 |
enterUnop("---", floatType, floatType, fneg); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
576 |
enterUnop("---", longType, longType, lneg); |
ee1e93e83d2b
8016610: javac, add new internal symbols to make operator resolution faster
vromero
parents:
17546
diff
changeset
|
577 |
enterUnop("---", intType, intType, ineg); |
10 | 578 |
|
579 |
enterUnop("~", longType, longType, lxor); |
|
580 |
enterUnop("~", intType, intType, ixor); |
|
581 |
||
582 |
enterUnop("++", doubleType, doubleType, dadd); |
|
583 |
enterUnop("++", floatType, floatType, fadd); |
|
584 |
enterUnop("++", longType, longType, ladd); |
|
585 |
enterUnop("++", intType, intType, iadd); |
|
586 |
enterUnop("++", charType, charType, iadd); |
|
587 |
enterUnop("++", shortType, shortType, iadd); |
|
588 |
enterUnop("++", byteType, byteType, iadd); |
|
589 |
||
590 |
enterUnop("--", doubleType, doubleType, dsub); |
|
591 |
enterUnop("--", floatType, floatType, fsub); |
|
592 |
enterUnop("--", longType, longType, lsub); |
|
593 |
enterUnop("--", intType, intType, isub); |
|
594 |
enterUnop("--", charType, charType, isub); |
|
595 |
enterUnop("--", shortType, shortType, isub); |
|
596 |
enterUnop("--", byteType, byteType, isub); |
|
597 |
||
598 |
enterUnop("!", booleanType, booleanType, bool_not); |
|
599 |
nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk); |
|
600 |
||
601 |
// string concatenation |
|
602 |
enterBinop("+", stringType, objectType, stringType, string_add); |
|
603 |
enterBinop("+", objectType, stringType, stringType, string_add); |
|
604 |
enterBinop("+", stringType, stringType, stringType, string_add); |
|
605 |
enterBinop("+", stringType, intType, stringType, string_add); |
|
606 |
enterBinop("+", stringType, longType, stringType, string_add); |
|
607 |
enterBinop("+", stringType, floatType, stringType, string_add); |
|
608 |
enterBinop("+", stringType, doubleType, stringType, string_add); |
|
609 |
enterBinop("+", stringType, booleanType, stringType, string_add); |
|
610 |
enterBinop("+", stringType, botType, stringType, string_add); |
|
611 |
enterBinop("+", intType, stringType, stringType, string_add); |
|
612 |
enterBinop("+", longType, stringType, stringType, string_add); |
|
613 |
enterBinop("+", floatType, stringType, stringType, string_add); |
|
614 |
enterBinop("+", doubleType, stringType, stringType, string_add); |
|
615 |
enterBinop("+", booleanType, stringType, stringType, string_add); |
|
616 |
enterBinop("+", botType, stringType, stringType, string_add); |
|
617 |
||
618 |
// these errors would otherwise be matched as string concatenation |
|
619 |
enterBinop("+", botType, botType, botType, error); |
|
620 |
enterBinop("+", botType, intType, botType, error); |
|
621 |
enterBinop("+", botType, longType, botType, error); |
|
622 |
enterBinop("+", botType, floatType, botType, error); |
|
623 |
enterBinop("+", botType, doubleType, botType, error); |
|
624 |
enterBinop("+", botType, booleanType, botType, error); |
|
625 |
enterBinop("+", botType, objectType, botType, error); |
|
626 |
enterBinop("+", intType, botType, botType, error); |
|
627 |
enterBinop("+", longType, botType, botType, error); |
|
628 |
enterBinop("+", floatType, botType, botType, error); |
|
629 |
enterBinop("+", doubleType, botType, botType, error); |
|
630 |
enterBinop("+", booleanType, botType, botType, error); |
|
631 |
enterBinop("+", objectType, botType, botType, error); |
|
632 |
||
633 |
enterBinop("+", doubleType, doubleType, doubleType, dadd); |
|
634 |
enterBinop("+", floatType, floatType, floatType, fadd); |
|
635 |
enterBinop("+", longType, longType, longType, ladd); |
|
636 |
enterBinop("+", intType, intType, intType, iadd); |
|
637 |
||
638 |
enterBinop("-", doubleType, doubleType, doubleType, dsub); |
|
639 |
enterBinop("-", floatType, floatType, floatType, fsub); |
|
640 |
enterBinop("-", longType, longType, longType, lsub); |
|
641 |
enterBinop("-", intType, intType, intType, isub); |
|
642 |
||
643 |
enterBinop("*", doubleType, doubleType, doubleType, dmul); |
|
644 |
enterBinop("*", floatType, floatType, floatType, fmul); |
|
645 |
enterBinop("*", longType, longType, longType, lmul); |
|
646 |
enterBinop("*", intType, intType, intType, imul); |
|
647 |
||
648 |
enterBinop("/", doubleType, doubleType, doubleType, ddiv); |
|
649 |
enterBinop("/", floatType, floatType, floatType, fdiv); |
|
650 |
enterBinop("/", longType, longType, longType, ldiv); |
|
651 |
enterBinop("/", intType, intType, intType, idiv); |
|
652 |
||
653 |
enterBinop("%", doubleType, doubleType, doubleType, dmod); |
|
654 |
enterBinop("%", floatType, floatType, floatType, fmod); |
|
655 |
enterBinop("%", longType, longType, longType, lmod); |
|
656 |
enterBinop("%", intType, intType, intType, imod); |
|
657 |
||
658 |
enterBinop("&", booleanType, booleanType, booleanType, iand); |
|
659 |
enterBinop("&", longType, longType, longType, land); |
|
660 |
enterBinop("&", intType, intType, intType, iand); |
|
661 |
||
662 |
enterBinop("|", booleanType, booleanType, booleanType, ior); |
|
663 |
enterBinop("|", longType, longType, longType, lor); |
|
664 |
enterBinop("|", intType, intType, intType, ior); |
|
665 |
||
666 |
enterBinop("^", booleanType, booleanType, booleanType, ixor); |
|
667 |
enterBinop("^", longType, longType, longType, lxor); |
|
668 |
enterBinop("^", intType, intType, intType, ixor); |
|
669 |
||
670 |
enterBinop("<<", longType, longType, longType, lshll); |
|
671 |
enterBinop("<<", intType, longType, intType, ishll); |
|
672 |
enterBinop("<<", longType, intType, longType, lshl); |
|
673 |
enterBinop("<<", intType, intType, intType, ishl); |
|
674 |
||
675 |
enterBinop(">>", longType, longType, longType, lshrl); |
|
676 |
enterBinop(">>", intType, longType, intType, ishrl); |
|
677 |
enterBinop(">>", longType, intType, longType, lshr); |
|
678 |
enterBinop(">>", intType, intType, intType, ishr); |
|
679 |
||
680 |
enterBinop(">>>", longType, longType, longType, lushrl); |
|
681 |
enterBinop(">>>", intType, longType, intType, iushrl); |
|
682 |
enterBinop(">>>", longType, intType, longType, lushr); |
|
683 |
enterBinop(">>>", intType, intType, intType, iushr); |
|
684 |
||
685 |
enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt); |
|
686 |
enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt); |
|
687 |
enterBinop("<", longType, longType, booleanType, lcmp, iflt); |
|
688 |
enterBinop("<", intType, intType, booleanType, if_icmplt); |
|
689 |
||
690 |
enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt); |
|
691 |
enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt); |
|
692 |
enterBinop(">", longType, longType, booleanType, lcmp, ifgt); |
|
693 |
enterBinop(">", intType, intType, booleanType, if_icmpgt); |
|
694 |
||
695 |
enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle); |
|
696 |
enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle); |
|
697 |
enterBinop("<=", longType, longType, booleanType, lcmp, ifle); |
|
698 |
enterBinop("<=", intType, intType, booleanType, if_icmple); |
|
699 |
||
700 |
enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge); |
|
701 |
enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge); |
|
702 |
enterBinop(">=", longType, longType, booleanType, lcmp, ifge); |
|
703 |
enterBinop(">=", intType, intType, booleanType, if_icmpge); |
|
704 |
||
705 |
enterBinop("==", objectType, objectType, booleanType, if_acmpeq); |
|
706 |
enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq); |
|
707 |
enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq); |
|
708 |
enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq); |
|
709 |
enterBinop("==", longType, longType, booleanType, lcmp, ifeq); |
|
710 |
enterBinop("==", intType, intType, booleanType, if_icmpeq); |
|
711 |
||
712 |
enterBinop("!=", objectType, objectType, booleanType, if_acmpne); |
|
713 |
enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne); |
|
714 |
enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne); |
|
715 |
enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne); |
|
716 |
enterBinop("!=", longType, longType, booleanType, lcmp, ifne); |
|
717 |
enterBinop("!=", intType, intType, booleanType, if_icmpne); |
|
718 |
||
719 |
enterBinop("&&", booleanType, booleanType, booleanType, bool_and); |
|
720 |
enterBinop("||", booleanType, booleanType, booleanType, bool_or); |
|
721 |
} |
|
722 |
} |