InstructionFactory.java revision 42627b850c8f68a594f105e04b97c512b292b698
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 33package org.jf.dexlib2.writer; 34 35import org.jf.dexlib2.Opcode; 36import org.jf.dexlib2.iface.instruction.Instruction; 37import org.jf.dexlib2.iface.instruction.SwitchElement; 38import org.jf.dexlib2.iface.reference.Reference; 39 40import javax.annotation.Nonnull; 41import javax.annotation.Nullable; 42import java.util.List; 43 44public interface InstructionFactory<Insn extends Instruction, Ref extends Reference> { 45 Insn makeInstruction10t(@Nonnull Opcode opcode, int codeOffset); 46 Insn makeInstruction10x(@Nonnull Opcode opcode); 47 Insn makeInstruction11n(@Nonnull Opcode opcode, int registerA, int literal); 48 Insn makeInstruction11x(@Nonnull Opcode opcode, int registerA); 49 Insn makeInstruction12x(@Nonnull Opcode opcode, int registerA, int registerB); 50 Insn makeInstruction20bc(@Nonnull Opcode opcode, int verificationError, @Nonnull Ref reference); 51 Insn makeInstruction20t(@Nonnull Opcode opcode, int codeOffset); 52 Insn makeInstruction21c(@Nonnull Opcode opcode, int registerA, @Nonnull Ref reference); 53 Insn makeInstruction21ih(@Nonnull Opcode opcode, int registerA, int literal); 54 Insn makeInstruction21lh(@Nonnull Opcode opcode, int registerA, long literal); 55 Insn makeInstruction21s(@Nonnull Opcode opcode, int registerA, int literal); 56 Insn makeInstruction21t(@Nonnull Opcode opcode, int registerA, int codeOffset); 57 Insn makeInstruction22b(@Nonnull Opcode opcode, int registerA, int registerB, int literal); 58 Insn makeInstruction22c(@Nonnull Opcode opcode, int registerA, int registerB, @Nonnull Ref reference); 59 Insn makeInstruction22s(@Nonnull Opcode opcode, int registerA, int registerB, int literal); 60 Insn makeInstruction22t(@Nonnull Opcode opcode, int registerA, int registerB, int codeOffset); 61 Insn makeInstruction22x(@Nonnull Opcode opcode, int registerA, int registerB); 62 Insn makeInstruction23x(@Nonnull Opcode opcode, int registerA, int registerB, int registerC); 63 Insn makeInstruction30t(@Nonnull Opcode opcode, int codeOffset); 64 Insn makeInstruction31c(@Nonnull Opcode opcode, int registerA, @Nonnull Ref reference); 65 Insn makeInstruction31i(@Nonnull Opcode opcode, int registerA, int literal); 66 Insn makeInstruction31t(@Nonnull Opcode opcode, int registerA, int codeOffset); 67 Insn makeInstruction32x(@Nonnull Opcode opcode, int registerA, int registerB); 68 Insn makeInstruction35c(@Nonnull Opcode opcode, int registerCount, int registerC, int registerD, int registerE, 69 int registerF, int registerG, @Nonnull Ref reference); 70 Insn makeInstruction3rc(@Nonnull Opcode opcode, int startRegister, int registerCount, 71 @Nonnull Ref reference); 72 Insn makeInstruction51l(@Nonnull Opcode opcode, int registerA, long literal); 73 Insn makeSparseSwitchPayload(@Nullable List<? extends SwitchElement> switchElements); 74 Insn makePackedSwitchPayload(@Nullable List<? extends SwitchElement> switchElements); 75 Insn makeArrayPayload(int elementWidth, @Nullable List<Number> arrayElements); 76} 77