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

Wed, 16 Jan 2013 16:30:11 +0000

author
mcimadamore
date
Wed, 16 Jan 2013 16:30:11 +0000
changeset 1497
7aa2025bbb7b
parent 1492
df694c775e8a
child 1570
f91144b7da75
child 1587
f1f605f85850
permissions
-rw-r--r--

8005299: Add FunctionalInterface checking to javac
Summary: Javac should check that types annotated with @FunctionalInterface are indeed functional interfaces
Reviewed-by: jjg

     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  */
    26 package com.sun.tools.javac.code;
    28 import java.util.*;
    30 import javax.lang.model.element.ElementVisitor;
    31 import javax.lang.model.type.TypeVisitor;
    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.*;
    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>();
    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     }
    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);
    79     private final Names names;
    80     private final ClassReader reader;
    81     private final Target target;
    83     /** A symbol for the root package.
    84      */
    85     public final PackageSymbol rootPackage;
    87     /** A symbol for the unnamed package.
    88      */
    89     public final PackageSymbol unnamedPackage;
    91     /** A symbol that stands for a missing symbol.
    92      */
    93     public final TypeSymbol noSymbol;
    95     /** The error symbol.
    96      */
    97     public final ClassSymbol errSymbol;
    99     /** The unknown symbol.
   100      */
   101     public final ClassSymbol unknownSymbol;
   103     /** A value for the errType, with a originalType of noType */
   104     public final Type errType;
   106     /** A value for the unknown type. */
   107     public final Type unknownType;
   109     /** The builtin type of all arrays. */
   110     public final ClassSymbol arrayClass;
   111     public final MethodSymbol arrayCloneMethod;
   113     /** VGJ: The (singleton) type of all bound types. */
   114     public final ClassSymbol boundClass;
   116     /** The builtin type of all methods. */
   117     public final ClassSymbol methodClass;
   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 proprietaryType;
   160     public final Type systemType;
   161     public final Type autoCloseableType;
   162     public final Type trustMeType;
   163     public final Type lambdaMetafactory;
   164     public final Type repeatableType;
   165     public final Type documentedType;
   166     public final Type elementTypeType;
   167     public final Type functionalInterfaceType;
   169     /** The symbol representing the length field of an array.
   170      */
   171     public final VarSymbol lengthVar;
   173     /** The null check operator. */
   174     public final OperatorSymbol nullcheck;
   176     /** The symbol representing the final finalize method on enums */
   177     public final MethodSymbol enumFinalFinalize;
   179     /** The symbol representing the close method on TWR AutoCloseable type */
   180     public final MethodSymbol autoCloseableClose;
   182     /** The predefined type that belongs to a tag.
   183      */
   184     public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
   186     /** The name of the class that belongs to a basix type tag.
   187      */
   188     public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
   190     /** A set containing all operator names.
   191      */
   192     public final Set<Name> operatorNames = new HashSet<Name>();
   194     /** A hashtable containing the encountered top-level and member classes,
   195      *  indexed by flat names. The table does not contain local classes.
   196      *  It should be updated from the outside to reflect classes defined
   197      *  by compiled source files.
   198      */
   199     public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
   201     /** A hashtable containing the encountered packages.
   202      *  the table should be updated from outside to reflect packages defined
   203      *  by compiled source files.
   204      */
   205     public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
   207     public void initType(Type type, ClassSymbol c) {
   208         type.tsym = c;
   209         typeOfTag[type.tag.ordinal()] = type;
   210     }
   212     public void initType(Type type, String name) {
   213         initType(
   214             type,
   215             new ClassSymbol(
   216                 PUBLIC, names.fromString(name), type, rootPackage));
   217     }
   219     public void initType(Type type, String name, String bname) {
   220         initType(type, name);
   221             boxedName[type.tag.ordinal()] = names.fromString("java.lang." + bname);
   222     }
   224     /** The class symbol that owns all predefined symbols.
   225      */
   226     public final ClassSymbol predefClass;
   228     /** Enter a constant into symbol table.
   229      *  @param name   The constant's name.
   230      *  @param type   The constant's type.
   231      */
   232     private VarSymbol enterConstant(String name, Type type) {
   233         VarSymbol c = new VarSymbol(
   234             PUBLIC | STATIC | FINAL,
   235             names.fromString(name),
   236             type,
   237             predefClass);
   238         c.setData(type.constValue());
   239         predefClass.members().enter(c);
   240         return c;
   241     }
   243     /** Enter a binary operation into symbol table.
   244      *  @param name     The name of the operator.
   245      *  @param left     The type of the left operand.
   246      *  @param right    The type of the left operand.
   247      *  @param res      The operation's result type.
   248      *  @param opcode   The operation's bytecode instruction.
   249      */
   250     private void enterBinop(String name,
   251                             Type left, Type right, Type res,
   252                             int opcode) {
   253         predefClass.members().enter(
   254             new OperatorSymbol(
   255                 makeOperatorName(name),
   256                 new MethodType(List.of(left, right), res,
   257                                List.<Type>nil(), methodClass),
   258                 opcode,
   259                 predefClass));
   260     }
   262     /** Enter a binary operation, as above but with two opcodes,
   263      *  which get encoded as
   264      *  {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }.
   265      *  @param opcode1     First opcode.
   266      *  @param opcode2     Second opcode.
   267      */
   268     private void enterBinop(String name,
   269                             Type left, Type right, Type res,
   270                             int opcode1, int opcode2) {
   271         enterBinop(
   272             name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
   273     }
   275     /** Enter a unary operation into symbol table.
   276      *  @param name     The name of the operator.
   277      *  @param arg      The type of the operand.
   278      *  @param res      The operation's result type.
   279      *  @param opcode   The operation's bytecode instruction.
   280      */
   281     private OperatorSymbol enterUnop(String name,
   282                                      Type arg,
   283                                      Type res,
   284                                      int opcode) {
   285         OperatorSymbol sym =
   286             new OperatorSymbol(makeOperatorName(name),
   287                                new MethodType(List.of(arg),
   288                                               res,
   289                                               List.<Type>nil(),
   290                                               methodClass),
   291                                opcode,
   292                                predefClass);
   293         predefClass.members().enter(sym);
   294         return sym;
   295     }
   297     /**
   298      * Create a new operator name from corresponding String representation
   299      * and add the name to the set of known operator names.
   300      */
   301     private Name makeOperatorName(String name) {
   302         Name opName = names.fromString(name);
   303         operatorNames.add(opName);
   304         return opName;
   305     }
   307     /** Enter a class into symbol table.
   308      *  @param s The name of the class.
   309      */
   310     private Type enterClass(String s) {
   311         return reader.enterClass(names.fromString(s)).type;
   312     }
   314     public void synthesizeEmptyInterfaceIfMissing(final Type type) {
   315         final Completer completer = type.tsym.completer;
   316         if (completer != null) {
   317             type.tsym.completer = new Completer() {
   318                 public void complete(Symbol sym) throws CompletionFailure {
   319                     try {
   320                         completer.complete(sym);
   321                     } catch (CompletionFailure e) {
   322                         sym.flags_field |= (PUBLIC | INTERFACE);
   323                         ((ClassType) sym.type).supertype_field = objectType;
   324                     }
   325                 }
   326             };
   327         }
   328     }
   330     public void synthesizeBoxTypeIfMissing(final Type type) {
   331         ClassSymbol sym = reader.enterClass(boxedName[type.tag.ordinal()]);
   332         final Completer completer = sym.completer;
   333         if (completer != null) {
   334             sym.completer = new Completer() {
   335                 public void complete(Symbol sym) throws CompletionFailure {
   336                     try {
   337                         completer.complete(sym);
   338                     } catch (CompletionFailure e) {
   339                         sym.flags_field |= PUBLIC;
   340                         ((ClassType) sym.type).supertype_field = objectType;
   341                         Name n = target.boxWithConstructors() ? names.init : names.valueOf;
   342                         MethodSymbol boxMethod =
   343                             new MethodSymbol(PUBLIC | STATIC,
   344                                 n,
   345                                 new MethodType(List.of(type), sym.type,
   346                                     List.<Type>nil(), methodClass),
   347                                 sym);
   348                         sym.members().enter(boxMethod);
   349                         MethodSymbol unboxMethod =
   350                             new MethodSymbol(PUBLIC,
   351                                 type.tsym.name.append(names.Value), // x.intValue()
   352                                 new MethodType(List.<Type>nil(), type,
   353                                     List.<Type>nil(), methodClass),
   354                                 sym);
   355                         sym.members().enter(unboxMethod);
   356                     }
   357                 }
   358             };
   359         }
   361     }
   363     /** Constructor; enters all predefined identifiers and operators
   364      *  into symbol table.
   365      */
   366     protected Symtab(Context context) throws CompletionFailure {
   367         context.put(symtabKey, this);
   369         names = Names.instance(context);
   370         target = Target.instance(context);
   372         // Create the unknown type
   373         unknownType = new Type(UNKNOWN, null) {
   374             @Override
   375             public <R, P> R accept(TypeVisitor<R, P> v, P p) {
   376                 return v.visitUnknown(this, p);
   377             }
   378         };
   380         // create the basic builtin symbols
   381         rootPackage = new PackageSymbol(names.empty, null);
   382         final JavacMessages messages = JavacMessages.instance(context);
   383         unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
   384                 public String toString() {
   385                     return messages.getLocalizedString("compiler.misc.unnamed.package");
   386                 }
   387             };
   388         noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
   389             public <R, P> R accept(ElementVisitor<R, P> v, P p) {
   390                 return v.visitUnknown(this, p);
   391             }
   392         };
   393         noSymbol.kind = Kinds.NIL;
   395         // create the error symbols
   396         errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
   397         errType = new ErrorType(errSymbol, Type.noType);
   399         unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
   400         unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
   401         unknownSymbol.type = unknownType;
   403         // initialize builtin types
   404         initType(byteType, "byte", "Byte");
   405         initType(shortType, "short", "Short");
   406         initType(charType, "char", "Character");
   407         initType(intType, "int", "Integer");
   408         initType(longType, "long", "Long");
   409         initType(floatType, "float", "Float");
   410         initType(doubleType, "double", "Double");
   411         initType(booleanType, "boolean", "Boolean");
   412         initType(voidType, "void", "Void");
   413         initType(botType, "<nulltype>");
   414         initType(errType, errSymbol);
   415         initType(unknownType, unknownSymbol);
   417         // the builtin class of all arrays
   418         arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
   420         // VGJ
   421         boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
   422         boundClass.members_field = new Scope.ErrorScope(boundClass);
   424         // the builtin class of all methods
   425         methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
   426         methodClass.members_field = new Scope.ErrorScope(boundClass);
   428         // Create class to hold all predefined constants and operations.
   429         predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
   430         Scope scope = new Scope(predefClass);
   431         predefClass.members_field = scope;
   433         // Enter symbols for basic types.
   434         scope.enter(byteType.tsym);
   435         scope.enter(shortType.tsym);
   436         scope.enter(charType.tsym);
   437         scope.enter(intType.tsym);
   438         scope.enter(longType.tsym);
   439         scope.enter(floatType.tsym);
   440         scope.enter(doubleType.tsym);
   441         scope.enter(booleanType.tsym);
   442         scope.enter(errType.tsym);
   444         // Enter symbol for the errSymbol
   445         scope.enter(errSymbol);
   447         classes.put(predefClass.fullname, predefClass);
   449         reader = ClassReader.instance(context);
   450         reader.init(this);
   452         // Enter predefined classes.
   453         objectType = enterClass("java.lang.Object");
   454         classType = enterClass("java.lang.Class");
   455         stringType = enterClass("java.lang.String");
   456         stringBufferType = enterClass("java.lang.StringBuffer");
   457         stringBuilderType = enterClass("java.lang.StringBuilder");
   458         cloneableType = enterClass("java.lang.Cloneable");
   459         throwableType = enterClass("java.lang.Throwable");
   460         serializableType = enterClass("java.io.Serializable");
   461         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
   462         methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
   463         methodTypeType = enterClass("java.lang.invoke.MethodType");
   464         errorType = enterClass("java.lang.Error");
   465         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
   466         interruptedExceptionType = enterClass("java.lang.InterruptedException");
   467         exceptionType = enterClass("java.lang.Exception");
   468         runtimeExceptionType = enterClass("java.lang.RuntimeException");
   469         classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
   470         noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
   471         noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
   472         assertionErrorType = enterClass("java.lang.AssertionError");
   473         cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
   474         annotationType = enterClass("java.lang.annotation.Annotation");
   475         classLoaderType = enterClass("java.lang.ClassLoader");
   476         enumSym = reader.enterClass(names.java_lang_Enum);
   477         enumFinalFinalize =
   478             new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
   479                              names.finalize,
   480                              new MethodType(List.<Type>nil(), voidType,
   481                                             List.<Type>nil(), methodClass),
   482                              enumSym);
   483         listType = enterClass("java.util.List");
   484         collectionsType = enterClass("java.util.Collections");
   485         comparableType = enterClass("java.lang.Comparable");
   486         arraysType = enterClass("java.util.Arrays");
   487         iterableType = target.hasIterable()
   488             ? enterClass("java.lang.Iterable")
   489             : enterClass("java.util.Collection");
   490         iteratorType = enterClass("java.util.Iterator");
   491         annotationTargetType = enterClass("java.lang.annotation.Target");
   492         overrideType = enterClass("java.lang.Override");
   493         retentionType = enterClass("java.lang.annotation.Retention");
   494         deprecatedType = enterClass("java.lang.Deprecated");
   495         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
   496         inheritedType = enterClass("java.lang.annotation.Inherited");
   497         repeatableType = enterClass("java.lang.annotation.Repeatable");
   498         documentedType = enterClass("java.lang.annotation.Documented");
   499         elementTypeType = enterClass("java.lang.annotation.ElementType");
   500         systemType = enterClass("java.lang.System");
   501         autoCloseableType = enterClass("java.lang.AutoCloseable");
   502         autoCloseableClose = new MethodSymbol(PUBLIC,
   503                              names.close,
   504                              new MethodType(List.<Type>nil(), voidType,
   505                                             List.of(exceptionType), methodClass),
   506                              autoCloseableType.tsym);
   507         trustMeType = enterClass("java.lang.SafeVarargs");
   508         nativeHeaderType = enterClass("java.lang.annotation.Native");
   509         nativeHeaderType_old = enterClass("javax.tools.annotation.GenerateNativeHeader");
   510         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
   511         functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
   513         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
   514         synthesizeEmptyInterfaceIfMissing(cloneableType);
   515         synthesizeEmptyInterfaceIfMissing(serializableType);
   516         synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
   517         synthesizeBoxTypeIfMissing(doubleType);
   518         synthesizeBoxTypeIfMissing(floatType);
   519         synthesizeBoxTypeIfMissing(voidType);
   521         // Enter a synthetic class that is used to mark internal
   522         // proprietary classes in ct.sym.  This class does not have a
   523         // class file.
   524         ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
   525         this.proprietaryType = proprietaryType;
   526         ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
   527         proprietarySymbol.completer = null;
   528         proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
   529         proprietarySymbol.erasure_field = proprietaryType;
   530         proprietarySymbol.members_field = new Scope(proprietarySymbol);
   531         proprietaryType.typarams_field = List.nil();
   532         proprietaryType.allparams_field = List.nil();
   533         proprietaryType.supertype_field = annotationType;
   534         proprietaryType.interfaces_field = List.nil();
   536         // Enter a class for arrays.
   537         // The class implements java.lang.Cloneable and java.io.Serializable.
   538         // It has a final length field and a clone method.
   539         ClassType arrayClassType = (ClassType)arrayClass.type;
   540         arrayClassType.supertype_field = objectType;
   541         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
   542         arrayClass.members_field = new Scope(arrayClass);
   543         lengthVar = new VarSymbol(
   544             PUBLIC | FINAL,
   545             names.length,
   546             intType,
   547             arrayClass);
   548         arrayClass.members().enter(lengthVar);
   549         arrayCloneMethod = new MethodSymbol(
   550             PUBLIC,
   551             names.clone,
   552             new MethodType(List.<Type>nil(), objectType,
   553                            List.<Type>nil(), methodClass),
   554             arrayClass);
   555         arrayClass.members().enter(arrayCloneMethod);
   557         // Enter operators.
   558         enterUnop("+", doubleType, doubleType, nop);
   559         enterUnop("+", floatType, floatType, nop);
   560         enterUnop("+", longType, longType, nop);
   561         enterUnop("+", intType, intType, nop);
   563         enterUnop("-", doubleType, doubleType, dneg);
   564         enterUnop("-", floatType, floatType, fneg);
   565         enterUnop("-", longType, longType, lneg);
   566         enterUnop("-", intType, intType, ineg);
   568         enterUnop("~", longType, longType, lxor);
   569         enterUnop("~", intType, intType, ixor);
   571         enterUnop("++", doubleType, doubleType, dadd);
   572         enterUnop("++", floatType, floatType, fadd);
   573         enterUnop("++", longType, longType, ladd);
   574         enterUnop("++", intType, intType, iadd);
   575         enterUnop("++", charType, charType, iadd);
   576         enterUnop("++", shortType, shortType, iadd);
   577         enterUnop("++", byteType, byteType, iadd);
   579         enterUnop("--", doubleType, doubleType, dsub);
   580         enterUnop("--", floatType, floatType, fsub);
   581         enterUnop("--", longType, longType, lsub);
   582         enterUnop("--", intType, intType, isub);
   583         enterUnop("--", charType, charType, isub);
   584         enterUnop("--", shortType, shortType, isub);
   585         enterUnop("--", byteType, byteType, isub);
   587         enterUnop("!", booleanType, booleanType, bool_not);
   588         nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
   590         // string concatenation
   591         enterBinop("+", stringType, objectType, stringType, string_add);
   592         enterBinop("+", objectType, stringType, stringType, string_add);
   593         enterBinop("+", stringType, stringType, stringType, string_add);
   594         enterBinop("+", stringType, intType, stringType, string_add);
   595         enterBinop("+", stringType, longType, stringType, string_add);
   596         enterBinop("+", stringType, floatType, stringType, string_add);
   597         enterBinop("+", stringType, doubleType, stringType, string_add);
   598         enterBinop("+", stringType, booleanType, stringType, string_add);
   599         enterBinop("+", stringType, botType, stringType, string_add);
   600         enterBinop("+", intType, stringType, stringType, string_add);
   601         enterBinop("+", longType, stringType, stringType, string_add);
   602         enterBinop("+", floatType, stringType, stringType, string_add);
   603         enterBinop("+", doubleType, stringType, stringType, string_add);
   604         enterBinop("+", booleanType, stringType, stringType, string_add);
   605         enterBinop("+", botType, stringType, stringType, string_add);
   607         // these errors would otherwise be matched as string concatenation
   608         enterBinop("+", botType, botType, botType, error);
   609         enterBinop("+", botType, intType, botType, error);
   610         enterBinop("+", botType, longType, botType, error);
   611         enterBinop("+", botType, floatType, botType, error);
   612         enterBinop("+", botType, doubleType, botType, error);
   613         enterBinop("+", botType, booleanType, botType, error);
   614         enterBinop("+", botType, objectType, botType, error);
   615         enterBinop("+", intType, botType, botType, error);
   616         enterBinop("+", longType, botType, botType, error);
   617         enterBinop("+", floatType, botType, botType, error);
   618         enterBinop("+", doubleType, botType, botType, error);
   619         enterBinop("+", booleanType, botType, botType, error);
   620         enterBinop("+", objectType, botType, botType, error);
   622         enterBinop("+", doubleType, doubleType, doubleType, dadd);
   623         enterBinop("+", floatType, floatType, floatType, fadd);
   624         enterBinop("+", longType, longType, longType, ladd);
   625         enterBinop("+", intType, intType, intType, iadd);
   627         enterBinop("-", doubleType, doubleType, doubleType, dsub);
   628         enterBinop("-", floatType, floatType, floatType, fsub);
   629         enterBinop("-", longType, longType, longType, lsub);
   630         enterBinop("-", intType, intType, intType, isub);
   632         enterBinop("*", doubleType, doubleType, doubleType, dmul);
   633         enterBinop("*", floatType, floatType, floatType, fmul);
   634         enterBinop("*", longType, longType, longType, lmul);
   635         enterBinop("*", intType, intType, intType, imul);
   637         enterBinop("/", doubleType, doubleType, doubleType, ddiv);
   638         enterBinop("/", floatType, floatType, floatType, fdiv);
   639         enterBinop("/", longType, longType, longType, ldiv);
   640         enterBinop("/", intType, intType, intType, idiv);
   642         enterBinop("%", doubleType, doubleType, doubleType, dmod);
   643         enterBinop("%", floatType, floatType, floatType, fmod);
   644         enterBinop("%", longType, longType, longType, lmod);
   645         enterBinop("%", intType, intType, intType, imod);
   647         enterBinop("&", booleanType, booleanType, booleanType, iand);
   648         enterBinop("&", longType, longType, longType, land);
   649         enterBinop("&", intType, intType, intType, iand);
   651         enterBinop("|", booleanType, booleanType, booleanType, ior);
   652         enterBinop("|", longType, longType, longType, lor);
   653         enterBinop("|", intType, intType, intType, ior);
   655         enterBinop("^", booleanType, booleanType, booleanType, ixor);
   656         enterBinop("^", longType, longType, longType, lxor);
   657         enterBinop("^", intType, intType, intType, ixor);
   659         enterBinop("<<", longType, longType, longType, lshll);
   660         enterBinop("<<", intType, longType, intType, ishll);
   661         enterBinop("<<", longType, intType, longType, lshl);
   662         enterBinop("<<", intType, intType, intType, ishl);
   664         enterBinop(">>", longType, longType, longType, lshrl);
   665         enterBinop(">>", intType, longType, intType, ishrl);
   666         enterBinop(">>", longType, intType, longType, lshr);
   667         enterBinop(">>", intType, intType, intType, ishr);
   669         enterBinop(">>>", longType, longType, longType, lushrl);
   670         enterBinop(">>>", intType, longType, intType, iushrl);
   671         enterBinop(">>>", longType, intType, longType, lushr);
   672         enterBinop(">>>", intType, intType, intType, iushr);
   674         enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
   675         enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
   676         enterBinop("<", longType, longType, booleanType, lcmp, iflt);
   677         enterBinop("<", intType, intType, booleanType, if_icmplt);
   679         enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
   680         enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
   681         enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
   682         enterBinop(">", intType, intType, booleanType, if_icmpgt);
   684         enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
   685         enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
   686         enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
   687         enterBinop("<=", intType, intType, booleanType, if_icmple);
   689         enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
   690         enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
   691         enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
   692         enterBinop(">=", intType, intType, booleanType, if_icmpge);
   694         enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
   695         enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
   696         enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
   697         enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
   698         enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
   699         enterBinop("==", intType, intType, booleanType, if_icmpeq);
   701         enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
   702         enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
   703         enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
   704         enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
   705         enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
   706         enterBinop("!=", intType, intType, booleanType, if_icmpne);
   708         enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
   709         enterBinop("||", booleanType, booleanType, booleanType, bool_or);
   710     }
   711 }

mercurial