1 /*
2  * Copyright 2013, Google Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following disclaimer
13  * in the documentation and/or other materials provided with the
14  * distribution.
15  *     * Neither the name of Google Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 
33 package org.jf.dexlib2.writer;
34 
35 import org.jf.dexlib2.Opcode;
36 import org.jf.dexlib2.iface.instruction.Instruction;
37 import org.jf.dexlib2.iface.instruction.SwitchElement;
38 import org.jf.dexlib2.iface.reference.Reference;
39 
40 import javax.annotation.Nonnull;
41 import javax.annotation.Nullable;
42 import java.util.List;
43 
44 public interface InstructionFactory<Ref extends Reference> {
makeInstruction10t(@onnull Opcode opcode, int codeOffset)45     Instruction makeInstruction10t(@Nonnull Opcode opcode, int codeOffset);
makeInstruction10x(@onnull Opcode opcode)46     Instruction makeInstruction10x(@Nonnull Opcode opcode);
makeInstruction11n(@onnull Opcode opcode, int registerA, int literal)47     Instruction makeInstruction11n(@Nonnull Opcode opcode, int registerA, int literal);
makeInstruction11x(@onnull Opcode opcode, int registerA)48     Instruction makeInstruction11x(@Nonnull Opcode opcode, int registerA);
makeInstruction12x(@onnull Opcode opcode, int registerA, int registerB)49     Instruction makeInstruction12x(@Nonnull Opcode opcode, int registerA, int registerB);
makeInstruction20bc(@onnull Opcode opcode, int verificationError, @Nonnull Ref reference)50     Instruction makeInstruction20bc(@Nonnull Opcode opcode, int verificationError, @Nonnull Ref reference);
makeInstruction20t(@onnull Opcode opcode, int codeOffset)51     Instruction makeInstruction20t(@Nonnull Opcode opcode, int codeOffset);
makeInstruction21c(@onnull Opcode opcode, int registerA, @Nonnull Ref reference)52     Instruction makeInstruction21c(@Nonnull Opcode opcode, int registerA, @Nonnull Ref reference);
makeInstruction21ih(@onnull Opcode opcode, int registerA, int literal)53     Instruction makeInstruction21ih(@Nonnull Opcode opcode, int registerA, int literal);
makeInstruction21lh(@onnull Opcode opcode, int registerA, long literal)54     Instruction makeInstruction21lh(@Nonnull Opcode opcode, int registerA, long literal);
makeInstruction21s(@onnull Opcode opcode, int registerA, int literal)55     Instruction makeInstruction21s(@Nonnull Opcode opcode, int registerA, int literal);
makeInstruction21t(@onnull Opcode opcode, int registerA, int codeOffset)56     Instruction makeInstruction21t(@Nonnull Opcode opcode, int registerA, int codeOffset);
makeInstruction22b(@onnull Opcode opcode, int registerA, int registerB, int literal)57     Instruction makeInstruction22b(@Nonnull Opcode opcode, int registerA, int registerB, int literal);
makeInstruction22c(@onnull Opcode opcode, int registerA, int registerB, @Nonnull Ref reference)58     Instruction makeInstruction22c(@Nonnull Opcode opcode, int registerA, int registerB, @Nonnull Ref reference);
makeInstruction22s(@onnull Opcode opcode, int registerA, int registerB, int literal)59     Instruction makeInstruction22s(@Nonnull Opcode opcode, int registerA, int registerB, int literal);
makeInstruction22t(@onnull Opcode opcode, int registerA, int registerB, int codeOffset)60     Instruction makeInstruction22t(@Nonnull Opcode opcode, int registerA, int registerB, int codeOffset);
makeInstruction22x(@onnull Opcode opcode, int registerA, int registerB)61     Instruction makeInstruction22x(@Nonnull Opcode opcode, int registerA, int registerB);
makeInstruction23x(@onnull Opcode opcode, int registerA, int registerB, int registerC)62     Instruction makeInstruction23x(@Nonnull Opcode opcode, int registerA, int registerB, int registerC);
makeInstruction30t(@onnull Opcode opcode, int codeOffset)63     Instruction makeInstruction30t(@Nonnull Opcode opcode, int codeOffset);
makeInstruction31c(@onnull Opcode opcode, int registerA, @Nonnull Ref reference)64     Instruction makeInstruction31c(@Nonnull Opcode opcode, int registerA, @Nonnull Ref reference);
makeInstruction31i(@onnull Opcode opcode, int registerA, int literal)65     Instruction makeInstruction31i(@Nonnull Opcode opcode, int registerA, int literal);
makeInstruction31t(@onnull Opcode opcode, int registerA, int codeOffset)66     Instruction makeInstruction31t(@Nonnull Opcode opcode, int registerA, int codeOffset);
makeInstruction32x(@onnull Opcode opcode, int registerA, int registerB)67     Instruction makeInstruction32x(@Nonnull Opcode opcode, int registerA, int registerB);
makeInstruction35c(@onnull Opcode opcode, int registerCount, int registerC, int registerD, int registerE, int registerF, int registerG, @Nonnull Ref reference)68     Instruction makeInstruction35c(@Nonnull Opcode opcode, int registerCount, int registerC, int registerD, int registerE,
69                             int registerF, int registerG, @Nonnull Ref reference);
makeInstruction3rc(@onnull Opcode opcode, int startRegister, int registerCount, @Nonnull Ref reference)70     Instruction makeInstruction3rc(@Nonnull Opcode opcode,  int startRegister, int registerCount,
71                             @Nonnull Ref reference);
makeInstruction51l(@onnull Opcode opcode, int registerA, long literal)72     Instruction makeInstruction51l(@Nonnull Opcode opcode, int registerA, long literal);
makeSparseSwitchPayload(@ullable List<? extends SwitchElement> switchElements)73     Instruction makeSparseSwitchPayload(@Nullable List<? extends SwitchElement> switchElements);
makePackedSwitchPayload(@ullable List<? extends SwitchElement> switchElements)74     Instruction makePackedSwitchPayload(@Nullable List<? extends SwitchElement> switchElements);
makeArrayPayload(int elementWidth, @Nullable List<Number> arrayElements)75     Instruction makeArrayPayload(int elementWidth, @Nullable List<Number> arrayElements);
76 }
77