2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * instanceof, checkcast, etc.
19 #ifndef DALVIK_OO_TYPECHECK_H_
20 #define DALVIK_OO_TYPECHECK_H_
22 /* VM startup/shutdown */
23 bool dvmInstanceofStartup(void);
24 void dvmInstanceofShutdown(void);
27 /* used by dvmInstanceof; don't call */
28 extern "C" int dvmInstanceofNonTrivial(const ClassObject* instance,
29 const ClassObject* clazz);
32 * Determine whether "instance" is an instance of "clazz".
34 * Returns 0 (false) if not, 1 (true) if so.
36 INLINE int dvmInstanceof(const ClassObject* instance, const ClassObject* clazz)
38 if (instance == clazz) {
40 gDvm.instanceofCache->trivial++;
43 return dvmInstanceofNonTrivial(instance, clazz);
47 * Determine whether a class implements an interface.
49 * Returns 0 (false) if not, 1 (true) if so.
51 int dvmImplements(const ClassObject* clazz, const ClassObject* interface);
54 * Determine whether "sub" is a sub-class of "clazz".
56 * Returns 0 (false) if not, 1 (true) if so.
58 INLINE int dvmIsSubClass(const ClassObject* sub, const ClassObject* clazz) {
60 /*printf("###### sub='%s' clazz='%s'\n", sub->name, clazz->name);*/
64 } while (sub != NULL);
70 * Determine whether or not we can store an object into an array, based
71 * on the classes of the two.
73 * Returns 0 (false) if not, 1 (true) if so.
75 extern "C" bool dvmCanPutArrayElement(const ClassObject* elemClass,
76 const ClassObject* arrayClass);
78 #endif // DALVIK_OO_TYPECHECK_H_