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

Thu, 01 Nov 2012 10:48:36 +0100

author
ohrstrom
date
Thu, 01 Nov 2012 10:48:36 +0100
changeset 1384
bf54daa9dcd8
parent 1380
a65971893c50
child 1407
f14c693a0e48
permissions
-rw-r--r--

7153951: Add new lint option -Xlint:auxiliaryclass
Reviewed-by: jjg, mcimadamore, forax

     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  */
    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 throwableType;
   134     public final Type errorType;
   135     public final Type interruptedExceptionType;
   136     public final Type illegalArgumentExceptionType;
   137     public final Type exceptionType;
   138     public final Type runtimeExceptionType;
   139     public final Type classNotFoundExceptionType;
   140     public final Type noClassDefFoundErrorType;
   141     public final Type noSuchFieldErrorType;
   142     public final Type assertionErrorType;
   143     public final Type cloneNotSupportedExceptionType;
   144     public final Type annotationType;
   145     public final TypeSymbol enumSym;
   146     public final Type listType;
   147     public final Type collectionsType;
   148     public final Type comparableType;
   149     public final Type arraysType;
   150     public final Type iterableType;
   151     public final Type iteratorType;
   152     public final Type annotationTargetType;
   153     public final Type overrideType;
   154     public final Type retentionType;
   155     public final Type deprecatedType;
   156     public final Type suppressWarningsType;
   157     public final Type inheritedType;
   158     public final Type proprietaryType;
   159     public final Type systemType;
   160     public final Type autoCloseableType;
   161     public final Type trustMeType;
   162     public final Type lambdaMetafactory;
   163     public final Type containedByType;
   164     public final Type containerForType;
   165     public final Type documentedType;
   166     public final Type elementTypeType;
   168     /** The symbol representing the length field of an array.
   169      */
   170     public final VarSymbol lengthVar;
   172     /** The null check operator. */
   173     public final OperatorSymbol nullcheck;
   175     /** The symbol representing the final finalize method on enums */
   176     public final MethodSymbol enumFinalFinalize;
   178     /** The symbol representing the close method on TWR AutoCloseable type */
   179     public final MethodSymbol autoCloseableClose;
   181     /** The predefined type that belongs to a tag.
   182      */
   183     public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
   185     /** The name of the class that belongs to a basix type tag.
   186      */
   187     public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
   189     /** A set containing all operator names.
   190      */
   191     public final Set<Name> operatorNames = new HashSet<Name>();
   193     /** A hashtable containing the encountered top-level and member classes,
   194      *  indexed by flat names. The table does not contain local classes.
   195      *  It should be updated from the outside to reflect classes defined
   196      *  by compiled source files.
   197      */
   198     public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
   200     /** A hashtable containing the encountered packages.
   201      *  the table should be updated from outside to reflect packages defined
   202      *  by compiled source files.
   203      */
   204     public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
   206     public void initType(Type type, ClassSymbol c) {
   207         type.tsym = c;
   208         typeOfTag[type.tag.ordinal()] = type;
   209     }
   211     public void initType(Type type, String name) {
   212         initType(
   213             type,
   214             new ClassSymbol(
   215                 PUBLIC, names.fromString(name), type, rootPackage));
   216     }
   218     public void initType(Type type, String name, String bname) {
   219         initType(type, name);
   220             boxedName[type.tag.ordinal()] = names.fromString("java.lang." + bname);
   221     }
   223     /** The class symbol that owns all predefined symbols.
   224      */
   225     public final ClassSymbol predefClass;
   227     /** Enter a constant into symbol table.
   228      *  @param name   The constant's name.
   229      *  @param type   The constant's type.
   230      */
   231     private VarSymbol enterConstant(String name, Type type) {
   232         VarSymbol c = new VarSymbol(
   233             PUBLIC | STATIC | FINAL,
   234             names.fromString(name),
   235             type,
   236             predefClass);
   237         c.setData(type.constValue());
   238         predefClass.members().enter(c);
   239         return c;
   240     }
   242     /** Enter a binary operation into symbol table.
   243      *  @param name     The name of the operator.
   244      *  @param left     The type of the left operand.
   245      *  @param right    The type of the left operand.
   246      *  @param res      The operation's result type.
   247      *  @param opcode   The operation's bytecode instruction.
   248      */
   249     private void enterBinop(String name,
   250                             Type left, Type right, Type res,
   251                             int opcode) {
   252         predefClass.members().enter(
   253             new OperatorSymbol(
   254                 makeOperatorName(name),
   255                 new MethodType(List.of(left, right), res,
   256                                List.<Type>nil(), methodClass),
   257                 opcode,
   258                 predefClass));
   259     }
   261     /** Enter a binary operation, as above but with two opcodes,
   262      *  which get encoded as
   263      *  {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }.
   264      *  @param opcode1     First opcode.
   265      *  @param opcode2     Second opcode.
   266      */
   267     private void enterBinop(String name,
   268                             Type left, Type right, Type res,
   269                             int opcode1, int opcode2) {
   270         enterBinop(
   271             name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
   272     }
   274     /** Enter a unary operation into symbol table.
   275      *  @param name     The name of the operator.
   276      *  @param arg      The type of the operand.
   277      *  @param res      The operation's result type.
   278      *  @param opcode   The operation's bytecode instruction.
   279      */
   280     private OperatorSymbol enterUnop(String name,
   281                                      Type arg,
   282                                      Type res,
   283                                      int opcode) {
   284         OperatorSymbol sym =
   285             new OperatorSymbol(makeOperatorName(name),
   286                                new MethodType(List.of(arg),
   287                                               res,
   288                                               List.<Type>nil(),
   289                                               methodClass),
   290                                opcode,
   291                                predefClass);
   292         predefClass.members().enter(sym);
   293         return sym;
   294     }
   296     /**
   297      * Create a new operator name from corresponding String representation
   298      * and add the name to the set of known operator names.
   299      */
   300     private Name makeOperatorName(String name) {
   301         Name opName = names.fromString(name);
   302         operatorNames.add(opName);
   303         return opName;
   304     }
   306     /** Enter a class into symbol table.
   307      *  @param s The name of the class.
   308      */
   309     private Type enterClass(String s) {
   310         return reader.enterClass(names.fromString(s)).type;
   311     }
   313     public void synthesizeEmptyInterfaceIfMissing(final Type type) {
   314         final Completer completer = type.tsym.completer;
   315         if (completer != null) {
   316             type.tsym.completer = new Completer() {
   317                 public void complete(Symbol sym) throws CompletionFailure {
   318                     try {
   319                         completer.complete(sym);
   320                     } catch (CompletionFailure e) {
   321                         sym.flags_field |= (PUBLIC | INTERFACE);
   322                         ((ClassType) sym.type).supertype_field = objectType;
   323                     }
   324                 }
   325             };
   326         }
   327     }
   329     public void synthesizeBoxTypeIfMissing(final Type type) {
   330         ClassSymbol sym = reader.enterClass(boxedName[type.tag.ordinal()]);
   331         final Completer completer = sym.completer;
   332         if (completer != null) {
   333             sym.completer = new Completer() {
   334                 public void complete(Symbol sym) throws CompletionFailure {
   335                     try {
   336                         completer.complete(sym);
   337                     } catch (CompletionFailure e) {
   338                         sym.flags_field |= PUBLIC;
   339                         ((ClassType) sym.type).supertype_field = objectType;
   340                         Name n = target.boxWithConstructors() ? names.init : names.valueOf;
   341                         MethodSymbol boxMethod =
   342                             new MethodSymbol(PUBLIC | STATIC,
   343                                 n,
   344                                 new MethodType(List.of(type), sym.type,
   345                                     List.<Type>nil(), methodClass),
   346                                 sym);
   347                         sym.members().enter(boxMethod);
   348                         MethodSymbol unboxMethod =
   349                             new MethodSymbol(PUBLIC,
   350                                 type.tsym.name.append(names.Value), // x.intValue()
   351                                 new MethodType(List.<Type>nil(), type,
   352                                     List.<Type>nil(), methodClass),
   353                                 sym);
   354                         sym.members().enter(unboxMethod);
   355                     }
   356                 }
   357             };
   358         }
   360     }
   362     /** Constructor; enters all predefined identifiers and operators
   363      *  into symbol table.
   364      */
   365     protected Symtab(Context context) throws CompletionFailure {
   366         context.put(symtabKey, this);
   368         names = Names.instance(context);
   369         target = Target.instance(context);
   371         // Create the unknown type
   372         unknownType = new Type(UNKNOWN, null) {
   373             @Override
   374             public <R, P> R accept(TypeVisitor<R, P> v, P p) {
   375                 return v.visitUnknown(this, p);
   376             }
   377         };
   379         // create the basic builtin symbols
   380         rootPackage = new PackageSymbol(names.empty, null);
   381         final JavacMessages messages = JavacMessages.instance(context);
   382         unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
   383                 public String toString() {
   384                     return messages.getLocalizedString("compiler.misc.unnamed.package");
   385                 }
   386             };
   387         noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
   388             public <R, P> R accept(ElementVisitor<R, P> v, P p) {
   389                 return v.visitUnknown(this, p);
   390             }
   391         };
   392         noSymbol.kind = Kinds.NIL;
   394         // create the error symbols
   395         errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
   396         errType = new ErrorType(errSymbol, Type.noType);
   398         unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
   399         unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
   400         unknownSymbol.type = unknownType;
   402         // initialize builtin types
   403         initType(byteType, "byte", "Byte");
   404         initType(shortType, "short", "Short");
   405         initType(charType, "char", "Character");
   406         initType(intType, "int", "Integer");
   407         initType(longType, "long", "Long");
   408         initType(floatType, "float", "Float");
   409         initType(doubleType, "double", "Double");
   410         initType(booleanType, "boolean", "Boolean");
   411         initType(voidType, "void", "Void");
   412         initType(botType, "<nulltype>");
   413         initType(errType, errSymbol);
   414         initType(unknownType, unknownSymbol);
   416         // the builtin class of all arrays
   417         arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
   419         // VGJ
   420         boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
   421         boundClass.members_field = new Scope.ErrorScope(boundClass);
   423         // the builtin class of all methods
   424         methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
   425         methodClass.members_field = new Scope.ErrorScope(boundClass);
   427         // Create class to hold all predefined constants and operations.
   428         predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
   429         Scope scope = new Scope(predefClass);
   430         predefClass.members_field = scope;
   432         // Enter symbols for basic types.
   433         scope.enter(byteType.tsym);
   434         scope.enter(shortType.tsym);
   435         scope.enter(charType.tsym);
   436         scope.enter(intType.tsym);
   437         scope.enter(longType.tsym);
   438         scope.enter(floatType.tsym);
   439         scope.enter(doubleType.tsym);
   440         scope.enter(booleanType.tsym);
   441         scope.enter(errType.tsym);
   443         // Enter symbol for the errSymbol
   444         scope.enter(errSymbol);
   446         classes.put(predefClass.fullname, predefClass);
   448         reader = ClassReader.instance(context);
   449         reader.init(this);
   451         // Enter predefined classes.
   452         objectType = enterClass("java.lang.Object");
   453         classType = enterClass("java.lang.Class");
   454         stringType = enterClass("java.lang.String");
   455         stringBufferType = enterClass("java.lang.StringBuffer");
   456         stringBuilderType = enterClass("java.lang.StringBuilder");
   457         cloneableType = enterClass("java.lang.Cloneable");
   458         throwableType = enterClass("java.lang.Throwable");
   459         serializableType = enterClass("java.io.Serializable");
   460         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
   461         methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
   462         methodTypeType = enterClass("java.lang.invoke.MethodType");
   463         errorType = enterClass("java.lang.Error");
   464         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
   465         interruptedExceptionType = enterClass("java.lang.InterruptedException");
   466         exceptionType = enterClass("java.lang.Exception");
   467         runtimeExceptionType = enterClass("java.lang.RuntimeException");
   468         classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
   469         noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
   470         noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
   471         assertionErrorType = enterClass("java.lang.AssertionError");
   472         cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
   473         annotationType = enterClass("java.lang.annotation.Annotation");
   474         classLoaderType = enterClass("java.lang.ClassLoader");
   475         enumSym = reader.enterClass(names.java_lang_Enum);
   476         enumFinalFinalize =
   477             new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
   478                              names.finalize,
   479                              new MethodType(List.<Type>nil(), voidType,
   480                                             List.<Type>nil(), methodClass),
   481                              enumSym);
   482         listType = enterClass("java.util.List");
   483         collectionsType = enterClass("java.util.Collections");
   484         comparableType = enterClass("java.lang.Comparable");
   485         arraysType = enterClass("java.util.Arrays");
   486         iterableType = target.hasIterable()
   487             ? enterClass("java.lang.Iterable")
   488             : enterClass("java.util.Collection");
   489         iteratorType = enterClass("java.util.Iterator");
   490         annotationTargetType = enterClass("java.lang.annotation.Target");
   491         overrideType = enterClass("java.lang.Override");
   492         retentionType = enterClass("java.lang.annotation.Retention");
   493         deprecatedType = enterClass("java.lang.Deprecated");
   494         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
   495         inheritedType = enterClass("java.lang.annotation.Inherited");
   496         containedByType = enterClass("java.lang.annotation.ContainedBy");
   497         containerForType = enterClass("java.lang.annotation.ContainerFor");
   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("javax.tools.annotation.GenerateNativeHeader");
   509         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
   511         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
   512         synthesizeEmptyInterfaceIfMissing(cloneableType);
   513         synthesizeEmptyInterfaceIfMissing(serializableType);
   514         synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
   515         synthesizeBoxTypeIfMissing(doubleType);
   516         synthesizeBoxTypeIfMissing(floatType);
   517         synthesizeBoxTypeIfMissing(voidType);
   519         // Enter a synthetic class that is used to mark internal
   520         // proprietary classes in ct.sym.  This class does not have a
   521         // class file.
   522         ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
   523         this.proprietaryType = proprietaryType;
   524         ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
   525         proprietarySymbol.completer = null;
   526         proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
   527         proprietarySymbol.erasure_field = proprietaryType;
   528         proprietarySymbol.members_field = new Scope(proprietarySymbol);
   529         proprietaryType.typarams_field = List.nil();
   530         proprietaryType.allparams_field = List.nil();
   531         proprietaryType.supertype_field = annotationType;
   532         proprietaryType.interfaces_field = List.nil();
   534         // Enter a class for arrays.
   535         // The class implements java.lang.Cloneable and java.io.Serializable.
   536         // It has a final length field and a clone method.
   537         ClassType arrayClassType = (ClassType)arrayClass.type;
   538         arrayClassType.supertype_field = objectType;
   539         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
   540         arrayClass.members_field = new Scope(arrayClass);
   541         lengthVar = new VarSymbol(
   542             PUBLIC | FINAL,
   543             names.length,
   544             intType,
   545             arrayClass);
   546         arrayClass.members().enter(lengthVar);
   547         arrayCloneMethod = new MethodSymbol(
   548             PUBLIC,
   549             names.clone,
   550             new MethodType(List.<Type>nil(), objectType,
   551                            List.<Type>nil(), methodClass),
   552             arrayClass);
   553         arrayClass.members().enter(arrayCloneMethod);
   555         // Enter operators.
   556         enterUnop("+", doubleType, doubleType, nop);
   557         enterUnop("+", floatType, floatType, nop);
   558         enterUnop("+", longType, longType, nop);
   559         enterUnop("+", intType, intType, nop);
   561         enterUnop("-", doubleType, doubleType, dneg);
   562         enterUnop("-", floatType, floatType, fneg);
   563         enterUnop("-", longType, longType, lneg);
   564         enterUnop("-", intType, intType, ineg);
   566         enterUnop("~", longType, longType, lxor);
   567         enterUnop("~", intType, intType, ixor);
   569         enterUnop("++", doubleType, doubleType, dadd);
   570         enterUnop("++", floatType, floatType, fadd);
   571         enterUnop("++", longType, longType, ladd);
   572         enterUnop("++", intType, intType, iadd);
   573         enterUnop("++", charType, charType, iadd);
   574         enterUnop("++", shortType, shortType, iadd);
   575         enterUnop("++", byteType, byteType, iadd);
   577         enterUnop("--", doubleType, doubleType, dsub);
   578         enterUnop("--", floatType, floatType, fsub);
   579         enterUnop("--", longType, longType, lsub);
   580         enterUnop("--", intType, intType, isub);
   581         enterUnop("--", charType, charType, isub);
   582         enterUnop("--", shortType, shortType, isub);
   583         enterUnop("--", byteType, byteType, isub);
   585         enterUnop("!", booleanType, booleanType, bool_not);
   586         nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
   588         // string concatenation
   589         enterBinop("+", stringType, objectType, stringType, string_add);
   590         enterBinop("+", objectType, stringType, stringType, string_add);
   591         enterBinop("+", stringType, stringType, stringType, string_add);
   592         enterBinop("+", stringType, intType, stringType, string_add);
   593         enterBinop("+", stringType, longType, stringType, string_add);
   594         enterBinop("+", stringType, floatType, stringType, string_add);
   595         enterBinop("+", stringType, doubleType, stringType, string_add);
   596         enterBinop("+", stringType, booleanType, stringType, string_add);
   597         enterBinop("+", stringType, botType, stringType, string_add);
   598         enterBinop("+", intType, stringType, stringType, string_add);
   599         enterBinop("+", longType, stringType, stringType, string_add);
   600         enterBinop("+", floatType, stringType, stringType, string_add);
   601         enterBinop("+", doubleType, stringType, stringType, string_add);
   602         enterBinop("+", booleanType, stringType, stringType, string_add);
   603         enterBinop("+", botType, stringType, stringType, string_add);
   605         // these errors would otherwise be matched as string concatenation
   606         enterBinop("+", botType, botType, botType, error);
   607         enterBinop("+", botType, intType, botType, error);
   608         enterBinop("+", botType, longType, botType, error);
   609         enterBinop("+", botType, floatType, botType, error);
   610         enterBinop("+", botType, doubleType, botType, error);
   611         enterBinop("+", botType, booleanType, botType, error);
   612         enterBinop("+", botType, objectType, botType, error);
   613         enterBinop("+", intType, botType, botType, error);
   614         enterBinop("+", longType, botType, botType, error);
   615         enterBinop("+", floatType, botType, botType, error);
   616         enterBinop("+", doubleType, botType, botType, error);
   617         enterBinop("+", booleanType, botType, botType, error);
   618         enterBinop("+", objectType, botType, botType, error);
   620         enterBinop("+", doubleType, doubleType, doubleType, dadd);
   621         enterBinop("+", floatType, floatType, floatType, fadd);
   622         enterBinop("+", longType, longType, longType, ladd);
   623         enterBinop("+", intType, intType, intType, iadd);
   625         enterBinop("-", doubleType, doubleType, doubleType, dsub);
   626         enterBinop("-", floatType, floatType, floatType, fsub);
   627         enterBinop("-", longType, longType, longType, lsub);
   628         enterBinop("-", intType, intType, intType, isub);
   630         enterBinop("*", doubleType, doubleType, doubleType, dmul);
   631         enterBinop("*", floatType, floatType, floatType, fmul);
   632         enterBinop("*", longType, longType, longType, lmul);
   633         enterBinop("*", intType, intType, intType, imul);
   635         enterBinop("/", doubleType, doubleType, doubleType, ddiv);
   636         enterBinop("/", floatType, floatType, floatType, fdiv);
   637         enterBinop("/", longType, longType, longType, ldiv);
   638         enterBinop("/", intType, intType, intType, idiv);
   640         enterBinop("%", doubleType, doubleType, doubleType, dmod);
   641         enterBinop("%", floatType, floatType, floatType, fmod);
   642         enterBinop("%", longType, longType, longType, lmod);
   643         enterBinop("%", intType, intType, intType, imod);
   645         enterBinop("&", booleanType, booleanType, booleanType, iand);
   646         enterBinop("&", longType, longType, longType, land);
   647         enterBinop("&", intType, intType, intType, iand);
   649         enterBinop("|", booleanType, booleanType, booleanType, ior);
   650         enterBinop("|", longType, longType, longType, lor);
   651         enterBinop("|", intType, intType, intType, ior);
   653         enterBinop("^", booleanType, booleanType, booleanType, ixor);
   654         enterBinop("^", longType, longType, longType, lxor);
   655         enterBinop("^", intType, intType, intType, ixor);
   657         enterBinop("<<", longType, longType, longType, lshll);
   658         enterBinop("<<", intType, longType, intType, ishll);
   659         enterBinop("<<", longType, intType, longType, lshl);
   660         enterBinop("<<", intType, intType, intType, ishl);
   662         enterBinop(">>", longType, longType, longType, lshrl);
   663         enterBinop(">>", intType, longType, intType, ishrl);
   664         enterBinop(">>", longType, intType, longType, lshr);
   665         enterBinop(">>", intType, intType, intType, ishr);
   667         enterBinop(">>>", longType, longType, longType, lushrl);
   668         enterBinop(">>>", intType, longType, intType, iushrl);
   669         enterBinop(">>>", longType, intType, longType, lushr);
   670         enterBinop(">>>", intType, intType, intType, iushr);
   672         enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
   673         enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
   674         enterBinop("<", longType, longType, booleanType, lcmp, iflt);
   675         enterBinop("<", intType, intType, booleanType, if_icmplt);
   677         enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
   678         enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
   679         enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
   680         enterBinop(">", intType, intType, booleanType, if_icmpgt);
   682         enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
   683         enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
   684         enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
   685         enterBinop("<=", intType, intType, booleanType, if_icmple);
   687         enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
   688         enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
   689         enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
   690         enterBinop(">=", intType, intType, booleanType, if_icmpge);
   692         enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
   693         enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
   694         enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
   695         enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
   696         enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
   697         enterBinop("==", intType, intType, booleanType, if_icmpeq);
   699         enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
   700         enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
   701         enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
   702         enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
   703         enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
   704         enterBinop("!=", intType, intType, booleanType, if_icmpne);
   706         enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
   707         enterBinop("||", booleanType, booleanType, booleanType, bool_or);
   708     }
   709 }

mercurial