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

changeset 1
9a66ca7c79fa
child 86
3437676858e3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,577 @@
     1.4 +/*
     1.5 + * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.javac.code;
    1.30 +
    1.31 +import java.util.*;
    1.32 +
    1.33 +import com.sun.tools.javac.util.*;
    1.34 +import com.sun.tools.javac.util.List;
    1.35 +import com.sun.tools.javac.code.Symbol.*;
    1.36 +import com.sun.tools.javac.code.Type.*;
    1.37 +import com.sun.tools.javac.jvm.*;
    1.38 +
    1.39 +import static com.sun.tools.javac.jvm.ByteCodes.*;
    1.40 +import static com.sun.tools.javac.code.Flags.*;
    1.41 +
    1.42 +/** A class that defines all predefined constants and operators
    1.43 + *  as well as special classes such as java.lang.Object, which need
    1.44 + *  to be known to the compiler. All symbols are held in instance
    1.45 + *  fields. This makes it possible to work in multiple concurrent
    1.46 + *  projects, which might use different class files for library classes.
    1.47 + *
    1.48 + *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
    1.49 + *  you write code that depends on this, you do so at your own risk.
    1.50 + *  This code and its internal interfaces are subject to change or
    1.51 + *  deletion without notice.</b>
    1.52 + */
    1.53 +public class Symtab {
    1.54 +    /** The context key for the symbol table. */
    1.55 +    protected static final Context.Key<Symtab> symtabKey =
    1.56 +        new Context.Key<Symtab>();
    1.57 +
    1.58 +    /** Get the symbol table instance. */
    1.59 +    public static Symtab instance(Context context) {
    1.60 +        Symtab instance = context.get(symtabKey);
    1.61 +        if (instance == null)
    1.62 +            instance = new Symtab(context);
    1.63 +        return instance;
    1.64 +    }
    1.65 +
    1.66 +    /** Builtin types.
    1.67 +     */
    1.68 +    public final Type byteType = new Type(TypeTags.BYTE, null);
    1.69 +    public final Type charType = new Type(TypeTags.CHAR, null);
    1.70 +    public final Type shortType = new Type(TypeTags.SHORT, null);
    1.71 +    public final Type intType = new Type(TypeTags.INT, null);
    1.72 +    public final Type longType = new Type(TypeTags.LONG, null);
    1.73 +    public final Type floatType = new Type(TypeTags.FLOAT, null);
    1.74 +    public final Type doubleType = new Type(TypeTags.DOUBLE, null);
    1.75 +    public final Type booleanType = new Type(TypeTags.BOOLEAN, null);
    1.76 +    public final Type botType = new BottomType();
    1.77 +    public final JCNoType voidType = new JCNoType(TypeTags.VOID);
    1.78 +
    1.79 +    private final Name.Table names;
    1.80 +    private final ClassReader reader;
    1.81 +
    1.82 +    /** A symbol for the root package.
    1.83 +     */
    1.84 +    public final PackageSymbol rootPackage;
    1.85 +
    1.86 +    /** A symbol for the unnamed package.
    1.87 +     */
    1.88 +    public final PackageSymbol unnamedPackage;
    1.89 +
    1.90 +    /** A symbol that stands for a missing symbol.
    1.91 +     */
    1.92 +    public final TypeSymbol noSymbol;
    1.93 +
    1.94 +    /** The error symbol.
    1.95 +     */
    1.96 +    public final ClassSymbol errSymbol;
    1.97 +
    1.98 +    /** An instance of the error type.
    1.99 +     */
   1.100 +    public final Type errType;
   1.101 +
   1.102 +    /** A value for the unknown type. */
   1.103 +    public final Type unknownType;
   1.104 +
   1.105 +    /** The builtin type of all arrays. */
   1.106 +    public final ClassSymbol arrayClass;
   1.107 +    public final MethodSymbol arrayCloneMethod;
   1.108 +
   1.109 +    /** VGJ: The (singleton) type of all bound types. */
   1.110 +    public final ClassSymbol boundClass;
   1.111 +
   1.112 +    /** The builtin type of all methods. */
   1.113 +    public final ClassSymbol methodClass;
   1.114 +
   1.115 +    /** Predefined types.
   1.116 +     */
   1.117 +    public final Type objectType;
   1.118 +    public final Type classType;
   1.119 +    public final Type classLoaderType;
   1.120 +    public final Type stringType;
   1.121 +    public final Type stringBufferType;
   1.122 +    public final Type stringBuilderType;
   1.123 +    public final Type cloneableType;
   1.124 +    public final Type serializableType;
   1.125 +    public final Type throwableType;
   1.126 +    public final Type errorType;
   1.127 +    public final Type illegalArgumentExceptionType;
   1.128 +    public final Type exceptionType;
   1.129 +    public final Type runtimeExceptionType;
   1.130 +    public final Type classNotFoundExceptionType;
   1.131 +    public final Type noClassDefFoundErrorType;
   1.132 +    public final Type noSuchFieldErrorType;
   1.133 +    public final Type assertionErrorType;
   1.134 +    public final Type cloneNotSupportedExceptionType;
   1.135 +    public final Type annotationType;
   1.136 +    public final TypeSymbol enumSym;
   1.137 +    public final Type listType;
   1.138 +    public final Type collectionsType;
   1.139 +    public final Type comparableType;
   1.140 +    public final Type arraysType;
   1.141 +    public final Type iterableType;
   1.142 +    public final Type iteratorType;
   1.143 +    public final Type annotationTargetType;
   1.144 +    public final Type overrideType;
   1.145 +    public final Type retentionType;
   1.146 +    public final Type deprecatedType;
   1.147 +    public final Type suppressWarningsType;
   1.148 +    public final Type inheritedType;
   1.149 +    public final Type proprietaryType;
   1.150 +
   1.151 +    /** The symbol representing the length field of an array.
   1.152 +     */
   1.153 +    public final VarSymbol lengthVar;
   1.154 +
   1.155 +    /** The null check operator. */
   1.156 +    public final OperatorSymbol nullcheck;
   1.157 +
   1.158 +    /** The symbol representing the final finalize method on enums */
   1.159 +    public final MethodSymbol enumFinalFinalize;
   1.160 +
   1.161 +    /** The predefined type that belongs to a tag.
   1.162 +     */
   1.163 +    public final Type[] typeOfTag = new Type[TypeTags.TypeTagCount];
   1.164 +
   1.165 +    /** The name of the class that belongs to a basix type tag.
   1.166 +     */
   1.167 +    public final Name[] boxedName = new Name[TypeTags.TypeTagCount];
   1.168 +
   1.169 +    /** A hashtable containing the encountered top-level and member classes,
   1.170 +     *  indexed by flat names. The table does not contain local classes.
   1.171 +     *  It should be updated from the outside to reflect classes defined
   1.172 +     *  by compiled source files.
   1.173 +     */
   1.174 +    public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
   1.175 +
   1.176 +    /** A hashtable containing the encountered packages.
   1.177 +     *  the table should be updated from outside to reflect packages defined
   1.178 +     *  by compiled source files.
   1.179 +     */
   1.180 +    public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
   1.181 +
   1.182 +    public void initType(Type type, ClassSymbol c) {
   1.183 +        type.tsym = c;
   1.184 +        typeOfTag[type.tag] = type;
   1.185 +    }
   1.186 +
   1.187 +    public void initType(Type type, String name) {
   1.188 +        initType(
   1.189 +            type,
   1.190 +            new ClassSymbol(
   1.191 +                PUBLIC, names.fromString(name), type, rootPackage));
   1.192 +    }
   1.193 +
   1.194 +    public void initType(Type type, String name, String bname) {
   1.195 +        initType(type, name);
   1.196 +        boxedName[type.tag] = names.fromString("java.lang." + bname);
   1.197 +    }
   1.198 +
   1.199 +    /** The class symbol that owns all predefined symbols.
   1.200 +     */
   1.201 +    public final ClassSymbol predefClass;
   1.202 +
   1.203 +    /** Enter a constant into symbol table.
   1.204 +     *  @param name   The constant's name.
   1.205 +     *  @param type   The constant's type.
   1.206 +     */
   1.207 +    private VarSymbol enterConstant(String name, Type type) {
   1.208 +        VarSymbol c = new VarSymbol(
   1.209 +            PUBLIC | STATIC | FINAL,
   1.210 +            names.fromString(name),
   1.211 +            type,
   1.212 +            predefClass);
   1.213 +        c.setData(type.constValue());
   1.214 +        predefClass.members().enter(c);
   1.215 +        return c;
   1.216 +    }
   1.217 +
   1.218 +    /** Enter a binary operation into symbol table.
   1.219 +     *  @param name     The name of the operator.
   1.220 +     *  @param left     The type of the left operand.
   1.221 +     *  @param right    The type of the left operand.
   1.222 +     *  @param res      The operation's result type.
   1.223 +     *  @param opcode   The operation's bytecode instruction.
   1.224 +     */
   1.225 +    private void enterBinop(String name,
   1.226 +                            Type left, Type right, Type res,
   1.227 +                            int opcode) {
   1.228 +        predefClass.members().enter(
   1.229 +            new OperatorSymbol(
   1.230 +                names.fromString(name),
   1.231 +                new MethodType(List.of(left, right), res,
   1.232 +                               List.<Type>nil(), methodClass),
   1.233 +                opcode,
   1.234 +                predefClass));
   1.235 +    }
   1.236 +
   1.237 +    /** Enter a binary operation, as above but with two opcodes,
   1.238 +     *  which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
   1.239 +     *  @param opcode1     First opcode.
   1.240 +     *  @param opcode2     Second opcode.
   1.241 +     */
   1.242 +    private void enterBinop(String name,
   1.243 +                            Type left, Type right, Type res,
   1.244 +                            int opcode1, int opcode2) {
   1.245 +        enterBinop(
   1.246 +            name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
   1.247 +    }
   1.248 +
   1.249 +    /** Enter a unary operation into symbol table.
   1.250 +     *  @param name     The name of the operator.
   1.251 +     *  @param arg      The type of the operand.
   1.252 +     *  @param res      The operation's result type.
   1.253 +     *  @param opcode   The operation's bytecode instruction.
   1.254 +     */
   1.255 +    private OperatorSymbol enterUnop(String name,
   1.256 +                                     Type arg,
   1.257 +                                     Type res,
   1.258 +                                     int opcode) {
   1.259 +        OperatorSymbol sym =
   1.260 +            new OperatorSymbol(names.fromString(name),
   1.261 +                               new MethodType(List.of(arg),
   1.262 +                                              res,
   1.263 +                                              List.<Type>nil(),
   1.264 +                                              methodClass),
   1.265 +                               opcode,
   1.266 +                               predefClass);
   1.267 +        predefClass.members().enter(sym);
   1.268 +        return sym;
   1.269 +    }
   1.270 +
   1.271 +    /** Enter a class into symbol table.
   1.272 +     *  @param    The name of the class.
   1.273 +     */
   1.274 +    private Type enterClass(String s) {
   1.275 +        return reader.enterClass(names.fromString(s)).type;
   1.276 +    }
   1.277 +
   1.278 +    /** Constructor; enters all predefined identifiers and operators
   1.279 +     *  into symbol table.
   1.280 +     */
   1.281 +    protected Symtab(Context context) throws CompletionFailure {
   1.282 +        context.put(symtabKey, this);
   1.283 +
   1.284 +        names = Name.Table.instance(context);
   1.285 +
   1.286 +        // Create the unknown type
   1.287 +        unknownType = new Type(TypeTags.UNKNOWN, null);
   1.288 +
   1.289 +        // create the basic builtin symbols
   1.290 +        rootPackage = new PackageSymbol(names.empty, null);
   1.291 +        final Messages messages = Messages.instance(context);
   1.292 +        unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
   1.293 +                public String toString() {
   1.294 +                    return messages.getLocalizedString("compiler.misc.unnamed.package");
   1.295 +                }
   1.296 +            };
   1.297 +        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
   1.298 +        noSymbol.kind = Kinds.NIL;
   1.299 +
   1.300 +        // create the error symbols
   1.301 +        errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
   1.302 +        errType = new ErrorType(errSymbol);
   1.303 +
   1.304 +        // initialize builtin types
   1.305 +        initType(byteType, "byte", "Byte");
   1.306 +        initType(shortType, "short", "Short");
   1.307 +        initType(charType, "char", "Character");
   1.308 +        initType(intType, "int", "Integer");
   1.309 +        initType(longType, "long", "Long");
   1.310 +        initType(floatType, "float", "Float");
   1.311 +        initType(doubleType, "double", "Double");
   1.312 +        initType(booleanType, "boolean", "Boolean");
   1.313 +        initType(voidType, "void", "Void");
   1.314 +        initType(botType, "<nulltype>");
   1.315 +        initType(errType, errSymbol);
   1.316 +        initType(unknownType, "<any?>");
   1.317 +
   1.318 +        // the builtin class of all arrays
   1.319 +        arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
   1.320 +
   1.321 +        // VGJ
   1.322 +        boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
   1.323 +
   1.324 +        // the builtin class of all methods
   1.325 +        methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
   1.326 +
   1.327 +        // Create class to hold all predefined constants and operations.
   1.328 +        predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
   1.329 +        Scope scope = new Scope(predefClass);
   1.330 +        predefClass.members_field = scope;
   1.331 +
   1.332 +        // Enter symbols for basic types.
   1.333 +        scope.enter(byteType.tsym);
   1.334 +        scope.enter(shortType.tsym);
   1.335 +        scope.enter(charType.tsym);
   1.336 +        scope.enter(intType.tsym);
   1.337 +        scope.enter(longType.tsym);
   1.338 +        scope.enter(floatType.tsym);
   1.339 +        scope.enter(doubleType.tsym);
   1.340 +        scope.enter(booleanType.tsym);
   1.341 +        scope.enter(errType.tsym);
   1.342 +
   1.343 +        classes.put(predefClass.fullname, predefClass);
   1.344 +
   1.345 +        reader = ClassReader.instance(context);
   1.346 +        reader.init(this);
   1.347 +
   1.348 +        // Enter predefined classes.
   1.349 +        objectType = enterClass("java.lang.Object");
   1.350 +        classType = enterClass("java.lang.Class");
   1.351 +        stringType = enterClass("java.lang.String");
   1.352 +        stringBufferType = enterClass("java.lang.StringBuffer");
   1.353 +        stringBuilderType = enterClass("java.lang.StringBuilder");
   1.354 +        cloneableType = enterClass("java.lang.Cloneable");
   1.355 +        throwableType = enterClass("java.lang.Throwable");
   1.356 +        serializableType = enterClass("java.io.Serializable");
   1.357 +        errorType = enterClass("java.lang.Error");
   1.358 +        illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
   1.359 +        exceptionType = enterClass("java.lang.Exception");
   1.360 +        runtimeExceptionType = enterClass("java.lang.RuntimeException");
   1.361 +        classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
   1.362 +        noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
   1.363 +        noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
   1.364 +        assertionErrorType = enterClass("java.lang.AssertionError");
   1.365 +        cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
   1.366 +        annotationType = enterClass("java.lang.annotation.Annotation");
   1.367 +        classLoaderType = enterClass("java.lang.ClassLoader");
   1.368 +        enumSym = reader.enterClass(names.java_lang_Enum);
   1.369 +        enumFinalFinalize =
   1.370 +            new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
   1.371 +                             names.finalize,
   1.372 +                             new MethodType(List.<Type>nil(), voidType,
   1.373 +                                            List.<Type>nil(), methodClass),
   1.374 +                             enumSym);
   1.375 +        listType = enterClass("java.util.List");
   1.376 +        collectionsType = enterClass("java.util.Collections");
   1.377 +        comparableType = enterClass("java.lang.Comparable");
   1.378 +        arraysType = enterClass("java.util.Arrays");
   1.379 +        iterableType = Target.instance(context).hasIterable()
   1.380 +            ? enterClass("java.lang.Iterable")
   1.381 +            : enterClass("java.util.Collection");
   1.382 +        iteratorType = enterClass("java.util.Iterator");
   1.383 +        annotationTargetType = enterClass("java.lang.annotation.Target");
   1.384 +        overrideType = enterClass("java.lang.Override");
   1.385 +        retentionType = enterClass("java.lang.annotation.Retention");
   1.386 +        deprecatedType = enterClass("java.lang.Deprecated");
   1.387 +        suppressWarningsType = enterClass("java.lang.SuppressWarnings");
   1.388 +        inheritedType = enterClass("java.lang.annotation.Inherited");
   1.389 +
   1.390 +        // Enter a synthetic class that is used to mark Sun
   1.391 +        // proprietary classes in ct.sym.  This class does not have a
   1.392 +        // class file.
   1.393 +        ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
   1.394 +        this.proprietaryType = proprietaryType;
   1.395 +        ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
   1.396 +        proprietarySymbol.completer = null;
   1.397 +        proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
   1.398 +        proprietarySymbol.erasure_field = proprietaryType;
   1.399 +        proprietarySymbol.members_field = new Scope(proprietarySymbol);
   1.400 +        proprietaryType.typarams_field = List.nil();
   1.401 +        proprietaryType.allparams_field = List.nil();
   1.402 +        proprietaryType.supertype_field = annotationType;
   1.403 +        proprietaryType.interfaces_field = List.nil();
   1.404 +
   1.405 +        // Enter a class for arrays.
   1.406 +        // The class implements java.lang.Cloneable and java.io.Serializable.
   1.407 +        // It has a final length field and a clone method.
   1.408 +        ClassType arrayClassType = (ClassType)arrayClass.type;
   1.409 +        arrayClassType.supertype_field = objectType;
   1.410 +        arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
   1.411 +        arrayClass.members_field = new Scope(arrayClass);
   1.412 +        lengthVar = new VarSymbol(
   1.413 +            PUBLIC | FINAL,
   1.414 +            names.length,
   1.415 +            intType,
   1.416 +            arrayClass);
   1.417 +        arrayClass.members().enter(lengthVar);
   1.418 +        arrayCloneMethod = new MethodSymbol(
   1.419 +            PUBLIC,
   1.420 +            names.clone,
   1.421 +            new MethodType(List.<Type>nil(), objectType,
   1.422 +                           List.<Type>nil(), methodClass),
   1.423 +            arrayClass);
   1.424 +        arrayClass.members().enter(arrayCloneMethod);
   1.425 +
   1.426 +        // Enter operators.
   1.427 +        enterUnop("+", doubleType, doubleType, nop);
   1.428 +        enterUnop("+", floatType, floatType, nop);
   1.429 +        enterUnop("+", longType, longType, nop);
   1.430 +        enterUnop("+", intType, intType, nop);
   1.431 +
   1.432 +        enterUnop("-", doubleType, doubleType, dneg);
   1.433 +        enterUnop("-", floatType, floatType, fneg);
   1.434 +        enterUnop("-", longType, longType, lneg);
   1.435 +        enterUnop("-", intType, intType, ineg);
   1.436 +
   1.437 +        enterUnop("~", longType, longType, lxor);
   1.438 +        enterUnop("~", intType, intType, ixor);
   1.439 +
   1.440 +        enterUnop("++", doubleType, doubleType, dadd);
   1.441 +        enterUnop("++", floatType, floatType, fadd);
   1.442 +        enterUnop("++", longType, longType, ladd);
   1.443 +        enterUnop("++", intType, intType, iadd);
   1.444 +        enterUnop("++", charType, charType, iadd);
   1.445 +        enterUnop("++", shortType, shortType, iadd);
   1.446 +        enterUnop("++", byteType, byteType, iadd);
   1.447 +
   1.448 +        enterUnop("--", doubleType, doubleType, dsub);
   1.449 +        enterUnop("--", floatType, floatType, fsub);
   1.450 +        enterUnop("--", longType, longType, lsub);
   1.451 +        enterUnop("--", intType, intType, isub);
   1.452 +        enterUnop("--", charType, charType, isub);
   1.453 +        enterUnop("--", shortType, shortType, isub);
   1.454 +        enterUnop("--", byteType, byteType, isub);
   1.455 +
   1.456 +        enterUnop("!", booleanType, booleanType, bool_not);
   1.457 +        nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
   1.458 +
   1.459 +        // string concatenation
   1.460 +        enterBinop("+", stringType, objectType, stringType, string_add);
   1.461 +        enterBinop("+", objectType, stringType, stringType, string_add);
   1.462 +        enterBinop("+", stringType, stringType, stringType, string_add);
   1.463 +        enterBinop("+", stringType, intType, stringType, string_add);
   1.464 +        enterBinop("+", stringType, longType, stringType, string_add);
   1.465 +        enterBinop("+", stringType, floatType, stringType, string_add);
   1.466 +        enterBinop("+", stringType, doubleType, stringType, string_add);
   1.467 +        enterBinop("+", stringType, booleanType, stringType, string_add);
   1.468 +        enterBinop("+", stringType, botType, stringType, string_add);
   1.469 +        enterBinop("+", intType, stringType, stringType, string_add);
   1.470 +        enterBinop("+", longType, stringType, stringType, string_add);
   1.471 +        enterBinop("+", floatType, stringType, stringType, string_add);
   1.472 +        enterBinop("+", doubleType, stringType, stringType, string_add);
   1.473 +        enterBinop("+", booleanType, stringType, stringType, string_add);
   1.474 +        enterBinop("+", botType, stringType, stringType, string_add);
   1.475 +
   1.476 +        // these errors would otherwise be matched as string concatenation
   1.477 +        enterBinop("+", botType, botType, botType, error);
   1.478 +        enterBinop("+", botType, intType, botType, error);
   1.479 +        enterBinop("+", botType, longType, botType, error);
   1.480 +        enterBinop("+", botType, floatType, botType, error);
   1.481 +        enterBinop("+", botType, doubleType, botType, error);
   1.482 +        enterBinop("+", botType, booleanType, botType, error);
   1.483 +        enterBinop("+", botType, objectType, botType, error);
   1.484 +        enterBinop("+", intType, botType, botType, error);
   1.485 +        enterBinop("+", longType, botType, botType, error);
   1.486 +        enterBinop("+", floatType, botType, botType, error);
   1.487 +        enterBinop("+", doubleType, botType, botType, error);
   1.488 +        enterBinop("+", booleanType, botType, botType, error);
   1.489 +        enterBinop("+", objectType, botType, botType, error);
   1.490 +
   1.491 +        enterBinop("+", doubleType, doubleType, doubleType, dadd);
   1.492 +        enterBinop("+", floatType, floatType, floatType, fadd);
   1.493 +        enterBinop("+", longType, longType, longType, ladd);
   1.494 +        enterBinop("+", intType, intType, intType, iadd);
   1.495 +
   1.496 +        enterBinop("-", doubleType, doubleType, doubleType, dsub);
   1.497 +        enterBinop("-", floatType, floatType, floatType, fsub);
   1.498 +        enterBinop("-", longType, longType, longType, lsub);
   1.499 +        enterBinop("-", intType, intType, intType, isub);
   1.500 +
   1.501 +        enterBinop("*", doubleType, doubleType, doubleType, dmul);
   1.502 +        enterBinop("*", floatType, floatType, floatType, fmul);
   1.503 +        enterBinop("*", longType, longType, longType, lmul);
   1.504 +        enterBinop("*", intType, intType, intType, imul);
   1.505 +
   1.506 +        enterBinop("/", doubleType, doubleType, doubleType, ddiv);
   1.507 +        enterBinop("/", floatType, floatType, floatType, fdiv);
   1.508 +        enterBinop("/", longType, longType, longType, ldiv);
   1.509 +        enterBinop("/", intType, intType, intType, idiv);
   1.510 +
   1.511 +        enterBinop("%", doubleType, doubleType, doubleType, dmod);
   1.512 +        enterBinop("%", floatType, floatType, floatType, fmod);
   1.513 +        enterBinop("%", longType, longType, longType, lmod);
   1.514 +        enterBinop("%", intType, intType, intType, imod);
   1.515 +
   1.516 +        enterBinop("&", booleanType, booleanType, booleanType, iand);
   1.517 +        enterBinop("&", longType, longType, longType, land);
   1.518 +        enterBinop("&", intType, intType, intType, iand);
   1.519 +
   1.520 +        enterBinop("|", booleanType, booleanType, booleanType, ior);
   1.521 +        enterBinop("|", longType, longType, longType, lor);
   1.522 +        enterBinop("|", intType, intType, intType, ior);
   1.523 +
   1.524 +        enterBinop("^", booleanType, booleanType, booleanType, ixor);
   1.525 +        enterBinop("^", longType, longType, longType, lxor);
   1.526 +        enterBinop("^", intType, intType, intType, ixor);
   1.527 +
   1.528 +        enterBinop("<<", longType, longType, longType, lshll);
   1.529 +        enterBinop("<<", intType, longType, intType, ishll);
   1.530 +        enterBinop("<<", longType, intType, longType, lshl);
   1.531 +        enterBinop("<<", intType, intType, intType, ishl);
   1.532 +
   1.533 +        enterBinop(">>", longType, longType, longType, lshrl);
   1.534 +        enterBinop(">>", intType, longType, intType, ishrl);
   1.535 +        enterBinop(">>", longType, intType, longType, lshr);
   1.536 +        enterBinop(">>", intType, intType, intType, ishr);
   1.537 +
   1.538 +        enterBinop(">>>", longType, longType, longType, lushrl);
   1.539 +        enterBinop(">>>", intType, longType, intType, iushrl);
   1.540 +        enterBinop(">>>", longType, intType, longType, lushr);
   1.541 +        enterBinop(">>>", intType, intType, intType, iushr);
   1.542 +
   1.543 +        enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
   1.544 +        enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
   1.545 +        enterBinop("<", longType, longType, booleanType, lcmp, iflt);
   1.546 +        enterBinop("<", intType, intType, booleanType, if_icmplt);
   1.547 +
   1.548 +        enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
   1.549 +        enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
   1.550 +        enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
   1.551 +        enterBinop(">", intType, intType, booleanType, if_icmpgt);
   1.552 +
   1.553 +        enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
   1.554 +        enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
   1.555 +        enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
   1.556 +        enterBinop("<=", intType, intType, booleanType, if_icmple);
   1.557 +
   1.558 +        enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
   1.559 +        enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
   1.560 +        enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
   1.561 +        enterBinop(">=", intType, intType, booleanType, if_icmpge);
   1.562 +
   1.563 +        enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
   1.564 +        enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
   1.565 +        enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
   1.566 +        enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
   1.567 +        enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
   1.568 +        enterBinop("==", intType, intType, booleanType, if_icmpeq);
   1.569 +
   1.570 +        enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
   1.571 +        enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
   1.572 +        enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
   1.573 +        enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
   1.574 +        enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
   1.575 +        enterBinop("!=", intType, intType, booleanType, if_icmpne);
   1.576 +
   1.577 +        enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
   1.578 +        enterBinop("||", booleanType, booleanType, booleanType, bool_or);
   1.579 +    }
   1.580 +}

mercurial