blob: d037d973c5f0caf46a58314f5852045339883088 [file] [log] [blame]
Christopher Wiley038485e2015-09-12 11:14:14 -07001/*
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
Steven Moreland9fccf582018-08-27 20:36:27 -070017#pragma once
Adam Lesinskiffa16862014-01-23 18:17:42 -080018
Adam Lesinskiffa16862014-01-23 18:17:42 -080019#include <stdarg.h>
20#include <stdio.h>
Jeongik Chaaabc1442019-02-12 17:44:48 +090021#include <memory>
22#include <optional>
Christopher Wileyae589972016-01-29 11:19:23 -080023#include <string>
Jeongik Cha439f2c42019-02-13 12:38:30 +090024#include <variant>
Christopher Wileyae589972016-01-29 11:19:23 -080025#include <vector>
Adam Lesinskiffa16862014-01-23 18:17:42 -080026
Adam Lesinskiffa16862014-01-23 18:17:42 -080027enum {
Christopher Wileyae589972016-01-29 11:19:23 -080028 PACKAGE_PRIVATE = 0x00000000,
29 PUBLIC = 0x00000001,
30 PRIVATE = 0x00000002,
31 PROTECTED = 0x00000003,
32 SCOPE_MASK = 0x00000003,
Adam Lesinskiffa16862014-01-23 18:17:42 -080033
Christopher Wileyae589972016-01-29 11:19:23 -080034 STATIC = 0x00000010,
35 FINAL = 0x00000020,
36 ABSTRACT = 0x00000040,
Adam Lesinskiffa16862014-01-23 18:17:42 -080037
Christopher Wileyae589972016-01-29 11:19:23 -080038 OVERRIDE = 0x00000100,
Adam Lesinskiffa16862014-01-23 18:17:42 -080039
Christopher Wileyae589972016-01-29 11:19:23 -080040 ALL_MODIFIERS = 0xffffffff
Adam Lesinskiffa16862014-01-23 18:17:42 -080041};
42
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070043namespace android {
44namespace aidl {
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070045class CodeWriter;
Christopher Wileydb154a52015-09-28 16:32:25 -070046} // namespace aidl
47} // namespace android
48
49namespace android {
50namespace aidl {
51namespace java {
52
Adam Lesinskiffa16862014-01-23 18:17:42 -080053// Write the modifiers that are set in both mod and mask
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070054void WriteModifiers(CodeWriter* to, int mod, int mask);
Adam Lesinskiffa16862014-01-23 18:17:42 -080055
Jiyong Park176905e2018-07-04 22:29:41 +090056struct AstNode {
57 AstNode() = default;
58 virtual ~AstNode() = default;
Christopher Wileyae589972016-01-29 11:19:23 -080059 virtual void Write(CodeWriter* to) const = 0;
Jiyong Park176905e2018-07-04 22:29:41 +090060 std::string ToString();
Adam Lesinskiffa16862014-01-23 18:17:42 -080061};
62
Jiyong Park176905e2018-07-04 22:29:41 +090063struct ClassElement : public AstNode {
64 ClassElement() = default;
65 virtual ~ClassElement() = default;
66};
67
68struct Expression : public AstNode {
Christopher Wileyae589972016-01-29 11:19:23 -080069 virtual ~Expression() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -080070};
71
Christopher Wileyae589972016-01-29 11:19:23 -080072struct LiteralExpression : public Expression {
Christopher Wiley12e894a2016-01-29 11:55:07 -080073 std::string value;
Adam Lesinskiffa16862014-01-23 18:17:42 -080074
Chih-Hung Hsieh156a57f2016-06-02 16:17:28 -070075 explicit LiteralExpression(const std::string& value);
Christopher Wileyae589972016-01-29 11:19:23 -080076 virtual ~LiteralExpression() = default;
77 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -080078};
79
80// TODO: also escape the contents. not needed for now
Christopher Wileyae589972016-01-29 11:19:23 -080081struct StringLiteralExpression : public Expression {
Christopher Wiley12e894a2016-01-29 11:55:07 -080082 std::string value;
Adam Lesinskiffa16862014-01-23 18:17:42 -080083
Chih-Hung Hsieh156a57f2016-06-02 16:17:28 -070084 explicit StringLiteralExpression(const std::string& value);
Christopher Wileyae589972016-01-29 11:19:23 -080085 virtual ~StringLiteralExpression() = default;
86 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -080087};
88
Christopher Wileyae589972016-01-29 11:19:23 -080089struct Variable : public Expression {
Jeongik Chadc77c1b2019-02-12 16:13:25 +090090 const std::string type;
Christopher Wiley12e894a2016-01-29 11:55:07 -080091 std::string name;
Adam Lesinskiffa16862014-01-23 18:17:42 -080092
Christopher Wileyae589972016-01-29 11:19:23 -080093 Variable() = default;
Jeongik Chadc77c1b2019-02-12 16:13:25 +090094 Variable(const std::string& type, const std::string& name);
Christopher Wileyae589972016-01-29 11:19:23 -080095 virtual ~Variable() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -080096
Christopher Wileyae589972016-01-29 11:19:23 -080097 void WriteDeclaration(CodeWriter* to) const;
98 void Write(CodeWriter* to) const;
Adam Lesinskiffa16862014-01-23 18:17:42 -080099};
100
Christopher Wileyae589972016-01-29 11:19:23 -0800101struct FieldVariable : public Expression {
Steven Moreland48548e02019-09-18 15:10:22 -0700102 std::variant<std::shared_ptr<Expression>, std::string> receiver;
Christopher Wiley12e894a2016-01-29 11:55:07 -0800103 std::string name;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800104
Steven Moreland48548e02019-09-18 15:10:22 -0700105 FieldVariable(std::shared_ptr<Expression> object, const std::string& name);
Jeongik Cha439f2c42019-02-13 12:38:30 +0900106 FieldVariable(const std::string& clazz, const std::string& name);
Christopher Wileyae589972016-01-29 11:19:23 -0800107 virtual ~FieldVariable() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800108
Christopher Wileyae589972016-01-29 11:19:23 -0800109 void Write(CodeWriter* to) const;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800110};
111
Christopher Wileyae589972016-01-29 11:19:23 -0800112struct Field : public ClassElement {
Christopher Wiley12e894a2016-01-29 11:55:07 -0800113 std::string comment;
Jiyong Parka6605ab2018-11-11 14:30:21 +0900114 std::vector<std::string> annotations;
Christopher Wileyae589972016-01-29 11:19:23 -0800115 int modifiers = 0;
Steven Moreland48548e02019-09-18 15:10:22 -0700116 std::shared_ptr<Variable> variable = nullptr;
Christopher Wiley12e894a2016-01-29 11:55:07 -0800117 std::string value;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800118
Christopher Wileyae589972016-01-29 11:19:23 -0800119 Field() = default;
Steven Moreland48548e02019-09-18 15:10:22 -0700120 Field(int modifiers, std::shared_ptr<Variable> variable);
Christopher Wileyae589972016-01-29 11:19:23 -0800121 virtual ~Field() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800122
Christopher Wileyae589972016-01-29 11:19:23 -0800123 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800124};
125
Jiyong Park176905e2018-07-04 22:29:41 +0900126struct Statement : public AstNode {
Christopher Wileyae589972016-01-29 11:19:23 -0800127 virtual ~Statement() = default;
Jiyong Park176905e2018-07-04 22:29:41 +0900128};
129
130struct LiteralStatement : public Statement {
131 public:
132 LiteralStatement(const std::string& value);
133 virtual ~LiteralStatement() = default;
134 void Write(CodeWriter* to) const override;
135
136 private:
137 const std::string value_;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800138};
139
Christopher Wileyae589972016-01-29 11:19:23 -0800140struct StatementBlock : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700141 std::vector<std::shared_ptr<Statement>> statements;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800142
Christopher Wileyae589972016-01-29 11:19:23 -0800143 StatementBlock() = default;
144 virtual ~StatementBlock() = default;
145 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800146
Steven Moreland48548e02019-09-18 15:10:22 -0700147 void Add(std::shared_ptr<Statement> statement);
148 void Add(std::shared_ptr<Expression> expression);
Adam Lesinskiffa16862014-01-23 18:17:42 -0800149};
150
Christopher Wileyae589972016-01-29 11:19:23 -0800151struct ExpressionStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700152 std::shared_ptr<Expression> expression;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800153
Steven Moreland48548e02019-09-18 15:10:22 -0700154 explicit ExpressionStatement(std::shared_ptr<Expression> expression);
Christopher Wileyae589972016-01-29 11:19:23 -0800155 virtual ~ExpressionStatement() = default;
156 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800157};
158
Christopher Wileyae589972016-01-29 11:19:23 -0800159struct Assignment : public Expression {
Steven Moreland48548e02019-09-18 15:10:22 -0700160 std::shared_ptr<Variable> lvalue;
161 std::shared_ptr<Expression> rvalue;
Jeongik Cha439f2c42019-02-13 12:38:30 +0900162 std::optional<std::string> cast = std::nullopt;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800163
Steven Moreland48548e02019-09-18 15:10:22 -0700164 Assignment(std::shared_ptr<Variable> lvalue, std::shared_ptr<Expression> rvalue);
165 Assignment(std::shared_ptr<Variable> lvalue, std::shared_ptr<Expression> rvalue,
166 std::string cast);
Christopher Wileyae589972016-01-29 11:19:23 -0800167 virtual ~Assignment() = default;
168 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800169};
170
Christopher Wileyae589972016-01-29 11:19:23 -0800171struct MethodCall : public Expression {
Steven Moreland48548e02019-09-18 15:10:22 -0700172 std::variant<std::monostate, std::shared_ptr<Expression>, std::string> receiver;
Christopher Wiley12e894a2016-01-29 11:55:07 -0800173 std::string name;
Steven Moreland48548e02019-09-18 15:10:22 -0700174 std::vector<std::shared_ptr<Expression>> arguments;
Christopher Wiley12e894a2016-01-29 11:55:07 -0800175 std::vector<std::string> exceptions;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800176
Chih-Hung Hsieh156a57f2016-06-02 16:17:28 -0700177 explicit MethodCall(const std::string& name);
Steven Moreland48548e02019-09-18 15:10:22 -0700178 MethodCall(const std::string& name, const std::vector<std::shared_ptr<Expression>>& args);
179 MethodCall(std::shared_ptr<Expression> obj, const std::string& name);
Jeongik Cha439f2c42019-02-13 12:38:30 +0900180 MethodCall(const std::string& clazz, const std::string& name);
Steven Moreland48548e02019-09-18 15:10:22 -0700181 MethodCall(std::shared_ptr<Expression> obj, const std::string& name,
182 const std::vector<std::shared_ptr<Expression>>& args);
183 MethodCall(const std::string&, const std::string& name,
184 const std::vector<std::shared_ptr<Expression>>& args);
Christopher Wileyae589972016-01-29 11:19:23 -0800185 virtual ~MethodCall() = default;
186 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800187};
188
Christopher Wileyae589972016-01-29 11:19:23 -0800189struct Comparison : public Expression {
Steven Moreland48548e02019-09-18 15:10:22 -0700190 std::shared_ptr<Expression> lvalue;
Christopher Wiley12e894a2016-01-29 11:55:07 -0800191 std::string op;
Steven Moreland48548e02019-09-18 15:10:22 -0700192 std::shared_ptr<Expression> rvalue;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800193
Steven Moreland48548e02019-09-18 15:10:22 -0700194 Comparison(std::shared_ptr<Expression> lvalue, const std::string& op,
195 std::shared_ptr<Expression> rvalue);
Christopher Wileyae589972016-01-29 11:19:23 -0800196 virtual ~Comparison() = default;
197 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800198};
199
Christopher Wileyae589972016-01-29 11:19:23 -0800200struct NewExpression : public Expression {
Jeongik Cha9a7f21f2019-02-13 14:42:47 +0900201 const std::string instantiableName;
Steven Moreland48548e02019-09-18 15:10:22 -0700202 std::vector<std::shared_ptr<Expression>> arguments;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800203
Jeongik Cha9a7f21f2019-02-13 14:42:47 +0900204 explicit NewExpression(const std::string& name);
Steven Moreland48548e02019-09-18 15:10:22 -0700205 NewExpression(const std::string& name, const std::vector<std::shared_ptr<Expression>>& args);
Christopher Wileyae589972016-01-29 11:19:23 -0800206 virtual ~NewExpression() = default;
207 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800208};
209
Christopher Wileyae589972016-01-29 11:19:23 -0800210struct NewArrayExpression : public Expression {
Jeongik Cha9a7f21f2019-02-13 14:42:47 +0900211 const std::string type;
Steven Moreland48548e02019-09-18 15:10:22 -0700212 std::shared_ptr<Expression> size;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800213
Steven Moreland48548e02019-09-18 15:10:22 -0700214 NewArrayExpression(const std::string& type, std::shared_ptr<Expression> size);
Christopher Wileyae589972016-01-29 11:19:23 -0800215 virtual ~NewArrayExpression() = default;
216 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800217};
218
Christopher Wileyae589972016-01-29 11:19:23 -0800219struct Cast : public Expression {
Jeongik Cha9a7f21f2019-02-13 14:42:47 +0900220 const std::string type;
Steven Moreland48548e02019-09-18 15:10:22 -0700221 std::shared_ptr<Expression> expression = nullptr;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800222
Christopher Wileyae589972016-01-29 11:19:23 -0800223 Cast() = default;
Steven Moreland48548e02019-09-18 15:10:22 -0700224 Cast(const std::string& type, std::shared_ptr<Expression> expression);
Christopher Wileyae589972016-01-29 11:19:23 -0800225 virtual ~Cast() = default;
226 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800227};
228
Christopher Wileyae589972016-01-29 11:19:23 -0800229struct VariableDeclaration : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700230 std::shared_ptr<Variable> lvalue = nullptr;
231 std::shared_ptr<Expression> rvalue = nullptr;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800232
Steven Moreland48548e02019-09-18 15:10:22 -0700233 explicit VariableDeclaration(std::shared_ptr<Variable> lvalue);
234 VariableDeclaration(std::shared_ptr<Variable> lvalue, std::shared_ptr<Expression> rvalue);
Christopher Wileyae589972016-01-29 11:19:23 -0800235 virtual ~VariableDeclaration() = default;
236 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800237};
238
Christopher Wileyae589972016-01-29 11:19:23 -0800239struct IfStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700240 std::shared_ptr<Expression> expression = nullptr;
241 std::shared_ptr<StatementBlock> statements = std::make_shared<StatementBlock>();
242 std::shared_ptr<IfStatement> elseif = nullptr;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800243
Christopher Wileyae589972016-01-29 11:19:23 -0800244 IfStatement() = default;
245 virtual ~IfStatement() = default;
246 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800247};
248
Christopher Wileyae589972016-01-29 11:19:23 -0800249struct ReturnStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700250 std::shared_ptr<Expression> expression;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800251
Steven Moreland48548e02019-09-18 15:10:22 -0700252 explicit ReturnStatement(std::shared_ptr<Expression> expression);
Christopher Wileyae589972016-01-29 11:19:23 -0800253 virtual ~ReturnStatement() = default;
254 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800255};
256
Christopher Wileyae589972016-01-29 11:19:23 -0800257struct TryStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700258 std::shared_ptr<StatementBlock> statements = std::make_shared<StatementBlock>();
Adam Lesinskiffa16862014-01-23 18:17:42 -0800259
Christopher Wileyae589972016-01-29 11:19:23 -0800260 TryStatement() = default;
261 virtual ~TryStatement() = default;
262 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800263};
264
Christopher Wileyae589972016-01-29 11:19:23 -0800265struct FinallyStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700266 std::shared_ptr<StatementBlock> statements = std::make_shared<StatementBlock>();
Adam Lesinskiffa16862014-01-23 18:17:42 -0800267
Christopher Wileyae589972016-01-29 11:19:23 -0800268 FinallyStatement() = default;
269 virtual ~FinallyStatement() = default;
270 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800271};
272
Jiyong Park176905e2018-07-04 22:29:41 +0900273struct Case : public AstNode {
Christopher Wiley12e894a2016-01-29 11:55:07 -0800274 std::vector<std::string> cases;
Steven Moreland48548e02019-09-18 15:10:22 -0700275 std::shared_ptr<StatementBlock> statements = std::make_shared<StatementBlock>();
Adam Lesinskiffa16862014-01-23 18:17:42 -0800276
Christopher Wileyae589972016-01-29 11:19:23 -0800277 Case() = default;
Chih-Hung Hsieh156a57f2016-06-02 16:17:28 -0700278 explicit Case(const std::string& c);
Christopher Wileyae589972016-01-29 11:19:23 -0800279 virtual ~Case() = default;
Jiyong Park176905e2018-07-04 22:29:41 +0900280 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800281};
282
Christopher Wileyae589972016-01-29 11:19:23 -0800283struct SwitchStatement : public Statement {
Steven Moreland48548e02019-09-18 15:10:22 -0700284 std::shared_ptr<Expression> expression;
285 std::vector<std::shared_ptr<Case>> cases;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800286
Steven Moreland48548e02019-09-18 15:10:22 -0700287 explicit SwitchStatement(std::shared_ptr<Expression> expression);
Christopher Wileyae589972016-01-29 11:19:23 -0800288 virtual ~SwitchStatement() = default;
289 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800290};
291
Christopher Wileyae589972016-01-29 11:19:23 -0800292struct Method : public ClassElement {
Christopher Wiley12e894a2016-01-29 11:55:07 -0800293 std::string comment;
Jiyong Parka6605ab2018-11-11 14:30:21 +0900294 std::vector<std::string> annotations;
Christopher Wileyae589972016-01-29 11:19:23 -0800295 int modifiers = 0;
Jeongik Cha6cadc212019-02-12 18:16:03 +0900296 std::optional<std::string> returnType = std::nullopt; // nullopt means constructor
Christopher Wiley12e894a2016-01-29 11:55:07 -0800297 std::string name;
Steven Moreland48548e02019-09-18 15:10:22 -0700298 std::vector<std::shared_ptr<Variable>> parameters;
Jeongik Cha6cadc212019-02-12 18:16:03 +0900299 std::vector<std::string> exceptions;
Steven Moreland48548e02019-09-18 15:10:22 -0700300 std::shared_ptr<StatementBlock> statements = nullptr;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800301
Christopher Wileyae589972016-01-29 11:19:23 -0800302 Method() = default;
303 virtual ~Method() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800304
Christopher Wileyae589972016-01-29 11:19:23 -0800305 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800306};
307
Steven Moreland5557f1c2018-07-02 13:50:23 -0700308struct LiteralClassElement : public ClassElement {
309 std::string element;
310
311 LiteralClassElement(std::string e) : element(e) {}
312 virtual ~LiteralClassElement() = default;
313
314 void Write(CodeWriter* to) const override;
315};
316
Christopher Wileyae589972016-01-29 11:19:23 -0800317struct Class : public ClassElement {
318 enum { CLASS, INTERFACE };
Adam Lesinskiffa16862014-01-23 18:17:42 -0800319
Christopher Wiley12e894a2016-01-29 11:55:07 -0800320 std::string comment;
Jiyong Parka6605ab2018-11-11 14:30:21 +0900321 std::vector<std::string> annotations;
Christopher Wileyae589972016-01-29 11:19:23 -0800322 int modifiers = 0;
323 int what = CLASS; // CLASS or INTERFACE
Jeongik Chaaabc1442019-02-12 17:44:48 +0900324 std::string type;
325 std::optional<std::string> extends = std::nullopt;
326 std::vector<std::string> interfaces;
Steven Moreland48548e02019-09-18 15:10:22 -0700327 std::vector<std::shared_ptr<ClassElement>> elements;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800328
Christopher Wileyae589972016-01-29 11:19:23 -0800329 Class() = default;
330 virtual ~Class() = default;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800331
Christopher Wileyae589972016-01-29 11:19:23 -0800332 void Write(CodeWriter* to) const override;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800333};
334
Jiyong Park176905e2018-07-04 22:29:41 +0900335class Document : public AstNode {
Christopher Wileyf76b59a2016-01-29 11:32:11 -0800336 public:
337 Document(const std::string& comment,
338 const std::string& package,
Christopher Wileyf76b59a2016-01-29 11:32:11 -0800339 std::unique_ptr<Class> clazz);
Christopher Wileyae589972016-01-29 11:19:23 -0800340 virtual ~Document() = default;
Jiyong Park176905e2018-07-04 22:29:41 +0900341 void Write(CodeWriter* to) const override;
Christopher Wileyf76b59a2016-01-29 11:32:11 -0800342
343 private:
344 std::string comment_;
345 std::string package_;
Christopher Wileyf76b59a2016-01-29 11:32:11 -0800346 std::unique_ptr<Class> clazz_;
Adam Lesinskiffa16862014-01-23 18:17:42 -0800347};
348
Steven Moreland48548e02019-09-18 15:10:22 -0700349extern std::shared_ptr<Expression> NULL_VALUE;
350extern std::shared_ptr<Expression> THIS_VALUE;
351extern std::shared_ptr<Expression> SUPER_VALUE;
352extern std::shared_ptr<Expression> TRUE_VALUE;
353extern std::shared_ptr<Expression> FALSE_VALUE;
Christopher Wileydb154a52015-09-28 16:32:25 -0700354} // namespace java
Christopher Wileyfdeb0f42015-09-11 15:38:22 -0700355} // namespace aidl
356} // namespace android