1 /* 2 * Copyright 2012, Google LLC 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google LLC nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 package com.android.tools.smali.dexlib2.iface; 32 33 import com.android.tools.smali.dexlib2.iface.debug.DebugItem; 34 import com.android.tools.smali.dexlib2.iface.instruction.Instruction; 35 36 import javax.annotation.Nonnull; 37 import java.util.List; 38 39 /** 40 * This class represents the implementation details of a method. 41 */ 42 public interface MethodImplementation { 43 /** 44 * Gets the number of registers in this method. 45 * 46 * @return The number of register in this method. 47 */ getRegisterCount()48 int getRegisterCount(); 49 50 /** 51 * Gets the instructions in this method. 52 * 53 * @return An Iterable of the instructions in this method 54 */ getInstructions()55 @Nonnull Iterable<? extends Instruction> getInstructions(); 56 57 /** 58 * Gets a list of the try blocks defined for this method. 59 * 60 * Try blocks may overlap freely, and do not need to be strictly nested, as in java. This is a more relaxed 61 * requirement than specified by the dex format, where try blocks may not overlap, and must be specified in 62 * ascending order. When writing to a dex file, the try blocks will be massaged into the appropriate format. 63 * 64 * In any region where there are overlapping try blocks, set of exception handlers for the overlapping region will 65 * consist of the union of all handlers in any try block that covers that region. 66 * 67 * If multiple overlapping try blocks define a handler for the same exception type, or define a catch-all 68 * handler, then those duplicate handlers must use the same handler offset. 69 * 70 * @return A list of the TryBlock items 71 */ getTryBlocks()72 @Nonnull List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(); 73 74 /** 75 * Get a list of debug items for this method. 76 * 77 * This generally matches the semantics of the debug_info_item in the dex specification, although in an easier to 78 * digest form. 79 * 80 * The addresses of the DebugItems in the returned list will be in non-descending order. 81 * 82 * @return A list of DebugInfo items 83 */ getDebugItems()84 @Nonnull Iterable<? extends DebugItem> getDebugItems(); 85 } 86