Everywhere: Pass step2 tests by supporting hash-maps

This commit is contained in:
Riyyi
2023-03-24 22:28:31 +01:00
parent 5c5a766b7e
commit c6ea42bc5d
6 changed files with 50 additions and 12 deletions
+11 -2
View File
@@ -12,6 +12,7 @@
#include <string>
#include <string_view>
#include <typeinfo> // typeid
#include <unordered_map>
#include <vector>
#include "ruc/format/formatter.h"
@@ -90,13 +91,21 @@ public:
// -----------------------------------------
// {}
class HashMap final : public Collection {
class HashMap final : public ASTNode {
public:
HashMap() = default;
virtual ~HashMap() = default;
virtual bool isCollection() const override { return false; }
virtual bool isHashMap() const override { return true; }
void addElement(const std::string& key, ASTNode* value);
const std::unordered_map<std::string, ASTNode*>& elements() const { return m_elements; }
size_t size() const { return m_elements.size(); }
bool empty() const { return m_elements.size() == 0; }
private:
std::unordered_map<std::string, ASTNode*> m_elements;
};
// -----------------------------------------