From edd961477ec83d9f320bc65c5ca97572fceaccc5 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Sun, 15 Sep 2013 12:41:16 -0700 Subject: [PATCH] Remove the now unused builder instructions and instruction factories --- .../java/org/jf/dexlib2/writer/DexWriter.java | 5 - .../writer/builder/BuilderInstruction.java | 426 ------------------ .../builder/BuilderInstructionFactory.java | 223 --------- .../jf/dexlib2/writer/builder/DexBuilder.java | 4 +- .../org/jf/dexlib2/writer/pool/DexPool.java | 5 +- smali/src/main/antlr3/smaliTreeWalker.g | 2 - 6 files changed, 4 insertions(+), 661 deletions(-) delete mode 100644 dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstruction.java delete mode 100644 dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstructionFactory.java diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java index 0a26a5f7..bdd6dbf7 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/DexWriter.java @@ -80,7 +80,6 @@ public abstract class DexWriter< StringKey extends CharSequence, StringRef extends StringReference, TypeKey extends CharSequence, TypeRef extends TypeReference, ProtoKey extends Comparable, FieldRefKey extends FieldReference, MethodRefKey extends MethodReference, - BaseReference extends Reference, ClassKey extends Comparable, AnnotationKey extends Annotation, AnnotationSetKey, TypeListKey, @@ -117,8 +116,6 @@ public abstract class DexWriter< protected int numCodeItemItems = 0; protected int numClassDataItems = 0; - protected final InstructionFactory instructionFactory; - protected final StringSection stringSection; protected final TypeSection typeSection; protected final ProtoSection protoSection; @@ -132,7 +129,6 @@ public abstract class DexWriter< protected final AnnotationSetSection annotationSetSection; protected DexWriter(int api, - InstructionFactory instructionFactory, StringSection stringSection, TypeSection typeSection, ProtoSection protoSection, @@ -145,7 +141,6 @@ public abstract class DexWriter< EncodedValue> annotationSection, AnnotationSetSection annotationSetSection) { this.api = api; - this.instructionFactory = instructionFactory; this.stringSection = stringSection; this.typeSection = typeSection; this.protoSection = protoSection; diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstruction.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstruction.java deleted file mode 100644 index c82d28ab..00000000 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstruction.java +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 COPYRIGHT - * OWNER OR CONTRIBUTORS 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.dexlib2.writer.builder; - -import com.google.common.collect.ImmutableList; -import org.jf.dexlib2.Format; -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.Instruction; -import org.jf.dexlib2.iface.instruction.SwitchElement; -import org.jf.dexlib2.iface.instruction.formats.*; -import org.jf.dexlib2.immutable.instruction.*; -import org.jf.dexlib2.util.Preconditions; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; - -public interface BuilderInstruction extends Instruction { - static abstract class BaseBuilderInstruction implements BuilderInstruction { - @Nonnull protected final Opcode opcode; - - public BaseBuilderInstruction(@Nonnull Opcode opcode) { - Preconditions.checkFormat(opcode, getFormat()); - this.opcode = opcode; - } - - @Nonnull public abstract Format getFormat(); - - @Nonnull @Override public Opcode getOpcode() { - return opcode; - } - - @Override public int getCodeUnits() { - return getFormat().size/2; - } - } - - public static class BuilderInstruction10t extends ImmutableInstruction10t implements BuilderInstruction { - public BuilderInstruction10t(@Nonnull Opcode opcode, int codeOffset) { - super(opcode, codeOffset); - } - } - - public static class BuilderInstruction10x extends ImmutableInstruction10x implements BuilderInstruction { - public BuilderInstruction10x(@Nonnull Opcode opcode) { - super(opcode); - } - } - - public static class BuilderInstruction11n extends ImmutableInstruction11n implements BuilderInstruction { - public BuilderInstruction11n(@Nonnull Opcode opcode, int registerA, int literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderInstruction11x extends ImmutableInstruction11x implements BuilderInstruction { - public BuilderInstruction11x(@Nonnull Opcode opcode, int registerA) { - super(opcode, registerA); - } - } - - public static class BuilderInstruction12x extends ImmutableInstruction12x implements BuilderInstruction { - public BuilderInstruction12x(@Nonnull Opcode opcode, int registerA, int registerB) { - super(opcode, registerA, registerB); - } - } - - public static class BuilderInstruction20bc extends BaseBuilderInstruction implements Instruction20bc { - public static final Format FORMAT = Format.Format20bc; - - protected final int verificationError; - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction20bc(@Nonnull Opcode opcode, - int verificationError, - @Nonnull BuilderReference reference) { - super(opcode); - this.verificationError = Preconditions.checkVerificationError(verificationError); - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Override public int getVerificationError() { return verificationError; } - @Nonnull @Override public BuilderReference getReference() { return reference; } - - @Nonnull @Override public Format getFormat() { return FORMAT; } - } - - public static class BuilderInstruction20t extends ImmutableInstruction20t implements BuilderInstruction { - public BuilderInstruction20t(@Nonnull Opcode opcode, int codeOffset) { - super(opcode, codeOffset); - } - } - - public static class BuilderInstruction21c extends BaseBuilderInstruction implements Instruction21c { - public static final Format FORMAT = Format.Format21c; - - protected final int registerA; - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction21c(@Nonnull Opcode opcode, - int registerA, - @Nonnull BuilderReference reference) { - super(opcode); - this.registerA = Preconditions.checkByteRegister(registerA); - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Override public int getRegisterA() { return registerA; } - @Nonnull @Override public BuilderReference getReference() { return reference; } - - @Nonnull @Override public Format getFormat() { return FORMAT; } - } - - public static class BuilderInstruction21ih extends ImmutableInstruction21ih implements BuilderInstruction { - public BuilderInstruction21ih(@Nonnull Opcode opcode, int registerA, int literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderInstruction21lh extends ImmutableInstruction21lh implements BuilderInstruction { - public BuilderInstruction21lh(@Nonnull Opcode opcode, int registerA, long literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderInstruction21s extends ImmutableInstruction21s implements BuilderInstruction { - public BuilderInstruction21s(@Nonnull Opcode opcode, int registerA, int literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderInstruction21t extends ImmutableInstruction21t implements BuilderInstruction { - public BuilderInstruction21t(@Nonnull Opcode opcode, int registerA, int codeOffset) { - super(opcode, registerA, codeOffset); - } - } - - public static class BuilderInstruction22b extends ImmutableInstruction22b implements BuilderInstruction { - public BuilderInstruction22b(@Nonnull Opcode opcode, int registerA, int registerB, int literal) { - super(opcode, registerA, registerB, literal); - } - } - - public static class BuilderInstruction22c extends BaseBuilderInstruction implements Instruction22c { - public static final Format FORMAT = Format.Format22c; - - protected final int registerA; - protected final int registerB; - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction22c(@Nonnull Opcode opcode, - int registerA, - int registerB, - @Nonnull BuilderReference reference) { - super(opcode); - this.registerA = Preconditions.checkNibbleRegister(registerA); - this.registerB = Preconditions.checkNibbleRegister(registerB); - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Override public int getRegisterA() { return registerA; } - @Override public int getRegisterB() { return registerB; } - @Nonnull @Override public BuilderReference getReference() { return reference; } - - @Nonnull @Override public Format getFormat() { return FORMAT; } - } - - public static class BuilderInstruction22s extends ImmutableInstruction22s implements BuilderInstruction { - public BuilderInstruction22s(@Nonnull Opcode opcode, int registerA, int registerB, int literal) { - super(opcode, registerA, registerB, literal); - } - } - - public static class BuilderInstruction22t extends ImmutableInstruction22t implements BuilderInstruction { - public BuilderInstruction22t(@Nonnull Opcode opcode, int registerA, int registerB, int codeOffset) { - super(opcode, registerA, registerB, codeOffset); - } - } - - public static class BuilderInstruction22x extends ImmutableInstruction22x implements BuilderInstruction { - public BuilderInstruction22x(@Nonnull Opcode opcode, int registerA, int registerB) { - super(opcode, registerA, registerB); - } - } - - public static class BuilderInstruction23x extends ImmutableInstruction23x implements BuilderInstruction { - public BuilderInstruction23x(@Nonnull Opcode opcode, int registerA, int registerB, int registerC) { - super(opcode, registerA, registerB, registerC); - } - } - - public static class BuilderInstruction30t extends ImmutableInstruction30t implements BuilderInstruction { - public BuilderInstruction30t(@Nonnull Opcode opcode, int codeOffset) { - super(opcode, codeOffset); - } - } - - public static class BuilderInstruction31c extends BaseBuilderInstruction implements Instruction31c { - public static final Format FORMAT = Format.Format31c; - - protected final int registerA; - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction31c(@Nonnull Opcode opcode, - int registerA, - @Nonnull BuilderReference reference) { - super(opcode); - this.registerA = Preconditions.checkByteRegister(registerA); - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Override public int getRegisterA() { return registerA; } - @Nonnull @Override public BuilderReference getReference() { return reference; } - - @Nonnull @Override public Format getFormat() { return FORMAT; } - } - - public static class BuilderInstruction31i extends ImmutableInstruction31i implements BuilderInstruction { - public BuilderInstruction31i(@Nonnull Opcode opcode, int registerA, int literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderInstruction31t extends ImmutableInstruction31t implements BuilderInstruction { - public BuilderInstruction31t(@Nonnull Opcode opcode, int registerA, int codeOffset) { - super(opcode, registerA, codeOffset); - } - } - - public static class BuilderInstruction32x extends ImmutableInstruction32x implements BuilderInstruction { - public BuilderInstruction32x(@Nonnull Opcode opcode, int registerA, int registerB) { - super(opcode, registerA, registerB); - } - } - - public static class BuilderInstruction35c extends BaseBuilderInstruction implements Instruction35c { - public static final Format FORMAT = Format.Format35c; - - protected final int registerCount; - protected final int registerC; - protected final int registerD; - protected final int registerE; - protected final int registerF; - protected final int registerG; - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction35c(@Nonnull Opcode opcode, - int registerCount, - int registerC, - int registerD, - int registerE, - int registerF, - int registerG, - @Nonnull BuilderReference reference) { - super(opcode); - this.registerCount = Preconditions.check35cRegisterCount(registerCount); - this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0; - this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0; - this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0; - this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0; - this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0; - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Override public int getRegisterCount() { return registerCount; } - @Override public int getRegisterC() { return registerC; } - @Override public int getRegisterD() { return registerD; } - @Override public int getRegisterE() { return registerE; } - @Override public int getRegisterF() { return registerF; } - @Override public int getRegisterG() { return registerG; } - @Nonnull @Override public BuilderReference getReference() { return reference; } - - @Nonnull @Override public Format getFormat() { return FORMAT; } - } - - public static class BuilderInstruction3rc extends BaseBuilderInstruction implements Instruction3rc { - public static final Format FORMAT = Format.Format3rc; - - private final int startRegister; - private final int registerCount; - - @Nonnull protected final BuilderReference reference; - - public BuilderInstruction3rc(@Nonnull Opcode opcode, - int startRegister, - int registerCount, - @Nonnull BuilderReference reference) { - super(opcode); - this.startRegister = Preconditions.checkShortRegister(startRegister); - this.registerCount = Preconditions.checkRegisterRangeCount(registerCount); - this.reference = Preconditions.checkReference(opcode.referenceType, reference); - } - - @Nonnull @Override public BuilderReference getReference() { - return reference; - } - - @Override public int getStartRegister() { - return startRegister; - } - - @Override public int getRegisterCount() { - return registerCount; - } - - @Nonnull @Override public Format getFormat() { - return FORMAT; - } - } - - public static class BuilderInstruction51l extends ImmutableInstruction51l implements BuilderInstruction { - public BuilderInstruction51l(@Nonnull Opcode opcode, int registerA, long literal) { - super(opcode, registerA, literal); - } - } - - public static class BuilderArrayPayload extends BaseBuilderInstruction implements ArrayPayload { - public static final Format FORMAT = Format.ArrayPayload; - private final int elementWidth; - @Nonnull private final List arrayElements; - - public BuilderArrayPayload(int elementWidth, @Nullable List arrayElements) { - super(Opcode.ARRAY_PAYLOAD); - this.elementWidth = elementWidth; - if (arrayElements == null) { - arrayElements = ImmutableList.of(); - } - this.arrayElements = arrayElements; - } - - @Override public int getElementWidth() { - return elementWidth; - } - - @Nonnull @Override public List getArrayElements() { - return arrayElements; - } - - @Nonnull @Override public Format getFormat() { - return FORMAT; - } - - @Override public int getCodeUnits() { - return 4 + (elementWidth * arrayElements.size() + 1) / 2; - } - } - - public static class BuilderPackedSwitchPayload extends BaseBuilderInstruction implements PackedSwitchPayload { - public static final Format FORMAT = Format.PackedSwitchPayload; - @Nonnull private final List elements; - - public BuilderPackedSwitchPayload(@Nullable List switchElements) { - super(Opcode.PACKED_SWITCH_PAYLOAD); - if (switchElements == null) { - switchElements = ImmutableList.of(); - } - this.elements = switchElements; - } - - @Nonnull @Override public List getSwitchElements() { - return elements; - } - - @Nonnull @Override public Format getFormat() { - return FORMAT; - } - - @Override public int getCodeUnits() { - return 4 + elements.size() * 2; - } - } - - public static class BuilderSparseSwitchPayload extends BaseBuilderInstruction implements SparseSwitchPayload { - public static final Format FORMAT = Format.SparseSwitchPayload; - @Nonnull private final List elements; - - public BuilderSparseSwitchPayload(@Nullable List switchElements) { - super(Opcode.SPARSE_SWITCH_PAYLOAD); - if (switchElements == null) { - switchElements = ImmutableList.of(); - } - this.elements = switchElements; - } - - @Nonnull @Override public List getSwitchElements() { - return elements; - } - - @Nonnull @Override public Format getFormat() { - return FORMAT; - } - - @Override public int getCodeUnits() { - return 2 + elements.size() * 4; - } - } -} diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstructionFactory.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstructionFactory.java deleted file mode 100644 index 280c318d..00000000 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/BuilderInstructionFactory.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2013, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 COPYRIGHT - * OWNER OR CONTRIBUTORS 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.dexlib2.writer.builder; - -import org.jf.dexlib2.Opcode; -import org.jf.dexlib2.iface.instruction.SwitchElement; -import org.jf.dexlib2.writer.InstructionFactory; -import org.jf.dexlib2.writer.builder.BuilderInstruction.*; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; - -public class BuilderInstructionFactory implements InstructionFactory { - public static final BuilderInstructionFactory INSTANCE = new BuilderInstructionFactory(); - - private BuilderInstructionFactory() { - } - - public BuilderInstruction10t makeInstruction10t(@Nonnull Opcode opcode, - int codeOffset) { - return new BuilderInstruction10t(opcode, codeOffset); - } - - public BuilderInstruction10x makeInstruction10x(@Nonnull Opcode opcode) { - return new BuilderInstruction10x(opcode); - } - - public BuilderInstruction11n makeInstruction11n(@Nonnull Opcode opcode, - int registerA, - int literal) { - return new BuilderInstruction11n(opcode, registerA, literal); - } - - public BuilderInstruction11x makeInstruction11x(@Nonnull Opcode opcode, - int registerA) { - return new BuilderInstruction11x(opcode, registerA); - } - - public BuilderInstruction12x makeInstruction12x(@Nonnull Opcode opcode, - int registerA, - int registerB) { - return new BuilderInstruction12x(opcode, registerA, registerB); - } - - public BuilderInstruction20bc makeInstruction20bc(@Nonnull Opcode opcode, - int verificationError, - @Nonnull BuilderReference reference) { - return new BuilderInstruction20bc(opcode, verificationError, reference); - } - - public BuilderInstruction20t makeInstruction20t(@Nonnull Opcode opcode, - int codeOffset) { - return new BuilderInstruction20t(opcode, codeOffset); - } - - public BuilderInstruction21c makeInstruction21c(@Nonnull Opcode opcode, - int registerA, - @Nonnull BuilderReference reference) { - return new BuilderInstruction21c(opcode, registerA, reference); - } - - public BuilderInstruction21ih makeInstruction21ih(@Nonnull Opcode opcode, - int registerA, - int literal) { - return new BuilderInstruction21ih(opcode, registerA, literal); - } - - public BuilderInstruction21lh makeInstruction21lh(@Nonnull Opcode opcode, - int registerA, - long literal) { - return new BuilderInstruction21lh(opcode, registerA, literal); - } - - public BuilderInstruction21s makeInstruction21s(@Nonnull Opcode opcode, - int registerA, - int literal) { - return new BuilderInstruction21s(opcode, registerA, literal); - } - - public BuilderInstruction21t makeInstruction21t(@Nonnull Opcode opcode, - int registerA, - int codeOffset) { - return new BuilderInstruction21t(opcode, registerA, codeOffset); - } - - public BuilderInstruction22b makeInstruction22b(@Nonnull Opcode opcode, - int registerA, - int registerB, - int literal) { - return new BuilderInstruction22b(opcode, registerA, registerB, literal); - } - - public BuilderInstruction22c makeInstruction22c(@Nonnull Opcode opcode, - int registerA, - int registerB, - @Nonnull BuilderReference reference) { - return new BuilderInstruction22c(opcode, registerA, registerB, reference); - } - - public BuilderInstruction22s makeInstruction22s(@Nonnull Opcode opcode, - int registerA, - int registerB, - int literal) { - return new BuilderInstruction22s(opcode, registerA, registerB, literal); - } - - public BuilderInstruction22t makeInstruction22t(@Nonnull Opcode opcode, - int registerA, - int registerB, - int codeOffset) { - return new BuilderInstruction22t(opcode, registerA, registerB, codeOffset); - } - - public BuilderInstruction22x makeInstruction22x(@Nonnull Opcode opcode, - int registerA, - int registerB) { - return new BuilderInstruction22x(opcode, registerA, registerB); - } - - public BuilderInstruction23x makeInstruction23x(@Nonnull Opcode opcode, - int registerA, - int registerB, - int registerC) { - return new BuilderInstruction23x(opcode, registerA, registerB, registerC); - } - - public BuilderInstruction30t makeInstruction30t(@Nonnull Opcode opcode, - int codeOffset) { - return new BuilderInstruction30t(opcode, codeOffset); - } - - public BuilderInstruction31c makeInstruction31c(@Nonnull Opcode opcode, - int registerA, - @Nonnull BuilderReference reference) { - return new BuilderInstruction31c(opcode, registerA, reference); - } - - public BuilderInstruction31i makeInstruction31i(@Nonnull Opcode opcode, - int registerA, - int literal) { - return new BuilderInstruction31i(opcode, registerA, literal); - } - - public BuilderInstruction31t makeInstruction31t(@Nonnull Opcode opcode, - int registerA, - int codeOffset) { - return new BuilderInstruction31t(opcode, registerA, codeOffset); - } - - public BuilderInstruction32x makeInstruction32x(@Nonnull Opcode opcode, - int registerA, - int registerB) { - return new BuilderInstruction32x(opcode, registerA, registerB); - } - - public BuilderInstruction35c makeInstruction35c(@Nonnull Opcode opcode, - int registerCount, - int registerC, - int registerD, - int registerE, - int registerF, - int registerG, - @Nonnull BuilderReference reference) { - return new BuilderInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG, - reference); - } - - public BuilderInstruction3rc makeInstruction3rc(@Nonnull Opcode opcode, - int startRegister, - int registerCount, - @Nonnull BuilderReference reference) { - return new BuilderInstruction3rc(opcode, startRegister, registerCount, reference); - } - - public BuilderInstruction51l makeInstruction51l(@Nonnull Opcode opcode, - int registerA, - long literal) { - return new BuilderInstruction51l(opcode, registerA, literal); - } - - public BuilderSparseSwitchPayload makeSparseSwitchPayload(@Nullable List switchElements) { - return new BuilderSparseSwitchPayload(switchElements); - } - - public BuilderPackedSwitchPayload makePackedSwitchPayload(@Nullable List switchElements) { - return new BuilderPackedSwitchPayload(switchElements); - } - - public BuilderArrayPayload makeArrayPayload(int elementWidth, - @Nullable List arrayElements) { - return new BuilderArrayPayload(elementWidth, arrayElements); - } -} diff --git a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/DexBuilder.java b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/DexBuilder.java index aabf071e..469a3324 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/DexBuilder.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/writer/builder/DexBuilder.java @@ -54,7 +54,7 @@ import java.util.List; import java.util.Set; public class DexBuilder extends DexWriter { @@ -71,7 +71,7 @@ public class DexBuilder extends DexWriter, TypeListPool.Key>, Field, PoolMethod, EncodedValue, AnnotationElement> { @@ -79,7 +78,7 @@ public class DexPool extends DexWriter instructionFactory = - BuilderInstructionFactory.INSTANCE; public void setDexBuilder(DexBuilder dexBuilder) { this.dexBuilder = dexBuilder;