• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H_
20 #define DALVIK_OO_RESOLVE_H_
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 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 };
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 extern "C" ClassObject* dvmResolveClass(const ClassObject* referrer,
47                                         u4 classIdx,
48                                         bool fromUnverifiedConstant);
49 
50 /*
51  * Resolve a direct, static, or virtual method.
52  *
53  * Can cause the method's class to be initialized if methodType is
54  * METHOD_STATIC.
55  *
56  * Throws an exception and returns NULL on failure.
57  */
58 extern "C" Method* dvmResolveMethod(const ClassObject* referrer, u4 methodIdx,
59                                     MethodType methodType);
60 
61 /*
62  * Resolve an interface method.
63  *
64  * Throws an exception and returns NULL on failure.
65  */
66 Method* dvmResolveInterfaceMethod(const ClassObject* referrer, u4 methodIdx);
67 
68 /*
69  * Resolve an instance field.
70  *
71  * Throws an exception and returns NULL on failure.
72  */
73 extern "C" InstField* dvmResolveInstField(const ClassObject* referrer,
74                                           u4 ifieldIdx);
75 
76 /*
77  * Resolve a static field.
78  *
79  * Causes the field's class to be initialized.
80  *
81  * Throws an exception and returns NULL on failure.
82  */
83 extern "C" StaticField* dvmResolveStaticField(const ClassObject* referrer,
84                                               u4 sfieldIdx);
85 
86 /*
87  * Resolve a "const-string" reference.
88  *
89  * Throws an exception and returns NULL on failure.
90  */
91 extern "C" StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx);
92 
93 /*
94  * Return debug string constant for enum.
95  */
96 const char* dvmMethodTypeStr(MethodType methodType);
97 
98 #endif  // DALVIK_OO_RESOLVE_H_
99