blob: 227d80c1c7926a92c69dce309d69e2dcc686cc43 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef AST_H_
2
3#define AST_H_
4
5#include <android-base/macros.h>
Andreas Hubereb1081f2016-07-28 13:13:24 -07006#include <string>
Andreas Huberc9410c72016-07-28 12:18:40 -07007#include <utils/Vector.h>
8
Andreas Huberda51b8e2016-07-28 16:00:57 -07009#include "FQName.h"
10
Andreas Huberc9410c72016-07-28 12:18:40 -070011namespace android {
12
13struct Formatter;
14struct Type;
15struct Scope;
16
17struct AST {
18 AST();
19 ~AST();
20
21 static AST *Parse(const char *path);
22
Andreas Huber84f89de2016-07-28 15:39:51 -070023 bool setPackage(const char *package);
24 bool addImport(const char *import);
Andreas Hubereb1081f2016-07-28 13:13:24 -070025
Andreas Huberc9410c72016-07-28 12:18:40 -070026 void enterScope(Scope *container);
27 void leaveScope();
28 Scope *scope();
29
30 void *scanner();
31 void setScanner(void *scanner);
32
33 Type *lookupType(const char *name);
34
35 void dump(Formatter &out) const;
36
37private:
38 Vector<Scope *> mScopePath;
39
40 void *mScanner;
41 Scope *mRootScope;
42
Andreas Huberda51b8e2016-07-28 16:00:57 -070043 FQName mPackage;
Andreas Huber84f89de2016-07-28 15:39:51 -070044
Andreas Huberc9410c72016-07-28 12:18:40 -070045 DISALLOW_COPY_AND_ASSIGN(AST);
46};
47
48} // namespace android
49
50#endif // AST_H_