summaryrefslogtreecommitdiffstats
path: root/src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java
diff options
context:
space:
mode:
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-08-28 20:52:43 +0400
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-08-28 20:52:43 +0400
commit663631f0456fcc245dd835889f86541d75161c53 (patch)
treee183fa9777242e2900ff3648a726f05b190bc51b /src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java
parentf864084061806fda5510e50bfd2e69bf1dea406b (diff)
downloadfernflower-663631f0456fcc245dd835889f86541d75161c53.tar
fernflower-663631f0456fcc245dd835889f86541d75161c53.tar.gz
fernflower-663631f0456fcc245dd835889f86541d75161c53.tar.lz
fernflower-663631f0456fcc245dd835889f86541d75161c53.tar.xz
fernflower-663631f0456fcc245dd835889f86541d75161c53.zip
java-decompiler: post-import cleanup (classes moved)
Diffstat (limited to 'src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java')
-rw-r--r--src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java b/src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java
new file mode 100644
index 0000000..90874c5
--- /dev/null
+++ b/src/org/jetbrains/java/decompiler/code/instructions/BIPUSH.java
@@ -0,0 +1,30 @@
+package org.jetbrains.java.decompiler.code.instructions;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.jetbrains.java.decompiler.code.Instruction;
+
+public class BIPUSH extends Instruction {
+
+ private static int[] opcodes = new int[] {opc_iconst_m1,opc_iconst_0,opc_iconst_1,opc_iconst_2,opc_iconst_3,opc_iconst_4,opc_iconst_5};
+
+ public void writeToStream(DataOutputStream out, int offset) throws IOException {
+ int value = getOperand(0);
+ if(value<-1 || value > 5) {
+ out.writeByte(opc_bipush);
+ out.writeByte(value);
+ } else {
+ out.writeByte(opcodes[value+1]);
+ }
+ }
+
+ public int length() {
+ int value = getOperand(0);
+ if(value<-1 || value > 5) {
+ return 2;
+ } else {
+ return 1;
+ }
+ }
+}