deodex refactoring part 1

Significantly simplified how instructions are handled in baksmali. Normal
disassembly seems to be working, deodexing definitely not.

git-svn-id: https://smali.googlecode.com/svn/trunk@561 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2010-01-12 08:10:23 +00:00
parent 575bd4ce54
commit b2e1e2067d
48 changed files with 568 additions and 2365 deletions

View File

@ -245,30 +245,33 @@ public class ClassDefinition {
} }
private List<StringTemplate> getDirectMethods() { private List<StringTemplate> getDirectMethods() {
List<StringTemplate> directMethods = new ArrayList<StringTemplate>(); if (classDataItem == null) {
return null;
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));
}
} }
return directMethods; return getTemplatesForMethods(classDataItem.getDirectMethods());
} }
private List<StringTemplate> getVirtualMethods() { private List<StringTemplate> getVirtualMethods() {
List<StringTemplate> virtualMethods = new ArrayList<StringTemplate>(); if (classDataItem == null) {
return null;
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));
}
} }
return virtualMethods; return getTemplatesForMethods(classDataItem.getVirtualMethods());
}
private List<StringTemplate> getTemplatesForMethods(ClassDataItem.EncodedMethod[] methods) {
List<StringTemplate> methodTemplates = new ArrayList<StringTemplate>();
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;
} }
} }

View File

@ -35,7 +35,7 @@ import org.jf.dexlib.CodeItem;
import java.util.Iterator; import java.util.Iterator;
public class ArrayDataMethodItem extends InstructionFormatMethodItem<ArrayDataPseudoInstruction> { public class ArrayDataMethodItem extends InstructionMethodItem<ArrayDataPseudoInstruction> {
public ArrayDataMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg, public ArrayDataMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg,
ArrayDataPseudoInstruction instruction) { ArrayDataPseudoInstruction instruction) {
super(codeItem, codeAddress, stg, instruction); super(codeItem, codeAddress, stg, instruction);

View File

@ -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<Instruction10t> {
public Instruction10tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress,
StringTemplateGroup stg, Instruction10t instruction) {
super(labelCache, codeItem, codeAddress, stg, instruction);
}
protected String getLabelPrefix() {
return "goto_";
}
}

View File

@ -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<Instruction10x> {
public Instruction10xMethodItem(CodeItem codeItem, int codeAddress, StringTemplateGroup stg,
Instruction10x instruction) {
super(codeItem, codeAddress, stg, instruction);
}
protected void setAttributes(StringTemplate template) {
}
}

View File

@ -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<Instruction11n> {
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());
}
}

View File

@ -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<Instruction11x> {
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()));
}
}

View File

@ -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<Instruction12x> {
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()));
}
}

View File

@ -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<Instruction20t> {
public Instruction20tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress,
StringTemplateGroup stg, Instruction20t instruction) {
super(labelCache, codeItem, codeAddress, stg, instruction);
}
protected String getLabelPrefix() {
return "goto_";
}
}

View File

@ -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<Instruction21c> {
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()));
}
}

View File

@ -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<Instruction21h> {
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());
}
}

View File

@ -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<Instruction21s> {
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());
}
}

View File

@ -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<Instruction21t> {
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_";
}
}

View File

@ -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<Instruction22b> {
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());
}
}

View File

@ -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<Instruction22c> {
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()));
}
}

View File

@ -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<Instruction22cs> {
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()));
}
}

View File

@ -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<Instruction22csf> {
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()));
}
}

View File

@ -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<Instruction22s> {
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());
}
}

View File

@ -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<Instruction22t> {
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_";
}
}

View File

@ -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<Instruction22x> {
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()));
}
}

View File

@ -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<Instruction23x> {
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()));
}
}

View File

@ -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<Instruction30t> {
public Instruction30tMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress,
StringTemplateGroup stg, Instruction30t instruction) {
super(labelCache, codeItem, codeAddress, stg, instruction);
}
protected String getLabelPrefix() {
return "goto_";
}
}

View File

@ -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<Instruction31c> {
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()));
}
}

View File

@ -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<Instruction31i> {
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());
}
}

View File

@ -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<Instruction31t> {
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_";
}
}

View File

@ -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<Instruction32x> {
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()));
}
}

View File

@ -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<Instruction35c> {
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()));
}
}
}

View File

@ -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<Instruction35ms> {
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()));
}
}
}

View File

@ -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<Instruction35msf> {
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()));
}
}
}

View File

@ -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<Instruction35s> {
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()));
}
}
}

View File

@ -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<Instruction35sf> {
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()));
}
}
}

View File

@ -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<Instruction3rc> {
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]);
}
}

View File

@ -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<Instruction3rms> {
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]);
}
}

View File

@ -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<Instruction3rmsf> {
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]);
}
}

View File

@ -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<Instruction51l> {
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());
}
}
}

View File

@ -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<T extends Instruction> 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);
}

View File

@ -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<T extends Instruction> extends MethodItem {
protected final CodeItem codeItem;
protected final StringTemplateGroup stg;
protected final T instruction;
/**
* Instructions that execution could pass on to next
*/
private LinkedList<InstructionMethodItem> successors = new LinkedList<InstructionMethodItem>();
/**
* Instructions that can pass on execution to this one
*/
private LinkedList<InstructionMethodItem> predecessors = new LinkedList<InstructionMethodItem>();
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()));
}
}

View File

@ -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);
}
}
}

View File

@ -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<T extends Instruction> extends InstructionMethodItem<T> {
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;
}
}

View File

@ -28,6 +28,7 @@
package org.jf.baksmali.Adaptors.Format; package org.jf.baksmali.Adaptors.Format;
import org.jf.dexlib.Code.Opcode;
import org.jf.dexlib.CodeItem; import org.jf.dexlib.CodeItem;
import org.jf.dexlib.Code.Instruction; import org.jf.dexlib.Code.Instruction;
import org.jf.dexlib.Code.OffsetInstruction; 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.StringTemplateGroup;
import org.antlr.stringtemplate.StringTemplate; import org.antlr.stringtemplate.StringTemplate;
public abstract class OffsetInstructionFormatMethodItem<T extends Instruction & OffsetInstruction> public class OffsetInstructionFormatMethodItem<T extends Instruction & OffsetInstruction>
extends InstructionFormatMethodItem<T> { extends InstructionMethodItem<T> {
protected LabelMethodItem label; protected LabelMethodItem label;
public OffsetInstructionFormatMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, public OffsetInstructionFormatMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress,
@ -46,15 +47,39 @@ public abstract class OffsetInstructionFormatMethodItem<T extends Instruction &
label = new LabelMethodItem(codeAddress + instruction.getTargetAddressOffset(), stg, getLabelPrefix()); label = new LabelMethodItem(codeAddress + instruction.getTargetAddressOffset(), stg, getLabelPrefix());
label = labelCache.internLabel(label); label = labelCache.internLabel(label);
label.setUncommented();
} }
protected abstract String getLabelPrefix();
protected void setAttributes(StringTemplate template) { protected void setAttributes(StringTemplate template) {
template.setAttribute("TargetLabel", label); template.setAttribute("TargetLabel", label);
super.setAttributes(template);
} }
public LabelMethodItem getLabel() { public LabelMethodItem getLabel() {
return label; return label;
} }
private String getLabelPrefix() {
switch (instruction.getFormat()) {
case Format10t:
case Format20t:
case Format30t:
return "goto_";
case Format21t:
case Format22t:
return "cond_";
case Format31t:
if (instruction.opcode == Opcode.FILL_ARRAY_DATA) {
return "array_";
}
if (instruction.opcode == Opcode.PACKED_SWITCH) {
return "pswitch_data_";
}
assert instruction.opcode == Opcode.SPARSE_SWITCH;
return "sswitch_data_";
}
assert false;
return null;
}
} }

View File

@ -39,21 +39,24 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class PackedSwitchMethodItem extends InstructionFormatMethodItem<PackedSwitchDataPseudoInstruction> public class PackedSwitchMethodItem extends InstructionMethodItem<PackedSwitchDataPseudoInstruction>
implements Iterable<LabelMethodItem> { implements Iterable<LabelMethodItem> {
private List<LabelMethodItem> labels = new ArrayList<LabelMethodItem>(); private List<LabelMethodItem> labels;
public PackedSwitchMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int codeAddress, public PackedSwitchMethodItem(MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress,
StringTemplateGroup stg, PackedSwitchDataPseudoInstruction instruction, StringTemplateGroup stg, PackedSwitchDataPseudoInstruction instruction) {
int baseCodeAddress) {
super(codeItem, codeAddress, stg, instruction); super(codeItem, codeAddress, stg, instruction);
int baseCodeAddress = methodDefinition.getPackedSwitchBaseAddress(codeAddress);
labels = new ArrayList<LabelMethodItem>();
Iterator<PackedSwitchDataPseudoInstruction.PackedSwitchTarget> iterator = instruction.iterateKeysAndTargets(); Iterator<PackedSwitchDataPseudoInstruction.PackedSwitchTarget> iterator = instruction.iterateKeysAndTargets();
while (iterator.hasNext()) { while (iterator.hasNext()) {
PackedSwitchDataPseudoInstruction.PackedSwitchTarget target = iterator.next(); PackedSwitchDataPseudoInstruction.PackedSwitchTarget target = iterator.next();
LabelMethodItem label = new LabelMethodItem(baseCodeAddress + target.targetAddressOffset, stg, "pswitch_"); LabelMethodItem label = new LabelMethodItem(baseCodeAddress + target.targetAddressOffset, stg, "pswitch_");
label = labelCache.internLabel(label); label = methodDefinition.getLabelCache().internLabel(label);
labels.add(label); labels.add(label);
label.setUncommented();
} }
} }

View File

@ -30,34 +30,36 @@ package org.jf.baksmali.Adaptors.Format;
import org.antlr.stringtemplate.StringTemplate; import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup; import org.antlr.stringtemplate.StringTemplateGroup;
import org.jf.baksmali.Adaptors.MethodDefinition;
import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction; import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction;
import org.jf.dexlib.CodeItem; import org.jf.dexlib.CodeItem;
import org.jf.baksmali.Adaptors.LabelMethodItem; import org.jf.baksmali.Adaptors.LabelMethodItem;
import org.jf.baksmali.Adaptors.MethodDefinition;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class SparseSwitchMethodItem extends InstructionFormatMethodItem<SparseSwitchDataPseudoInstruction> public class SparseSwitchMethodItem extends InstructionMethodItem<SparseSwitchDataPseudoInstruction>
implements Iterable<LabelMethodItem> { implements Iterable<LabelMethodItem> {
private List<SparseSwitchTarget> targets = new ArrayList<SparseSwitchTarget>(); private List<SparseSwitchTarget> targets = null;
public SparseSwitchMethodItem(MethodDefinition.LabelCache labelCache, CodeItem codeItem, int targetAddressOffset, public SparseSwitchMethodItem(MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress,
StringTemplateGroup stg, SparseSwitchDataPseudoInstruction instruction, StringTemplateGroup stg, SparseSwitchDataPseudoInstruction instruction) {
int baseAddress) { super(codeItem, codeAddress, stg, instruction);
super(codeItem, targetAddressOffset, stg, instruction);
int baseCodeAddress = methodDefinition.getSparseSwitchBaseAddress(codeAddress);
targets = new ArrayList<SparseSwitchTarget>();
Iterator<SparseSwitchDataPseudoInstruction.SparseSwitchTarget> iterator = instruction.iterateKeysAndTargets(); Iterator<SparseSwitchDataPseudoInstruction.SparseSwitchTarget> iterator = instruction.iterateKeysAndTargets();
while (iterator.hasNext()) { while (iterator.hasNext()) {
SparseSwitchDataPseudoInstruction.SparseSwitchTarget target = iterator.next(); SparseSwitchDataPseudoInstruction.SparseSwitchTarget target = iterator.next();
SparseSwitchTarget sparseSwitchTarget = new SparseSwitchTarget(); SparseSwitchTarget sparseSwitchTarget = new SparseSwitchTarget();
sparseSwitchTarget.Key = target.key; sparseSwitchTarget.Key = target.key;
LabelMethodItem label = new LabelMethodItem(baseAddress + target.targetAddressOffset, stg, "sswitch_"); LabelMethodItem label = new LabelMethodItem(baseCodeAddress + target.targetAddressOffset, stg, "sswitch_");
label = labelCache.internLabel(label); label = methodDefinition.getLabelCache().internLabel(label);
sparseSwitchTarget.Target = label; sparseSwitchTarget.Target = label;
label.setUncommented();
targets.add(sparseSwitchTarget); targets.add(sparseSwitchTarget);
} }

View File

@ -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<UnresolvedNullReference> {
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);
}
}
}
}

View File

@ -32,20 +32,63 @@ import org.jf.baksmali.Adaptors.Format.*;
import org.jf.baksmali.baksmali; import org.jf.baksmali.baksmali;
import org.jf.dexlib.*; import org.jf.dexlib.*;
import org.jf.dexlib.Debug.DebugInstructionIterator; import org.jf.dexlib.Debug.DebugInstructionIterator;
import org.jf.dexlib.Code.Format.*;
import org.jf.dexlib.Code.Instruction; import org.jf.dexlib.Code.Instruction;
import org.jf.dexlib.Code.Opcode; import org.jf.dexlib.Code.Opcode;
import org.jf.dexlib.Code.OffsetInstruction; import org.jf.dexlib.Code.OffsetInstruction;
import org.jf.dexlib.Util.AccessFlags; import org.jf.dexlib.Util.AccessFlags;
import org.antlr.stringtemplate.StringTemplateGroup; import org.antlr.stringtemplate.StringTemplateGroup;
import org.antlr.stringtemplate.StringTemplate; import org.antlr.stringtemplate.StringTemplate;
import org.jf.dexlib.Util.SparseIntArray;
import java.util.*; import java.util.*;
public class MethodDefinition { public class MethodDefinition {
public static StringTemplate createTemplate(StringTemplateGroup stg, ClassDataItem.EncodedMethod encodedMethod, private final StringTemplateGroup stg;
AnnotationSetItem annotationSet, private final ClassDataItem.EncodedMethod encodedMethod;
AnnotationSetRefList parameterAnnotations) {
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<instructions.length; i++) {
Instruction instruction = instructions[i];
if (instruction.opcode == Opcode.PACKED_SWITCH) {
packedSwitchMap.append(
currentCodeAddress + ((OffsetInstruction)instruction).getTargetAddressOffset(),
currentCodeAddress);
} else if (instruction.opcode == Opcode.SPARSE_SWITCH) {
sparseSwitchMap.append(
currentCodeAddress + ((OffsetInstruction)instruction).getTargetAddressOffset(),
currentCodeAddress);
}
instructionMap.append(currentCodeAddress, i);
currentCodeAddress += instruction.getSize(currentCodeAddress);
}
} else {
packedSwitchMap = null;
sparseSwitchMap = null;
instructionMap = null;
}
}
public StringTemplate createTemplate(AnnotationSetItem annotationSet,
AnnotationSetRefList parameterAnnotations) {
CodeItem codeItem = encodedMethod.codeItem; CodeItem codeItem = encodedMethod.codeItem;
@ -59,7 +102,7 @@ public class MethodDefinition {
template.setAttribute("RegisterCount", codeItem==null?"0":Integer.toString(getRegisterCount(encodedMethod))); template.setAttribute("RegisterCount", codeItem==null?"0":Integer.toString(getRegisterCount(encodedMethod)));
template.setAttribute("Parameters", getParameters(stg, codeItem, parameterAnnotations)); template.setAttribute("Parameters", getParameters(stg, codeItem, parameterAnnotations));
template.setAttribute("Annotations", getAnnotations(stg, annotationSet)); template.setAttribute("Annotations", getAnnotations(stg, annotationSet));
template.setAttribute("MethodItems", getMethodItems(encodedMethod.method.getDexFile(), stg, codeItem)); template.setAttribute("MethodItems", getMethodItems());
return template; return template;
} }
@ -138,6 +181,32 @@ public class MethodDefinition {
return parameters; return parameters;
} }
public LabelCache getLabelCache() {
return labelCache;
}
public int getPackedSwitchBaseAddress(int packedSwitchDataAddress) {
int packedSwitchBaseAddress = this.packedSwitchMap.get(packedSwitchDataAddress, -1);
if (packedSwitchBaseAddress == -1) {
throw new RuntimeException("Could not find the packed switch statement corresponding to the packed " +
"switch data at address " + packedSwitchDataAddress);
}
return packedSwitchBaseAddress;
}
public int getSparseSwitchBaseAddress(int sparseSwitchDataAddress) {
int sparseSwitchBaseAddress = this.sparseSwitchMap.get(sparseSwitchDataAddress, -1);
if (sparseSwitchBaseAddress == -1) {
throw new RuntimeException("Could not find the sparse switch statement corresponding to the sparse " +
"switch data at address " + sparseSwitchDataAddress);
}
return sparseSwitchBaseAddress;
}
private static List<StringTemplate> getAnnotations(StringTemplateGroup stg, AnnotationSetItem annotationSet) { private static List<StringTemplate> getAnnotations(StringTemplateGroup stg, AnnotationSetItem annotationSet) {
if (annotationSet == null) { if (annotationSet == null) {
return null; return null;
@ -151,13 +220,38 @@ public class MethodDefinition {
return annotationAdaptors; return annotationAdaptors;
} }
private static List<MethodItem> getMethodItems(DexFile dexFile, StringTemplateGroup stg, CodeItem codeItem) { private List<MethodItem> getMethodItems() {
List<MethodItem> methodItems = new ArrayList<MethodItem>(); List<MethodItem> methodItems = new ArrayList<MethodItem>();
MethodItemList methodItemList = new MethodItemList(dexFile, stg, codeItem); if (encodedMethod.codeItem == null) {
methodItemList.generateMethodItemList(); return methodItems;
}
for (LabelMethodItem labelMethodItem: methodItemList.labels.getLabels()) { Instruction[] instructions = encodedMethod.codeItem.getInstructions();
int currentCodeAddress = 0;
for (int i=0; i<instructions.length; i++) {
Instruction instruction = instructions[i];
methodItems.add(InstructionMethodItemFactory.makeInstructionFormatMethodItem(this,
encodedMethod.codeItem, currentCodeAddress, stg, instruction));
if (i != instructions.length - 1) {
methodItems.add(new BlankMethodItem(stg, currentCodeAddress));
}
currentCodeAddress += instruction.getSize(currentCodeAddress);
}
addTries(methodItems);
addDebugInfo(methodItems);
if (baksmali.useSequentialLabels) {
setLabelSequentialNumbers();
}
for (LabelMethodItem labelMethodItem: labelCache.getLabels()) {
if (labelMethodItem.isCommentedOut()) { if (labelMethodItem.isCommentedOut()) {
methodItems.add(new CommentedOutMethodItem(stg, labelMethodItem)); methodItems.add(new CommentedOutMethodItem(stg, labelMethodItem));
} else { } else {
@ -165,501 +259,162 @@ public class MethodDefinition {
} }
} }
methodItems.addAll(methodItemList.instructions);
methodItems.addAll(methodItemList.blanks);
methodItems.addAll(methodItemList.catches);
if (baksmali.outputDebugInfo) {
methodItems.addAll(methodItemList.debugItems);
}
Collections.sort(methodItems); Collections.sort(methodItems);
return methodItems; return methodItems;
} }
private void addTries(List<MethodItem> methodItems) {
private static class MethodItemList { if (encodedMethod.codeItem == null || encodedMethod.codeItem.getTries() == null) {
private final DexFile dexFile; return;
private final StringTemplateGroup stg;
private final CodeItem codeItem;
public LabelCache labels = new LabelCache();
public List<MethodItem> instructions = new ArrayList<MethodItem>();
public List<BlankMethodItem> blanks = new ArrayList<BlankMethodItem>();
public List<CatchMethodItem> catches = new ArrayList<CatchMethodItem>();
public List<MethodItem> debugItems = new ArrayList<MethodItem>();
private HashMap<Integer, Integer> packedSwitchMap = new HashMap<Integer, Integer>();
private HashMap<Integer, Integer> sparseSwitchMap = new HashMap<Integer, Integer>();
public MethodItemList(DexFile dexFile, StringTemplateGroup stg, CodeItem codeItem) {
this.dexFile = dexFile;
this.stg = stg;
this.codeItem = codeItem;
} }
public void generateMethodItemList() { Instruction[] instructions = encodedMethod.codeItem.getInstructions();
if (codeItem == null) {
return;
}
if (baksmali.deodexUtil != null && dexFile.isOdex()) { for (CodeItem.TryItem tryItem: encodedMethod.codeItem.getTries()) {
List<Instruction> instructions = baksmali.deodexUtil.deodexerizeCode(codeItem); int startAddress = tryItem.getStartCodeAddress();
int endAddress = tryItem.getStartCodeAddress() + tryItem.getTryLength();
int currentCodeAddress = 0; /**
for (Instruction instruction: instructions) { * The end address points to the address immediately after the end of the last
if (instruction.opcode == Opcode.PACKED_SWITCH) { * instruction that the try block covers. We want the .catch directive and end_try
Instruction31t ins = (Instruction31t)instruction; * label to be associated with the last covered instruction, so we need to get
packedSwitchMap.put(currentCodeAddress + ins.getTargetAddressOffset(), currentCodeAddress); * the address for that instruction
} else if (instruction.opcode == Opcode.SPARSE_SWITCH) { */
Instruction31t ins = (Instruction31t)instruction;
sparseSwitchMap.put(currentCodeAddress + ins.getTargetAddressOffset(), currentCodeAddress);
}
currentCodeAddress += instruction.getSize(currentCodeAddress); int index = instructionMap.get(endAddress, -1);
} int lastInstructionAddress;
currentCodeAddress = 0; /**
for (Instruction instruction: instructions) { * If we couldn't find the index, then the try block probably extends to the last instruction in the
addMethodItemsForInstruction(currentCodeAddress, instruction, false); * method, and so endAddress would be the address immediately after the end of the last instruction.
blanks.add(new BlankMethodItem(stg, currentCodeAddress)); * 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); if (endAddress != lastInstructionAddress + lastInstruction.getSize(lastInstructionAddress)) {
} throw new RuntimeException("Invalid code offset " + endAddress + " for the try block end address");
/*
* 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;
}
} }
} else { } else {
int currentCodeAddress = 0; if (index == 0) {
for (Instruction instruction: codeItem.getInstructions()) { throw new RuntimeException("Unexpected instruction index");
if (instruction.opcode == Opcode.PACKED_SWITCH) { }
OffsetInstruction offsetInstruction = (OffsetInstruction)instruction; Instruction lastInstruction = instructions[index - 1];
packedSwitchMap.put(currentCodeAddress + offsetInstruction.getTargetAddressOffset(), currentCodeAddress);
} else if (instruction.opcode == Opcode.SPARSE_SWITCH) { if (lastInstruction.getFormat().variableSizeFormat) {
OffsetInstruction offsetInstruction = (OffsetInstruction)instruction; throw new RuntimeException("This try block unexpectedly ends on a switch/array data block.");
sparseSwitchMap.put(currentCodeAddress + offsetInstruction.getTargetAddressOffset(), currentCodeAddress); }
//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<MethodItem> 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); @Override
} public void ProcessStartLocalExtended(int codeAddress, int length, int registerNum,
StringIdItem name, TypeIdItem type,
currentCodeAddress = 0; StringIdItem signature) {
for (Instruction instruction: codeItem.getInstructions()) { methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "StartLocal",
addMethodItemsForInstruction(currentCodeAddress, instruction, false); -1, registerNum, name, type, signature));
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();
}
}
} }
return;
}
case SparseSwitchData:
{
final Integer baseAddress = sparseSwitchMap.get(codeAddress);
if (baseAddress != null) { @Override
SparseSwitchDataPseudoInstruction sparseSwitchInstruction = public void ProcessEndLocal(int codeAddress, int length, int registerNum, StringIdItem name,
(SparseSwitchDataPseudoInstruction)instruction; TypeIdItem type, StringIdItem signature) {
methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "EndLocal", -1,
SparseSwitchMethodItem sparseSwitch = new SparseSwitchMethodItem(labels, codeItem, codeAddress, stg, registerNum, name, type, signature));
sparseSwitchInstruction, baseAddress);
addInstructionMethodItem(sparseSwitch, commentedOut);
if (!commentedOut) {
for (LabelMethodItem label: sparseSwitch) {
label.setUncommented();
}
}
} }
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() { @Override
if (codeItem.getTries() == null) { public void ProcessRestartLocal(int codeAddress, int length, int registerNum, StringIdItem name,
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,
TypeIdItem type, StringIdItem signature) { TypeIdItem type, StringIdItem signature) {
debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "EndLocal", -1, methodItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "RestartLocal", -1,
registerNum, name, type, signature)); registerNum, name, type, signature));
} }
@Override @Override
public void ProcessRestartLocal(int codeAddress, int length, int registerNum, StringIdItem name, public void ProcessSetPrologueEnd(int codeAddress) {
TypeIdItem type, StringIdItem signature) { methodItems.add(new DebugMethodItem(codeAddress, stg, "EndPrologue", -4));
debugItems.add(new LocalDebugMethodItem(codeItem, codeAddress, stg, "RestartLocal", -1, }
registerNum, name, type, signature));
}
@Override @Override
public void ProcessSetPrologueEnd(int codeAddress) { public void ProcessSetEpilogueBegin(int codeAddress) {
debugItems.add(new DebugMethodItem(codeAddress, stg, "EndPrologue", -4)); methodItems.add(new DebugMethodItem(codeAddress, stg, "StartEpilogue", -4));
} }
@Override @Override
public void ProcessSetEpilogueBegin(int codeAddress) { public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) {
debugItems.add(new DebugMethodItem(codeAddress, stg, "StartEpilogue", -4)); methodItems.add(new DebugMethodItem(codeAddress, stg, "SetFile", -3) {
} @Override
protected void setAttributes(StringTemplate template) {
template.setAttribute("FileName", name.getStringValue());
}
});
}
@Override @Override
public void ProcessSetFile(int codeAddress, int length, final StringIdItem name) { public void ProcessLineEmit(int codeAddress, final int line) {
debugItems.add(new DebugMethodItem(codeAddress, stg, "SetFile", -3) { methodItems.add(new DebugMethodItem(codeAddress, stg, "Line", -2) {
@Override @Override
protected void setAttributes(StringTemplate template) { protected void setAttributes(StringTemplate template) {
template.setAttribute("FileName", name.getStringValue()); template.setAttribute("Line", line);
} }
}); });
} }
});
}
@Override private void setLabelSequentialNumbers() {
public void ProcessLineEmit(int codeAddress, final int line) { HashMap<String, Integer> nextLabelSequenceByType = new HashMap<String, Integer>();
debugItems.add(new DebugMethodItem(codeAddress, stg, "Line", -2) { ArrayList<LabelMethodItem> sortedLabels = new ArrayList<LabelMethodItem>(labelCache.getLabels());
@Override
protected void setAttributes(StringTemplate template) {
template.setAttribute("Line", line);
}
});
}
});
}
private void setLabelSequentialNumbers() { //sort the labels by their location in the method
HashMap<String, Integer> nextLabelSequenceByType = new HashMap<String, Integer>(); Collections.sort(sortedLabels);
ArrayList<LabelMethodItem> sortedLabels = new ArrayList<LabelMethodItem>(labels.getLabels());
//sort the labels by their location in the method for (LabelMethodItem labelMethodItem: sortedLabels) {
Collections.sort(sortedLabels); Integer labelSequence = nextLabelSequenceByType.get(labelMethodItem.getLabelPrefix());
if (labelSequence == null) {
for (LabelMethodItem labelMethodItem: sortedLabels) { labelSequence = 0;
Integer labelSequence = nextLabelSequenceByType.get(labelMethodItem.getLabelPrefix());
if (labelSequence == null) {
labelSequence = 0;
}
labelMethodItem.setLabelSequence(labelSequence);
nextLabelSequenceByType.put(labelMethodItem.getLabelPrefix(), labelSequence + 1);
} }
labelMethodItem.setLabelSequence(labelSequence);
nextLabelSequenceByType.put(labelMethodItem.getLabelPrefix(), labelSequence + 1);
} }
} }

View File

@ -29,7 +29,7 @@
package org.jf.baksmali.Adaptors; package org.jf.baksmali.Adaptors;
public abstract class MethodItem implements Comparable<MethodItem> { public abstract class MethodItem implements Comparable<MethodItem> {
private int codeAddress; protected final int codeAddress;
protected MethodItem(int codeAddress) { protected MethodItem(int codeAddress) {
this.codeAddress = codeAddress; this.codeAddress = codeAddress;

View File

@ -0,0 +1,4 @@
package org.jf.baksmali.Analysis;
public class Analysis {
}

View File

@ -0,0 +1,5 @@
package org.jf.baksmali.Analysis;
public interface AnalysisInstruction {
}

View File

@ -0,0 +1,4 @@
package org.jf.baksmali.Deodex;
public class DeodexUtil2 {
}

View File

@ -133,14 +133,14 @@ Format10x(Opcode) ::=
<Opcode> <Opcode>
>> >>
Format11n(Opcode, Register, Literal) ::= Format11n(Opcode, RegisterA, Literal) ::=
<< <<
<Opcode> <Register>, <Literal> <Opcode> <RegisterA>, <Literal>
>> >>
Format11x(Opcode, Register) ::= Format11x(Opcode, RegisterA) ::=
<< <<
<Opcode> <Register> <Opcode> <RegisterA>
>> >>
Format12x(Opcode, RegisterA, RegisterB) ::= Format12x(Opcode, RegisterA, RegisterB) ::=
@ -153,24 +153,24 @@ Format20t(Opcode, TargetLabel) ::=
<Opcode> <TargetLabel> <Opcode> <TargetLabel>
>> >>
Format21c(Opcode, Register, Reference) ::= Format21c(Opcode, RegisterA, Reference) ::=
<< <<
<Opcode> <Register>, <Reference> <Opcode> <RegisterA>, <Reference>
>> >>
Format21h(Opcode, Register, Literal) ::= Format21h(Opcode, RegisterA, Literal) ::=
<< <<
<Opcode> <Register>, <Literal> <Opcode> <RegisterA>, <Literal>
>> >>
Format21s(Opcode, Register, Literal) ::= Format21s(Opcode, RegisterA, Literal) ::=
<< <<
<Opcode> <Register>, <Literal> <Opcode> <RegisterA>, <Literal>
>> >>
Format21t(Opcode, Register, TargetLabel) ::= Format21t(Opcode, RegisterA, TargetLabel) ::=
<< <<
<Opcode> <Register>, <TargetLabel> <Opcode> <RegisterA>, <TargetLabel>
>> >>
Format22b(Opcode, RegisterA, RegisterB, Literal) ::= Format22b(Opcode, RegisterA, RegisterB, Literal) ::=
@ -218,19 +218,19 @@ Format30t(Opcode, TargetLabel) ::=
<Opcode> <TargetLabel> <Opcode> <TargetLabel>
>> >>
Format31c(Opcode, Register, Reference) ::= Format31c(Opcode, RegisterA, Reference) ::=
<< <<
<Opcode> <Register>, <Reference> <Opcode> <RegisterA>, <Reference>
>> >>
Format31i(Opcode, Register, Literal) ::= Format31i(Opcode, RegisterA, Literal) ::=
<< <<
<Opcode> <Register>, <Literal> <Opcode> <RegisterA>, <Literal>
>> >>
Format31t(Opcode, Register, TargetLabel) ::= Format31t(Opcode, RegisterA, TargetLabel) ::=
<< <<
<Opcode> <Register>, <TargetLabel> <Opcode> <RegisterA>, <TargetLabel>
>> >>
Format32x(Opcode, RegisterA, RegisterB) ::= Format32x(Opcode, RegisterA, RegisterB) ::=
@ -278,9 +278,9 @@ Format3rmsf(Opcode, StartRegister, LastRegister, Reference) ::=
<Opcode> {<StartRegister> .. <LastRegister>}, <Reference> <Opcode> {<StartRegister> .. <LastRegister>}, <Reference>
>> >>
Format51l(Opcode, Register, Literal) ::= Format51l(Opcode, RegisterA, Literal) ::=
<< <<
<Opcode> <Register>, <Literal> <Opcode> <RegisterA>, <Literal>
>> >>
CommentedOutMethodItem(MethodItem) ::= CommentedOutMethodItem(MethodItem) ::=