diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java index 3eed7f99..683f0b4e 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/ClassDefinition.java @@ -245,30 +245,33 @@ public class ClassDefinition { } private List getDirectMethods() { - List directMethods = new ArrayList(); - - if (classDataItem != null) { - for (ClassDataItem.EncodedMethod method: classDataItem.getDirectMethods()) { - AnnotationSetItem annotationSet = methodAnnotationsMap.get(method.method.getIndex()); - AnnotationSetRefList parameterAnnotationList = parameterAnnotationsMap.get(method.method.getIndex()); - directMethods.add(MethodDefinition.createTemplate(stg, method, annotationSet, parameterAnnotationList)); - } + if (classDataItem == null) { + return null; } - return directMethods; + return getTemplatesForMethods(classDataItem.getDirectMethods()); } private List getVirtualMethods() { - List virtualMethods = new ArrayList(); - - if (classDataItem != null) { - for (ClassDataItem.EncodedMethod method: classDataItem.getVirtualMethods()) { - AnnotationSetItem annotationSet = methodAnnotationsMap.get(method.method.getIndex()); - AnnotationSetRefList parameterAnnotationList = parameterAnnotationsMap.get(method.method.getIndex()); - virtualMethods.add(MethodDefinition.createTemplate(stg, method, annotationSet, parameterAnnotationList)); - } + if (classDataItem == null) { + return null; } - return virtualMethods; + return getTemplatesForMethods(classDataItem.getVirtualMethods()); + } + + private List getTemplatesForMethods(ClassDataItem.EncodedMethod[] methods) { + List methodTemplates = new ArrayList(); + + for (ClassDataItem.EncodedMethod method: methods) { + AnnotationSetItem annotationSet = methodAnnotationsMap.get(method.method.getIndex()); + AnnotationSetRefList parameterAnnotationList = parameterAnnotationsMap.get(method.method.getIndex()); + + MethodDefinition methodDefinition = new MethodDefinition(stg, method); + + methodTemplates.add(methodDefinition.createTemplate(annotationSet, parameterAnnotationList)); + } + + return methodTemplates; } } diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java index 04381015..8789f704 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/ArrayDataMethodItem.java @@ -35,7 +35,7 @@ import org.jf.dexlib.CodeItem; import java.util.Iterator; -public class ArrayDataMethodItem extends InstructionFormatMethodItem { +public class ArrayDataMethodItem extends InstructionMethodItem { public ArrayDataMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, ArrayDataPseudoInstruction instruction) { super(codeItem, codeAddress, stg, instruction); diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10tMethodItem.java deleted file mode 100644 index 160f1ca2..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10tMethodItem.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction10t; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction10tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction10tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction10t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected String getLabelPrefix() { - return "goto_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10xMethodItem.java deleted file mode 100644 index 0b3aa019..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction10xMethodItem.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction10x; -import org.jf.dexlib.CodeItem; - -public class Instruction10xMethodItem extends InstructionFormatMethodItem { - public Instruction10xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction10x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11nMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11nMethodItem.java deleted file mode 100644 index 8a661034..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11nMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction11n; -import org.jf.dexlib.CodeItem; - -public class Instruction11nMethodItem extends InstructionFormatMethodItem { - public Instruction11nMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction11n instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11xMethodItem.java deleted file mode 100644 index dc7916a6..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction11xMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction11x; -import org.jf.dexlib.CodeItem; - -public class Instruction11xMethodItem extends InstructionFormatMethodItem { - public Instruction11xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction11x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - } -} - diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction12xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction12xMethodItem.java deleted file mode 100644 index 1315f6ed..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction12xMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction12x; -import org.jf.dexlib.CodeItem; - -public class Instruction12xMethodItem extends InstructionFormatMethodItem { - public Instruction12xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction12x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction20tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction20tMethodItem.java deleted file mode 100644 index eace9fd4..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction20tMethodItem.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction20t; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction20tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction20tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction20t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected String getLabelPrefix() { - return "goto_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21cMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21cMethodItem.java deleted file mode 100644 index e5aa2c49..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21cMethodItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.dexlib.Code.Format.Instruction21c; -import org.jf.dexlib.CodeItem; - -public class Instruction21cMethodItem extends InstructionFormatMethodItem { - public Instruction21cMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction21c instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21hMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21hMethodItem.java deleted file mode 100644 index 70f85688..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21hMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction21h; -import org.jf.dexlib.CodeItem; - -public class Instruction21hMethodItem extends InstructionFormatMethodItem { - public Instruction21hMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction21h instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21sMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21sMethodItem.java deleted file mode 100644 index c59ab474..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21sMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction21s; -import org.jf.dexlib.CodeItem; - -public class Instruction21sMethodItem extends InstructionFormatMethodItem { - public Instruction21sMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction21s instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21tMethodItem.java deleted file mode 100644 index 252105a7..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction21tMethodItem.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction21t; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction21tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction21tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction21t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - super.setAttributes(template); - template.setAttribute("Register", formatRegister(instruction.getRegister())); - } - - protected String getLabelPrefix() { - return "cond_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22bMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22bMethodItem.java deleted file mode 100644 index 0ce1c2f0..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22bMethodItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction22b; -import org.jf.dexlib.CodeItem; - -public class Instruction22bMethodItem extends InstructionFormatMethodItem { - public Instruction22bMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22b instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22cMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22cMethodItem.java deleted file mode 100644 index 19cd0007..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22cMethodItem.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.dexlib.Code.Format.Instruction22c; -import org.jf.dexlib.CodeItem; - -public class Instruction22cMethodItem extends InstructionFormatMethodItem { - public Instruction22cMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22c instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csMethodItem.java deleted file mode 100644 index 9a983934..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csMethodItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.Instruction22cs; -import org.jf.dexlib.CodeItem; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction22csMethodItem extends InstructionFormatMethodItem { - public Instruction22csMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22cs instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("FieldOffset", instruction.getFieldOffset()); - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csfMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csfMethodItem.java deleted file mode 100644 index 07c9c57f..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22csfMethodItem.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.Code.Format.Instruction22csf; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction22csfMethodItem extends InstructionFormatMethodItem { - public Instruction22csfMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22csf instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22sMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22sMethodItem.java deleted file mode 100644 index a5c01036..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22sMethodItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction22s; -import org.jf.dexlib.CodeItem; - -public class Instruction22sMethodItem extends InstructionFormatMethodItem { - public Instruction22sMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22s instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22tMethodItem.java deleted file mode 100644 index 9540a939..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22tMethodItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction22t; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction22tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction22tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction22t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - super.setAttributes(template); - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } - - protected String getLabelPrefix() { - return "cond_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22xMethodItem.java deleted file mode 100644 index e92b3217..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction22xMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction22x; -import org.jf.dexlib.CodeItem; - -public class Instruction22xMethodItem extends InstructionFormatMethodItem { - public Instruction22xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction22x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction23xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction23xMethodItem.java deleted file mode 100644 index 1b515968..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction23xMethodItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction23x; -import org.jf.dexlib.CodeItem; - -public class Instruction23xMethodItem extends InstructionFormatMethodItem { - public Instruction23xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction23x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - template.setAttribute("RegisterC", formatRegister(instruction.getRegisterC())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction30tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction30tMethodItem.java deleted file mode 100644 index 7742be1e..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction30tMethodItem.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction30t; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction30tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction30tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction30t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected String getLabelPrefix() { - return "goto_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31cMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31cMethodItem.java deleted file mode 100644 index 5f51b5e0..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31cMethodItem.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.dexlib.Code.Format.Instruction31c; -import org.jf.dexlib.CodeItem; - -public class Instruction31cMethodItem extends InstructionFormatMethodItem { - public Instruction31cMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction31c instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31iMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31iMethodItem.java deleted file mode 100644 index a5f3d5e8..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31iMethodItem.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction31i; -import org.jf.dexlib.CodeItem; - -public class Instruction31iMethodItem extends InstructionFormatMethodItem { - public Instruction31iMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction31i instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - - template.setAttribute("Literal", (int)instruction.getLiteral()); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31tMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31tMethodItem.java deleted file mode 100644 index e13f71dd..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction31tMethodItem.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction31t; -import org.jf.dexlib.Code.Opcode; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.MethodDefinition; - -public class Instruction31tMethodItem extends OffsetInstructionFormatMethodItem { - public Instruction31tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, Instruction31t instruction) { - super(labelCache, codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - super.setAttributes(template); - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - } - - protected String getLabelPrefix() { - if (instruction.opcode == Opcode.FILL_ARRAY_DATA) { - return "array_"; - } - if (instruction.opcode == Opcode.PACKED_SWITCH) { - return "pswitch_data_"; - } - return "sswitch_data_"; - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction32xMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction32xMethodItem.java deleted file mode 100644 index 50703688..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction32xMethodItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction32x; -import org.jf.dexlib.CodeItem; - -public class Instruction32xMethodItem extends InstructionFormatMethodItem { - public Instruction32xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction32x instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); - template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35cMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35cMethodItem.java deleted file mode 100644 index 43501b59..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35cMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.dexlib.Code.Format.Instruction35c; -import org.jf.dexlib.CodeItem; - -public class Instruction35cMethodItem extends InstructionFormatMethodItem { - public Instruction35cMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction35c instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - setRegistersAttribute(template); - } - - private void setRegistersAttribute(StringTemplate template) { - switch (instruction.getRegCount()) { - case 1: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - return; - case 2: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - return; - case 3: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - return; - case 4: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - return; - case 5: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msMethodItem.java deleted file mode 100644 index 5d165130..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.Code.Format.Instruction35ms; -import org.jf.dexlib.Code.Format.Instruction35c; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction35msMethodItem extends InstructionFormatMethodItem { - public Instruction35msMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction35ms instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("MethodIndex", instruction.getMethodIndex()); - setRegistersAttribute(template); - } - - private void setRegistersAttribute(StringTemplate template) { - switch (instruction.getRegCount()) { - case 1: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - return; - case 2: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - return; - case 3: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - return; - case 4: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - return; - case 5: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msfMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msfMethodItem.java deleted file mode 100644 index ae1f5f2c..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35msfMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.Instruction35msf; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction35msfMethodItem extends InstructionFormatMethodItem { - public Instruction35msfMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction35msf instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - setRegistersAttribute(template); - } - - private void setRegistersAttribute(StringTemplate template) { - switch (instruction.getRegCount()) { - case 1: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - return; - case 2: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - return; - case 3: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - return; - case 4: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - return; - case 5: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sMethodItem.java deleted file mode 100644 index 6d811506..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.Instruction35s; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction35sMethodItem extends InstructionFormatMethodItem { - public Instruction35sMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction35s instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - setRegistersAttribute(template); - } - - private void setRegistersAttribute(StringTemplate template) { - switch (instruction.getRegCount()) { - case 1: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - return; - case 2: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - return; - case 3: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - return; - case 4: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - return; - case 5: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sfMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sfMethodItem.java deleted file mode 100644 index 5dc87057..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction35sfMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.Instruction35sf; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction35sfMethodItem extends InstructionFormatMethodItem { - public Instruction35sfMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction35sf instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - setRegistersAttribute(template); - } - - private void setRegistersAttribute(StringTemplate template) { - switch (instruction.getRegCount()) { - case 1: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - return; - case 2: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - return; - case 3: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - return; - case 4: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - return; - case 5: - template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); - template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rcMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rcMethodItem.java deleted file mode 100644 index e4b0645d..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rcMethodItem.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib.Code.Format.Instruction3rc; -import org.jf.dexlib.CodeItem; - -public class Instruction3rcMethodItem extends InstructionFormatMethodItem { - public Instruction3rcMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction3rc instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - - String[] registers = RegisterFormatter.formatFormat3rcRegisters(codeItem, instruction.getStartRegister(), - instruction.getStartRegister() + instruction.getRegCount() - 1); - - template.setAttribute("StartRegister", registers[0]); - template.setAttribute("LastRegister", registers[1]); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsMethodItem.java deleted file mode 100644 index 6d227bbd..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsMethodItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; -import org.jf.dexlib.Code.Format.Instruction3rms; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.RegisterFormatter; - -public class Instruction3rmsMethodItem extends InstructionFormatMethodItem { - public Instruction3rmsMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction3rms instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("MethodIndex", instruction.getMethodIndex()); - - String[] registers = RegisterFormatter.formatFormat3rcRegisters(codeItem, instruction.getStartRegister(), - instruction.getStartRegister() + instruction.getRegCount() - 1); - - template.setAttribute("StartRegister", registers[0]); - template.setAttribute("LastRegister", registers[1]); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsfMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsfMethodItem.java deleted file mode 100644 index a00ef0fc..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction3rmsfMethodItem.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.Instruction3rmsf; -import org.jf.dexlib.CodeItem; -import org.jf.baksmali.Adaptors.Reference.Reference; -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class Instruction3rmsfMethodItem extends InstructionFormatMethodItem { - public Instruction3rmsfMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction3rmsf instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Reference", Reference.createReference(template.getGroup(), - instruction.getReferencedItem())); - - String[] registers = RegisterFormatter.formatFormat3rcRegisters(codeItem, instruction.getStartRegister(), - instruction.getStartRegister() + instruction.getRegCount() - 1); - - template.setAttribute("StartRegister", registers[0]); - template.setAttribute("LastRegister", registers[1]); - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction51lMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction51lMethodItem.java deleted file mode 100644 index ae793bc5..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/Instruction51lMethodItem.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.dexlib.Code.Format.Instruction51l; -import org.jf.dexlib.CodeItem; - -public class Instruction51lMethodItem extends InstructionFormatMethodItem { - public Instruction51lMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - Instruction51l instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.getRegisterA())); - - long lit = instruction.getLiteral(); - if (lit <= Integer.MAX_VALUE && lit >= Integer.MIN_VALUE) { - template.setAttribute("Literal", (int)instruction.getLiteral()); - } else { - template.setAttribute("Literal", instruction.getLiteral()); - } - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionFormatMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionFormatMethodItem.java deleted file mode 100644 index 3eb1c790..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionFormatMethodItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.antlr.stringtemplate.StringTemplate; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.jf.baksmali.Adaptors.MethodItem; -import org.jf.baksmali.Adaptors.RegisterFormatter; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.CodeItem; - -public abstract class InstructionFormatMethodItem extends MethodItem { - protected final CodeItem codeItem; - private final StringTemplateGroup stg; - protected final T instruction; - - - public InstructionFormatMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, T instruction) { - super(codeAddress); - this.codeItem = codeItem; - this.stg = stg; - this.instruction = instruction; - } - - public int getSortOrder() { - //instructions should appear after everything except an "end try" label and .catch directive - return 100; - } - - public String getOpcode() { - return instruction.opcode.name; - } - - public String getTemplate() { - return instruction.getFormat().name(); - } - - protected String formatRegister(int register) { - return RegisterFormatter.formatRegister(codeItem, register); - } - - @Override - public String toString() { - StringTemplate template = stg.getInstanceOf(instruction.getFormat().name()); - template.setAttribute("Opcode", instruction.opcode.name); - setAttributes(template); - return template.toString(); - } - - protected abstract void setAttributes(StringTemplate template); -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java new file mode 100644 index 00000000..62eac7c5 --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java @@ -0,0 +1,173 @@ +/* + * [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.jf.baksmali.Adaptors.Format; + +import org.antlr.stringtemplate.StringTemplate; +import org.antlr.stringtemplate.StringTemplateGroup; +import org.jf.baksmali.Adaptors.MethodItem; +import org.jf.baksmali.Adaptors.Reference.Reference; +import org.jf.baksmali.Adaptors.RegisterFormatter; +import org.jf.dexlib.Code.*; +import org.jf.dexlib.CodeItem; + +import java.util.LinkedList; + +public class InstructionMethodItem extends MethodItem { + protected final CodeItem codeItem; + protected final StringTemplateGroup stg; + protected final T instruction; + + /** + * Instructions that execution could pass on to next + */ + private LinkedList successors = new LinkedList(); + + /** + * Instructions that can pass on execution to this one + */ + private LinkedList predecessors = new LinkedList(); + + public InstructionMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, T instruction) { + super(codeAddress); + this.codeItem = codeItem; + this.stg = stg; + this.instruction = instruction; + } + + public int getSortOrder() { + //instructions should appear after everything except an "end try" label and .catch directive + return 100; + } + + protected String formatRegister(int register) { + return RegisterFormatter.formatRegister(codeItem, register); + } + + @Override + public String toString() { + StringTemplate template = stg.getInstanceOf(instruction.getFormat().name()); + template.setAttribute("Opcode", instruction.opcode.name); + setAttributes(template); + return template.toString(); + } + + protected void setAttributes(StringTemplate template) { + if (instruction instanceof LiteralInstruction) { + setLiteralAttributes((LiteralInstruction)instruction, template); + } + + if (instruction instanceof SingleRegisterInstruction) { + setSingleRegisterAttributes((SingleRegisterInstruction)instruction, template); + } + + if (instruction instanceof FiveRegisterInstruction) { + setFiveRegisterAttributes((FiveRegisterInstruction)instruction, template); + } + + if (instruction instanceof RegisterRangeInstruction) { + setRegisterRangeAttributes((RegisterRangeInstruction)instruction, template); + } + + if (instruction instanceof InstructionWithReference) { + setInstructionWithReferenceAttributes((InstructionWithReference)instruction, template); + } + } + + private void setLiteralAttributes(LiteralInstruction instruction, StringTemplate template) { + long literal = instruction.getLiteral(); + //TODO: do we really need to check and cast it to an int? + if (literal <= Integer.MAX_VALUE && literal >= Integer.MIN_VALUE) { + template.setAttribute("Literal", (int)literal); + } else { + template.setAttribute("Literal", literal); + } + } + + private void setSingleRegisterAttributes(SingleRegisterInstruction instruction, StringTemplate template) { + template.setAttribute("RegisterA", formatRegister(instruction.getRegisterA())); + + if (instruction instanceof TwoRegisterInstruction) { + setTwoRegisterAttributes((TwoRegisterInstruction)instruction, template); + } + } + + private void setTwoRegisterAttributes(TwoRegisterInstruction instruction, StringTemplate template) { + template.setAttribute("RegisterB", formatRegister(instruction.getRegisterB())); + + if (instruction instanceof ThreeRegisterInstruction) { + setThreeRegisterAttributes((ThreeRegisterInstruction)instruction, template); + } + } + + private void setThreeRegisterAttributes(ThreeRegisterInstruction instruction, StringTemplate template) { + template.setAttribute("RegisterC", formatRegister(instruction.getRegisterC())); + } + + private void setFiveRegisterAttributes(FiveRegisterInstruction instruction, StringTemplate template) { + switch (instruction.getRegCount()) { + case 1: + template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); + return; + case 2: + template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); + return; + case 3: + template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); + return; + case 4: + template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); + return; + case 5: + template.setAttribute("Registers", formatRegister(instruction.getRegisterD())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterE())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterF())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterG())); + template.setAttribute("Registers", formatRegister(instruction.getRegisterA())); + } + } + + private void setRegisterRangeAttributes(RegisterRangeInstruction instruction, StringTemplate template) { + String[] registers = RegisterFormatter.formatFormat3rcRegisters(codeItem, instruction.getStartRegister(), + instruction.getStartRegister() + instruction.getRegCount() - 1); + + template.setAttribute("StartRegister", registers[0]); + template.setAttribute("LastRegister", registers[1]); + } + + private void setInstructionWithReferenceAttributes(InstructionWithReference instruction, StringTemplate template) { + template.setAttribute("Reference", Reference.createReference(template.getGroup(), + instruction.getReferencedItem())); + } +} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java new file mode 100644 index 00000000..40052b5b --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItemFactory.java @@ -0,0 +1,39 @@ +package org.jf.baksmali.Adaptors.Format; + +import org.antlr.stringtemplate.StringTemplateGroup; +import org.jf.baksmali.Adaptors.MethodDefinition; +import org.jf.dexlib.Code.Format.*; +import org.jf.dexlib.Code.Instruction; +import org.jf.dexlib.Code.OffsetInstruction; +import org.jf.dexlib.CodeItem; + +public class InstructionMethodItemFactory { + private InstructionMethodItemFactory() { + } + + public static InstructionMethodItem makeInstructionFormatMethodItem(MethodDefinition methodDefinition, + CodeItem codeItem, + int codeAddress, + StringTemplateGroup stg, + Instruction instruction) { + + if (instruction instanceof OffsetInstruction) { + return new OffsetInstructionFormatMethodItem(methodDefinition.getLabelCache(), codeItem, codeAddress, stg, + instruction); + } + + switch (instruction.getFormat()) { + case ArrayData: + return new ArrayDataMethodItem(codeItem, codeAddress, stg, + (ArrayDataPseudoInstruction)instruction); + case PackedSwitchData: + return new PackedSwitchMethodItem(methodDefinition, codeItem, codeAddress, stg, + (PackedSwitchDataPseudoInstruction)instruction); + case SparseSwitchData: + return new SparseSwitchMethodItem(methodDefinition, codeItem, codeAddress, stg, + (SparseSwitchDataPseudoInstruction)instruction); + default: + return new InstructionMethodItem(codeItem, codeAddress, stg, instruction); + } + } +} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OdexInstructionMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OdexInstructionMethodItem.java new file mode 100644 index 00000000..f3e07b87 --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OdexInstructionMethodItem.java @@ -0,0 +1,21 @@ +package org.jf.baksmali.Adaptors.Format; + +import org.antlr.stringtemplate.StringTemplateGroup; +import org.jf.dexlib.Code.Instruction; +import org.jf.dexlib.CodeItem; + +public class OdexInstructionMethodItem extends InstructionMethodItem { + protected Instruction fixedInstruction = null; + + public OdexInstructionMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, T ins) { + super(codeItem, codeAddress, stg, ins); + } + + public Instruction getFixedInstruction() { + return fixedInstruction; + } + + public void setFixedInstruction(Instruction fixedInstruction) { + this.fixedInstruction = fixedInstruction; + } +} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java index f0724444..adbd9780 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/OffsetInstructionFormatMethodItem.java @@ -28,6 +28,7 @@ package org.jf.baksmali.Adaptors.Format; +import org.jf.dexlib.Code.Opcode; import org.jf.dexlib.CodeItem; import org.jf.dexlib.Code.Instruction; import org.jf.dexlib.Code.OffsetInstruction; @@ -36,8 +37,8 @@ import org.jf.baksmali.Adaptors.MethodDefinition; import org.antlr.stringtemplate.StringTemplateGroup; import org.antlr.stringtemplate.StringTemplate; -public abstract class OffsetInstructionFormatMethodItem - extends InstructionFormatMethodItem { +public class OffsetInstructionFormatMethodItem + extends InstructionMethodItem { protected LabelMethodItem label; public OffsetInstructionFormatMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, @@ -46,15 +47,39 @@ public abstract class OffsetInstructionFormatMethodItem +public class PackedSwitchMethodItem extends InstructionMethodItem implements Iterable { - private List labels = new ArrayList(); + private List labels; - public PackedSwitchMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, - StringTemplateGroup stg, PackedSwitchDataPseudoInstruction instruction, - int baseCodeAddress) { + public PackedSwitchMethodItem(MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress, + StringTemplateGroup stg, PackedSwitchDataPseudoInstruction instruction) { super(codeItem, codeAddress, stg, instruction); + int baseCodeAddress = methodDefinition.getPackedSwitchBaseAddress(codeAddress); + + labels = new ArrayList(); Iterator iterator = instruction.iterateKeysAndTargets(); while (iterator.hasNext()) { PackedSwitchDataPseudoInstruction.PackedSwitchTarget target = iterator.next(); LabelMethodItem label = new LabelMethodItem(baseCodeAddress + target.targetAddressOffset, stg, "pswitch_"); - label = labelCache.internLabel(label); + label = methodDefinition.getLabelCache().internLabel(label); labels.add(label); + label.setUncommented(); } } diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java index 25b5abc5..322506fc 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/SparseSwitchMethodItem.java @@ -30,34 +30,36 @@ package org.jf.baksmali.Adaptors.Format; import org.antlr.stringtemplate.StringTemplate; import org.antlr.stringtemplate.StringTemplateGroup; +import org.jf.baksmali.Adaptors.MethodDefinition; import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction; import org.jf.dexlib.CodeItem; import org.jf.baksmali.Adaptors.LabelMethodItem; -import org.jf.baksmali.Adaptors.MethodDefinition; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class SparseSwitchMethodItem extends InstructionFormatMethodItem +public class SparseSwitchMethodItem extends InstructionMethodItem implements Iterable { - private List targets = new ArrayList(); + private List targets = null; - public SparseSwitchMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int targetAddressOffset, - StringTemplateGroup stg, SparseSwitchDataPseudoInstruction instruction, - int baseAddress) { - super(codeItem, targetAddressOffset, stg, instruction); + public SparseSwitchMethodItem(MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress, + StringTemplateGroup stg, SparseSwitchDataPseudoInstruction instruction) { + super(codeItem, codeAddress, stg, instruction); + int baseCodeAddress = methodDefinition.getSparseSwitchBaseAddress(codeAddress); + targets = new ArrayList(); Iterator iterator = instruction.iterateKeysAndTargets(); while (iterator.hasNext()) { SparseSwitchDataPseudoInstruction.SparseSwitchTarget target = iterator.next(); SparseSwitchTarget sparseSwitchTarget = new SparseSwitchTarget(); sparseSwitchTarget.Key = target.key; - LabelMethodItem label = new LabelMethodItem(baseAddress + target.targetAddressOffset, stg, "sswitch_"); - label = labelCache.internLabel(label); + LabelMethodItem label = new LabelMethodItem(baseCodeAddress + target.targetAddressOffset, stg, "sswitch_"); + label = methodDefinition.getLabelCache().internLabel(label); sparseSwitchTarget.Target = label; + label.setUncommented(); targets.add(sparseSwitchTarget); } diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedNullReferenceMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedNullReferenceMethodItem.java deleted file mode 100644 index c6af01dd..00000000 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/UnresolvedNullReferenceMethodItem.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * [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.jf.baksmali.Adaptors.Format; - -import org.jf.dexlib.Code.Format.UnresolvedNullReference; -import org.jf.dexlib.CodeItem; -import org.antlr.stringtemplate.StringTemplateGroup; -import org.antlr.stringtemplate.StringTemplate; - -public class UnresolvedNullReferenceMethodItem extends InstructionFormatMethodItem { - private boolean isLastInstruction; - - public boolean getIsLastInstruction() { - return isLastInstruction; - } - - public void setIsLastInstruction(boolean isLastInstruction) { - this.isLastInstruction = isLastInstruction; - } - - public UnresolvedNullReferenceMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, - UnresolvedNullReference instruction) { - super(codeItem, codeAddress, stg, instruction); - } - - protected void setAttributes(StringTemplate template) { - template.setAttribute("Register", formatRegister(instruction.ObjectRegisterNum)); - switch (instruction.OriginalInstruction.opcode) - { - case EXECUTE_INLINE_RANGE: - case INVOKE_VIRTUAL_QUICK_RANGE: - case INVOKE_SUPER_QUICK_RANGE: - template.setAttribute("UseInvokeRange", 1); - if (isLastInstruction) { - template.setAttribute("AddGoto", 1); - } - } - - } -} diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java index aaf2482c..7777d6ea 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodDefinition.java @@ -32,20 +32,63 @@ import org.jf.baksmali.Adaptors.Format.*; import org.jf.baksmali.baksmali; import org.jf.dexlib.*; import org.jf.dexlib.Debug.DebugInstructionIterator; -import org.jf.dexlib.Code.Format.*; import org.jf.dexlib.Code.Instruction; import org.jf.dexlib.Code.Opcode; import org.jf.dexlib.Code.OffsetInstruction; import org.jf.dexlib.Util.AccessFlags; import org.antlr.stringtemplate.StringTemplateGroup; import org.antlr.stringtemplate.StringTemplate; +import org.jf.dexlib.Util.SparseIntArray; import java.util.*; public class MethodDefinition { - public static StringTemplate createTemplate(StringTemplateGroup stg, ClassDataItem.EncodedMethod encodedMethod, - AnnotationSetItem annotationSet, - AnnotationSetRefList parameterAnnotations) { + private final StringTemplateGroup stg; + private final ClassDataItem.EncodedMethod encodedMethod; + + private final LabelCache labelCache = new LabelCache(); + + private final SparseIntArray packedSwitchMap; + private final SparseIntArray sparseSwitchMap; + private final SparseIntArray instructionMap; + + public MethodDefinition(StringTemplateGroup stg, ClassDataItem.EncodedMethod encodedMethod) { + this.stg = stg; + this.encodedMethod = encodedMethod; + + //TODO: what about try/catch blocks inside the dead code? those will need to be commented out too. ugh. + + if (encodedMethod.codeItem != null) { + Instruction[] instructions = encodedMethod.codeItem.getInstructions(); + + packedSwitchMap = new SparseIntArray(1); + sparseSwitchMap = new SparseIntArray(1); + instructionMap = new SparseIntArray(instructions.length); + + int currentCodeAddress = 0; + for (int i=0; i getAnnotations(StringTemplateGroup stg, AnnotationSetItem annotationSet) { if (annotationSet == null) { return null; @@ -151,13 +220,38 @@ public class MethodDefinition { return annotationAdaptors; } - private static List getMethodItems(DexFile dexFile, StringTemplateGroup stg, CodeItem codeItem) { + private List getMethodItems() { List methodItems = new ArrayList(); - MethodItemList methodItemList = new MethodItemList(dexFile, stg, codeItem); - methodItemList.generateMethodItemList(); + if (encodedMethod.codeItem == null) { + return methodItems; + } - for (LabelMethodItem labelMethodItem: methodItemList.labels.getLabels()) { + Instruction[] instructions = encodedMethod.codeItem.getInstructions(); + + int currentCodeAddress = 0; + for (int i=0; i instructions = new ArrayList(); - public List blanks = new ArrayList(); - public List catches = new ArrayList(); - public List debugItems = new ArrayList(); - - private HashMap packedSwitchMap = new HashMap(); - private HashMap sparseSwitchMap = new HashMap(); - - public MethodItemList(DexFile dexFile, StringTemplateGroup stg, CodeItem codeItem) { - this.dexFile = dexFile; - this.stg = stg; - this.codeItem = codeItem; + private void addTries(List methodItems) { + if (encodedMethod.codeItem == null || encodedMethod.codeItem.getTries() == null) { + return; } - public void generateMethodItemList() { - if (codeItem == null) { - return; - } + Instruction[] instructions = encodedMethod.codeItem.getInstructions(); - if (baksmali.deodexUtil != null && dexFile.isOdex()) { - List instructions = baksmali.deodexUtil.deodexerizeCode(codeItem); + for (CodeItem.TryItem tryItem: encodedMethod.codeItem.getTries()) { + int startAddress = tryItem.getStartCodeAddress(); + int endAddress = tryItem.getStartCodeAddress() + tryItem.getTryLength(); - int currentCodeAddress = 0; - for (Instruction instruction: instructions) { - if (instruction.opcode == Opcode.PACKED_SWITCH) { - Instruction31t ins = (Instruction31t)instruction; - packedSwitchMap.put(currentCodeAddress + ins.getTargetAddressOffset(), currentCodeAddress); - } else if (instruction.opcode == Opcode.SPARSE_SWITCH) { - Instruction31t ins = (Instruction31t)instruction; - sparseSwitchMap.put(currentCodeAddress + ins.getTargetAddressOffset(), currentCodeAddress); - } + /** + * The end address points to the address immediately after the end of the last + * instruction that the try block covers. We want the .catch directive and end_try + * label to be associated with the last covered instruction, so we need to get + * the address for that instruction + */ - currentCodeAddress += instruction.getSize(currentCodeAddress); - } + int index = instructionMap.get(endAddress, -1); + int lastInstructionAddress; - currentCodeAddress = 0; - for (Instruction instruction: instructions) { - addMethodItemsForInstruction(currentCodeAddress, instruction, false); - blanks.add(new BlankMethodItem(stg, currentCodeAddress)); + /** + * If we couldn't find the index, then the try block probably extends to the last instruction in the + * method, and so endAddress would be the address immediately after the end of the last instruction. + * Check to make sure this is the case, if not, throw an exception. + */ + if (index == -1) { + Instruction lastInstruction = instructions[instructions.length - 1]; + lastInstructionAddress = instructionMap.keyAt(instructionMap.size() - 1); - currentCodeAddress += instruction.getSize(currentCodeAddress); - } - - /* - * Look for the last uncommented instruction. If it is an UnresolvedNullReference, - * then set IsLastInstruction, so a goto will be added after it, to avoid validation - * issues - */ - for (int i=this.instructions.size()-1; i>=0; i--) { - MethodItem ins = this.instructions.get(i); - if (ins instanceof UnresolvedNullReferenceMethodItem) { - ((UnresolvedNullReferenceMethodItem)ins).setIsLastInstruction(true); - break; - } - - if (!(ins instanceof CommentedOutMethodItem)) { - break; - } + if (endAddress != lastInstructionAddress + lastInstruction.getSize(lastInstructionAddress)) { + throw new RuntimeException("Invalid code offset " + endAddress + " for the try block end address"); } } else { - int currentCodeAddress = 0; - for (Instruction instruction: codeItem.getInstructions()) { - if (instruction.opcode == Opcode.PACKED_SWITCH) { - OffsetInstruction offsetInstruction = (OffsetInstruction)instruction; - packedSwitchMap.put(currentCodeAddress + offsetInstruction.getTargetAddressOffset(), currentCodeAddress); - } else if (instruction.opcode == Opcode.SPARSE_SWITCH) { - OffsetInstruction offsetInstruction = (OffsetInstruction)instruction; - sparseSwitchMap.put(currentCodeAddress + offsetInstruction.getTargetAddressOffset(), currentCodeAddress); + if (index == 0) { + throw new RuntimeException("Unexpected instruction index"); + } + Instruction lastInstruction = instructions[index - 1]; + + if (lastInstruction.getFormat().variableSizeFormat) { + throw new RuntimeException("This try block unexpectedly ends on a switch/array data block."); + } + + //getSize for non-variable size formats should return the same size regardless of code address, so just + //use a dummy address of "0" + lastInstructionAddress = endAddress - lastInstruction.getSize(0); + } + + //add the catch all handler if it exists + int catchAllAddress = tryItem.encodedCatchHandler.getCatchAllHandlerAddress(); + if (catchAllAddress != -1) { + CatchMethodItem catchAllMethodItem = new CatchMethodItem(labelCache, lastInstructionAddress, stg, null, + startAddress, endAddress, catchAllAddress); + methodItems.add(catchAllMethodItem); + } + + //add the rest of the handlers + for (CodeItem.EncodedTypeAddrPair handler: tryItem.encodedCatchHandler.handlers) { + //use the address from the last covered instruction + CatchMethodItem catchMethodItem = new CatchMethodItem(labelCache, lastInstructionAddress, stg, + handler.exceptionType, startAddress, endAddress, handler.getHandlerAddress()); + methodItems.add(catchMethodItem); + } + } + } + + private void addDebugInfo(final List methodItems) { + if (encodedMethod.codeItem == null || encodedMethod.codeItem.getDebugInfo() == null) { + return; + } + + final CodeItem codeItem = encodedMethod.codeItem; + DebugInfoItem debugInfoItem = codeItem.getDebugInfo(); + + DebugInstructionIterator.DecodeInstructions(debugInfoItem, codeItem.getRegisterCount(), + new DebugInstructionIterator.ProcessDecodedDebugInstructionDelegate() { + @Override + public void ProcessStartLocal(int codeAddress, int length, int registerNum, StringIdItem name, + TypeIdItem type) { + methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "StartLocal", + -1, registerNum, name, type, null)); } - currentCodeAddress += instruction.getSize(currentCodeAddress); - } - - currentCodeAddress = 0; - for (Instruction instruction: codeItem.getInstructions()) { - addMethodItemsForInstruction(currentCodeAddress, instruction, false); - blanks.add(new BlankMethodItem(stg, currentCodeAddress)); - currentCodeAddress += instruction.getSize(currentCodeAddress); - } - - } - - blanks.remove(blanks.size()-1); - - addTries(); - - addDebugInfo(); - - if (baksmali.useSequentialLabels) { - setLabelSequentialNumbers(); - } - } - - private void addOffsetInstructionMethodItem(OffsetInstructionFormatMethodItem methodItem, - boolean commentedOut) { - if (commentedOut) { - instructions.add(new CommentedOutMethodItem(stg, methodItem)); - } else { - instructions.add(methodItem); - LabelMethodItem label = methodItem.getLabel(); - label.setUncommented(); - } - } - - - private void addInstructionMethodItem(InstructionFormatMethodItem methodItem, boolean commentedOut) { - if (commentedOut) { - instructions.add(new CommentedOutMethodItem(stg, methodItem)); - } else { - instructions.add(methodItem); - } - } - - private void addMethodItemsForInstruction(int codeAddress, Instruction instruction, boolean commentedOut) { - switch (instruction.getFormat()) { - case Format10t: - addOffsetInstructionMethodItem( - new Instruction10tMethodItem(labels, codeItem, codeAddress, stg,(Instruction10t)instruction), - commentedOut); - return; - case Format10x: - addInstructionMethodItem( - new Instruction10xMethodItem(codeItem, codeAddress, stg, (Instruction10x)instruction), - commentedOut); - return; - case Format11n: - addInstructionMethodItem( - new Instruction11nMethodItem(codeItem, codeAddress, stg, (Instruction11n)instruction), - commentedOut); - return; - case Format11x: - addInstructionMethodItem( - new Instruction11xMethodItem(codeItem, codeAddress, stg, (Instruction11x)instruction), - commentedOut); - return; - case Format12x: - addInstructionMethodItem( - new Instruction12xMethodItem(codeItem, codeAddress, stg, (Instruction12x)instruction), - commentedOut); - return; - case Format20t: - addOffsetInstructionMethodItem( - new Instruction20tMethodItem(labels, codeItem, codeAddress, stg, (Instruction20t)instruction), - commentedOut); - return; - case Format21c: - addInstructionMethodItem( - new Instruction21cMethodItem(codeItem, codeAddress, stg, (Instruction21c)instruction), - commentedOut); - return; - case Format21h: - addInstructionMethodItem( - new Instruction21hMethodItem(codeItem, codeAddress, stg, (Instruction21h)instruction), - commentedOut); - return; - case Format21s: - addInstructionMethodItem( - new Instruction21sMethodItem(codeItem, codeAddress, stg, (Instruction21s)instruction), - commentedOut); - return; - case Format21t: - addOffsetInstructionMethodItem( - new Instruction21tMethodItem(labels, codeItem, codeAddress, stg, (Instruction21t)instruction), - commentedOut); - return; - case Format22b: - addInstructionMethodItem( - new Instruction22bMethodItem(codeItem, codeAddress, stg, (Instruction22b)instruction), - commentedOut); - return; - case Format22c: - addInstructionMethodItem( - new Instruction22cMethodItem(codeItem, codeAddress, stg, (Instruction22c)instruction), - commentedOut); - return; - case Format22cs: - addInstructionMethodItem( - new Instruction22csMethodItem(codeItem, codeAddress, stg, (Instruction22cs)instruction), - commentedOut); - return; - case Format22csf: - addInstructionMethodItem( - new Instruction22csfMethodItem(codeItem, codeAddress, stg, (Instruction22csf)instruction), - commentedOut); - return; - case Format22s: - addInstructionMethodItem( - new Instruction22sMethodItem(codeItem, codeAddress, stg, (Instruction22s)instruction), - commentedOut); - return; - case Format22t: - addOffsetInstructionMethodItem( - new Instruction22tMethodItem(labels, codeItem, codeAddress, stg, (Instruction22t)instruction), - commentedOut); - return; - case Format22x: - addInstructionMethodItem( - new Instruction22xMethodItem(codeItem, codeAddress, stg, (Instruction22x)instruction), - commentedOut); - return; - case Format23x: - addInstructionMethodItem( - new Instruction23xMethodItem(codeItem, codeAddress, stg, (Instruction23x)instruction), - commentedOut); - return; - case Format30t: - addOffsetInstructionMethodItem( - new Instruction30tMethodItem(labels, codeItem, codeAddress, stg, (Instruction30t)instruction), - commentedOut); - return; - case Format31c: - addInstructionMethodItem( - new Instruction31cMethodItem(codeItem, codeAddress, stg, (Instruction31c)instruction), - commentedOut); - return; - case Format31i: - addInstructionMethodItem( - new Instruction31iMethodItem(codeItem, codeAddress, stg, (Instruction31i)instruction), - commentedOut); - return; - case Format31t: - addOffsetInstructionMethodItem( - new Instruction31tMethodItem(labels, codeItem, codeAddress, stg, (Instruction31t)instruction), - commentedOut); - return; - case Format32x: - addInstructionMethodItem( - new Instruction32xMethodItem(codeItem, codeAddress, stg, (Instruction32x)instruction), - commentedOut); - return; - case Format35c: - addInstructionMethodItem( - new Instruction35cMethodItem(codeItem, codeAddress, stg, (Instruction35c)instruction), - commentedOut); - return; - case Format35s: - addInstructionMethodItem( - new Instruction35sMethodItem(codeItem, codeAddress, stg, (Instruction35s)instruction), - commentedOut); - return; - case Format35sf: - addInstructionMethodItem( - new Instruction35sfMethodItem(codeItem, codeAddress, stg, (Instruction35sf)instruction), - commentedOut); - return; - case Format35ms: - addInstructionMethodItem( - new Instruction35msMethodItem(codeItem, codeAddress, stg, (Instruction35ms)instruction), - commentedOut); - return; - case Format35msf: - addInstructionMethodItem( - new Instruction35msfMethodItem(codeItem, codeAddress, stg, (Instruction35msf)instruction), - commentedOut); - return; - case Format3rc: - addInstructionMethodItem( - new Instruction3rcMethodItem(codeItem, codeAddress, stg, (Instruction3rc)instruction), - commentedOut); - return; - case Format3rms: - addInstructionMethodItem( - new Instruction3rmsMethodItem(codeItem, codeAddress, stg, (Instruction3rms)instruction), - commentedOut); - return; - case Format3rmsf: - addInstructionMethodItem( - new Instruction3rmsfMethodItem(codeItem, codeAddress, stg, (Instruction3rmsf)instruction), - commentedOut); - return; - case Format51l: - addInstructionMethodItem( - new Instruction51lMethodItem(codeItem, codeAddress, stg, (Instruction51l)instruction), - commentedOut); - return; - case ArrayData: - addInstructionMethodItem( - new ArrayDataMethodItem(codeItem, codeAddress, stg, (ArrayDataPseudoInstruction)instruction), - commentedOut); - return; - case PackedSwitchData: - { - final Integer baseAddress = packedSwitchMap.get(codeAddress); - - if (baseAddress != null) { - PackedSwitchDataPseudoInstruction packedSwitchInstruction = - (PackedSwitchDataPseudoInstruction)instruction; - - PackedSwitchMethodItem packedSwitch = new PackedSwitchMethodItem(labels, codeItem, codeAddress, stg, - packedSwitchInstruction, baseAddress); - addInstructionMethodItem(packedSwitch, commentedOut); - - if (!commentedOut) { - for (LabelMethodItem label: packedSwitch) { - label.setUncommented(); - } - } + @Override + public void ProcessStartLocalExtended(int codeAddress, int length, int registerNum, + StringIdItem name, TypeIdItem type, + StringIdItem signature) { + methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "StartLocal", + -1, registerNum, name, type, signature)); } - return; - } - case SparseSwitchData: - { - final Integer baseAddress = sparseSwitchMap.get(codeAddress); - if (baseAddress != null) { - SparseSwitchDataPseudoInstruction sparseSwitchInstruction = - (SparseSwitchDataPseudoInstruction)instruction; - - SparseSwitchMethodItem sparseSwitch = new SparseSwitchMethodItem(labels, codeItem, codeAddress, stg, - sparseSwitchInstruction, baseAddress); - addInstructionMethodItem(sparseSwitch, commentedOut); - - if (!commentedOut) { - for (LabelMethodItem label: sparseSwitch) { - label.setUncommented(); - } - } + @Override + public void ProcessEndLocal(int codeAddress, int length, int registerNum, StringIdItem name, + TypeIdItem type, StringIdItem signature) { + methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "EndLocal", -1, + registerNum, name, type, signature)); } - return; - } - case UnresolvedNullReference: - { - addInstructionMethodItem(new UnresolvedNullReferenceMethodItem(codeItem, codeAddress, stg, - (UnresolvedNullReference)instruction), commentedOut); - addMethodItemsForInstruction(codeAddress, ((UnresolvedNullReference)instruction).OriginalInstruction, - true); - return; - } - case DeadInstruction: - { - //TODO: what about try/catch blocks inside the dead code? those will need to be commented out too. ugh. - addMethodItemsForInstruction(codeAddress, ((DeadInstruction)instruction).OriginalInstruction, true); - return; - } - } - } - private void addTries() { - if (codeItem.getTries() == null) { - return; - } - for (CodeItem.TryItem tryItem: codeItem.getTries()) { - int startAddress = tryItem.getStartCodeAddress(); - int endAddress = tryItem.getStartCodeAddress() + tryItem.getTryLength(); - - /** - * The end address points to the address immediately after the end of the last - * instruction that the try block covers. We want the .catch directive and end_try - * label to be associated with the last covered instruction, so we need to get - * the address for that instruction - */ - int index = Collections.binarySearch(instructions, new BlankMethodItem(stg, endAddress)); - if (index < 0) { - index = (index * -1) - 1; - } - //index should never be 0, so this should be safe - if (index == instructions.size()) { - //if the end address is the same as the address of the last instruction, then - //this try item ends at the next to last instruction. - //otherwise, if the end address is past the address of the last instruction, - //thin this try item ends at the last instruction - if (instructions.get(instructions.size() - 1).getCodeAddress() == endAddress) { - //get the address for the next to last instruction - index -= 2; - } else { - //get the address for the last instruction - index--; - } - } else { - index -= 2; - } - - int lastInstructionAddress = instructions.get(index).getCodeAddress(); - - //add the catch all handler if it exists - int catchAllAddress = tryItem.encodedCatchHandler.getCatchAllHandlerAddress(); - if (catchAllAddress != -1) { - CatchMethodItem catchMethodItem = new CatchMethodItem(labels, lastInstructionAddress, stg, null, - startAddress, endAddress, catchAllAddress); - catches.add(catchMethodItem); - } - - //add the rest of the handlers - for (CodeItem.EncodedTypeAddrPair handler: tryItem.encodedCatchHandler.handlers) { - //use the address from the last covered instruction - CatchMethodItem catchMethodItem = new CatchMethodItem(labels, lastInstructionAddress, stg, - handler.exceptionType, startAddress, endAddress, handler.getHandlerAddress()); - catches.add(catchMethodItem); - } - } - } - - private void addDebugInfo() { - DebugInfoItem debugInfoItem = codeItem.getDebugInfo(); - if (debugInfoItem == null) { - return; - } - - DebugInstructionIterator.DecodeInstructions(debugInfoItem, codeItem.getRegisterCount(), - new DebugInstructionIterator.ProcessDecodedDebugInstructionDelegate() { - @Override - public void ProcessStartLocal(int codeAddress, int length, int registerNum, StringIdItem name, - TypeIdItem type) { - debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "StartLocal", -1, - registerNum, name, type, null)); - } - - @Override - public void ProcessStartLocalExtended(int codeAddress, int length, int registerNum, - StringIdItem name, TypeIdItem type, - StringIdItem signature) { - debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "StartLocal", -1, - registerNum, name, type, signature)); - } - - @Override - public void ProcessEndLocal(int codeAddress, int length, int registerNum, StringIdItem name, + @Override + public void ProcessRestartLocal(int codeAddress, int length, int registerNum, StringIdItem name, TypeIdItem type, StringIdItem signature) { - debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "EndLocal", -1, - registerNum, name, type, signature)); - } + methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "RestartLocal", -1, + registerNum, name, type, signature)); + } - @Override - public void ProcessRestartLocal(int codeAddress, int length, int registerNum, StringIdItem name, - TypeIdItem type, StringIdItem signature) { - debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "RestartLocal", -1, - registerNum, name, type, signature)); - } + @Override + public void ProcessSetPrologueEnd(int codeAddress) { + methodItems.add(new DebugMethodItem(codeAddress, stg, "EndPrologue", -4)); + } - @Override - public void ProcessSetPrologueEnd(int codeAddress) { - debugItems.add(new DebugMethodItem(codeAddress, stg, "EndPrologue", -4)); - } + @Override + public void ProcessSetEpilogueBegin(int codeAddress) { + methodItems.add(new DebugMethodItem(codeAddress, stg, "StartEpilogue", -4)); + } - @Override - public void ProcessSetEpilogueBegin(int codeAddress) { - debugItems.add(new DebugMethodItem(codeAddress, stg, "StartEpilogue", -4)); - } + @Override + public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) { + methodItems.add(new DebugMethodItem(codeAddress, stg, "SetFile", -3) { + @Override + protected void setAttributes(StringTemplate template) { + template.setAttribute("FileName", name.getStringValue()); + } + }); + } - @Override - public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) { - debugItems.add(new DebugMethodItem(codeAddress, stg, "SetFile", -3) { - @Override - protected void setAttributes(StringTemplate template) { - template.setAttribute("FileName", name.getStringValue()); - } - }); - } + @Override + public void ProcessLineEmit(int codeAddress, final int line) { + methodItems.add(new DebugMethodItem(codeAddress, stg, "Line", -2) { + @Override + protected void setAttributes(StringTemplate template) { + template.setAttribute("Line", line); + } + }); + } + }); + } - @Override - public void ProcessLineEmit(int codeAddress, final int line) { - debugItems.add(new DebugMethodItem(codeAddress, stg, "Line", -2) { - @Override - protected void setAttributes(StringTemplate template) { - template.setAttribute("Line", line); - } - }); - } - }); - } + private void setLabelSequentialNumbers() { + HashMap nextLabelSequenceByType = new HashMap(); + ArrayList sortedLabels = new ArrayList(labelCache.getLabels()); - private void setLabelSequentialNumbers() { - HashMap nextLabelSequenceByType = new HashMap(); - ArrayList sortedLabels = new ArrayList(labels.getLabels()); + //sort the labels by their location in the method + Collections.sort(sortedLabels); - //sort the labels by their location in the method - Collections.sort(sortedLabels); - - for (LabelMethodItem labelMethodItem: sortedLabels) { - Integer labelSequence = nextLabelSequenceByType.get(labelMethodItem.getLabelPrefix()); - if (labelSequence == null) { - labelSequence = 0; - } - labelMethodItem.setLabelSequence(labelSequence); - nextLabelSequenceByType.put(labelMethodItem.getLabelPrefix(), labelSequence + 1); + for (LabelMethodItem labelMethodItem: sortedLabels) { + Integer labelSequence = nextLabelSequenceByType.get(labelMethodItem.getLabelPrefix()); + if (labelSequence == null) { + labelSequence = 0; } + labelMethodItem.setLabelSequence(labelSequence); + nextLabelSequenceByType.put(labelMethodItem.getLabelPrefix(), labelSequence + 1); } } diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java index 0859aa2f..2a570fda 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/MethodItem.java @@ -29,7 +29,7 @@ package org.jf.baksmali.Adaptors; public abstract class MethodItem implements Comparable { - private int codeAddress; + protected final int codeAddress; protected MethodItem(int codeAddress) { this.codeAddress = codeAddress; diff --git a/baksmali/src/main/java/org/jf/baksmali/Analysis/Analysis.java b/baksmali/src/main/java/org/jf/baksmali/Analysis/Analysis.java new file mode 100644 index 00000000..9f80e15c --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Analysis/Analysis.java @@ -0,0 +1,4 @@ +package org.jf.baksmali.Analysis; + +public class Analysis { +} diff --git a/baksmali/src/main/java/org/jf/baksmali/Analysis/AnalysisInstruction.java b/baksmali/src/main/java/org/jf/baksmali/Analysis/AnalysisInstruction.java new file mode 100644 index 00000000..d36be25e --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Analysis/AnalysisInstruction.java @@ -0,0 +1,5 @@ +package org.jf.baksmali.Analysis; + +public interface AnalysisInstruction { + +} diff --git a/baksmali/src/main/java/org/jf/baksmali/Deodex/DeodexUtil2.java b/baksmali/src/main/java/org/jf/baksmali/Deodex/DeodexUtil2.java new file mode 100644 index 00000000..82b1364d --- /dev/null +++ b/baksmali/src/main/java/org/jf/baksmali/Deodex/DeodexUtil2.java @@ -0,0 +1,4 @@ +package org.jf.baksmali.Deodex; + +public class DeodexUtil2 { +} diff --git a/baksmali/src/main/resources/templates/templates/baksmali.stg b/baksmali/src/main/resources/templates/templates/baksmali.stg index 2fa46ef8..55084034 100644 --- a/baksmali/src/main/resources/templates/templates/baksmali.stg +++ b/baksmali/src/main/resources/templates/templates/baksmali.stg @@ -133,14 +133,14 @@ Format10x(Opcode) ::= >> -Format11n(Opcode, Register, Literal) ::= +Format11n(Opcode, RegisterA, Literal) ::= << - , + , >> -Format11x(Opcode, Register) ::= +Format11x(Opcode, RegisterA) ::= << - + >> Format12x(Opcode, RegisterA, RegisterB) ::= @@ -153,24 +153,24 @@ Format20t(Opcode, TargetLabel) ::= >> -Format21c(Opcode, Register, Reference) ::= +Format21c(Opcode, RegisterA, Reference) ::= << - , + , >> -Format21h(Opcode, Register, Literal) ::= +Format21h(Opcode, RegisterA, Literal) ::= << - , + , >> -Format21s(Opcode, Register, Literal) ::= +Format21s(Opcode, RegisterA, Literal) ::= << - , + , >> -Format21t(Opcode, Register, TargetLabel) ::= +Format21t(Opcode, RegisterA, TargetLabel) ::= << - , + , >> Format22b(Opcode, RegisterA, RegisterB, Literal) ::= @@ -218,19 +218,19 @@ Format30t(Opcode, TargetLabel) ::= >> -Format31c(Opcode, Register, Reference) ::= +Format31c(Opcode, RegisterA, Reference) ::= << - , + , >> -Format31i(Opcode, Register, Literal) ::= +Format31i(Opcode, RegisterA, Literal) ::= << - , + , >> -Format31t(Opcode, Register, TargetLabel) ::= +Format31t(Opcode, RegisterA, TargetLabel) ::= << - , + , >> Format32x(Opcode, RegisterA, RegisterB) ::= @@ -278,9 +278,9 @@ Format3rmsf(Opcode, StartRegister, LastRegister, Reference) ::= { .. }, >> -Format51l(Opcode, Register, Literal) ::= +Format51l(Opcode, RegisterA, Literal) ::= << - , + , >> CommentedOutMethodItem(MethodItem) ::=