OSDN Git Service

am ce3de859: am 4934b377: Several fixes for JIT and self-verification under corner...
[android-x86/dalvik.git] / dexgen / src / com / android / dexgen / rop / StdField.java
1 /*
2  * Copyright (C) 2007 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 package com.android.dexgen.rop;
18
19 import com.android.dexgen.rop.cst.CstNat;
20 import com.android.dexgen.rop.cst.CstType;
21 import com.android.dexgen.rop.cst.TypedConstant;
22
23 /**
24  * Standard implementation of {@link Field}, which directly stores
25  * all the associated data.
26  */
27 public final class StdField extends StdMember implements Field {
28     /**
29      * Constructs an instance.
30      *
31      * @param definingClass {@code non-null;} the defining class
32      * @param accessFlags access flags
33      * @param nat {@code non-null;} member name and type (descriptor)
34      * @param attributes {@code non-null;} list of associated attributes
35      */
36     public StdField(CstType definingClass, int accessFlags, CstNat nat,
37                     AttributeList attributes) {
38         super(definingClass, accessFlags, nat, attributes);
39     }
40
41     /** {@inheritDoc} */
42     public TypedConstant getConstantValue() {
43         AttributeList attribs = getAttributes();
44         AttConstantValue cval = (AttConstantValue)
45             attribs.findFirst(AttConstantValue.ATTRIBUTE_NAME);
46
47         if (cval == null) {
48             return null;
49         }
50
51         return cval.getConstantValue();
52     }
53 }