src/share/classes/com/sun/tools/javac/code/Symtab.java

Mon, 07 Feb 2011 18:10:13 +0000

author
mcimadamore
date
Mon, 07 Feb 2011 18:10:13 +0000
changeset 858
96d4226bdd60
parent 857
3aa269645199
child 900
938dda0bec17
permissions
-rw-r--r--

7007615: java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
Summary: override clash algorithm is not implemented correctly
Reviewed-by: jjg

duke@1 1 /*
ohair@798 2 * Copyright (c) 1999, 2010, 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.code;
duke@1 27
duke@1 28 import java.util.*;
duke@1 29
duke@1 30 import com.sun.tools.javac.util.*;
duke@1 31 import com.sun.tools.javac.util.List;
duke@1 32 import com.sun.tools.javac.code.Symbol.*;
duke@1 33 import com.sun.tools.javac.code.Type.*;
duke@1 34 import com.sun.tools.javac.jvm.*;
duke@1 35
duke@1 36 import static com.sun.tools.javac.jvm.ByteCodes.*;
duke@1 37 import static com.sun.tools.javac.code.Flags.*;
duke@1 38
duke@1 39 /** A class that defines all predefined constants and operators
duke@1 40 * as well as special classes such as java.lang.Object, which need
duke@1 41 * to be known to the compiler. All symbols are held in instance
duke@1 42 * fields. This makes it possible to work in multiple concurrent
duke@1 43 * projects, which might use different class files for library classes.
duke@1 44 *
jjg@581 45 * <p><b>This is NOT part of any supported API.
jjg@581 46 * If you write code that depends on this, you do so at your own risk.
duke@1 47 * This code and its internal interfaces are subject to change or
duke@1 48 * deletion without notice.</b>
duke@1 49 */
duke@1 50 public class Symtab {
duke@1 51 /** The context key for the symbol table. */
duke@1 52 protected static final Context.Key<Symtab> symtabKey =
duke@1 53 new Context.Key<Symtab>();
duke@1 54
duke@1 55 /** Get the symbol table instance. */
duke@1 56 public static Symtab instance(Context context) {
duke@1 57 Symtab instance = context.get(symtabKey);
duke@1 58 if (instance == null)
duke@1 59 instance = new Symtab(context);
duke@1 60 return instance;
duke@1 61 }
duke@1 62
duke@1 63 /** Builtin types.
duke@1 64 */
duke@1 65 public final Type byteType = new Type(TypeTags.BYTE, null);
duke@1 66 public final Type charType = new Type(TypeTags.CHAR, null);
duke@1 67 public final Type shortType = new Type(TypeTags.SHORT, null);
duke@1 68 public final Type intType = new Type(TypeTags.INT, null);
duke@1 69 public final Type longType = new Type(TypeTags.LONG, null);
duke@1 70 public final Type floatType = new Type(TypeTags.FLOAT, null);
duke@1 71 public final Type doubleType = new Type(TypeTags.DOUBLE, null);
duke@1 72 public final Type booleanType = new Type(TypeTags.BOOLEAN, null);
duke@1 73 public final Type botType = new BottomType();
duke@1 74 public final JCNoType voidType = new JCNoType(TypeTags.VOID);
duke@1 75
jjg@113 76 private final Names names;
duke@1 77 private final ClassReader reader;
jjg@86 78 private final Target target;
duke@1 79
duke@1 80 /** A symbol for the root package.
duke@1 81 */
duke@1 82 public final PackageSymbol rootPackage;
duke@1 83
duke@1 84 /** A symbol for the unnamed package.
duke@1 85 */
duke@1 86 public final PackageSymbol unnamedPackage;
duke@1 87
duke@1 88 /** A symbol that stands for a missing symbol.
duke@1 89 */
duke@1 90 public final TypeSymbol noSymbol;
duke@1 91
duke@1 92 /** The error symbol.
duke@1 93 */
duke@1 94 public final ClassSymbol errSymbol;
duke@1 95
mcimadamore@676 96 /** The unknown symbol.
mcimadamore@676 97 */
mcimadamore@676 98 public final ClassSymbol unknownSymbol;
mcimadamore@676 99
jjg@110 100 /** A value for the errType, with a originalType of noType */
duke@1 101 public final Type errType;
duke@1 102
duke@1 103 /** A value for the unknown type. */
duke@1 104 public final Type unknownType;
duke@1 105
duke@1 106 /** The builtin type of all arrays. */
duke@1 107 public final ClassSymbol arrayClass;
duke@1 108 public final MethodSymbol arrayCloneMethod;
duke@1 109
duke@1 110 /** VGJ: The (singleton) type of all bound types. */
duke@1 111 public final ClassSymbol boundClass;
duke@1 112
duke@1 113 /** The builtin type of all methods. */
duke@1 114 public final ClassSymbol methodClass;
duke@1 115
duke@1 116 /** Predefined types.
duke@1 117 */
duke@1 118 public final Type objectType;
duke@1 119 public final Type classType;
duke@1 120 public final Type classLoaderType;
duke@1 121 public final Type stringType;
duke@1 122 public final Type stringBufferType;
duke@1 123 public final Type stringBuilderType;
duke@1 124 public final Type cloneableType;
duke@1 125 public final Type serializableType;
mcimadamore@857 126 public final Type transientMethodHandleType; // transient - 292
jrose@267 127 public final Type methodHandleType;
mcimadamore@857 128 public final Type transientPolymorphicSignatureType; // transient - 292
jrose@571 129 public final Type polymorphicSignatureType;
duke@1 130 public final Type throwableType;
duke@1 131 public final Type errorType;
duke@1 132 public final Type illegalArgumentExceptionType;
duke@1 133 public final Type exceptionType;
duke@1 134 public final Type runtimeExceptionType;
duke@1 135 public final Type classNotFoundExceptionType;
duke@1 136 public final Type noClassDefFoundErrorType;
duke@1 137 public final Type noSuchFieldErrorType;
duke@1 138 public final Type assertionErrorType;
duke@1 139 public final Type cloneNotSupportedExceptionType;
duke@1 140 public final Type annotationType;
duke@1 141 public final TypeSymbol enumSym;
duke@1 142 public final Type listType;
duke@1 143 public final Type collectionsType;
duke@1 144 public final Type comparableType;
duke@1 145 public final Type arraysType;
duke@1 146 public final Type iterableType;
duke@1 147 public final Type iteratorType;
duke@1 148 public final Type annotationTargetType;
duke@1 149 public final Type overrideType;
duke@1 150 public final Type retentionType;
duke@1 151 public final Type deprecatedType;
duke@1 152 public final Type suppressWarningsType;
duke@1 153 public final Type inheritedType;
duke@1 154 public final Type proprietaryType;
jjg@86 155 public final Type systemType;
darcy@609 156 public final Type autoCloseableType;
mcimadamore@795 157 public final Type trustMeType;
duke@1 158
duke@1 159 /** The symbol representing the length field of an array.
duke@1 160 */
duke@1 161 public final VarSymbol lengthVar;
duke@1 162
duke@1 163 /** The null check operator. */
duke@1 164 public final OperatorSymbol nullcheck;
duke@1 165
duke@1 166 /** The symbol representing the final finalize method on enums */
duke@1 167 public final MethodSymbol enumFinalFinalize;
duke@1 168
darcy@609 169 /** The symbol representing the close method on TWR AutoCloseable type */
darcy@609 170 public final MethodSymbol autoCloseableClose;
darcy@609 171
duke@1 172 /** The predefined type that belongs to a tag.
duke@1 173 */
duke@1 174 public final Type[] typeOfTag = new Type[TypeTags.TypeTagCount];
duke@1 175
duke@1 176 /** The name of the class that belongs to a basix type tag.
duke@1 177 */
duke@1 178 public final Name[] boxedName = new Name[TypeTags.TypeTagCount];
duke@1 179
duke@1 180 /** A hashtable containing the encountered top-level and member classes,
duke@1 181 * indexed by flat names. The table does not contain local classes.
duke@1 182 * It should be updated from the outside to reflect classes defined
duke@1 183 * by compiled source files.
duke@1 184 */
duke@1 185 public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
duke@1 186
duke@1 187 /** A hashtable containing the encountered packages.
duke@1 188 * the table should be updated from outside to reflect packages defined
duke@1 189 * by compiled source files.
duke@1 190 */
duke@1 191 public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
duke@1 192
duke@1 193 public void initType(Type type, ClassSymbol c) {
duke@1 194 type.tsym = c;
duke@1 195 typeOfTag[type.tag] = type;
duke@1 196 }
duke@1 197
duke@1 198 public void initType(Type type, String name) {
duke@1 199 initType(
duke@1 200 type,
duke@1 201 new ClassSymbol(
duke@1 202 PUBLIC, names.fromString(name), type, rootPackage));
duke@1 203 }
duke@1 204
duke@1 205 public void initType(Type type, String name, String bname) {
duke@1 206 initType(type, name);
mcimadamore@357 207 boxedName[type.tag] = names.fromString("java.lang." + bname);
duke@1 208 }
duke@1 209
duke@1 210 /** The class symbol that owns all predefined symbols.
duke@1 211 */
duke@1 212 public final ClassSymbol predefClass;
duke@1 213
duke@1 214 /** Enter a constant into symbol table.
duke@1 215 * @param name The constant's name.
duke@1 216 * @param type The constant's type.
duke@1 217 */
duke@1 218 private VarSymbol enterConstant(String name, Type type) {
duke@1 219 VarSymbol c = new VarSymbol(
duke@1 220 PUBLIC | STATIC | FINAL,
duke@1 221 names.fromString(name),
duke@1 222 type,
duke@1 223 predefClass);
duke@1 224 c.setData(type.constValue());
duke@1 225 predefClass.members().enter(c);
duke@1 226 return c;
duke@1 227 }
duke@1 228
duke@1 229 /** Enter a binary operation into symbol table.
duke@1 230 * @param name The name of the operator.
duke@1 231 * @param left The type of the left operand.
duke@1 232 * @param right The type of the left operand.
duke@1 233 * @param res The operation's result type.
duke@1 234 * @param opcode The operation's bytecode instruction.
duke@1 235 */
duke@1 236 private void enterBinop(String name,
duke@1 237 Type left, Type right, Type res,
duke@1 238 int opcode) {
duke@1 239 predefClass.members().enter(
duke@1 240 new OperatorSymbol(
duke@1 241 names.fromString(name),
duke@1 242 new MethodType(List.of(left, right), res,
duke@1 243 List.<Type>nil(), methodClass),
duke@1 244 opcode,
duke@1 245 predefClass));
duke@1 246 }
duke@1 247
duke@1 248 /** Enter a binary operation, as above but with two opcodes,
duke@1 249 * which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
duke@1 250 * @param opcode1 First opcode.
duke@1 251 * @param opcode2 Second opcode.
duke@1 252 */
duke@1 253 private void enterBinop(String name,
duke@1 254 Type left, Type right, Type res,
duke@1 255 int opcode1, int opcode2) {
duke@1 256 enterBinop(
duke@1 257 name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
duke@1 258 }
duke@1 259
duke@1 260 /** Enter a unary operation into symbol table.
duke@1 261 * @param name The name of the operator.
duke@1 262 * @param arg The type of the operand.
duke@1 263 * @param res The operation's result type.
duke@1 264 * @param opcode The operation's bytecode instruction.
duke@1 265 */
duke@1 266 private OperatorSymbol enterUnop(String name,
duke@1 267 Type arg,
duke@1 268 Type res,
duke@1 269 int opcode) {
duke@1 270 OperatorSymbol sym =
duke@1 271 new OperatorSymbol(names.fromString(name),
duke@1 272 new MethodType(List.of(arg),
duke@1 273 res,
duke@1 274 List.<Type>nil(),
duke@1 275 methodClass),
duke@1 276 opcode,
duke@1 277 predefClass);
duke@1 278 predefClass.members().enter(sym);
duke@1 279 return sym;
duke@1 280 }
duke@1 281
duke@1 282 /** Enter a class into symbol table.
duke@1 283 * @param The name of the class.
duke@1 284 */
duke@1 285 private Type enterClass(String s) {
duke@1 286 return reader.enterClass(names.fromString(s)).type;
duke@1 287 }
duke@1 288
jjg@86 289 public void synthesizeEmptyInterfaceIfMissing(final Type type) {
jjg@86 290 final Completer completer = type.tsym.completer;
jjg@86 291 if (completer != null) {
jjg@86 292 type.tsym.completer = new Completer() {
jjg@86 293 public void complete(Symbol sym) throws CompletionFailure {
jjg@86 294 try {
jjg@86 295 completer.complete(sym);
jjg@86 296 } catch (CompletionFailure e) {
jjg@86 297 sym.flags_field |= (PUBLIC | INTERFACE);
jjg@86 298 ((ClassType) sym.type).supertype_field = objectType;
jjg@86 299 }
jjg@86 300 }
jjg@86 301 };
jjg@86 302 }
jjg@86 303 }
jjg@86 304
jjg@86 305 public void synthesizeBoxTypeIfMissing(final Type type) {
jjg@86 306 ClassSymbol sym = reader.enterClass(boxedName[type.tag]);
jjg@86 307 final Completer completer = sym.completer;
jjg@86 308 if (completer != null) {
jjg@86 309 sym.completer = new Completer() {
jjg@86 310 public void complete(Symbol sym) throws CompletionFailure {
jjg@86 311 try {
jjg@86 312 completer.complete(sym);
jjg@86 313 } catch (CompletionFailure e) {
jjg@86 314 sym.flags_field |= PUBLIC;
jjg@86 315 ((ClassType) sym.type).supertype_field = objectType;
jjg@86 316 Name n = target.boxWithConstructors() ? names.init : names.valueOf;
jjg@86 317 MethodSymbol boxMethod =
jjg@86 318 new MethodSymbol(PUBLIC | STATIC,
jjg@86 319 n,
jjg@86 320 new MethodType(List.of(type), sym.type,
jjg@86 321 List.<Type>nil(), methodClass),
jjg@86 322 sym);
jjg@86 323 sym.members().enter(boxMethod);
jjg@86 324 MethodSymbol unboxMethod =
jjg@86 325 new MethodSymbol(PUBLIC,
jjg@86 326 type.tsym.name.append(names.Value), // x.intValue()
jjg@86 327 new MethodType(List.<Type>nil(), type,
jjg@86 328 List.<Type>nil(), methodClass),
jjg@86 329 sym);
jjg@86 330 sym.members().enter(unboxMethod);
jjg@86 331 }
jjg@86 332 }
jjg@86 333 };
jjg@86 334 }
jjg@86 335
jjg@86 336 }
jjg@86 337
duke@1 338 /** Constructor; enters all predefined identifiers and operators
duke@1 339 * into symbol table.
duke@1 340 */
duke@1 341 protected Symtab(Context context) throws CompletionFailure {
duke@1 342 context.put(symtabKey, this);
duke@1 343
jjg@113 344 names = Names.instance(context);
jjg@86 345 target = Target.instance(context);
duke@1 346
duke@1 347 // Create the unknown type
duke@1 348 unknownType = new Type(TypeTags.UNKNOWN, null);
duke@1 349
duke@1 350 // create the basic builtin symbols
duke@1 351 rootPackage = new PackageSymbol(names.empty, null);
mcimadamore@136 352 final JavacMessages messages = JavacMessages.instance(context);
duke@1 353 unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
duke@1 354 public String toString() {
duke@1 355 return messages.getLocalizedString("compiler.misc.unnamed.package");
duke@1 356 }
duke@1 357 };
duke@1 358 noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
duke@1 359 noSymbol.kind = Kinds.NIL;
duke@1 360
duke@1 361 // create the error symbols
duke@1 362 errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
mcimadamore@676 363 unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
jjg@110 364 errType = new ErrorType(errSymbol, Type.noType);
duke@1 365
duke@1 366 // initialize builtin types
duke@1 367 initType(byteType, "byte", "Byte");
duke@1 368 initType(shortType, "short", "Short");
duke@1 369 initType(charType, "char", "Character");
duke@1 370 initType(intType, "int", "Integer");
duke@1 371 initType(longType, "long", "Long");
duke@1 372 initType(floatType, "float", "Float");
duke@1 373 initType(doubleType, "double", "Double");
duke@1 374 initType(booleanType, "boolean", "Boolean");
duke@1 375 initType(voidType, "void", "Void");
duke@1 376 initType(botType, "<nulltype>");
duke@1 377 initType(errType, errSymbol);
mcimadamore@676 378 initType(unknownType, unknownSymbol);
duke@1 379
duke@1 380 // the builtin class of all arrays
duke@1 381 arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
duke@1 382
duke@1 383 // VGJ
duke@1 384 boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
duke@1 385
duke@1 386 // the builtin class of all methods
duke@1 387 methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
duke@1 388
duke@1 389 // Create class to hold all predefined constants and operations.
duke@1 390 predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
mcimadamore@858 391 Scope scope = new Scope(predefClass);
duke@1 392 predefClass.members_field = scope;
duke@1 393
duke@1 394 // Enter symbols for basic types.
duke@1 395 scope.enter(byteType.tsym);
duke@1 396 scope.enter(shortType.tsym);
duke@1 397 scope.enter(charType.tsym);
duke@1 398 scope.enter(intType.tsym);
duke@1 399 scope.enter(longType.tsym);
duke@1 400 scope.enter(floatType.tsym);
duke@1 401 scope.enter(doubleType.tsym);
duke@1 402 scope.enter(booleanType.tsym);
duke@1 403 scope.enter(errType.tsym);
duke@1 404
jjg@110 405 // Enter symbol for the errSymbol
jjg@110 406 scope.enter(errSymbol);
jjg@110 407
duke@1 408 classes.put(predefClass.fullname, predefClass);
duke@1 409
duke@1 410 reader = ClassReader.instance(context);
duke@1 411 reader.init(this);
duke@1 412
duke@1 413 // Enter predefined classes.
duke@1 414 objectType = enterClass("java.lang.Object");
duke@1 415 classType = enterClass("java.lang.Class");
duke@1 416 stringType = enterClass("java.lang.String");
duke@1 417 stringBufferType = enterClass("java.lang.StringBuffer");
duke@1 418 stringBuilderType = enterClass("java.lang.StringBuilder");
duke@1 419 cloneableType = enterClass("java.lang.Cloneable");
duke@1 420 throwableType = enterClass("java.lang.Throwable");
duke@1 421 serializableType = enterClass("java.io.Serializable");
mcimadamore@857 422 transientMethodHandleType = enterClass("java.dyn.MethodHandle"); // transient - 292
mcimadamore@857 423 methodHandleType = enterClass("java.lang.invoke.MethodHandle");
mcimadamore@857 424 transientPolymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature"); // transient - 292
mcimadamore@857 425 polymorphicSignatureType = enterClass("java.lang.invoke.MethodHandle$PolymorphicSignature");
duke@1 426 errorType = enterClass("java.lang.Error");
duke@1 427 illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
duke@1 428 exceptionType = enterClass("java.lang.Exception");
duke@1 429 runtimeExceptionType = enterClass("java.lang.RuntimeException");
duke@1 430 classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
duke@1 431 noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
duke@1 432 noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
duke@1 433 assertionErrorType = enterClass("java.lang.AssertionError");
duke@1 434 cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
duke@1 435 annotationType = enterClass("java.lang.annotation.Annotation");
duke@1 436 classLoaderType = enterClass("java.lang.ClassLoader");
duke@1 437 enumSym = reader.enterClass(names.java_lang_Enum);
duke@1 438 enumFinalFinalize =
duke@1 439 new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
duke@1 440 names.finalize,
duke@1 441 new MethodType(List.<Type>nil(), voidType,
duke@1 442 List.<Type>nil(), methodClass),
duke@1 443 enumSym);
duke@1 444 listType = enterClass("java.util.List");
duke@1 445 collectionsType = enterClass("java.util.Collections");
duke@1 446 comparableType = enterClass("java.lang.Comparable");
duke@1 447 arraysType = enterClass("java.util.Arrays");
jjg@86 448 iterableType = target.hasIterable()
duke@1 449 ? enterClass("java.lang.Iterable")
duke@1 450 : enterClass("java.util.Collection");
duke@1 451 iteratorType = enterClass("java.util.Iterator");
duke@1 452 annotationTargetType = enterClass("java.lang.annotation.Target");
duke@1 453 overrideType = enterClass("java.lang.Override");
duke@1 454 retentionType = enterClass("java.lang.annotation.Retention");
duke@1 455 deprecatedType = enterClass("java.lang.Deprecated");
duke@1 456 suppressWarningsType = enterClass("java.lang.SuppressWarnings");
duke@1 457 inheritedType = enterClass("java.lang.annotation.Inherited");
jjg@86 458 systemType = enterClass("java.lang.System");
darcy@609 459 autoCloseableType = enterClass("java.lang.AutoCloseable");
darcy@609 460 autoCloseableClose = new MethodSymbol(PUBLIC,
darcy@609 461 names.close,
darcy@609 462 new MethodType(List.<Type>nil(), voidType,
darcy@609 463 List.of(exceptionType), methodClass),
darcy@609 464 autoCloseableType.tsym);
mcimadamore@795 465 trustMeType = enterClass("java.lang.SafeVarargs");
jjg@86 466
jjg@86 467 synthesizeEmptyInterfaceIfMissing(cloneableType);
jjg@86 468 synthesizeEmptyInterfaceIfMissing(serializableType);
mcimadamore@857 469 synthesizeEmptyInterfaceIfMissing(transientPolymorphicSignatureType); // transient - 292
jrose@571 470 synthesizeEmptyInterfaceIfMissing(polymorphicSignatureType);
jjg@86 471 synthesizeBoxTypeIfMissing(doubleType);
jjg@86 472 synthesizeBoxTypeIfMissing(floatType);
mcimadamore@357 473 synthesizeBoxTypeIfMissing(voidType);
duke@1 474
jjg@582 475 // Enter a synthetic class that is used to mark internal
duke@1 476 // proprietary classes in ct.sym. This class does not have a
duke@1 477 // class file.
duke@1 478 ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
duke@1 479 this.proprietaryType = proprietaryType;
duke@1 480 ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
duke@1 481 proprietarySymbol.completer = null;
duke@1 482 proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
duke@1 483 proprietarySymbol.erasure_field = proprietaryType;
mcimadamore@858 484 proprietarySymbol.members_field = new Scope(proprietarySymbol);
duke@1 485 proprietaryType.typarams_field = List.nil();
duke@1 486 proprietaryType.allparams_field = List.nil();
duke@1 487 proprietaryType.supertype_field = annotationType;
duke@1 488 proprietaryType.interfaces_field = List.nil();
duke@1 489
duke@1 490 // Enter a class for arrays.
duke@1 491 // The class implements java.lang.Cloneable and java.io.Serializable.
duke@1 492 // It has a final length field and a clone method.
duke@1 493 ClassType arrayClassType = (ClassType)arrayClass.type;
duke@1 494 arrayClassType.supertype_field = objectType;
duke@1 495 arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
mcimadamore@858 496 arrayClass.members_field = new Scope(arrayClass);
duke@1 497 lengthVar = new VarSymbol(
duke@1 498 PUBLIC | FINAL,
duke@1 499 names.length,
duke@1 500 intType,
duke@1 501 arrayClass);
duke@1 502 arrayClass.members().enter(lengthVar);
duke@1 503 arrayCloneMethod = new MethodSymbol(
duke@1 504 PUBLIC,
duke@1 505 names.clone,
duke@1 506 new MethodType(List.<Type>nil(), objectType,
duke@1 507 List.<Type>nil(), methodClass),
duke@1 508 arrayClass);
duke@1 509 arrayClass.members().enter(arrayCloneMethod);
duke@1 510
duke@1 511 // Enter operators.
duke@1 512 enterUnop("+", doubleType, doubleType, nop);
duke@1 513 enterUnop("+", floatType, floatType, nop);
duke@1 514 enterUnop("+", longType, longType, nop);
duke@1 515 enterUnop("+", intType, intType, nop);
duke@1 516
duke@1 517 enterUnop("-", doubleType, doubleType, dneg);
duke@1 518 enterUnop("-", floatType, floatType, fneg);
duke@1 519 enterUnop("-", longType, longType, lneg);
duke@1 520 enterUnop("-", intType, intType, ineg);
duke@1 521
duke@1 522 enterUnop("~", longType, longType, lxor);
duke@1 523 enterUnop("~", intType, intType, ixor);
duke@1 524
duke@1 525 enterUnop("++", doubleType, doubleType, dadd);
duke@1 526 enterUnop("++", floatType, floatType, fadd);
duke@1 527 enterUnop("++", longType, longType, ladd);
duke@1 528 enterUnop("++", intType, intType, iadd);
duke@1 529 enterUnop("++", charType, charType, iadd);
duke@1 530 enterUnop("++", shortType, shortType, iadd);
duke@1 531 enterUnop("++", byteType, byteType, iadd);
duke@1 532
duke@1 533 enterUnop("--", doubleType, doubleType, dsub);
duke@1 534 enterUnop("--", floatType, floatType, fsub);
duke@1 535 enterUnop("--", longType, longType, lsub);
duke@1 536 enterUnop("--", intType, intType, isub);
duke@1 537 enterUnop("--", charType, charType, isub);
duke@1 538 enterUnop("--", shortType, shortType, isub);
duke@1 539 enterUnop("--", byteType, byteType, isub);
duke@1 540
duke@1 541 enterUnop("!", booleanType, booleanType, bool_not);
duke@1 542 nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
duke@1 543
duke@1 544 // string concatenation
duke@1 545 enterBinop("+", stringType, objectType, stringType, string_add);
duke@1 546 enterBinop("+", objectType, stringType, stringType, string_add);
duke@1 547 enterBinop("+", stringType, stringType, stringType, string_add);
duke@1 548 enterBinop("+", stringType, intType, stringType, string_add);
duke@1 549 enterBinop("+", stringType, longType, stringType, string_add);
duke@1 550 enterBinop("+", stringType, floatType, stringType, string_add);
duke@1 551 enterBinop("+", stringType, doubleType, stringType, string_add);
duke@1 552 enterBinop("+", stringType, booleanType, stringType, string_add);
duke@1 553 enterBinop("+", stringType, botType, stringType, string_add);
duke@1 554 enterBinop("+", intType, stringType, stringType, string_add);
duke@1 555 enterBinop("+", longType, stringType, stringType, string_add);
duke@1 556 enterBinop("+", floatType, stringType, stringType, string_add);
duke@1 557 enterBinop("+", doubleType, stringType, stringType, string_add);
duke@1 558 enterBinop("+", booleanType, stringType, stringType, string_add);
duke@1 559 enterBinop("+", botType, stringType, stringType, string_add);
duke@1 560
duke@1 561 // these errors would otherwise be matched as string concatenation
duke@1 562 enterBinop("+", botType, botType, botType, error);
duke@1 563 enterBinop("+", botType, intType, botType, error);
duke@1 564 enterBinop("+", botType, longType, botType, error);
duke@1 565 enterBinop("+", botType, floatType, botType, error);
duke@1 566 enterBinop("+", botType, doubleType, botType, error);
duke@1 567 enterBinop("+", botType, booleanType, botType, error);
duke@1 568 enterBinop("+", botType, objectType, botType, error);
duke@1 569 enterBinop("+", intType, botType, botType, error);
duke@1 570 enterBinop("+", longType, botType, botType, error);
duke@1 571 enterBinop("+", floatType, botType, botType, error);
duke@1 572 enterBinop("+", doubleType, botType, botType, error);
duke@1 573 enterBinop("+", booleanType, botType, botType, error);
duke@1 574 enterBinop("+", objectType, botType, botType, error);
duke@1 575
duke@1 576 enterBinop("+", doubleType, doubleType, doubleType, dadd);
duke@1 577 enterBinop("+", floatType, floatType, floatType, fadd);
duke@1 578 enterBinop("+", longType, longType, longType, ladd);
duke@1 579 enterBinop("+", intType, intType, intType, iadd);
duke@1 580
duke@1 581 enterBinop("-", doubleType, doubleType, doubleType, dsub);
duke@1 582 enterBinop("-", floatType, floatType, floatType, fsub);
duke@1 583 enterBinop("-", longType, longType, longType, lsub);
duke@1 584 enterBinop("-", intType, intType, intType, isub);
duke@1 585
duke@1 586 enterBinop("*", doubleType, doubleType, doubleType, dmul);
duke@1 587 enterBinop("*", floatType, floatType, floatType, fmul);
duke@1 588 enterBinop("*", longType, longType, longType, lmul);
duke@1 589 enterBinop("*", intType, intType, intType, imul);
duke@1 590
duke@1 591 enterBinop("/", doubleType, doubleType, doubleType, ddiv);
duke@1 592 enterBinop("/", floatType, floatType, floatType, fdiv);
duke@1 593 enterBinop("/", longType, longType, longType, ldiv);
duke@1 594 enterBinop("/", intType, intType, intType, idiv);
duke@1 595
duke@1 596 enterBinop("%", doubleType, doubleType, doubleType, dmod);
duke@1 597 enterBinop("%", floatType, floatType, floatType, fmod);
duke@1 598 enterBinop("%", longType, longType, longType, lmod);
duke@1 599 enterBinop("%", intType, intType, intType, imod);
duke@1 600
duke@1 601 enterBinop("&", booleanType, booleanType, booleanType, iand);
duke@1 602 enterBinop("&", longType, longType, longType, land);
duke@1 603 enterBinop("&", intType, intType, intType, iand);
duke@1 604
duke@1 605 enterBinop("|", booleanType, booleanType, booleanType, ior);
duke@1 606 enterBinop("|", longType, longType, longType, lor);
duke@1 607 enterBinop("|", intType, intType, intType, ior);
duke@1 608
duke@1 609 enterBinop("^", booleanType, booleanType, booleanType, ixor);
duke@1 610 enterBinop("^", longType, longType, longType, lxor);
duke@1 611 enterBinop("^", intType, intType, intType, ixor);
duke@1 612
duke@1 613 enterBinop("<<", longType, longType, longType, lshll);
duke@1 614 enterBinop("<<", intType, longType, intType, ishll);
duke@1 615 enterBinop("<<", longType, intType, longType, lshl);
duke@1 616 enterBinop("<<", intType, intType, intType, ishl);
duke@1 617
duke@1 618 enterBinop(">>", longType, longType, longType, lshrl);
duke@1 619 enterBinop(">>", intType, longType, intType, ishrl);
duke@1 620 enterBinop(">>", longType, intType, longType, lshr);
duke@1 621 enterBinop(">>", intType, intType, intType, ishr);
duke@1 622
duke@1 623 enterBinop(">>>", longType, longType, longType, lushrl);
duke@1 624 enterBinop(">>>", intType, longType, intType, iushrl);
duke@1 625 enterBinop(">>>", longType, intType, longType, lushr);
duke@1 626 enterBinop(">>>", intType, intType, intType, iushr);
duke@1 627
duke@1 628 enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
duke@1 629 enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
duke@1 630 enterBinop("<", longType, longType, booleanType, lcmp, iflt);
duke@1 631 enterBinop("<", intType, intType, booleanType, if_icmplt);
duke@1 632
duke@1 633 enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
duke@1 634 enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
duke@1 635 enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
duke@1 636 enterBinop(">", intType, intType, booleanType, if_icmpgt);
duke@1 637
duke@1 638 enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
duke@1 639 enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
duke@1 640 enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
duke@1 641 enterBinop("<=", intType, intType, booleanType, if_icmple);
duke@1 642
duke@1 643 enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
duke@1 644 enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
duke@1 645 enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
duke@1 646 enterBinop(">=", intType, intType, booleanType, if_icmpge);
duke@1 647
duke@1 648 enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
duke@1 649 enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
duke@1 650 enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
duke@1 651 enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
duke@1 652 enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
duke@1 653 enterBinop("==", intType, intType, booleanType, if_icmpeq);
duke@1 654
duke@1 655 enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
duke@1 656 enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
duke@1 657 enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
duke@1 658 enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
duke@1 659 enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
duke@1 660 enterBinop("!=", intType, intType, booleanType, if_icmpne);
duke@1 661
duke@1 662 enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
duke@1 663 enterBinop("||", booleanType, booleanType, booleanType, bool_or);
duke@1 664 }
duke@1 665 }

mercurial