src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/IntType.java
author joehw
Wed, 18 Oct 2017 13:25:49 -0700
changeset 47359 e1a6c0168741
parent 47216 71c04702a3d5
child 48409 5ab69533994b
permissions -rw-r--r--
8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked Reviewed-by: lancea, rriggs, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
     3
 * @LastModified: Oct 2017
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
import com.sun.org.apache.bcel.internal.generic.BranchHandle;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.bcel.internal.generic.BranchInstruction;
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.bcel.internal.generic.GOTO;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import com.sun.org.apache.bcel.internal.generic.IFEQ;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.bcel.internal.generic.IFGE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import com.sun.org.apache.bcel.internal.generic.IFGT;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import com.sun.org.apache.bcel.internal.generic.IFLE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import com.sun.org.apache.bcel.internal.generic.IFLT;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import com.sun.org.apache.bcel.internal.generic.IF_ICMPGE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import com.sun.org.apache.bcel.internal.generic.IF_ICMPGT;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import com.sun.org.apache.bcel.internal.generic.IF_ICMPLE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
import com.sun.org.apache.bcel.internal.generic.IF_ICMPLT;
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
import com.sun.org.apache.bcel.internal.generic.ILOAD;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
import com.sun.org.apache.bcel.internal.generic.INVOKESTATIC;
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
import com.sun.org.apache.bcel.internal.generic.ISTORE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
import com.sun.org.apache.bcel.internal.generic.Instruction;
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    44
import com.sun.org.apache.bcel.internal.generic.InstructionConst;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
import com.sun.org.apache.bcel.internal.generic.InstructionList;
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
import com.sun.org.apache.bcel.internal.generic.NEW;
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
import com.sun.org.apache.xalan.internal.xsltc.compiler.FlowList;
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * @author Jacek Ambroziak
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * @author Santiago Pericas-Geertsen
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
public final class IntType extends NumberType {
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
    protected IntType() {}
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
    public String toString() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
        return "int";
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    public boolean identicalTo(Type other) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
        return this == other;
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
    public String toSignature() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
        return "I";
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    public com.sun.org.apache.bcel.internal.generic.Type toJCType() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
        return com.sun.org.apache.bcel.internal.generic.Type.INT;
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#distanceTo
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    public int distanceTo(Type type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
        if (type == this) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
            return 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
        else if (type == Type.Real) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
            return 1;
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
            return Integer.MAX_VALUE;
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
     * Translates an integer into an object of internal type <code>type</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
                            final Type type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
        if (type == Type.Real) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
            translateTo(classGen, methodGen, (RealType) type);
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
        else if (type == Type.String) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
            translateTo(classGen, methodGen, (StringType) type);
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
        else if (type == Type.Boolean) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
            translateTo(classGen, methodGen, (BooleanType) type);
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
        else if (type == Type.Reference) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
            translateTo(classGen, methodGen, (ReferenceType) type);
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
                                        toString(), type.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
            classGen.getParser().reportError(Constants.FATAL, err);
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     * Expects an integer on the stack and pushes a real.
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
                            RealType type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
        methodGen.getInstructionList().append(I2D);
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     * Expects an integer on the stack and pushes its string value by calling
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     * <code>Integer.toString(int i)</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
                            StringType type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
        final ConstantPoolGen cpg = classGen.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
        il.append(new INVOKESTATIC(cpg.addMethodref(INTEGER_CLASS,
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
                                                    "toString",
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
                                                    "(I)" + STRING_SIG)));
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
     * Expects an integer on the stack and pushes a 0 if its value is 0 and
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
     * a 1 otherwise.
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
                            BooleanType type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
        final BranchHandle falsec = il.append(new IFEQ(null));
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
        il.append(ICONST_1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
        final BranchHandle truec = il.append(new GOTO(null));
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
        falsec.setTarget(il.append(ICONST_0));
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
        truec.setTarget(il.append(NOP));
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     * Expects an integer on the stack and translates it to a non-synthesized
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
     * boolean. It does not push a 0 or a 1 but instead returns branchhandle
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     * list to be appended to the false list.
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateToDesynthesized
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
    public FlowList translateToDesynthesized(ClassGenerator classGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
                                             MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
                                             BooleanType type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
        return new FlowList(il.append(new IFEQ(null)));
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
     * Expects an integer on the stack and pushes a boxed integer.
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
     * Boxed integers are represented by an instance of
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
     * <code>java.lang.Integer</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
     * @see     com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type#translateTo
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
                            ReferenceType type) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
        final ConstantPoolGen cpg = classGen.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
        il.append(new NEW(cpg.addClass(INTEGER_CLASS)));
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
        il.append(DUP_X1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
        il.append(SWAP);
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
        il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS,
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
                                                     "<init>", "(I)V")));
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
     * Translates an integer into the Java type denoted by <code>clazz</code>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
     * Expects an integer on the stack and pushes a number of the appropriate
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
     * type after coercion.
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen,
47359
e1a6c0168741 8181150: Fix lint warnings in JAXP repo: rawtypes and unchecked
joehw
parents: 47216
diff changeset
   192
                            Class<?> clazz) {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
        if (clazz == Character.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
            il.append(I2C);
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
        else if (clazz == Byte.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
            il.append(I2B);
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
        else if (clazz == Short.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
            il.append(I2S);
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
        else if (clazz == Integer.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
            il.append(NOP);
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
        else if (clazz == Long.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
            il.append(I2L);
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
        else if (clazz == Float.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
            il.append(I2F);
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        else if (clazz == Double.TYPE) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
            il.append(I2D);
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
         // Is Double <: clazz? I.e. clazz in { Double, Number, Object }
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
       else if (clazz.isAssignableFrom(java.lang.Double.class)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
           il.append(I2D);
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
           Type.Real.translateTo(classGen, methodGen, Type.Reference);
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
            ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
                                        toString(), clazz.getName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
            classGen.getParser().reportError(Constants.FATAL, err);
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
     * Translates an object of this type to its boxed representation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
    public void translateBox(ClassGenerator classGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
                             MethodGenerator methodGen) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
        translateTo(classGen, methodGen, Type.Reference);
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
     * Translates an object of this type to its unboxed representation.
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
    public void translateUnBox(ClassGenerator classGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
                               MethodGenerator methodGen) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
        final ConstantPoolGen cpg = classGen.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
        il.append(new CHECKCAST(cpg.addClass(INTEGER_CLASS)));
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
        final int index = cpg.addMethodref(INTEGER_CLASS,
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
                                           INT_VALUE,
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
                                           INT_VALUE_SIG);
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
        il.append(new INVOKEVIRTUAL(index));
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
    public Instruction ADD() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   250
        return InstructionConst.IADD;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
    public Instruction SUB() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   254
        return InstructionConst.ISUB;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
    public Instruction MUL() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   258
        return InstructionConst.IMUL;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
    public Instruction DIV() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   262
        return InstructionConst.IDIV;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
    public Instruction REM() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   266
        return InstructionConst.IREM;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
    public Instruction NEG() {
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   270
        return InstructionConst.INEG;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
    public Instruction LOAD(int slot) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
        return new ILOAD(slot);
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
    public Instruction STORE(int slot) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
        return new ISTORE(slot);
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
    public BranchInstruction GT(boolean tozero) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
        return tozero ? (BranchInstruction) new IFGT(null) :
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
            (BranchInstruction) new IF_ICMPGT(null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
    public BranchInstruction GE(boolean tozero) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
        return tozero ? (BranchInstruction) new IFGE(null) :
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
            (BranchInstruction) new IF_ICMPGE(null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
    public BranchInstruction LT(boolean tozero) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
        return tozero ? (BranchInstruction) new IFLT(null) :
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
            (BranchInstruction) new IF_ICMPLT(null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
    public BranchInstruction LE(boolean tozero) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
        return tozero ? (BranchInstruction) new IFLE(null) :
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
            (BranchInstruction) new IF_ICMPLE(null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
}