| 1 | #ifndef NIX_IRC_IR_GEN_H |
| 2 | #define NIX_IRC_IR_GEN_H |
| 3 | |
| 4 | #include "types.h" |
| 5 | #include <memory> |
| 6 | #include <string> |
| 7 | #include <unordered_map> |
| 8 | #include <vector> |
| 9 | |
| 10 | namespace nix_irc { |
| 11 | |
| 12 | class IRGenerator { |
| 13 | public: |
| 14 | IRGenerator(); |
| 15 | ~IRGenerator(); |
| 16 | |
| 17 | void set_string_table(const std::unordered_map<std::string, uint32_t>& table); |
| 18 | uint32_t add_string(const std::string& str); |
| 19 | |
| 20 | std::shared_ptr<Node> generate(const std::shared_ptr<Node>& ast); |
| 21 | |
| 22 | private: |
| 23 | struct Impl; |
| 24 | std::unique_ptr<Impl> pImpl; |
| 25 | }; |
| 26 | |
| 27 | class NameResolver { |
| 28 | public: |
| 29 | NameResolver(); |
| 30 | ~NameResolver(); |
| 31 | |
| 32 | void enter_scope(); |
| 33 | void exit_scope(); |
| 34 | void bind(const std::string& name); |
| 35 | uint32_t resolve(const std::string& name); |
| 36 | bool is_bound(const std::string& name) const; |
| 37 | |
| 38 | private: |
| 39 | struct Impl; |
| 40 | std::unique_ptr<Impl> pImpl; |
| 41 | }; |
| 42 | |
| 43 | } // namespace nix_irc |
| 44 | |
| 45 | #endif |