1 /*
   2  * Copyright (c) 1999, 2013, 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 serializedLambdaType;
 130     public final Type methodHandleType;
 131     public final Type methodHandleLookupType;
 132     public final Type methodTypeType;
 133     public final Type nativeHeaderType;
 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 comparatorType;
 151     public final Type arraysType;
 152     public final Type iterableType;
 153     public final Type iteratorType;
 154     public final Type annotationTargetType;
 155     public final Type overrideType;
 156     public final Type retentionType;
 157     public final Type deprecatedType;
 158     public final Type suppressWarningsType;
 159     public final Type inheritedType;
 160     public final Type profileType;
 161     public final Type proprietaryType;
 162     public final Type systemType;
 163     public final Type autoCloseableType;
 164     public final Type trustMeType;
 165     public final Type lambdaMetafactory;
 166     public final Type repeatableType;
 167     public final Type documentedType;
 168     public final Type elementTypeType;
 169     public final Type functionalInterfaceType;
 170 
 171     /** The symbol representing the length field of an array.
 172      */
 173     public final VarSymbol lengthVar;
 174 
 175     /** The null check operator. */
 176     public final OperatorSymbol nullcheck;
 177 
 178     /** The symbol representing the final finalize method on enums */
 179     public final MethodSymbol enumFinalFinalize;
 180 
 181     /** The symbol representing the close method on TWR AutoCloseable type */
 182     public final MethodSymbol autoCloseableClose;
 183 
 184     /** The predefined type that belongs to a tag.
 185      */
 186     public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
 187 
 188     /** The name of the class that belongs to a basix type tag.
 189      */
 190     public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
 191 
 192     /** A set containing all operator names.
 193      */
 194     public final Set<Name> operatorNames = new HashSet<Name>();
 195 
 196     /** A hashtable containing the encountered top-level and member classes,
 197      *  indexed by flat names. The table does not contain local classes.
 198      *  It should be updated from the outside to reflect classes defined
 199      *  by compiled source files.
 200      */
 201     public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
 202 
 203     /** A hashtable containing the encountered packages.
 204      *  the table should be updated from outside to reflect packages defined
 205      *  by compiled source files.
 206      */
 207     public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
 208 
 209     public void initType(Type type, ClassSymbol c) {
 210         type.tsym = c;
 211         typeOfTag[type.tag.ordinal()] = type;
 212     }
 213 
 214     public void initType(Type type, String name) {
 215         initType(
 216             type,
 217             new ClassSymbol(
 218                 PUBLIC, names.fromString(name), type, rootPackage));
 219     }
 220 
 221     public void initType(Type type, String name, String bname) {
 222         initType(type, name);
 223             boxedName[type.tag.ordinal()] = names.fromString("java.lang." + bname);
 224     }
 225 
 226     /** The class symbol that owns all predefined symbols.
 227      */
 228     public final ClassSymbol predefClass;
 229 
 230     /** Enter a constant into symbol table.
 231      *  @param name   The constant's name.
 232      *  @param type   The constant's type.
 233      */
 234     private VarSymbol enterConstant(String name, Type type) {
 235         VarSymbol c = new VarSymbol(
 236             PUBLIC | STATIC | FINAL,
 237             names.fromString(name),
 238             type,
 239             predefClass);
 240         c.setData(type.constValue());
 241         predefClass.members().enter(c);
 242         return c;
 243     }
 244 
 245     /** Enter a binary operation into symbol table.
 246      *  @param name     The name of the operator.
 247      *  @param left     The type of the left operand.
 248      *  @param right    The type of the left operand.
 249      *  @param res      The operation's result type.
 250      *  @param opcode   The operation's bytecode instruction.
 251      */
 252     private void enterBinop(String name,
 253                             Type left, Type right, Type res,
 254                             int opcode) {
 255         predefClass.members().enter(
 256             new OperatorSymbol(
 257                 makeOperatorName(name),
 258                 new MethodType(List.of(left, right), res,
 259                                List.<Type>nil(), methodClass),
 260                 opcode,
 261                 predefClass));
 262     }
 263 
 264     /** Enter a binary operation, as above but with two opcodes,
 265      *  which get encoded as
 266      *  {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }.
 267      *  @param opcode1     First opcode.
 268      *  @param opcode2     Second opcode.
 269      */
 270     private void enterBinop(String name,
 271                             Type left, Type right, Type res,
 272                             int opcode1, int opcode2) {
 273         enterBinop(
 274             name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
 275     }
 276 
 277     /** Enter a unary operation into symbol table.
 278      *  @param name     The name of the operator.
 279      *  @param arg      The type of the operand.
 280      *  @param res      The operation's result type.
 281      *  @param opcode   The operation's bytecode instruction.
 282      */
 283     private OperatorSymbol enterUnop(String name,
 284                                      Type arg,
 285                                      Type res,
 286                                      int opcode) {
 287         OperatorSymbol sym =
 288             new OperatorSymbol(makeOperatorName(name),
 289                                new MethodType(List.of(arg),
 290                                               res,
 291                                               List.<Type>nil(),
 292                                               methodClass),
 293                                opcode,
 294                                predefClass);
 295         predefClass.members().enter(sym);
 296         return sym;
 297     }
 298 
 299     /**
 300      * Create a new operator name from corresponding String representation
 301      * and add the name to the set of known operator names.
 302      */
 303     private Name makeOperatorName(String name) {
 304         Name opName = names.fromString(name);
 305         operatorNames.add(opName);
 306         return opName;
 307     }
 308 
 309     /** Enter a class into symbol table.
 310      *  @param s The name of the class.
 311      */
 312     private Type enterClass(String s) {
 313         return reader.enterClass(names.fromString(s)).type;
 314     }
 315 
 316     public void synthesizeEmptyInterfaceIfMissing(final Type type) {
 317         final Completer completer = type.tsym.completer;
 318         if (completer != null) {
 319             type.tsym.completer = new Completer() {
 320                 public void complete(Symbol sym) throws CompletionFailure {
 321                     try {
 322                         completer.complete(sym);
 323                     } catch (CompletionFailure e) {
 324                         sym.flags_field |= (PUBLIC | INTERFACE);
 325                         ((ClassType) sym.type).supertype_field = objectType;
 326                     }
 327                 }
 328             };
 329         }
 330     }
 331 
 332     public void synthesizeBoxTypeIfMissing(final Type type) {
 333         ClassSymbol sym = reader.enterClass(boxedName[type.tag.ordinal()]);
 334         final Completer completer = sym.completer;
 335         if (completer != null) {
 336             sym.completer = new Completer() {
 337                 public void complete(Symbol sym) throws CompletionFailure {
 338                     try {
 339                         completer.complete(sym);
 340                     } catch (CompletionFailure e) {
 341                         sym.flags_field |= PUBLIC;
 342                         ((ClassType) sym.type).supertype_field = objectType;
 343                         Name n = target.boxWithConstructors() ? names.init : names.valueOf;
 344                         MethodSymbol boxMethod =
 345                             new MethodSymbol(PUBLIC | STATIC,
 346                                 n,
 347                                 new MethodType(List.of(type), sym.type,
 348                                     List.<Type>nil(), methodClass),
 349                                 sym);
 350                         sym.members().enter(boxMethod);
 351                         MethodSymbol unboxMethod =
 352                             new MethodSymbol(PUBLIC,
 353                                 type.tsym.name.append(names.Value), // x.intValue()
 354                                 new MethodType(List.<Type>nil(), type,
 355                                     List.<Type>nil(), methodClass),
 356                                 sym);
 357                         sym.members().enter(unboxMethod);
 358                     }
 359                 }
 360             };
 361         }
 362 
 363     }
 364 
 365     // Enter a synthetic class that is used to mark classes in ct.sym.
 366     // This class does not have a class file.
 367     private Type enterSyntheticAnnotation(String name) {
 368         ClassType type = (ClassType)enterClass(name);
 369         ClassSymbol sym = (ClassSymbol)type.tsym;
 370         sym.completer = null;
 371         sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
 372         sym.erasure_field = type;
 373         sym.members_field = new Scope(sym);
 374         type.typarams_field = List.nil();
 375         type.allparams_field = List.nil();
 376         type.supertype_field = annotationType;
 377         type.interfaces_field = List.nil();
 378         return type;
 379     }
 380 
 381     /** Constructor; enters all predefined identifiers and operators
 382      *  into symbol table.
 383      */
 384     protected Symtab(Context context) throws CompletionFailure {
 385         context.put(symtabKey, this);
 386 
 387         names = Names.instance(context);
 388         target = Target.instance(context);
 389 
 390         // Create the unknown type
 391         unknownType = new Type(UNKNOWN, null) {
 392             @Override
 393             public <R, P> R accept(TypeVisitor<R, P> v, P p) {
 394                 return v.visitUnknown(this, p);
 395             }
 396         };
 397 
 398         // create the basic builtin symbols
 399         rootPackage = new PackageSymbol(names.empty, null);
 400         final JavacMessages messages = JavacMessages.instance(context);
 401         unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
 402                 public String toString() {
 403                     return messages.getLocalizedString("compiler.misc.unnamed.package");
 404                 }
 405             };
 406         noSymbol = new TypeSymbol(Kinds.NIL, 0, names.empty, Type.noType, rootPackage) {
 407             public <R, P> R accept(ElementVisitor<R, P> v, P p) {
 408                 return v.visitUnknown(this, p);
 409             }
 410         };
 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         serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
 479         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
 480         methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
 481         methodTypeType = enterClass("java.lang.invoke.MethodType");
 482         errorType = enterClass("java.lang.Error");
 483         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
 484         interruptedExceptionType = enterClass("java.lang.InterruptedException");
 485         exceptionType = enterClass("java.lang.Exception");
 486         runtimeExceptionType = enterClass("java.lang.RuntimeException");
 487         classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
 488         noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
 489         noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
 490         assertionErrorType = enterClass("java.lang.AssertionError");
 491         cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
 492         annotationType = enterClass("java.lang.annotation.Annotation");
 493         classLoaderType = enterClass("java.lang.ClassLoader");
 494         enumSym = reader.enterClass(names.java_lang_Enum);
 495         enumFinalFinalize =
 496             new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
 497                              names.finalize,
 498                              new MethodType(List.<Type>nil(), voidType,
 499                                             List.<Type>nil(), methodClass),
 500                              enumSym);
 501         listType = enterClass("java.util.List");
 502         collectionsType = enterClass("java.util.Collections");
 503         comparableType = enterClass("java.lang.Comparable");
 504         comparatorType = enterClass("java.util.Comparator");
 505         arraysType = enterClass("java.util.Arrays");
 506         iterableType = target.hasIterable()
 507             ? enterClass("java.lang.Iterable")
 508             : enterClass("java.util.Collection");
 509         iteratorType = enterClass("java.util.Iterator");
 510         annotationTargetType = enterClass("java.lang.annotation.Target");
 511         overrideType = enterClass("java.lang.Override");
 512         retentionType = enterClass("java.lang.annotation.Retention");
 513         deprecatedType = enterClass("java.lang.Deprecated");
 514         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
 515         inheritedType = enterClass("java.lang.annotation.Inherited");
 516         repeatableType = enterClass("java.lang.annotation.Repeatable");
 517         documentedType = enterClass("java.lang.annotation.Documented");
 518         elementTypeType = enterClass("java.lang.annotation.ElementType");
 519         systemType = enterClass("java.lang.System");
 520         autoCloseableType = enterClass("java.lang.AutoCloseable");
 521         autoCloseableClose = new MethodSymbol(PUBLIC,
 522                              names.close,
 523                              new MethodType(List.<Type>nil(), voidType,
 524                                             List.of(exceptionType), methodClass),
 525                              autoCloseableType.tsym);
 526         trustMeType = enterClass("java.lang.SafeVarargs");
 527         nativeHeaderType = enterClass("java.lang.annotation.Native");
 528         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
 529         functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
 530 
 531         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
 532         synthesizeEmptyInterfaceIfMissing(cloneableType);
 533         synthesizeEmptyInterfaceIfMissing(serializableType);
 534         synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
 535         synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
 536         synthesizeBoxTypeIfMissing(doubleType);
 537         synthesizeBoxTypeIfMissing(floatType);
 538         synthesizeBoxTypeIfMissing(voidType);
 539 
 540         // Enter a synthetic class that is used to mark internal
 541         // proprietary classes in ct.sym.  This class does not have a
 542         // class file.
 543         proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
 544 
 545         // Enter a synthetic class that is used to provide profile info for
 546         // classes in ct.sym.  This class does not have a class file.
 547         profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
 548         MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
 549         profileType.tsym.members().enter(m);
 550 
 551         // Enter a class for arrays.
 552         // The class implements java.lang.Cloneable and java.io.Serializable.
 553         // It has a final length field and a clone method.
 554         ClassType arrayClassType = (ClassType)arrayClass.type;
 555         arrayClassType.supertype_field = objectType;
 556         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
 557         arrayClass.members_field = new Scope(arrayClass);
 558         lengthVar = new VarSymbol(
 559             PUBLIC | FINAL,
 560             names.length,
 561             intType,
 562             arrayClass);
 563         arrayClass.members().enter(lengthVar);
 564         arrayCloneMethod = new MethodSymbol(
 565             PUBLIC,
 566             names.clone,
 567             new MethodType(List.<Type>nil(), objectType,
 568                            List.<Type>nil(), methodClass),
 569             arrayClass);
 570         arrayClass.members().enter(arrayCloneMethod);
 571 
 572         // Enter operators.
 573         enterUnop("+", doubleType, doubleType, nop);
 574         enterUnop("+", floatType, floatType, nop);
 575         enterUnop("+", longType, longType, nop);
 576         enterUnop("+", intType, intType, nop);
 577 
 578         enterUnop("-", doubleType, doubleType, dneg);
 579         enterUnop("-", floatType, floatType, fneg);
 580         enterUnop("-", longType, longType, lneg);
 581         enterUnop("-", intType, intType, ineg);
 582 
 583         enterUnop("~", longType, longType, lxor);
 584         enterUnop("~", intType, intType, ixor);
 585 
 586         enterUnop("++", doubleType, doubleType, dadd);
 587         enterUnop("++", floatType, floatType, fadd);
 588         enterUnop("++", longType, longType, ladd);
 589         enterUnop("++", intType, intType, iadd);
 590         enterUnop("++", charType, charType, iadd);
 591         enterUnop("++", shortType, shortType, iadd);
 592         enterUnop("++", byteType, byteType, iadd);
 593 
 594         enterUnop("--", doubleType, doubleType, dsub);
 595         enterUnop("--", floatType, floatType, fsub);
 596         enterUnop("--", longType, longType, lsub);
 597         enterUnop("--", intType, intType, isub);
 598         enterUnop("--", charType, charType, isub);
 599         enterUnop("--", shortType, shortType, isub);
 600         enterUnop("--", byteType, byteType, isub);
 601 
 602         enterUnop("!", booleanType, booleanType, bool_not);
 603         nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
 604 
 605         // string concatenation
 606         enterBinop("+", stringType, objectType, stringType, string_add);
 607         enterBinop("+", objectType, stringType, stringType, string_add);
 608         enterBinop("+", stringType, stringType, stringType, string_add);
 609         enterBinop("+", stringType, intType, stringType, string_add);
 610         enterBinop("+", stringType, longType, stringType, string_add);
 611         enterBinop("+", stringType, floatType, stringType, string_add);
 612         enterBinop("+", stringType, doubleType, stringType, string_add);
 613         enterBinop("+", stringType, booleanType, stringType, string_add);
 614         enterBinop("+", stringType, botType, stringType, string_add);
 615         enterBinop("+", intType, stringType, stringType, string_add);
 616         enterBinop("+", longType, stringType, stringType, string_add);
 617         enterBinop("+", floatType, stringType, stringType, string_add);
 618         enterBinop("+", doubleType, stringType, stringType, string_add);
 619         enterBinop("+", booleanType, stringType, stringType, string_add);
 620         enterBinop("+", botType, stringType, stringType, string_add);
 621 
 622         // these errors would otherwise be matched as string concatenation
 623         enterBinop("+", botType, botType, botType, error);
 624         enterBinop("+", botType, intType, botType, error);
 625         enterBinop("+", botType, longType, botType, error);
 626         enterBinop("+", botType, floatType, botType, error);
 627         enterBinop("+", botType, doubleType, botType, error);
 628         enterBinop("+", botType, booleanType, botType, error);
 629         enterBinop("+", botType, objectType, botType, error);
 630         enterBinop("+", intType, botType, botType, error);
 631         enterBinop("+", longType, botType, botType, error);
 632         enterBinop("+", floatType, botType, botType, error);
 633         enterBinop("+", doubleType, botType, botType, error);
 634         enterBinop("+", booleanType, botType, botType, error);
 635         enterBinop("+", objectType, botType, botType, error);
 636 
 637         enterBinop("+", doubleType, doubleType, doubleType, dadd);
 638         enterBinop("+", floatType, floatType, floatType, fadd);
 639         enterBinop("+", longType, longType, longType, ladd);
 640         enterBinop("+", intType, intType, intType, iadd);
 641 
 642         enterBinop("-", doubleType, doubleType, doubleType, dsub);
 643         enterBinop("-", floatType, floatType, floatType, fsub);
 644         enterBinop("-", longType, longType, longType, lsub);
 645         enterBinop("-", intType, intType, intType, isub);
 646 
 647         enterBinop("*", doubleType, doubleType, doubleType, dmul);
 648         enterBinop("*", floatType, floatType, floatType, fmul);
 649         enterBinop("*", longType, longType, longType, lmul);
 650         enterBinop("*", intType, intType, intType, imul);
 651 
 652         enterBinop("/", doubleType, doubleType, doubleType, ddiv);
 653         enterBinop("/", floatType, floatType, floatType, fdiv);
 654         enterBinop("/", longType, longType, longType, ldiv);
 655         enterBinop("/", intType, intType, intType, idiv);
 656 
 657         enterBinop("%", doubleType, doubleType, doubleType, dmod);
 658         enterBinop("%", floatType, floatType, floatType, fmod);
 659         enterBinop("%", longType, longType, longType, lmod);
 660         enterBinop("%", intType, intType, intType, imod);
 661 
 662         enterBinop("&", booleanType, booleanType, booleanType, iand);
 663         enterBinop("&", longType, longType, longType, land);
 664         enterBinop("&", intType, intType, intType, iand);
 665 
 666         enterBinop("|", booleanType, booleanType, booleanType, ior);
 667         enterBinop("|", longType, longType, longType, lor);
 668         enterBinop("|", intType, intType, intType, ior);
 669 
 670         enterBinop("^", booleanType, booleanType, booleanType, ixor);
 671         enterBinop("^", longType, longType, longType, lxor);
 672         enterBinop("^", intType, intType, intType, ixor);
 673 
 674         enterBinop("<<", longType, longType, longType, lshll);
 675         enterBinop("<<", intType, longType, intType, ishll);
 676         enterBinop("<<", longType, intType, longType, lshl);
 677         enterBinop("<<", intType, intType, intType, ishl);
 678 
 679         enterBinop(">>", longType, longType, longType, lshrl);
 680         enterBinop(">>", intType, longType, intType, ishrl);
 681         enterBinop(">>", longType, intType, longType, lshr);
 682         enterBinop(">>", intType, intType, intType, ishr);
 683 
 684         enterBinop(">>>", longType, longType, longType, lushrl);
 685         enterBinop(">>>", intType, longType, intType, iushrl);
 686         enterBinop(">>>", longType, intType, longType, lushr);
 687         enterBinop(">>>", intType, intType, intType, iushr);
 688 
 689         enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
 690         enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
 691         enterBinop("<", longType, longType, booleanType, lcmp, iflt);
 692         enterBinop("<", intType, intType, booleanType, if_icmplt);
 693 
 694         enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
 695         enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
 696         enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
 697         enterBinop(">", intType, intType, booleanType, if_icmpgt);
 698 
 699         enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
 700         enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
 701         enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
 702         enterBinop("<=", intType, intType, booleanType, if_icmple);
 703 
 704         enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
 705         enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
 706         enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
 707         enterBinop(">=", intType, intType, booleanType, if_icmpge);
 708 
 709         enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
 710         enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
 711         enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
 712         enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
 713         enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
 714         enterBinop("==", intType, intType, booleanType, if_icmpeq);
 715 
 716         enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
 717         enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
 718         enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
 719         enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
 720         enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
 721         enterBinop("!=", intType, intType, booleanType, if_icmpne);
 722 
 723         enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
 724         enterBinop("||", booleanType, booleanType, booleanType, bool_or);
 725     }
 726 }