Adds support for BUILD_CONST_KEY_MAP opcode

Tests have also been added.

Fixes #172
This commit is contained in:
John Richards
2020-10-20 01:46:38 -04:00
parent 8fdfe170fc
commit 5b819fa23e
6 changed files with 76 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ public:
NODE_TUPLE, NODE_LIST, NODE_MAP, NODE_SUBSCR, NODE_PRINT,
NODE_CONVERT, NODE_KEYWORD, NODE_RAISE, NODE_EXEC, NODE_BLOCK,
NODE_COMPREHENSION, NODE_LOADBUILDCLASS, NODE_AWAITABLE,
NODE_CONST_MAP,
// Empty node types
NODE_LOCALS,
@@ -358,6 +359,21 @@ private:
map_t m_values;
};
class ASTConstMap : public ASTNode {
public:
typedef std::vector<PycRef<ASTNode>> values_t;
ASTConstMap(PycRef<ASTNode> keys, const values_t& values)
: ASTNode(NODE_CONST_MAP), m_keys(std::move(keys)), m_values(std::move(values)) { }
const PycRef<ASTNode>& keys() const { return m_keys; }
const values_t& values() const { return m_values; }
private:
PycRef<ASTNode> m_keys;
values_t m_values;
};
class ASTSubscr : public ASTNode {
public: