实现了语法树cache机制

This commit is contained in:
codeboss 2024-06-18 19:55:36 +08:00
parent 8404719d26
commit ac99860469
3 changed files with 3 additions and 3 deletions

View File

@ -117,7 +117,7 @@ void example_novel::Document::cacheLoad()
} }
example_novel::AbstractImpl::AbstractImpl(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind) example_novel::AbstractImpl::AbstractImpl(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind)
: ExpressionElement(rule_bind) {} : ExpressionElement(rule_bind) { parent_store.reset(); }
QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const { QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() const {
auto tokensx = ast_basic::ExpressionElement::tokens(); auto tokensx = ast_basic::ExpressionElement::tokens();
@ -131,7 +131,7 @@ QList<std::shared_ptr<const ast_gen::TokenAccess> > AbstractImpl::selfTokens() c
std::shared_ptr<const ast_gen::SyntaxElement> example_novel::AbstractImpl::parent() const std::shared_ptr<const ast_gen::SyntaxElement> example_novel::AbstractImpl::parent() const
{ {
return this->parent_store; return this->parent_store.lock();
} }
void example_novel::AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst) void example_novel::AbstractImpl::setParent(std::shared_ptr<const ast_gen::SyntaxElement> inst)

View File

@ -17,7 +17,7 @@ namespace example_novel
class LIBSYNTAX_EXPORT AbstractImpl : class LIBSYNTAX_EXPORT AbstractImpl :
public ast_basic::ExpressionElement, public ast_gen::SyntaxElement { public ast_basic::ExpressionElement, public ast_gen::SyntaxElement {
private: private:
std::shared_ptr<const SyntaxElement> parent_store = nullptr; std::weak_ptr<const SyntaxElement> parent_store;
public: public:
explicit AbstractImpl(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind); explicit AbstractImpl(std::shared_ptr<const lib_syntax::ExpressionRule> rule_bind);

Binary file not shown.