diff options
| author | Nagi5Yeq <wu@x-nagi.com> | 2020-05-25 00:53:57 +0800 |
|---|---|---|
| committer | Nagi5Yeq <wu@x-nagi.com> | 2020-05-25 00:53:57 +0800 |
| commit | c5e9f890dab0e4595482301d77876793c8bceb8c (patch) | |
| tree | cb115b6b5b8ffaa5d0de88f9ad5df34016223ec6 /VariableList.hh | |
| parent | 3832be8be4b23fb9e93a3f181e4205eadbdbf4de (diff) | |
finish function node.
Parser.y: rename 'context' to 'ctx' to avoid conflict in new version bison.
Diffstat (limited to 'VariableList.hh')
| -rw-r--r-- | VariableList.hh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/VariableList.hh b/VariableList.hh new file mode 100644 index 0000000..cf622ee --- /dev/null +++ b/VariableList.hh @@ -0,0 +1,28 @@ +#ifndef PCC_VARIABLELIST_HH +#define PCC_VARIABLELIST_HH + +#include <memory> +#include <string> +#include <unordered_map> + +#include "Type.hh" + +namespace pcc { +// type and value +using Variable = std::pair<std::shared_ptr<Type>, Value>; +// name and type +using Declaration = std::pair<std::string, std::shared_ptr<Type>>; + +class VariableList { + public: + VariableList(VariableList* parent = nullptr); + Variable Find(const std::string& name); + void Add(std::string name, Variable variable); + + protected: + std::unordered_map<std::string, Variable> variables_; + VariableList* parent_; +}; +} // namespace pcc + +#endif // !PCC_VARIABLELIST_HH |
