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-check-conformance.cpp | 56 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'source/slang/slang-check-conformance.cpp') diff --git a/source/slang/slang-check-conformance.cpp b/source/slang/slang-check-conformance.cpp index f57e7cb38..2a0e661a3 100644 --- a/source/slang/slang-check-conformance.cpp +++ b/source/slang/slang-check-conformance.cpp @@ -7,21 +7,24 @@ namespace Slang { - RefPtr SemanticsVisitor::createSimpleSubtypeWitness( + DeclaredSubtypeWitness* SemanticsVisitor::createSimpleSubtypeWitness( TypeWitnessBreadcrumb* breadcrumb) { - RefPtr witness = m_astBuilder->create(); + DeclaredSubtypeWitness* witness = m_astBuilder->create(); witness->sub = breadcrumb->sub; witness->sup = breadcrumb->sup; witness->declRef = breadcrumb->declRef; return witness; } - RefPtr SemanticsVisitor::createTypeWitness( - RefPtr subType, + Val* SemanticsVisitor::createTypeWitness( + Type* subType, DeclRef superTypeDeclRef, TypeWitnessBreadcrumb* inBreadcrumbs) { + SLANG_UNUSED(subType); + SLANG_UNUSED(superTypeDeclRef); + if(!inBreadcrumbs) { // We need to construct a witness to the fact @@ -58,11 +61,11 @@ namespace Slang // `witness` here will hold the first (outer-most) object // we create, which is the overall result. - RefPtr witness; + SubtypeWitness* witness = nullptr; // `link` will point at the remaining "hole" in the // data structure, to be filled in. - RefPtr* link = &witness; + SubtypeWitness** link = &witness; // As long as there is more than one breadcrumb, we // need to be creating transitive witnesses. @@ -79,7 +82,7 @@ namespace Slang // where `[...]` represents the "hole" we leave // open to fill in next. // - RefPtr transitiveWitness = m_astBuilder->create(); + TransitiveSubtypeWitness* transitiveWitness = m_astBuilder->create(); transitiveWitness->sub = bb->sub; transitiveWitness->sup = bb->sup; transitiveWitness->midToSup = bb->declRef; @@ -97,7 +100,7 @@ namespace Slang // In our running example this would be `{ A : B }`. We create // a simple (declared) subtype witness for it, and plug the // final hole, after which there shouldn't be a hole to deal with. - RefPtr declaredWitness = createSimpleSubtypeWitness(bb); + DeclaredSubtypeWitness* declaredWitness = createSimpleSubtypeWitness(bb); *link = declaredWitness; // We now know that our original `witness` variable has been @@ -121,6 +124,8 @@ namespace Slang DeclRef interfaceDeclRef, DeclRef requirementDeclRef) { + SLANG_UNUSED(interfaceDeclRef); + if(auto callableDeclRef = requirementDeclRef.as()) { // A `static` method requirement can't be satisfied by a @@ -146,10 +151,10 @@ namespace Slang } bool SemanticsVisitor::_isDeclaredSubtype( - RefPtr originalSubType, - RefPtr subType, + Type* originalSubType, + Type* subType, DeclRef superTypeDeclRef, - RefPtr* outWitness, + Val** outWitness, TypeWitnessBreadcrumb* inBreadcrumbs) { // for now look up a conformance member... @@ -271,10 +276,10 @@ namespace Slang // value for the tagged union itself (that is, if // `outWitness` is non-null). // - List> caseWitnesses; + List caseWitnesses; for(auto caseType : taggedUnionType->caseTypes) { - RefPtr caseWitness; + Val* caseWitness = nullptr; if(!_isDeclaredSubtype( caseType, @@ -316,7 +321,7 @@ namespace Slang // if(outWitness) { - RefPtr taggedUnionWitness = m_astBuilder->create(); + TaggedUnionSubtypeWitness* taggedUnionWitness = m_astBuilder->create(); taggedUnionWitness->sub = taggedUnionType; taggedUnionWitness->sup = DeclRefType::create(m_astBuilder, superTypeDeclRef); taggedUnionWitness->caseWitnesses.swapWith(caseWitnesses); @@ -331,41 +336,40 @@ namespace Slang } bool SemanticsVisitor::isDeclaredSubtype( - RefPtr subType, + Type* subType, DeclRef superTypeDeclRef) { return _isDeclaredSubtype(subType, subType, superTypeDeclRef, nullptr, nullptr); } - RefPtr SemanticsVisitor::tryGetSubtypeWitness( - RefPtr subType, + Val* SemanticsVisitor::tryGetSubtypeWitness( + Type* subType, DeclRef superTypeDeclRef) { - RefPtr result; + Val* result = nullptr; _isDeclaredSubtype(subType, subType, superTypeDeclRef, &result, nullptr); return result; } - - RefPtr SemanticsVisitor::tryGetInterfaceConformanceWitness( - RefPtr type, + Val* SemanticsVisitor::tryGetInterfaceConformanceWitness( + Type* type, DeclRef interfaceDeclRef) { return tryGetSubtypeWitness(type, interfaceDeclRef); } - RefPtr SemanticsVisitor::createTypeEqualityWitness( + Val* SemanticsVisitor::createTypeEqualityWitness( Type* type) { - RefPtr rs = m_astBuilder->create(); + TypeEqualityWitness* rs = m_astBuilder->create(); rs->sub = type; rs->sup = type; return rs; } - RefPtr SemanticsVisitor::tryGetSubtypeWitness( - RefPtr sub, - RefPtr sup) + Val* SemanticsVisitor::tryGetSubtypeWitness( + Type* sub, + Type* sup) { if(sub->equals(sup)) { -- cgit v1.2.3