author | joehw |
Wed, 26 Jun 2019 05:49:59 +0000 | |
changeset 55496 | 8e0ae3830fca |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
6 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
4 |
*/ |
|
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
5 |
/* |
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 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
12 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
14 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
15 |
* Unless required by applicable law or agreed to in writing, software |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
16 |
* distributed under the License is distributed on an "AS IS" BASIS, |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
17 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
18 |
* See the License for the specific language governing permissions and |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
19 |
* limitations under the License. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
20 |
*/ |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
21 |
|
6 | 22 |
package com.sun.org.apache.bcel.internal.generic; |
23 |
||
46174 | 24 |
import com.sun.org.apache.bcel.internal.Const; |
25 |
||
6 | 26 |
/** |
27 |
* Super class for the family of arithmetic instructions. |
|
28 |
* |
|
55496 | 29 |
* @version $Id$ |
6 | 30 |
*/ |
46174 | 31 |
public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction, |
32 |
StackProducer, StackConsumer { |
|
6 | 33 |
|
46174 | 34 |
/** |
55496 | 35 |
* Empty constructor needed for Instruction.readInstruction. |
36 |
* Not to be used otherwise. |
|
46174 | 37 |
*/ |
38 |
ArithmeticInstruction() { |
|
39 |
} |
|
40 |
||
41 |
||
42 |
/** |
|
43 |
* @param opcode of instruction |
|
44 |
*/ |
|
45 |
protected ArithmeticInstruction(final short opcode) { |
|
46 |
super(opcode, (short) 1); |
|
47 |
} |
|
48 |
||
6 | 49 |
|
46174 | 50 |
/** @return type associated with the instruction |
51 |
*/ |
|
52 |
@Override |
|
53 |
public Type getType( final ConstantPoolGen cp ) { |
|
54 |
final short _opcode = super.getOpcode(); |
|
55 |
switch (_opcode) { |
|
56 |
case Const.DADD: |
|
57 |
case Const.DDIV: |
|
58 |
case Const.DMUL: |
|
59 |
case Const.DNEG: |
|
60 |
case Const.DREM: |
|
61 |
case Const.DSUB: |
|
62 |
return Type.DOUBLE; |
|
63 |
case Const.FADD: |
|
64 |
case Const.FDIV: |
|
65 |
case Const.FMUL: |
|
66 |
case Const.FNEG: |
|
67 |
case Const.FREM: |
|
68 |
case Const.FSUB: |
|
69 |
return Type.FLOAT; |
|
70 |
case Const.IADD: |
|
71 |
case Const.IAND: |
|
72 |
case Const.IDIV: |
|
73 |
case Const.IMUL: |
|
74 |
case Const.INEG: |
|
75 |
case Const.IOR: |
|
76 |
case Const.IREM: |
|
77 |
case Const.ISHL: |
|
78 |
case Const.ISHR: |
|
79 |
case Const.ISUB: |
|
80 |
case Const.IUSHR: |
|
81 |
case Const.IXOR: |
|
82 |
return Type.INT; |
|
83 |
case Const.LADD: |
|
84 |
case Const.LAND: |
|
85 |
case Const.LDIV: |
|
86 |
case Const.LMUL: |
|
87 |
case Const.LNEG: |
|
88 |
case Const.LOR: |
|
89 |
case Const.LREM: |
|
90 |
case Const.LSHL: |
|
91 |
case Const.LSHR: |
|
92 |
case Const.LSUB: |
|
93 |
case Const.LUSHR: |
|
94 |
case Const.LXOR: |
|
95 |
return Type.LONG; |
|
96 |
default: // Never reached |
|
97 |
throw new ClassGenException("Unknown type " + _opcode); |
|
98 |
} |
|
6 | 99 |
} |
100 |
} |