diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-06-05 18:20:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-05 18:20:09 -0400 |
| commit | 43c146794aab638924d2ab838d10f8af2ebf02a7 (patch) | |
| tree | 520eed8f2ae02c6953cf2aee7c87959a0008badc /source/slang/slang-check-conformance.cpp | |
| parent | e3e1cf2045f14837cfecb14e252c0e1083787b93 (diff) | |
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.
Diffstat (limited to 'source/slang/slang-check-conformance.cpp')
| -rw-r--r-- | source/slang/slang-check-conformance.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
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<DeclaredSubtypeWitness> SemanticsVisitor::createSimpleSubtypeWitness( + DeclaredSubtypeWitness* SemanticsVisitor::createSimpleSubtypeWitness( TypeWitnessBreadcrumb* breadcrumb) { - RefPtr<DeclaredSubtypeWitness> witness = m_astBuilder->create<DeclaredSubtypeWitness>(); + DeclaredSubtypeWitness* witness = m_astBuilder->create<DeclaredSubtypeWitness>(); witness->sub = breadcrumb->sub; witness->sup = breadcrumb->sup; witness->declRef = breadcrumb->declRef; return witness; } - RefPtr<Val> SemanticsVisitor::createTypeWitness( - RefPtr<Type> subType, + Val* SemanticsVisitor::createTypeWitness( + Type* subType, DeclRef<AggTypeDecl> 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<SubtypeWitness> witness; + SubtypeWitness* witness = nullptr; // `link` will point at the remaining "hole" in the // data structure, to be filled in. - RefPtr<SubtypeWitness>* 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<TransitiveSubtypeWitness> transitiveWitness = m_astBuilder->create<TransitiveSubtypeWitness>(); + TransitiveSubtypeWitness* transitiveWitness = m_astBuilder->create<TransitiveSubtypeWitness>(); 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<DeclaredSubtypeWitness> 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<InterfaceDecl> interfaceDeclRef, DeclRef<Decl> requirementDeclRef) { + SLANG_UNUSED(interfaceDeclRef); + if(auto callableDeclRef = requirementDeclRef.as<CallableDecl>()) { // A `static` method requirement can't be satisfied by a @@ -146,10 +151,10 @@ namespace Slang } bool SemanticsVisitor::_isDeclaredSubtype( - RefPtr<Type> originalSubType, - RefPtr<Type> subType, + Type* originalSubType, + Type* subType, DeclRef<AggTypeDecl> superTypeDeclRef, - RefPtr<Val>* 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<RefPtr<Val>> caseWitnesses; + List<Val*> caseWitnesses; for(auto caseType : taggedUnionType->caseTypes) { - RefPtr<Val> caseWitness; + Val* caseWitness = nullptr; if(!_isDeclaredSubtype( caseType, @@ -316,7 +321,7 @@ namespace Slang // if(outWitness) { - RefPtr<TaggedUnionSubtypeWitness> taggedUnionWitness = m_astBuilder->create<TaggedUnionSubtypeWitness>(); + TaggedUnionSubtypeWitness* taggedUnionWitness = m_astBuilder->create<TaggedUnionSubtypeWitness>(); taggedUnionWitness->sub = taggedUnionType; taggedUnionWitness->sup = DeclRefType::create(m_astBuilder, superTypeDeclRef); taggedUnionWitness->caseWitnesses.swapWith(caseWitnesses); @@ -331,41 +336,40 @@ namespace Slang } bool SemanticsVisitor::isDeclaredSubtype( - RefPtr<Type> subType, + Type* subType, DeclRef<AggTypeDecl> superTypeDeclRef) { return _isDeclaredSubtype(subType, subType, superTypeDeclRef, nullptr, nullptr); } - RefPtr<Val> SemanticsVisitor::tryGetSubtypeWitness( - RefPtr<Type> subType, + Val* SemanticsVisitor::tryGetSubtypeWitness( + Type* subType, DeclRef<AggTypeDecl> superTypeDeclRef) { - RefPtr<Val> result; + Val* result = nullptr; _isDeclaredSubtype(subType, subType, superTypeDeclRef, &result, nullptr); return result; } - - RefPtr<Val> SemanticsVisitor::tryGetInterfaceConformanceWitness( - RefPtr<Type> type, + Val* SemanticsVisitor::tryGetInterfaceConformanceWitness( + Type* type, DeclRef<InterfaceDecl> interfaceDeclRef) { return tryGetSubtypeWitness(type, interfaceDeclRef); } - RefPtr<Val> SemanticsVisitor::createTypeEqualityWitness( + Val* SemanticsVisitor::createTypeEqualityWitness( Type* type) { - RefPtr<TypeEqualityWitness> rs = m_astBuilder->create<TypeEqualityWitness>(); + TypeEqualityWitness* rs = m_astBuilder->create<TypeEqualityWitness>(); rs->sub = type; rs->sup = type; return rs; } - RefPtr<Val> SemanticsVisitor::tryGetSubtypeWitness( - RefPtr<Type> sub, - RefPtr<Type> sup) + Val* SemanticsVisitor::tryGetSubtypeWitness( + Type* sub, + Type* sup) { if(sub->equals(sup)) { |
