1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dx.io; 18 19 public final class Code { 20 private final int registersSize; 21 private final int insSize; 22 private final int outsSize; 23 private final int debugInfoOffset; 24 private final short[] instructions; 25 private final Try[] tries; 26 private final CatchHandler[] catchHandlers; 27 Code(int registersSize, int insSize, int outsSize, int debugInfoOffset, short[] instructions, Try[] tries, CatchHandler[] catchHandlers)28 public Code(int registersSize, int insSize, int outsSize, int debugInfoOffset, 29 short[] instructions, Try[] tries, CatchHandler[] catchHandlers) { 30 this.registersSize = registersSize; 31 this.insSize = insSize; 32 this.outsSize = outsSize; 33 this.debugInfoOffset = debugInfoOffset; 34 this.instructions = instructions; 35 this.tries = tries; 36 this.catchHandlers = catchHandlers; 37 } 38 getRegistersSize()39 public int getRegistersSize() { 40 return registersSize; 41 } 42 getInsSize()43 public int getInsSize() { 44 return insSize; 45 } 46 getOutsSize()47 public int getOutsSize() { 48 return outsSize; 49 } 50 getDebugInfoOffset()51 public int getDebugInfoOffset() { 52 return debugInfoOffset; 53 } 54 getInstructions()55 public short[] getInstructions() { 56 return instructions; 57 } 58 getTries()59 public Try[] getTries() { 60 return tries; 61 } 62 getCatchHandlers()63 public CatchHandler[] getCatchHandlers() { 64 return catchHandlers; 65 } 66 67 public static class Try { 68 final int startAddress; 69 final int instructionCount; 70 final int handlerOffset; 71 Try(int startAddress, int instructionCount, int handlerOffset)72 Try(int startAddress, int instructionCount, int handlerOffset) { 73 this.startAddress = startAddress; 74 this.instructionCount = instructionCount; 75 this.handlerOffset = handlerOffset; 76 } 77 getStartAddress()78 public int getStartAddress() { 79 return startAddress; 80 } 81 getInstructionCount()82 public int getInstructionCount() { 83 return instructionCount; 84 } 85 getHandlerOffset()86 public int getHandlerOffset() { 87 return handlerOffset; 88 } 89 } 90 91 public static class CatchHandler { 92 final int[] typeIndexes; 93 final int[] addresses; 94 final int catchAllAddress; 95 CatchHandler(int[] typeIndexes, int[] addresses, int catchAllAddress)96 public CatchHandler(int[] typeIndexes, int[] addresses, int catchAllAddress) { 97 this.typeIndexes = typeIndexes; 98 this.addresses = addresses; 99 this.catchAllAddress = catchAllAddress; 100 } 101 getTypeIndexes()102 public int[] getTypeIndexes() { 103 return typeIndexes; 104 } 105 getAddresses()106 public int[] getAddresses() { 107 return addresses; 108 } 109 getCatchAllAddress()110 public int getCatchAllAddress() { 111 return catchAllAddress; 112 } 113 } 114 } 115