diff options
Diffstat (limited to 'plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions')
38 files changed, 1587 insertions, 0 deletions
diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ALOAD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ALOAD.java new file mode 100644 index 000000000000..788795e6fe7d --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ALOAD.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class ALOAD extends Instruction { + + private static int[] opcodes = new int[]{opc_aload_0, opc_aload_1, opc_aload_2, opc_aload_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_aload); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ANEWARRAY.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ANEWARRAY.java new file mode 100644 index 000000000000..d514ffe9f772 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ANEWARRAY.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class ANEWARRAY extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_anewarray); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ASTORE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ASTORE.java new file mode 100644 index 000000000000..40336f483edf --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ASTORE.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class ASTORE extends Instruction { + + private static int[] opcodes = new int[]{opc_astore_0, opc_astore_1, opc_astore_2, opc_astore_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_astore); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/BIPUSH.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/BIPUSH.java new file mode 100644 index 000000000000..4686051cfe18 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/BIPUSH.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +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; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/CHECKCAST.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/CHECKCAST.java new file mode 100644 index 000000000000..9a42f656ed00 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/CHECKCAST.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class CHECKCAST extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_checkcast); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} + diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DLOAD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DLOAD.java new file mode 100644 index 000000000000..7630185b45bc --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DLOAD.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class DLOAD extends Instruction { + + private static int[] opcodes = new int[]{opc_dload_0, opc_dload_1, opc_dload_2, opc_dload_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_dload); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DSTORE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DSTORE.java new file mode 100644 index 000000000000..2bdb74911305 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/DSTORE.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class DSTORE extends Instruction { + + private static int[] opcodes = new int[]{opc_dstore_0, opc_dstore_1, opc_dstore_2, opc_dstore_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_dstore); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FLOAD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FLOAD.java new file mode 100644 index 000000000000..8a89dfff66fc --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FLOAD.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class FLOAD extends Instruction { + + private static int[] opcodes = new int[]{opc_fload_0, opc_fload_1, opc_fload_2, opc_fload_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_fload); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FSTORE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FSTORE.java new file mode 100644 index 000000000000..9061913c0032 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/FSTORE.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class FSTORE extends Instruction { + + private static int[] opcodes = new int[]{opc_fstore_0, opc_fstore_1, opc_fstore_2, opc_fstore_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_fstore); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + if (wide) { + return 4; + } + else { + return 2; + } + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETFIELD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETFIELD.java new file mode 100644 index 000000000000..6b95aaf91668 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETFIELD.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class GETFIELD extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_getfield); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETSTATIC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETSTATIC.java new file mode 100644 index 000000000000..c1401a6128c8 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GETSTATIC.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class GETSTATIC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_getstatic); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO.java new file mode 100644 index 000000000000..97374c081cb9 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.JumpInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class GOTO extends JumpInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int operand = getOperand(0); + if (operand < -32768 || operand > 32767) { + out.writeByte(opc_goto_w); + out.writeInt(operand); + } + else { + out.writeByte(opc_goto); + out.writeShort(operand); + } + } + + public int length() { + int operand = getOperand(0); + if (operand < -32768 || operand > 32767) { + return 5; + } + else { + return 3; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO_W.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO_W.java new file mode 100644 index 000000000000..56ba9e8d59fb --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/GOTO_W.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.JumpInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class GOTO_W extends JumpInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_goto_w); + out.writeInt(getOperand(0)); + } + + public int length() { + return 5; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/IINC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/IINC.java new file mode 100644 index 000000000000..05b446c861c9 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/IINC.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class IINC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_iinc); + if (wide) { + out.writeShort(getOperand(0)); + out.writeShort(getOperand(1)); + } + else { + out.writeByte(getOperand(0)); + out.writeByte(getOperand(1)); + } + } + + public int length() { + return wide ? 6 : 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ILOAD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ILOAD.java new file mode 100644 index 000000000000..24b95ffbea8d --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ILOAD.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class ILOAD extends Instruction { + + private static int[] opcodes = new int[]{opc_iload_0, opc_iload_1, opc_iload_2, opc_iload_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_iload); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + return wide ? 4 : 2; + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INSTANCEOF.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INSTANCEOF.java new file mode 100644 index 000000000000..f93d5b892105 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INSTANCEOF.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INSTANCEOF extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_instanceof); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEDYNAMIC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEDYNAMIC.java new file mode 100644 index 000000000000..917c5bde038d --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEDYNAMIC.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INVOKEDYNAMIC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_invokedynamic); + out.writeShort(getOperand(0)); + out.writeByte(0); + out.writeByte(0); + } + + public int length() { + return 5; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEINTERFACE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEINTERFACE.java new file mode 100644 index 000000000000..51259ff03eb5 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEINTERFACE.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INVOKEINTERFACE extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_invokeinterface); + out.writeShort(getOperand(0)); + out.writeByte(getOperand(1)); + out.writeByte(0); + } + + public int length() { + return 5; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESPECIAL.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESPECIAL.java new file mode 100644 index 000000000000..2436803541fd --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESPECIAL.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INVOKESPECIAL extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_invokespecial); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESTATIC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESTATIC.java new file mode 100644 index 000000000000..f036a1d90d79 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKESTATIC.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INVOKESTATIC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_invokestatic); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEVIRTUAL.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEVIRTUAL.java new file mode 100644 index 000000000000..ca3bcd3809ec --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/INVOKEVIRTUAL.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class INVOKEVIRTUAL extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_invokevirtual); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ISTORE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ISTORE.java new file mode 100644 index 000000000000..5907538389b5 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/ISTORE.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class ISTORE extends Instruction { + + private static int[] opcodes = new int[]{opc_istore_0, opc_istore_1, opc_istore_2, opc_istore_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_istore); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + return wide ? 4 : 2; + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR.java new file mode 100644 index 000000000000..bb000a7ad08a --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.JumpInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class JSR extends JumpInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int operand = getOperand(0); + if (operand < -32768 || operand > 32767) { + out.writeByte(opc_jsr_w); + out.writeInt(operand); + } + else { + out.writeByte(opc_jsr); + out.writeShort(operand); + } + } + + public int length() { + int operand = getOperand(0); + if (operand < -32768 || operand > 32767) { + return 5; + } + else { + return 3; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR_W.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR_W.java new file mode 100644 index 000000000000..fb04ed97e913 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/JSR_W.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.JumpInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class JSR_W extends JumpInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_jsr_w); + out.writeInt(getOperand(0)); + } + + public int length() { + return 5; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC.java new file mode 100644 index 000000000000..ae7b3c6b8802 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LDC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_ldc); + out.writeByte(getOperand(0)); + } + + public int length() { + return 2; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC2_W.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC2_W.java new file mode 100644 index 000000000000..6ba19649bdaf --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC2_W.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LDC2_W extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_ldc2_w); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC_W.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC_W.java new file mode 100644 index 000000000000..71e5fe021bbd --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LDC_W.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LDC_W extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_ldc_w); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LLOAD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LLOAD.java new file mode 100644 index 000000000000..6e506593197f --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LLOAD.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LLOAD extends Instruction { + + private static int[] opcodes = new int[]{opc_lload_0, opc_lload_1, opc_lload_2, opc_lload_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_lload); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + return wide ? 4 : 2; + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LOOKUPSWITCH.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LOOKUPSWITCH.java new file mode 100644 index 000000000000..418316886d29 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LOOKUPSWITCH.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.SwitchInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LOOKUPSWITCH extends SwitchInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + + out.writeByte(opc_lookupswitch); + + int padding = 3 - (offset % 4); + for (int i = 0; i < padding; i++) { + out.writeByte(0); + } + + for (int i = 0; i < operandsCount(); i++) { + out.writeInt(getOperand(i)); + } + } + + public int length() { + return 1 + operandsCount() * 4; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LSTORE.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LSTORE.java new file mode 100644 index 000000000000..9095f04ea883 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/LSTORE.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class LSTORE extends Instruction { + + private static int[] opcodes = new int[]{opc_lstore_0, opc_lstore_1, opc_lstore_2, opc_lstore_3}; + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + int index = getOperand(0); + if (index > 3) { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_lstore); + if (wide) { + out.writeShort(index); + } + else { + out.writeByte(index); + } + } + else { + out.writeByte(opcodes[index]); + } + } + + public int length() { + int index = getOperand(0); + if (index > 3) { + return wide ? 4 : 2; + } + else { + return 1; + } + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/MULTIANEWARRAY.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/MULTIANEWARRAY.java new file mode 100644 index 000000000000..b6835e80c761 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/MULTIANEWARRAY.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class MULTIANEWARRAY extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_multianewarray); + out.writeShort(getOperand(0)); + out.writeByte(getOperand(1)); + } + + public int length() { + return 4; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEW.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEW.java new file mode 100644 index 000000000000..2e8854f30877 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEW.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class NEW extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_new); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEWARRAY.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEWARRAY.java new file mode 100644 index 000000000000..f2f8e4d5a433 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/NEWARRAY.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class NEWARRAY extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_newarray); + out.writeByte(getOperand(0)); + } + + public int length() { + return 2; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTFIELD.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTFIELD.java new file mode 100644 index 000000000000..c1e3e9241985 --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTFIELD.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class PUTFIELD extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_putfield); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTSTATIC.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTSTATIC.java new file mode 100644 index 000000000000..0fe0240242ed --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/PUTSTATIC.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class PUTSTATIC extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_putstatic); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/RET.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/RET.java new file mode 100644 index 000000000000..93f62ff1bced --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/RET.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class RET extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + if (wide) { + out.writeByte(opc_wide); + } + out.writeByte(opc_ret); + if (wide) { + out.writeShort(getOperand(0)); + } + else { + out.writeByte(getOperand(0)); + } + } + + public int length() { + return wide ? 4 : 2; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/SIPUSH.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/SIPUSH.java new file mode 100644 index 000000000000..08b10a51725e --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/SIPUSH.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.Instruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class SIPUSH extends Instruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + out.writeByte(opc_sipush); + out.writeShort(getOperand(0)); + } + + public int length() { + return 3; + } +} diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/TABLESWITCH.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/TABLESWITCH.java new file mode 100644 index 000000000000..0b41ecf232fe --- /dev/null +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/code/optinstructions/TABLESWITCH.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.java.decompiler.code.optinstructions; + +import org.jetbrains.java.decompiler.code.SwitchInstruction; + +import java.io.DataOutputStream; +import java.io.IOException; + +public class TABLESWITCH extends SwitchInstruction { + + public void writeToStream(DataOutputStream out, int offset) throws IOException { + + out.writeByte(opc_tableswitch); + + int padding = 3 - (offset % 4); + for (int i = 0; i < padding; i++) { + out.writeByte(0); + } + + for (int i = 0; i < operandsCount(); i++) { + out.writeInt(getOperand(i)); + } + } + + public int length() { + return 1 + operandsCount() * 4; + } +} |