12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.bcel.internal.generic;
23
24 import java.io.DataOutputStream;
25 import java.io.IOException;
26
27 import com.sun.org.apache.bcel.internal.util.ByteSequence;
28
29 /**
30 * IINC - Increment local variable by constant
31 *
32 * @version $Id$
33 */
34 public class IINC extends LocalVariableInstruction {
35
36 private boolean wide;
37 private int c;
38
39
40 /**
41 * Empty constructor needed for Instruction.readInstruction.
42 * Not to be used otherwise.
43 */
44 IINC() {
45 }
46
47
48 /**
49 * @param n index of local variable
50 * @param c increment factor
51 */
52 public IINC(final int n, final int c) {
53 super(); // Default behaviour of LocalVariableInstruction causes error
54 super.setOpcode(com.sun.org.apache.bcel.internal.Const.IINC);
55 super.setLength((short) 3);
56 setIndex(n); // May set wide as side effect
57 setIncrement(c);
58 }
59
60
61 /**
62 * Dump instruction as byte code to stream out.
63 * @param out Output stream
64 */
65 @Override
66 public void dump( final DataOutputStream out ) throws IOException {
67 if (wide) {
68 out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
69 }
70 out.writeByte(super.getOpcode());
71 if (wide) {
72 out.writeShort(super.getIndex());
73 out.writeShort(c);
|
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package com.sun.org.apache.bcel.internal.generic;
23
24 import java.io.DataOutputStream;
25 import java.io.IOException;
26
27 import com.sun.org.apache.bcel.internal.util.ByteSequence;
28
29 /**
30 * IINC - Increment local variable by constant
31 *
32 */
33 public class IINC extends LocalVariableInstruction {
34
35 private boolean wide;
36 private int c;
37
38
39 /**
40 * Empty constructor needed for Instruction.readInstruction.
41 * Not to be used otherwise.
42 */
43 IINC() {
44 }
45
46
47 /**
48 * @param n index of local variable
49 * @param c increment factor
50 */
51 public IINC(final int n, final int c) {
52 super(); // Default behavior of LocalVariableInstruction causes error
53 super.setOpcode(com.sun.org.apache.bcel.internal.Const.IINC);
54 super.setLength((short) 3);
55 setIndex(n); // May set wide as side effect
56 setIncrement(c);
57 }
58
59
60 /**
61 * Dump instruction as byte code to stream out.
62 * @param out Output stream
63 */
64 @Override
65 public void dump( final DataOutputStream out ) throws IOException {
66 if (wide) {
67 out.writeByte(com.sun.org.apache.bcel.internal.Const.WIDE);
68 }
69 out.writeByte(super.getOpcode());
70 if (wide) {
71 out.writeShort(super.getIndex());
72 out.writeShort(c);
|