From 43c146794aab638924d2ab838d10f8af2ebf02a7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 5 Jun 2020 18:20:09 -0400 Subject: ASTNodes use MemoryArena (#1376) * Add a ASTBuilder to a Module Only construct on valid ASTBuilder (was being called on nullptr on occassion) * Add nodes to ASTBuilder. * Compiles with RefPtr removed from AST node types. * Initialize all AST node pointer variables in headers to nullptr; * Initialize AST node variables as nullptr. Make ASTBuilder keep a ref on node types. Make SyntaxParseCallback returns a NodeBase * Don't release canonicalType on dtor (managed by ASTBuilder). * Give ASTBuilders a name and id, to help in debugging. For now destroy the session TypeCache, to stop it holding things released when the compile request destroys ASTBuilders. * Moved the TypeCheckingCache over to Linkage from Session. * NodeBase no longer derived from RefObject. * Only add/dtor nodes that need destruction. First pass compile on linux. --- source/slang/slang-ast-dump.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/slang/slang-ast-dump.cpp') diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp index d0b2497bb..1ae51615f 100644 --- a/source/slang/slang-ast-dump.cpp +++ b/source/slang/slang-ast-dump.cpp @@ -17,7 +17,7 @@ struct Context struct ObjectInfo { const ReflectClassInfo* m_typeInfo; - RefObject* m_object; + NodeBase* m_object; bool m_isDumped; }; @@ -48,10 +48,10 @@ struct Context Context* m_context; }; - void dumpObject(const ReflectClassInfo& type, RefObject* obj); + void dumpObject(const ReflectClassInfo& type, NodeBase* obj); - void dumpObjectFull(const ReflectClassInfo& type, RefObject* obj, Index objIndex); - void dumpObjectReference(const ReflectClassInfo& type, RefObject* obj, Index objIndex); + void dumpObjectFull(const ReflectClassInfo& type, NodeBase* obj, Index objIndex); + void dumpObjectReference(const ReflectClassInfo& type, NodeBase* obj, Index objIndex); void dump(NodeBase* node) { @@ -264,7 +264,7 @@ struct Context m_writer->emit(" }"); } - Index getObjectIndex(const ReflectClassInfo& typeInfo, RefObject* obj) + Index getObjectIndex(const ReflectClassInfo& typeInfo, NodeBase* obj) { Index* indexPtr = m_objectMap.TryGetValueOrAdd(obj, m_objects.getCount()); if (indexPtr) @@ -576,7 +576,7 @@ struct Context // Using the SourceWriter, for automatic indentation. SourceWriter* m_writer; - Dictionary m_objectMap; ///< Object index + Dictionary m_objectMap; ///< Object index List m_objects; StringBuilder m_buf; @@ -605,7 +605,7 @@ SLANG_ALL_ASTNode_NodeBase(SLANG_AST_DUMP_FIELDS_IMPL, _) #define SLANG_AST_GET_DUMP_FUNC(NAME, SUPER, ORIGIN, LAST, MARKER, TYPE, param) m_funcs[Index(ASTNodeType::NAME)] = (DumpFieldsFunc)&ASTDumpAccess::dumpFields_##NAME; -typedef void (*DumpFieldsFunc)(RefObject* obj, Context& context); +typedef void (*DumpFieldsFunc)(NodeBase* obj, Context& context); struct DumpFieldFuncs { @@ -620,13 +620,13 @@ struct DumpFieldFuncs static const DumpFieldFuncs s_funcs; -void Context::dumpObjectReference(const ReflectClassInfo& type, RefObject* obj, Index objIndex) +void Context::dumpObjectReference(const ReflectClassInfo& type, NodeBase* obj, Index objIndex) { SLANG_UNUSED(obj); ScopeWrite(this).getBuf() << type.m_name << ":" << objIndex; } -void Context::dumpObjectFull(const ReflectClassInfo& type, RefObject* obj, Index objIndex) +void Context::dumpObjectFull(const ReflectClassInfo& type, NodeBase* obj, Index objIndex) { ObjectInfo& info = m_objects[objIndex]; SLANG_ASSERT(info.m_isDumped == false); @@ -662,7 +662,7 @@ void Context::dumpObjectFull(const ReflectClassInfo& type, RefObject* obj, Index m_writer->emit("}\n"); } -void Context::dumpObject(const ReflectClassInfo& typeInfo, RefObject* obj) +void Context::dumpObject(const ReflectClassInfo& typeInfo, NodeBase* obj) { Index index = getObjectIndex(typeInfo, obj); -- cgit v1.2.3