Add "global variables" which will get displayed in the hex editor

This commit is contained in:
WerWolv
2020-11-10 16:24:48 +01:00
parent f47ff5633b
commit 73f83dc01a
5 changed files with 63 additions and 36 deletions

View File

@@ -27,16 +27,19 @@ namespace hex::lang {
class ASTNodeVariableDecl : public ASTNode {
public:
explicit ASTNodeVariableDecl(const Token::TypeToken::Type &type, const std::string &name, const std::string& customTypeName = "")
: ASTNode(Type::VariableDecl), m_type(type), m_name(name), m_customTypeName(customTypeName) { }
explicit ASTNodeVariableDecl(const Token::TypeToken::Type &type, const std::string &name, const std::string& customTypeName = "", std::optional<u64> offset = { })
: ASTNode(Type::VariableDecl), m_type(type), m_name(name), m_customTypeName(customTypeName), m_offset(offset) { }
const Token::TypeToken::Type& getVariableType() const { return this->m_type; }
const std::string& getCustomVariableTypeName() const { return this->m_customTypeName; }
const std::string& getVariableName() const { return this->m_name; };
std::optional<u64> getOffset() { return this->m_offset; };
private:
Token::TypeToken::Type m_type;
std::string m_name, m_customTypeName;
std::optional<u64> m_offset;
};
class ASTNodeScope : public ASTNode {
@@ -50,16 +53,14 @@ namespace hex::lang {
class ASTNodeStruct : public ASTNode {
public:
explicit ASTNodeStruct(std::string name, std::vector<ASTNode*> nodes, std::optional<u64> offset = { })
: ASTNode(Type::Struct), m_name(name), m_nodes(nodes), m_offset(offset) { }
explicit ASTNodeStruct(std::string name, std::vector<ASTNode*> nodes)
: ASTNode(Type::Struct), m_name(name), m_nodes(nodes) { }
const std::string& getName() const { return this->m_name; }
std::vector<ASTNode*> &getNodes() { return this->m_nodes; }
std::optional<u64> getOffset() { return this->m_offset; };
private:
std::string m_name;
std::vector<ASTNode*> m_nodes;
std::optional<u64> m_offset;
};
class ASTNodeTypeDecl : public ASTNode {