diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-06-04 17:15:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-04 17:15:38 -0400 |
| commit | ecac0c76a93bd123d5a5a86473716ad166f8c5d6 (patch) | |
| tree | 183314db50ba8be4e173581204a4d3df6fc41be0 /source/slang/slang-ast-builder.cpp | |
| parent | f3d637ba4d90bc2e23db07f1a9df5a6be7533f08 (diff) | |
Add a ASTBuilder to a Module (#1369)
Only construct on valid ASTBuilder (was being called on nullptr on occassion)
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 316390353..67ce80120 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -21,18 +21,20 @@ void SharedASTBuilder::init(Session* session) m_session = session; // We just want as a place to store allocations of shared types - RefPtr<ASTBuilder> astBuilder(new ASTBuilder); - - astBuilder->m_sharedASTBuilder = this; + { + RefPtr<ASTBuilder> astBuilder(new ASTBuilder); + astBuilder->m_sharedASTBuilder = this; + m_astBuilder = astBuilder.detach(); + } + // Clear the built in types memset(m_builtinTypes, 0, sizeof(m_builtinTypes)); + // Create common shared types m_errorType = m_astBuilder->create<ErrorType>(); m_initializerListType = m_astBuilder->create<InitializerListType>(); m_overloadedType = m_astBuilder->create<OverloadGroupType>(); - m_astBuilder = astBuilder.detach(); - // We can just iterate over the class pointers. // NOTE! That this adds the names of the abstract classes too(!) for (Index i = 0; i < Index(ASTNodeType::CountOf); ++i) |
