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
17package com.android.dx.cf.iface;
18
19import com.android.dx.rop.code.AccessFlags;
20import com.android.dx.rop.cst.CstNat;
21import com.android.dx.rop.cst.CstType;
22import com.android.dx.rop.type.Prototype;
23
24/**
25 * Standard implementation of {@link Method}, which directly stores
26 * all the associated data.
27 */
28public final class StdMethod extends StdMember implements Method {
29    /** {@code non-null;} the effective method descriptor */
30    private final Prototype effectiveDescriptor;
31
32    /**
33     * Constructs an instance.
34     *
35     * @param definingClass {@code non-null;} the defining class
36     * @param accessFlags access flags
37     * @param nat {@code non-null;} member name and type (descriptor)
38     * @param attributes {@code non-null;} list of associated attributes
39     */
40    public StdMethod(CstType definingClass, int accessFlags, CstNat nat,
41            AttributeList attributes) {
42        super(definingClass, accessFlags, nat, attributes);
43
44        String descStr = getDescriptor().getString();
45        effectiveDescriptor =
46            Prototype.intern(descStr, definingClass.getClassType(),
47                                    AccessFlags.isStatic(accessFlags),
48                                    nat.isInstanceInit());
49    }
50
51    /** {@inheritDoc} */
52    public Prototype getEffectiveDescriptor() {
53        return effectiveDescriptor;
54    }
55}
56