Added missing Format files

git-svn-id: https://smali.googlecode.com/svn/trunk@32 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-05-05 06:52:43 +00:00
parent bc670e3f49
commit dc7bac4dd4
4 changed files with 291 additions and 0 deletions

View File

@ -0,0 +1,74 @@
/*
* [The "BSD licence"]
* Copyright (c) 2009 Ben Gruver
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.JesusFreke.dexlib.code.Format;
import org.JesusFreke.dexlib.code.Instruction;
import org.JesusFreke.dexlib.code.Opcode;
import org.JesusFreke.dexlib.DexFile;
public class Format22s extends Format
{
public static final Format22s Format = new Format22s();
private Format22s() {
}
public Instruction make(DexFile dexFile, byte opcode, byte regA, byte regB, short litC) {
byte[] bytes = new byte[4];
Opcode op = Opcode.getOpcodeByValue(opcode);
checkOpcodeFormat(op);
if (regA >= 1<<4) {
throw new RuntimeException("The register number must be less than v16");
}
if (regB >= 1<<4) {
throw new RuntimeException("The register number must be less than v16");
}
bytes[0] = opcode;
bytes[1] = (byte)((regB << 4) | regA);
bytes[2] = (byte)litC;
bytes[3] = (byte)(litC >> 8);
return new Instruction(dexFile, bytes, null);
}
public int getByteCount()
{
return 4;
}
public String getFormatName()
{
return "22s";
}
}

View File

@ -0,0 +1,77 @@
/*
* [The "BSD licence"]
* Copyright (c) 2009 Ben Gruver
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.JesusFreke.dexlib.code.Format;
import org.JesusFreke.dexlib.code.Instruction;
import org.JesusFreke.dexlib.code.Opcode;
import org.JesusFreke.dexlib.DexFile;
import org.JesusFreke.dexlib.IndexedItem;
public class Format22t extends Format
{
public static final Format22t Format = new Format22t();
private Format22t() {
}
public Instruction make(DexFile dexFile, byte opcode, byte regA, byte regB, short offC) {
byte[] bytes = new byte[4];
Opcode op = Opcode.getOpcodeByValue(opcode);
checkOpcodeFormat(op);
if (regA >= 1<<4) {
throw new RuntimeException("The register number must be less than v16");
}
if (regB >= 1<<4) {
throw new RuntimeException("The register number must be less than v16");
}
if (offC == 0) {
throw new RuntimeException("The offset cannot be 0.");
}
bytes[0] = opcode;
bytes[1] = (byte)((regB << 4) | regA);
bytes[2] = (byte)offC;
bytes[3] = (byte)(offC >> 8);
return new Instruction(dexFile, bytes, null);
}
public int getByteCount() {
return 4;
}
public String getFormatName() {
return "22t";
}
}

View File

@ -0,0 +1,67 @@
/*
* [The "BSD licence"]
* Copyright (c) 2009 Ben Gruver
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.JesusFreke.dexlib.code.Format;
import org.JesusFreke.dexlib.code.Instruction;
import org.JesusFreke.dexlib.code.Opcode;
import org.JesusFreke.dexlib.DexFile;
import org.JesusFreke.dexlib.IndexedItem;
public class Format31c extends Format
{
public static final Format31c Format = new Format31c();
private Format31c() {
}
public Instruction make(DexFile dexFile, byte opcode, short regA, IndexedItem item) {
byte[] bytes = new byte[6];
Opcode op = Opcode.getOpcodeByValue(opcode);
checkOpcodeFormat(op);
if (regA >= 1<<8) {
throw new RuntimeException("The register number must be less than v256");
}
bytes[0] = opcode;
bytes[1] = (byte)regA;
return new Instruction(dexFile, bytes, item);
}
public int getByteCount() {
return 6;
}
public String getFormatName() {
return "31c";
}
}

View File

@ -0,0 +1,73 @@
/*
* [The "BSD licence"]
* Copyright (c) 2009 Ben Gruver
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.JesusFreke.dexlib.code.Format;
import org.JesusFreke.dexlib.code.Instruction;
import org.JesusFreke.dexlib.code.Opcode;
import org.JesusFreke.dexlib.DexFile;
import org.JesusFreke.dexlib.IndexedItem;
public class Format31i extends Format
{
public static final Format31i Format = new Format31i();
private Format31i() {
}
public Instruction make(DexFile dexFile, byte opcode, short regA, int litB) {
byte[] bytes = new byte[6];
Opcode op = Opcode.getOpcodeByValue(opcode);
checkOpcodeFormat(op);
if (regA >= 1<<8) {
throw new RuntimeException("The register number must be less than v256");
}
bytes[0] = opcode;
bytes[1] = (byte)regA;
bytes[2] = (byte)litB;
bytes[3] = (byte)(litB >> 8);
bytes[4] = (byte)(litB >> 16);
bytes[5] = (byte)(litB >> 24);
return new Instruction(dexFile, bytes, null);
}
public int getByteCount() {
return 6;
}
public String getFormatName() {
return "31i";
}
}