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

Thu, 21 Feb 2013 17:49:56 -0800

author
lana
date
Thu, 21 Feb 2013 17:49:56 -0800
changeset 1603
6118072811e5
parent 1587
f1f605f85850
parent 1570
f91144b7da75
child 1620
3806171b52d8
permissions
-rw-r--r--

Merge

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

mercurial