author | joehw |
Fri, 01 Dec 2017 10:02:25 -0800 | |
changeset 48041 | 2743e489189e |
parent 47216 | 71c04702a3d5 |
child 55496 | 8e0ae3830fca |
permissions | -rw-r--r-- |
6 | 1 |
/* |
45853
bfa06be36a17
8181154: Fix lint warnings in JAXP repo: deprecation
joehw
parents:
44797
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
6 | 3 |
*/ |
44797
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
4 |
/* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
5 |
* 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
|
6 |
* contributor license agreements. See the NOTICE file distributed with |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
7 |
* this work for additional information regarding copyright ownership. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
8 |
* 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
|
9 |
* (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
|
10 |
* 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
|
11 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
13 |
* |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
14 |
* 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
|
15 |
* 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
|
16 |
* 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
|
17 |
* See the License for the specific language governing permissions and |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
18 |
* limitations under the License. |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
19 |
*/ |
8b3b3b911b8a
8162572: Update License Header for all JAXP sources
joehw
parents:
25868
diff
changeset
|
20 |
|
6 | 21 |
package com.sun.org.apache.bcel.internal.generic; |
22 |
||
23 |
/** |
|
24 |
* FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception |
|
25 |
* |
|
26 |
* <PRE>Stack: ... -> ..., </PRE> |
|
27 |
* |
|
46174 | 28 |
* @version $Id: FCONST.java 1747278 2016-06-07 17:28:43Z britter $ |
48041
2743e489189e
8191938: Fix lint warnings in JAXP repo: a few Deprecation warrnings and enable -Xlint:all
joehw
parents:
47216
diff
changeset
|
29 |
* @LastModified: Nov 2017 |
6 | 30 |
*/ |
46174 | 31 |
public class FCONST extends Instruction implements ConstantPushInstruction { |
32 |
||
33 |
private float value; |
|
34 |
||
6 | 35 |
|
46174 | 36 |
/** |
37 |
* Empty constructor needed for the Class.newInstance() statement in |
|
38 |
* Instruction.readInstruction(). Not to be used otherwise. |
|
39 |
*/ |
|
40 |
FCONST() { |
|
41 |
} |
|
42 |
||
6 | 43 |
|
46174 | 44 |
public FCONST(final float f) { |
45 |
super(com.sun.org.apache.bcel.internal.Const.FCONST_0, (short) 1); |
|
46 |
if (f == 0.0) { |
|
47 |
super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_0); |
|
48 |
} else if (f == 1.0) { |
|
49 |
super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_1); |
|
50 |
} else if (f == 2.0) { |
|
51 |
super.setOpcode(com.sun.org.apache.bcel.internal.Const.FCONST_2); |
|
52 |
} else { |
|
53 |
throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); |
|
54 |
} |
|
55 |
value = f; |
|
56 |
} |
|
6 | 57 |
|
58 |
||
46174 | 59 |
@Override |
60 |
public Number getValue() { |
|
48041
2743e489189e
8191938: Fix lint warnings in JAXP repo: a few Deprecation warrnings and enable -Xlint:all
joehw
parents:
47216
diff
changeset
|
61 |
return value; |
46174 | 62 |
} |
6 | 63 |
|
64 |
||
46174 | 65 |
/** @return Type.FLOAT |
66 |
*/ |
|
67 |
@Override |
|
68 |
public Type getType( final ConstantPoolGen cp ) { |
|
69 |
return Type.FLOAT; |
|
70 |
} |
|
71 |
||
6 | 72 |
|
46174 | 73 |
/** |
74 |
* Call corresponding visitor method(s). The order is: |
|
75 |
* Call visitor methods of implemented interfaces first, then |
|
76 |
* call methods according to the class hierarchy in descending order, |
|
77 |
* i.e., the most specific visitXXX() call comes last. |
|
78 |
* |
|
79 |
* @param v Visitor object |
|
80 |
*/ |
|
81 |
@Override |
|
82 |
public void accept( final Visitor v ) { |
|
83 |
v.visitPushInstruction(this); |
|
84 |
v.visitStackProducer(this); |
|
85 |
v.visitTypedInstruction(this); |
|
86 |
v.visitConstantPushInstruction(this); |
|
87 |
v.visitFCONST(this); |
|
88 |
} |
|
6 | 89 |
} |