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-constraint.cpp | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'source/slang/slang-check-constraint.cpp') diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index c37af8892..4d1379016 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -56,9 +56,9 @@ namespace Slang { - RefPtr SemanticsVisitor::TryJoinVectorAndScalarType( - RefPtr vectorType, - RefPtr scalarType) + Type* SemanticsVisitor::TryJoinVectorAndScalarType( + VectorExpressionType* vectorType, + BasicExpressionType* scalarType) { // Join( vector, S ) -> vetor // @@ -75,8 +75,8 @@ namespace Slang vectorType->elementCount); } - RefPtr SemanticsVisitor::TryJoinTypeWithInterface( - RefPtr type, + Type* SemanticsVisitor::TryJoinTypeWithInterface( + Type* type, DeclRef interfaceDeclRef) { // The most basic test here should be: does the type declare conformance to the trait. @@ -104,8 +104,8 @@ namespace Slang // the search process if `type` is a builtin scalar type, and then we only search // through types `X` that are also builtin scalar types. // - RefPtr bestType; - if(auto basicType = type.dynamicCast()) + Type* bestType = nullptr; + if(auto basicType = dynamicCast(type)) { for(Int baseTypeFlavorIndex = 0; baseTypeFlavorIndex < Int(BaseType::CountOf); baseTypeFlavorIndex++) { @@ -173,9 +173,9 @@ namespace Slang return nullptr; } - RefPtr SemanticsVisitor::TryJoinTypes( - RefPtr left, - RefPtr right) + Type* SemanticsVisitor::TryJoinTypes( + Type* left, + Type* right) { // Easy case: they are the same type! if (left->equals(right)) @@ -217,7 +217,7 @@ namespace Slang if(auto rightVector = as(right)) { // Check if the vector sizes match - if(!leftVector->elementCount->equalsVal(rightVector->elementCount.Ptr())) + if(!leftVector->elementCount->equalsVal(rightVector->elementCount)) return nullptr; // Try to join the element types @@ -293,12 +293,12 @@ namespace Slang // We will loop over the generic parameters, and for // each we will try to find a way to satisfy all // the constraints for that parameter - List> args; + List args; for (auto m : getMembers(genericDeclRef)) { if (auto typeParam = m.as()) { - RefPtr type = nullptr; + Type* type = nullptr; for (auto& c : system->constraints) { if (c.decl != typeParam.getDecl()) @@ -337,7 +337,7 @@ namespace Slang // TODO(tfoley): maybe support more than integers some day? // TODO(tfoley): figure out how this needs to interact with // compile-time integers that aren't just constants... - RefPtr val = nullptr; + IntVal* val = nullptr; for (auto& c : system->constraints) { if (c.decl != valParam.getDecl()) @@ -391,7 +391,7 @@ namespace Slang // search for a conformance `Robin : ISidekick`, which involved // apply the substitutions we already know... - RefPtr solvedSubst = m_astBuilder->create(); + GenericSubstitution* solvedSubst = m_astBuilder->create(); solvedSubst->genericDecl = genericDeclRef.getDecl(); solvedSubst->outer = genericDeclRef.substitutions.substitutions; solvedSubst->args = args; @@ -442,8 +442,8 @@ namespace Slang bool SemanticsVisitor::TryUnifyVals( ConstraintSystem& constraints, - RefPtr fst, - RefPtr snd) + Val* fst, + Val* snd) { // if both values are types, then unify types if (auto fstType = as(fst)) @@ -503,13 +503,13 @@ namespace Slang SLANG_UNIMPLEMENTED_X("value unification case"); // default: fail - return false; + //return false; } bool SemanticsVisitor::tryUnifySubstitutions( ConstraintSystem& constraints, - RefPtr fst, - RefPtr snd) + Substitutions* fst, + Substitutions* snd) { // They must both be NULL or non-NULL if (!fst || !snd) @@ -533,8 +533,8 @@ namespace Slang bool SemanticsVisitor::tryUnifyGenericSubstitutions( ConstraintSystem& constraints, - RefPtr fst, - RefPtr snd) + GenericSubstitution* fst, + GenericSubstitution* snd) { SLANG_ASSERT(fst); SLANG_ASSERT(snd); @@ -568,13 +568,13 @@ namespace Slang bool SemanticsVisitor::TryUnifyTypeParam( ConstraintSystem& constraints, - RefPtr typeParamDecl, - RefPtr type) + GenericTypeParamDecl* typeParamDecl, + Type* type) { // We want to constrain the given type parameter // to equal the given type. Constraint constraint; - constraint.decl = typeParamDecl.Ptr(); + constraint.decl = typeParamDecl; constraint.val = type; constraints.constraints.add(constraint); @@ -584,8 +584,8 @@ namespace Slang bool SemanticsVisitor::TryUnifyIntParam( ConstraintSystem& constraints, - RefPtr paramDecl, - RefPtr val) + GenericValueParamDecl* paramDecl, + IntVal* val) { // We only want to accumulate constraints on // the parameters of the declarations being @@ -597,7 +597,7 @@ namespace Slang // We want to constrain the given parameter to equal the given value. Constraint constraint; - constraint.decl = paramDecl.Ptr(); + constraint.decl = paramDecl; constraint.val = val; constraints.constraints.add(constraint); @@ -608,11 +608,11 @@ namespace Slang bool SemanticsVisitor::TryUnifyIntParam( ConstraintSystem& constraints, DeclRef const& varRef, - RefPtr val) + IntVal* val) { if(auto genericValueParamRef = varRef.as()) { - return TryUnifyIntParam(constraints, RefPtr(genericValueParamRef.getDecl()), val); + return TryUnifyIntParam(constraints, genericValueParamRef.getDecl(), val); } else { @@ -622,8 +622,8 @@ namespace Slang bool SemanticsVisitor::TryUnifyTypesByStructuralMatch( ConstraintSystem& constraints, - RefPtr fst, - RefPtr snd) + Type* fst, + Type* snd) { if (auto fstDeclRefType = as(fst)) { @@ -661,8 +661,8 @@ namespace Slang bool SemanticsVisitor::TryUnifyTypes( ConstraintSystem& constraints, - RefPtr fst, - RefPtr snd) + Type* fst, + Type* snd) { if (fst->equals(snd)) return true; -- cgit v1.2.3