| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | * Resolve "constant pool" references into pointers to VM structs. |
| 18 | */ |
| 19 | #ifndef _DALVIK_OO_RESOLVE |
| 20 | #define _DALVIK_OO_RESOLVE |
| 21 | |
| 22 | /* |
| 23 | * "Direct" and "virtual" methods are stored independently. The type of call |
| 24 | * used to invoke the method determines which list we search, and whether |
| 25 | * we travel up into superclasses. |
| 26 | * |
| 27 | * (<clinit>, <init>, and methods declared "private" or "static" are stored |
| 28 | * in the "direct" list. All others are stored in the "virtual" list.) |
| 29 | */ |
| 30 | typedef enum MethodType { |
| 31 | METHOD_UNKNOWN = 0, |
| 32 | METHOD_DIRECT, // <init>, private |
| 33 | METHOD_STATIC, // static |
| 34 | METHOD_VIRTUAL, // virtual, super |
| 35 | METHOD_INTERFACE // interface |
| 36 | } MethodType; |
| 37 | |
| 38 | /* |
| 39 | * Resolve a class, given the referring class and a constant pool index |
| 40 | * for the DexTypeId. |
| 41 | * |
| 42 | * Does not initialize the class. |
| 43 | * |
| 44 | * Throws an exception and returns NULL on failure. |
| 45 | */ |
| 46 | ClassObject* dvmResolveClass(const ClassObject* referrer, u4 classIdx, |
| 47 | bool fromUnverifiedConstant); |
| 48 | |
| 49 | /* |
| 50 | * Resolve a direct, static, or virtual method. |
| 51 | * |
| 52 | * Can cause the method's class to be initialized if methodType is |
| 53 | * METHOD_STATIC. |
| 54 | * |
| 55 | * Throws an exception and returns NULL on failure. |
| 56 | */ |
| 57 | Method* dvmResolveMethod(const ClassObject* referrer, u4 methodIdx, |
| 58 | MethodType methodType); |
| 59 | |
| 60 | /* |
| 61 | * Resolve an interface method. |
| 62 | * |
| 63 | * Throws an exception and returns NULL on failure. |
| 64 | */ |
| 65 | Method* dvmResolveInterfaceMethod(const ClassObject* referrer, u4 methodIdx); |
| 66 | |
| 67 | /* |
| 68 | * Resolve an instance field. |
| 69 | * |
| 70 | * Throws an exception and returns NULL on failure. |
| 71 | */ |
| 72 | InstField* dvmResolveInstField(const ClassObject* referrer, u4 ifieldIdx); |
| 73 | |
| 74 | /* |
| 75 | * Resolve a static field. |
| 76 | * |
| 77 | * Causes the field's class to be initialized. |
| 78 | * |
| 79 | * Throws an exception and returns NULL on failure. |
| 80 | */ |
| 81 | StaticField* dvmResolveStaticField(const ClassObject* referrer, u4 sfieldIdx); |
| 82 | |
| 83 | /* |
| 84 | * Resolve a "const-string" reference. |
| 85 | * |
| 86 | * Throws an exception and returns NULL on failure. |
| 87 | */ |
| 88 | StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx); |
| 89 | |
| 90 | /* |
| 91 | * Return debug string constant for enum. |
| 92 | */ |
| 93 | const char* dvmMethodTypeStr(MethodType methodType); |
| 94 | |
| 95 | #endif /*_DALVIK_OO_RESOLVE*/ |