#pragma once #include #include "gmachine.hpp" namespace lily { class compile_env { protected: std::shared_ptr parent = nullptr; public: virtual int get_offset(const std::string& name) = 0; virtual bool is_variable(const std::string& name) = 0; void set_parent(std::shared_ptr p); }; class compile_env_var : public compile_env { private: std::string var; public: compile_env_var(std::string v) : var(std::move(v)), compile_env() {} int get_offset(const std::string& name); bool is_variable(const std::string& name); }; class compile_env_offset : public compile_env { private: int offset; public: compile_env_offset(int o) : offset(o), compile_env() {} int get_offset(const std::string& name); bool is_variable(const std::string& name); }; };