blob: f6d876f8eeb797b5f8df9964620a986e20d9ba4e [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -07001/*
2 * Copyright (C) 2016 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
Andreas Huberc9410c72016-07-28 12:18:40 -070017#include "NamedType.h"
18
19namespace android {
20
Timur Iskhakovcb0ba522017-07-17 20:01:37 -070021NamedType::NamedType(const char* localName, const Location& loc, Scope* parent)
22 : mLocalName(localName), mLocation(loc), mParent(parent) {}
Andreas Huber31629bc2016-08-03 09:06:40 -070023
Andreas Huber39fa7182016-08-19 14:27:33 -070024bool NamedType::isNamedType() const {
25 return true;
26}
27
Andreas Huber31629bc2016-08-03 09:06:40 -070028void NamedType::setFullName(const FQName &fullName) {
29 mFullName = fullName;
Andreas Huberc9410c72016-07-28 12:18:40 -070030}
31
Andreas Huberbfd76212016-08-09 11:12:16 -070032const FQName &NamedType::fqName() const {
33 return mFullName;
34}
35
Andreas Huber0e00de42016-08-03 09:56:02 -070036std::string NamedType::localName() const {
Andreas Huber31629bc2016-08-03 09:06:40 -070037 return mLocalName;
38}
39
40std::string NamedType::fullName() const {
Andreas Huber0e00de42016-08-03 09:56:02 -070041 return mFullName.cppName();
Andreas Huberc9410c72016-07-28 12:18:40 -070042}
43
Steven Moreland979e0992016-09-07 09:18:08 -070044std::string NamedType::partialCppName() const {
45 return mFullName.cppLocalName();
46}
47
Andreas Huber2831d512016-08-15 09:33:47 -070048std::string NamedType::fullJavaName() const {
49 return mFullName.javaName();
50}
51
Yifan Honga4b53d02016-10-31 17:29:10 -070052const Location &NamedType::location() const {
53 return mLocation;
54}
55
Timur Iskhakovcb0ba522017-07-17 20:01:37 -070056Scope* NamedType::parent() const {
57 return mParent;
58}
59
Yifan Hongf5cc2f72017-01-04 18:02:34 -080060void NamedType::emitDump(
61 Formatter &out,
62 const std::string &streamName,
63 const std::string &name) const {
64 emitDumpWithMethod(out, streamName, fqName().cppNamespace() + "::toString", name);
65}
66
Andreas Huberc9410c72016-07-28 12:18:40 -070067} // namespace android
68