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

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 1347
1408af4cd8b0
child 1358
fc123bdeddb8
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

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

mercurial