001    /*
002     * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
003     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004     *
005     * This code is free software; you can redistribute it and/or modify it
006     * under the terms of the GNU General Public License version 2 only, as
007     * published by the Free Software Foundation.  Sun designates this
008     * particular file as subject to the "Classpath" exception as provided
009     * by Sun in the LICENSE file that accompanied this code.
010     *
011     * This code is distributed in the hope that it will be useful, but WITHOUT
012     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014     * version 2 for more details (a copy is included in the LICENSE file that
015     * accompanied this code).
016     *
017     * You should have received a copy of the GNU General Public License version
018     * 2 along with this work; if not, write to the Free Software Foundation,
019     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020     *
021     * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022     * CA 95054 USA or visit www.sun.com if you need additional information or
023     * have any questions.
024     */
025    
026    package com.sun.tools.javac.code;
027    
028    import java.util.*;
029    
030    import com.sun.tools.javac.util.*;
031    import com.sun.tools.javac.util.List;
032    import com.sun.tools.javac.code.Symbol.*;
033    import com.sun.tools.javac.code.Type.*;
034    import com.sun.tools.javac.jvm.*;
035    
036    import static com.sun.tools.javac.jvm.ByteCodes.*;
037    import static com.sun.tools.javac.code.Flags.*;
038    
039    /** A class that defines all predefined constants and operators
040     *  as well as special classes such as java.lang.Object, which need
041     *  to be known to the compiler. All symbols are held in instance
042     *  fields. This makes it possible to work in multiple concurrent
043     *  projects, which might use different class files for library classes.
044     *
045     *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
046     *  you write code that depends on this, you do so at your own risk.
047     *  This code and its internal interfaces are subject to change or
048     *  deletion without notice.</b>
049     */
050    public class Symtab {
051        /** The context key for the symbol table. */
052        protected static final Context.Key<Symtab> symtabKey =
053            new Context.Key<Symtab>();
054    
055        /** Get the symbol table instance. */
056        public static Symtab instance(Context context) {
057            Symtab instance = context.get(symtabKey);
058            if (instance == null)
059                instance = new Symtab(context);
060            return instance;
061        }
062    
063        /** Builtin types.
064         */
065        public final Type byteType = new Type(TypeTags.BYTE, null);
066        public final Type charType = new Type(TypeTags.CHAR, null);
067        public final Type shortType = new Type(TypeTags.SHORT, null);
068        public final Type intType = new Type(TypeTags.INT, null);
069        public final Type longType = new Type(TypeTags.LONG, null);
070        public final Type floatType = new Type(TypeTags.FLOAT, null);
071        public final Type doubleType = new Type(TypeTags.DOUBLE, null);
072        public final Type booleanType = new Type(TypeTags.BOOLEAN, null);
073        public final Type botType = new BottomType();
074        public final JCNoType voidType = new JCNoType(TypeTags.VOID);
075    
076        private final Names names;
077        private final ClassReader reader;
078        private final Target target;
079    
080        /** A symbol for the root package.
081         */
082        public final PackageSymbol rootPackage;
083    
084        /** A symbol for the unnamed package.
085         */
086        public final PackageSymbol unnamedPackage;
087    
088        /** A symbol that stands for a missing symbol.
089         */
090        public final TypeSymbol noSymbol;
091    
092        /** The error symbol.
093         */
094        public final ClassSymbol errSymbol;
095    
096        /** A value for the errType, with a originalType of noType */
097        public final Type errType;
098    
099        /** A value for the unknown type. */
100        public final Type unknownType;
101    
102        /** The builtin type of all arrays. */
103        public final ClassSymbol arrayClass;
104        public final MethodSymbol arrayCloneMethod;
105    
106        /** VGJ: The (singleton) type of all bound types. */
107        public final ClassSymbol boundClass;
108    
109        /** The builtin type of all methods. */
110        public final ClassSymbol methodClass;
111    
112        /** Predefined types.
113         */
114        public final Type objectType;
115        public final Type classType;
116        public final Type classLoaderType;
117        public final Type stringType;
118        public final Type stringBufferType;
119        public final Type stringBuilderType;
120        public final Type cloneableType;
121        public final Type serializableType;
122        public final Type throwableType;
123        public final Type errorType;
124        public final Type illegalArgumentExceptionType;
125        public final Type exceptionType;
126        public final Type runtimeExceptionType;
127        public final Type classNotFoundExceptionType;
128        public final Type noClassDefFoundErrorType;
129        public final Type noSuchFieldErrorType;
130        public final Type assertionErrorType;
131        public final Type cloneNotSupportedExceptionType;
132        public final Type annotationType;
133        public final TypeSymbol enumSym;
134        public final Type listType;
135        public final Type collectionsType;
136        public final Type comparableType;
137        public final Type arraysType;
138        public final Type iterableType;
139        public final Type iteratorType;
140        public final Type annotationTargetType;
141        public final Type overrideType;
142        public final Type retentionType;
143        public final Type deprecatedType;
144        public final Type suppressWarningsType;
145        public final Type inheritedType;
146        public final Type proprietaryType;
147        public final Type systemType;
148    
149        // mgr: staging additions
150        public final Type stringCodeType;
151        public final Type mspTreeCodeType;
152        public final Type safeMspTreeCodeType;
153        public final Type mspTreeType;
154        public final Type stringMspTreeType;
155        public final Type internalMspTreeType;
156        public final Type cspMspTreeType;
157        public final Type codeType;
158        public final Type safeCodeType;
159        public final Type javaLangVoidType;
160        
161        /** The symbol representing the length field of an array.
162         */
163        public final VarSymbol lengthVar;
164    
165        /** The null check operator. */
166        public final OperatorSymbol nullcheck;
167    
168        /** The symbol representing the final finalize method on enums */
169        public final MethodSymbol enumFinalFinalize;
170    
171        /** The predefined type that belongs to a tag.
172         */
173        public final Type[] typeOfTag = new Type[TypeTags.TypeTagCount];
174    
175        /** The name of the class that belongs to a basix type tag.
176         */
177        public final Name[] boxedName = new Name[TypeTags.TypeTagCount];
178    
179        /** A hashtable containing the encountered top-level and member classes,
180         *  indexed by flat names. The table does not contain local classes.
181         *  It should be updated from the outside to reflect classes defined
182         *  by compiled source files.
183         */
184        public final Map<Name, ClassSymbol> classes = new HashMap<Name, ClassSymbol>();
185    
186        /** A hashtable containing the encountered packages.
187         *  the table should be updated from outside to reflect packages defined
188         *  by compiled source files.
189         */
190        public final Map<Name, PackageSymbol> packages = new HashMap<Name, PackageSymbol>();
191    
192        public void initType(Type type, ClassSymbol c) {
193            type.tsym = c;
194            typeOfTag[type.tag] = type;
195        }
196    
197        public void initType(Type type, String name) {
198            initType(
199                type,
200                new ClassSymbol(
201                    PUBLIC, names.fromString(name), type, rootPackage));
202        }
203    
204        public void initType(Type type, String name, String bname) {
205            initType(type, name);
206            boxedName[type.tag] = names.fromString("java.lang." + bname);
207        }
208    
209        /** The class symbol that owns all predefined symbols.
210         */
211        public final ClassSymbol predefClass;
212    
213        /** Enter a constant into symbol table.
214         *  @param name   The constant's name.
215         *  @param type   The constant's type.
216         */
217        private VarSymbol enterConstant(String name, Type type) {
218            VarSymbol c = new VarSymbol(
219                PUBLIC | STATIC | FINAL,
220                names.fromString(name),
221                type,
222                predefClass);
223            c.setData(type.constValue());
224            predefClass.members().enter(c);
225            return c;
226        }
227    
228        /** Enter a binary operation into symbol table.
229         *  @param name     The name of the operator.
230         *  @param left     The type of the left operand.
231         *  @param right    The type of the left operand.
232         *  @param res      The operation's result type.
233         *  @param opcode   The operation's bytecode instruction.
234         */
235        private void enterBinop(String name,
236                                Type left, Type right, Type res,
237                                int opcode) {
238            predefClass.members().enter(
239                new OperatorSymbol(
240                    names.fromString(name),
241                    new MethodType(List.of(left, right), res,
242                                   List.<Type>nil(), methodClass),
243                    opcode,
244                    predefClass));
245        }
246    
247        /** Enter a binary operation, as above but with two opcodes,
248         *  which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
249         *  @param opcode1     First opcode.
250         *  @param opcode2     Second opcode.
251         */
252        private void enterBinop(String name,
253                                Type left, Type right, Type res,
254                                int opcode1, int opcode2) {
255            enterBinop(
256                name, left, right, res, (opcode1 << ByteCodes.preShift) | opcode2);
257        }
258    
259        /** Enter a unary operation into symbol table.
260         *  @param name     The name of the operator.
261         *  @param arg      The type of the operand.
262         *  @param res      The operation's result type.
263         *  @param opcode   The operation's bytecode instruction.
264         */
265        private OperatorSymbol enterUnop(String name,
266                                         Type arg,
267                                         Type res,
268                                         int opcode) {
269            OperatorSymbol sym =
270                new OperatorSymbol(names.fromString(name),
271                                   new MethodType(List.of(arg),
272                                                  res,
273                                                  List.<Type>nil(),
274                                                  methodClass),
275                                   opcode,
276                                   predefClass);
277            predefClass.members().enter(sym);
278            return sym;
279        }
280    
281        /** Enter a class into symbol table.
282         *  @param    The name of the class.
283         */
284        private Type enterClass(String s) {
285            return reader.enterClass(names.fromString(s)).type;
286        }
287    
288        public void synthesizeEmptyInterfaceIfMissing(final Type type) {
289            final Completer completer = type.tsym.completer;
290            if (completer != null) {
291                type.tsym.completer = new Completer() {
292                    public void complete(Symbol sym) throws CompletionFailure {
293                        try {
294                            completer.complete(sym);
295                        } catch (CompletionFailure e) {
296                            sym.flags_field |= (PUBLIC | INTERFACE);
297                            ((ClassType) sym.type).supertype_field = objectType;
298                        }
299                    }
300                };
301            }
302        }
303    
304        public void synthesizeBoxTypeIfMissing(final Type type) {
305            ClassSymbol sym = reader.enterClass(boxedName[type.tag]);
306            final Completer completer = sym.completer;
307            if (completer != null) {
308                sym.completer = new Completer() {
309                    public void complete(Symbol sym) throws CompletionFailure {
310                        try {
311                            completer.complete(sym);
312                        } catch (CompletionFailure e) {
313                            sym.flags_field |= PUBLIC;
314                            ((ClassType) sym.type).supertype_field = objectType;
315                            Name n = target.boxWithConstructors() ? names.init : names.valueOf;
316                            MethodSymbol boxMethod =
317                                new MethodSymbol(PUBLIC | STATIC,
318                                    n,
319                                    new MethodType(List.of(type), sym.type,
320                                        List.<Type>nil(), methodClass),
321                                    sym);
322                            sym.members().enter(boxMethod);
323                            MethodSymbol unboxMethod =
324                                new MethodSymbol(PUBLIC,
325                                    type.tsym.name.append(names.Value), // x.intValue()
326                                    new MethodType(List.<Type>nil(), type,
327                                        List.<Type>nil(), methodClass),
328                                    sym);
329                            sym.members().enter(unboxMethod);
330                        }
331                    }
332                };
333            }
334    
335        }
336    
337        /** Constructor; enters all predefined identifiers and operators
338         *  into symbol table.
339         */
340        protected Symtab(Context context) throws CompletionFailure {
341            context.put(symtabKey, this);
342    
343            names = Names.instance(context);
344            target = Target.instance(context);
345    
346            // Create the unknown type
347            unknownType = new Type(TypeTags.UNKNOWN, null);
348    
349            // create the basic builtin symbols
350            rootPackage = new PackageSymbol(names.empty, null);
351            final JavacMessages messages = JavacMessages.instance(context);
352            unnamedPackage = new PackageSymbol(names.empty, rootPackage) {
353                    public String toString() {
354                        return messages.getLocalizedString("compiler.misc.unnamed.package");
355                    }
356                };
357            noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
358            noSymbol.kind = Kinds.NIL;
359    
360            // mgr: Moved predefClass up here so we can enter errSymbol into scope before errSymbol is used
361            // Create class to hold all predefined constants and operations.
362            predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
363            predefClass.addParentLevel(new Level(0)); // mgr: predefClass is never entered into a scope
364            Scope scope = new Scope(predefClass);
365            predefClass.members_field = scope;
366    
367            // create the error symbols
368            errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
369            // Enter symbol for the errSymbol
370            scope.enter(errSymbol);
371            errType = new ErrorType(errSymbol, Type.noType);
372    
373            // initialize builtin types
374            initType(byteType, "byte", "Byte");
375            initType(shortType, "short", "Short");
376            initType(charType, "char", "Character");
377            initType(intType, "int", "Integer");
378            initType(longType, "long", "Long");
379            initType(floatType, "float", "Float");
380            initType(doubleType, "double", "Double");
381            initType(booleanType, "boolean", "Boolean");
382            initType(voidType, "void", "Void");
383            initType(botType, "<nulltype>");
384            initType(errType, errSymbol);
385            initType(unknownType, "<any?>");
386    
387            // the builtin class of all arrays
388            arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
389            arrayClass.addParentLevel(new Level(0)); // mgr: arrayClass is never entered into a scope
390    
391            // VGJ
392            boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
393            boundClass.addParentLevel(new Level(0)); // mgr: boundClass is never entered into a scope
394    
395            // the builtin class of all methods
396            methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
397            methodClass.addParentLevel(new Level(0)); // mgr: arrayClass is never entered into a scope
398    
399            // Enter symbols for basic types.
400            scope.enter(byteType.tsym);
401            scope.enter(shortType.tsym);
402            scope.enter(charType.tsym);
403            scope.enter(intType.tsym);
404            scope.enter(longType.tsym);
405            scope.enter(floatType.tsym);
406            scope.enter(doubleType.tsym);
407            scope.enter(booleanType.tsym);
408            voidType.tsym.addParentLevel(new Level(0));
409            botType.tsym.addParentLevel(new Level(0));
410            unknownType.tsym.addParentLevel(new Level(0));
411            // scope.enter(errType.tsym); // mgr: errType.tsym==errSymbol, which is entered above
412    
413            classes.put(predefClass.fullname, predefClass);
414    
415            reader = ClassReader.instance(context);
416            reader.init(this);
417    
418            // Enter predefined classes.
419            objectType = enterClass("java.lang.Object");
420            classType = enterClass("java.lang.Class");
421            stringType = enterClass("java.lang.String");
422            stringBufferType = enterClass("java.lang.StringBuffer");
423            stringBuilderType = enterClass("java.lang.StringBuilder");
424            cloneableType = enterClass("java.lang.Cloneable");
425            throwableType = enterClass("java.lang.Throwable");
426            serializableType = enterClass("java.io.Serializable");
427            errorType = enterClass("java.lang.Error");
428            illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
429            exceptionType = enterClass("java.lang.Exception");
430            runtimeExceptionType = enterClass("java.lang.RuntimeException");
431            classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException");
432            noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError");
433            noSuchFieldErrorType = enterClass("java.lang.NoSuchFieldError");
434            assertionErrorType = enterClass("java.lang.AssertionError");
435            cloneNotSupportedExceptionType = enterClass("java.lang.CloneNotSupportedException");
436            annotationType = enterClass("java.lang.annotation.Annotation");
437            classLoaderType = enterClass("java.lang.ClassLoader");
438            enumSym = reader.enterClass(names.java_lang_Enum);
439            enumFinalFinalize =
440                new MethodSymbol(PROTECTED|FINAL|HYPOTHETICAL,
441                                 names.finalize,
442                                 new MethodType(List.<Type>nil(), voidType,
443                                                List.<Type>nil(), methodClass),
444                                 enumSym);
445            listType = enterClass("java.util.List");
446            collectionsType = enterClass("java.util.Collections");
447            comparableType = enterClass("java.lang.Comparable");
448            arraysType = enterClass("java.util.Arrays");
449            iterableType = target.hasIterable()
450                ? enterClass("java.lang.Iterable")
451                : enterClass("java.util.Collection");
452            iteratorType = enterClass("java.util.Iterator");
453            annotationTargetType = enterClass("java.lang.annotation.Target");
454            overrideType = enterClass("java.lang.Override");
455            retentionType = enterClass("java.lang.annotation.Retention");
456            deprecatedType = enterClass("java.lang.Deprecated");
457            suppressWarningsType = enterClass("java.lang.SuppressWarnings");
458            inheritedType = enterClass("java.lang.annotation.Inherited");
459            systemType = enterClass("java.lang.System");
460            
461            // mgr: staging additions
462            stringCodeType = enterClass("edu.rice.cs.mint.runtime.StringCode");
463            mspTreeCodeType = enterClass("edu.rice.cs.mint.runtime.MSPTreeCode");
464            safeMspTreeCodeType = enterClass("edu.rice.cs.mint.runtime.SafeMSPTreeCode");
465            mspTreeType = enterClass("edu.rice.cs.mint.runtime.mspTree.MSPTree");
466            stringMspTreeType = enterClass("edu.rice.cs.mint.runtime.mspTree.StringMSPTree");
467            internalMspTreeType = enterClass("edu.rice.cs.mint.runtime.mspTree.InternalMSPTree");
468            cspMspTreeType = enterClass("edu.rice.cs.mint.runtime.mspTree.CspMSPTree");
469            codeType = enterClass("edu.rice.cs.mint.runtime.Code");
470            safeCodeType = enterClass("edu.rice.cs.mint.runtime.SafeCode");
471            javaLangVoidType = enterClass("java.lang.Void");
472    
473            synthesizeEmptyInterfaceIfMissing(cloneableType);
474            synthesizeEmptyInterfaceIfMissing(serializableType);
475            synthesizeBoxTypeIfMissing(doubleType);
476            synthesizeBoxTypeIfMissing(floatType);
477    
478            // Enter a synthetic class that is used to mark Sun
479            // proprietary classes in ct.sym.  This class does not have a
480            // class file.
481            ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
482            this.proprietaryType = proprietaryType;
483            ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
484            proprietarySymbol.addParentLevel(new Level(0)); // mgr: proprietarySymbol is never entered into a scope
485            proprietarySymbol.completer = null;
486            proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
487            proprietarySymbol.erasure_field = proprietaryType;
488            proprietarySymbol.members_field = new Scope(proprietarySymbol);
489            proprietaryType.typarams_field = List.nil();
490            proprietaryType.allparams_field = List.nil();
491            proprietaryType.supertype_field = annotationType;
492            proprietaryType.interfaces_field = List.nil();
493    
494            // Enter a class for arrays.
495            // The class implements java.lang.Cloneable and java.io.Serializable.
496            // It has a final length field and a clone method.
497            ClassType arrayClassType = (ClassType)arrayClass.type;
498            arrayClassType.supertype_field = objectType;
499            arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
500            arrayClass.members_field = new Scope(arrayClass);
501            lengthVar = new VarSymbol(
502                PUBLIC | FINAL,
503                names.length,
504                intType,
505                arrayClass);
506            arrayClass.members().enter(lengthVar);
507            arrayCloneMethod = new MethodSymbol(
508                PUBLIC,
509                names.clone,
510                new MethodType(List.<Type>nil(), objectType,
511                               List.<Type>nil(), methodClass),
512                arrayClass);
513            arrayClass.members().enter(arrayCloneMethod);
514    
515            // Enter operators.
516            enterUnop("+", doubleType, doubleType, nop);
517            enterUnop("+", floatType, floatType, nop);
518            enterUnop("+", longType, longType, nop);
519            enterUnop("+", intType, intType, nop);
520    
521            enterUnop("-", doubleType, doubleType, dneg);
522            enterUnop("-", floatType, floatType, fneg);
523            enterUnop("-", longType, longType, lneg);
524            enterUnop("-", intType, intType, ineg);
525    
526            enterUnop("~", longType, longType, lxor);
527            enterUnop("~", intType, intType, ixor);
528    
529            enterUnop("++", doubleType, doubleType, dadd);
530            enterUnop("++", floatType, floatType, fadd);
531            enterUnop("++", longType, longType, ladd);
532            enterUnop("++", intType, intType, iadd);
533            enterUnop("++", charType, charType, iadd);
534            enterUnop("++", shortType, shortType, iadd);
535            enterUnop("++", byteType, byteType, iadd);
536    
537            enterUnop("--", doubleType, doubleType, dsub);
538            enterUnop("--", floatType, floatType, fsub);
539            enterUnop("--", longType, longType, lsub);
540            enterUnop("--", intType, intType, isub);
541            enterUnop("--", charType, charType, isub);
542            enterUnop("--", shortType, shortType, isub);
543            enterUnop("--", byteType, byteType, isub);
544    
545            enterUnop("!", booleanType, booleanType, bool_not);
546            nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk);
547    
548            // string concatenation
549            enterBinop("+", stringType, objectType, stringType, string_add);
550            enterBinop("+", objectType, stringType, stringType, string_add);
551            enterBinop("+", stringType, stringType, stringType, string_add);
552            enterBinop("+", stringType, intType, stringType, string_add);
553            enterBinop("+", stringType, longType, stringType, string_add);
554            enterBinop("+", stringType, floatType, stringType, string_add);
555            enterBinop("+", stringType, doubleType, stringType, string_add);
556            enterBinop("+", stringType, booleanType, stringType, string_add);
557            enterBinop("+", stringType, botType, stringType, string_add);
558            enterBinop("+", intType, stringType, stringType, string_add);
559            enterBinop("+", longType, stringType, stringType, string_add);
560            enterBinop("+", floatType, stringType, stringType, string_add);
561            enterBinop("+", doubleType, stringType, stringType, string_add);
562            enterBinop("+", booleanType, stringType, stringType, string_add);
563            enterBinop("+", botType, stringType, stringType, string_add);
564    
565            // these errors would otherwise be matched as string concatenation
566            enterBinop("+", botType, botType, botType, error);
567            enterBinop("+", botType, intType, botType, error);
568            enterBinop("+", botType, longType, botType, error);
569            enterBinop("+", botType, floatType, botType, error);
570            enterBinop("+", botType, doubleType, botType, error);
571            enterBinop("+", botType, booleanType, botType, error);
572            enterBinop("+", botType, objectType, botType, error);
573            enterBinop("+", intType, botType, botType, error);
574            enterBinop("+", longType, botType, botType, error);
575            enterBinop("+", floatType, botType, botType, error);
576            enterBinop("+", doubleType, botType, botType, error);
577            enterBinop("+", booleanType, botType, botType, error);
578            enterBinop("+", objectType, botType, botType, error);
579    
580            enterBinop("+", doubleType, doubleType, doubleType, dadd);
581            enterBinop("+", floatType, floatType, floatType, fadd);
582            enterBinop("+", longType, longType, longType, ladd);
583            enterBinop("+", intType, intType, intType, iadd);
584    
585            enterBinop("-", doubleType, doubleType, doubleType, dsub);
586            enterBinop("-", floatType, floatType, floatType, fsub);
587            enterBinop("-", longType, longType, longType, lsub);
588            enterBinop("-", intType, intType, intType, isub);
589    
590            enterBinop("*", doubleType, doubleType, doubleType, dmul);
591            enterBinop("*", floatType, floatType, floatType, fmul);
592            enterBinop("*", longType, longType, longType, lmul);
593            enterBinop("*", intType, intType, intType, imul);
594    
595            enterBinop("/", doubleType, doubleType, doubleType, ddiv);
596            enterBinop("/", floatType, floatType, floatType, fdiv);
597            enterBinop("/", longType, longType, longType, ldiv);
598            enterBinop("/", intType, intType, intType, idiv);
599    
600            enterBinop("%", doubleType, doubleType, doubleType, dmod);
601            enterBinop("%", floatType, floatType, floatType, fmod);
602            enterBinop("%", longType, longType, longType, lmod);
603            enterBinop("%", intType, intType, intType, imod);
604    
605            enterBinop("&", booleanType, booleanType, booleanType, iand);
606            enterBinop("&", longType, longType, longType, land);
607            enterBinop("&", intType, intType, intType, iand);
608    
609            enterBinop("|", booleanType, booleanType, booleanType, ior);
610            enterBinop("|", longType, longType, longType, lor);
611            enterBinop("|", intType, intType, intType, ior);
612    
613            enterBinop("^", booleanType, booleanType, booleanType, ixor);
614            enterBinop("^", longType, longType, longType, lxor);
615            enterBinop("^", intType, intType, intType, ixor);
616    
617            enterBinop("<<", longType, longType, longType, lshll);
618            enterBinop("<<", intType, longType, intType, ishll);
619            enterBinop("<<", longType, intType, longType, lshl);
620            enterBinop("<<", intType, intType, intType, ishl);
621    
622            enterBinop(">>", longType, longType, longType, lshrl);
623            enterBinop(">>", intType, longType, intType, ishrl);
624            enterBinop(">>", longType, intType, longType, lshr);
625            enterBinop(">>", intType, intType, intType, ishr);
626    
627            enterBinop(">>>", longType, longType, longType, lushrl);
628            enterBinop(">>>", intType, longType, intType, iushrl);
629            enterBinop(">>>", longType, intType, longType, lushr);
630            enterBinop(">>>", intType, intType, intType, iushr);
631    
632            enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt);
633            enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt);
634            enterBinop("<", longType, longType, booleanType, lcmp, iflt);
635            enterBinop("<", intType, intType, booleanType, if_icmplt);
636    
637            enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt);
638            enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt);
639            enterBinop(">", longType, longType, booleanType, lcmp, ifgt);
640            enterBinop(">", intType, intType, booleanType, if_icmpgt);
641    
642            enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle);
643            enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle);
644            enterBinop("<=", longType, longType, booleanType, lcmp, ifle);
645            enterBinop("<=", intType, intType, booleanType, if_icmple);
646    
647            enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge);
648            enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge);
649            enterBinop(">=", longType, longType, booleanType, lcmp, ifge);
650            enterBinop(">=", intType, intType, booleanType, if_icmpge);
651    
652            enterBinop("==", objectType, objectType, booleanType, if_acmpeq);
653            enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq);
654            enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq);
655            enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq);
656            enterBinop("==", longType, longType, booleanType, lcmp, ifeq);
657            enterBinop("==", intType, intType, booleanType, if_icmpeq);
658    
659            enterBinop("!=", objectType, objectType, booleanType, if_acmpne);
660            enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne);
661            enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne);
662            enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne);
663            enterBinop("!=", longType, longType, booleanType, lcmp, ifne);
664            enterBinop("!=", intType, intType, booleanType, if_icmpne);
665    
666            enterBinop("&&", booleanType, booleanType, booleanType, bool_and);
667            enterBinop("||", booleanType, booleanType, booleanType, bool_or);
668        }
669    }