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

Save This Page
Home » openjdk-7 » com.sun.tools » javac » code » [javadoc | source]