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