1 /*
2  * Copyright (C) 2015 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 #ifndef ART_RUNTIME_MIRROR_FIELD_INL_H_
18 #define ART_RUNTIME_MIRROR_FIELD_INL_H_
19 
20 #include "field.h"
21 
22 #include "art_field-inl.h"
23 #include "class-alloc-inl.h"
24 #include "class_root-inl.h"
25 #include "object-inl.h"
26 
27 namespace art {
28 
29 namespace mirror {
30 
GetDeclaringClass()31 inline ObjPtr<mirror::Class> Field::GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_) {
32   return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_));
33 }
34 
GetTypeAsPrimitiveType()35 inline Primitive::Type Field::GetTypeAsPrimitiveType() {
36   return GetType()->GetPrimitiveType();
37 }
38 
GetType()39 inline ObjPtr<mirror::Class> Field::GetType() {
40   return GetFieldObject<mirror::Class>(OFFSET_OF_OBJECT_MEMBER(Field, type_));
41 }
42 
43 template<bool kTransactionActive, bool kCheckTransaction>
SetDeclaringClass(ObjPtr<Class> c)44 inline void Field::SetDeclaringClass(ObjPtr<Class> c) {
45   SetFieldObject<kTransactionActive, kCheckTransaction>(DeclaringClassOffset(), c);
46 }
47 
48 template<bool kTransactionActive, bool kCheckTransaction>
SetType(ObjPtr<Class> type)49 inline void Field::SetType(ObjPtr<Class> type) {
50   SetFieldObject<kTransactionActive, kCheckTransaction>(TypeOffset(), type);
51 }
52 
53 }  // namespace mirror
54 }  // namespace art
55 
56 #endif  // ART_RUNTIME_MIRROR_FIELD_INL_H_
57