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