blob: f34080235d7eae1e67cd04c83cd9b80ef60d2db2 [file] [log] [blame]
Steven Morelandf1a35f72016-08-17 08:41:49 -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
17#include "VarDeclaration.h"
18
19namespace android {
20
21VarDeclaration::VarDeclaration(Type *type, const std::string &name)
Steven Moreland95b46232016-09-20 14:46:55 -070022 : Declaration(""),
Steven Morelandf1a35f72016-08-17 08:41:49 -070023 mType(type)
Steven Moreland95b46232016-09-20 14:46:55 -070024 {
25 setName(name);
26 }
Steven Morelandf1a35f72016-08-17 08:41:49 -070027
28VarDeclaration::~VarDeclaration() {
29 delete mType;
30}
31
Steven Moreland95b46232016-09-20 14:46:55 -070032void VarDeclaration::setName(const std::string &name) {
33 Declaration::setName(name);
Yifan Hong42009032016-09-29 09:38:15 -070034 // special case for varargs
35 if(getName() == "...")
36 return;
Steven Moreland95b46232016-09-20 14:46:55 -070037 forceCamelCase();
38}
39
Steven Morelandf1a35f72016-08-17 08:41:49 -070040Type* VarDeclaration::getType() const {
41 return mType;
42}
43
44void VarDeclaration::generateSource(Formatter &out) const {
45 out << getType()->decorateName(getName())
46 << ";\n";
47}
48
49void VarDeclaration::generateParameterSource(Formatter &out) const {
50 out << getType()->decorateName(getName());
51}
52
53void VarDeclaration::processContents(AST &) {
54 // nothing to do
55}
56
57} // namespace android