patterns: Allow forward declaring of types

This commit is contained in:
WerWolv
2022-03-24 16:57:12 +01:00
parent c2803fe1e2
commit c09d85f46d
4 changed files with 46 additions and 13 deletions

View File

@@ -8,6 +8,8 @@ namespace hex::pl {
class ASTNodeTypeDecl : public ASTNode,
public Attributable {
public:
ASTNodeTypeDecl(std::string name) : m_forwardDeclared(true), m_name(name) { }
ASTNodeTypeDecl(std::string name, std::shared_ptr<ASTNode> type, std::optional<std::endian> endian = std::nullopt)
: ASTNode(), m_name(std::move(name)), m_type(std::move(type)), m_endian(endian) { }
@@ -69,7 +71,18 @@ namespace hex::pl {
Attributable::addAttribute(std::move(attribute));
}
[[nodiscard]]
bool isForwardDeclared() const {
return this->m_forwardDeclared;
}
void setType(std::shared_ptr<ASTNode> type) {
this->m_forwardDeclared = false;
this->m_type = type;
}
private:
bool m_forwardDeclared = false;
std::string m_name;
std::shared_ptr<ASTNode> m_type;
std::optional<std::endian> m_endian;