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

Fri, 12 Apr 2013 12:05:04 +0200

author
jfranck
date
Fri, 12 Apr 2013 12:05:04 +0200
changeset 1689
137994c189e5
parent 1620
3806171b52d8
child 1723
a2889739cf21
permissions
-rw-r--r--

7015104: use new subtype of TypeSymbol for type parameters
Reviewed-by: jjg, mcimadamore

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

mercurial