tan  0.0.1
organize_packages.h
1 #ifndef __TAN_SRC_ANALYSIS_ORGANIZE_PACKAGES_H__
2 #define __TAN_SRC_ANALYSIS_ORGANIZE_PACKAGES_H__
3 
4 #include "common/compiler_action.h"
5 #include "base/container.h"
6 
7 namespace tanlang {
8 
9 class Package;
10 
11 /**
12  * \brief Organize a list of source files into their corresponding packages according to the code.
13  * Run this stage early since semantic analysis is performed on the package level.
14  * \note The input will likely contain outdated information so any CompilerAction pass this should only operates
15  * on the package-level.
16  */
17 class OrganizePackages : public CompilerAction<OrganizePackages, vector<Program *>, vector<Package *>> {
18 public:
19  vector<Package *> run_impl(vector<Program *> ps);
20 
21  DECLARE_AST_VISITOR_IMPL(Program);
22  DECLARE_AST_VISITOR_IMPL(Intrinsic);
23 
24 private:
25  // package name => top level context
26  umap<str, vector<Context *>> _package_top_level_ctx{};
27  umap<str, vector<ASTBase *>> _package_top_level_asts{};
28 };
29 
30 } // namespace tanlang
31 
32 #endif // __TAN_SRC_ANALYSIS_ORGANIZE_PACKAGES_H__
A generic representation of Intrinsic variables/functions.
Definition: intrinsic.h:55
Organize a list of source files into their corresponding packages according to the code....