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-substitutions.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/slang/slang-ast-substitutions.cpp') diff --git a/source/slang/slang-ast-substitutions.cpp b/source/slang/slang-ast-substitutions.cpp index 05865fe8f..8a54a1d74 100644 --- a/source/slang/slang-ast-substitutions.cpp +++ b/source/slang/slang-ast-substitutions.cpp @@ -8,7 +8,7 @@ namespace Slang { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Substitutions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr Substitutions::applySubstitutionsShallow(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr substOuter, int* ioDiff) +Substitutions* Substitutions::applySubstitutionsShallow(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { SLANG_AST_NODE_VIRTUAL_CALL(Substitutions, applySubstitutionsShallow, (astBuilder, substSet, substOuter, ioDiff)) } @@ -23,14 +23,14 @@ HashCode Substitutions::getHashCode() const SLANG_AST_NODE_CONST_VIRTUAL_CALL(Substitutions, getHashCode, ()) } -RefPtr Substitutions::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr substOuter, int* ioDiff) +Substitutions* Substitutions::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { SLANG_UNUSED(astBuilder); SLANG_UNUSED(substSet); SLANG_UNUSED(substOuter); SLANG_UNUSED(ioDiff); SLANG_UNEXPECTED("Substitutions::_applySubstitutionsShallowOverride not overridden"); - //return RefPtr(); + //return Substitutions*(); } bool Substitutions::_equalsOverride(Substitutions* subst) @@ -48,13 +48,13 @@ HashCode Substitutions::_getHashCodeOverride() const // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GenericSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr GenericSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr substOuter, int* ioDiff) +Substitutions* GenericSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { int diff = 0; if (substOuter != outer) diff++; - List> substArgs; + List substArgs; for (auto a : args) { substArgs.add(a->substituteImpl(astBuilder, substSet, &diff)); @@ -88,14 +88,14 @@ bool GenericSubstitution::_equalsOverride(Substitutions* subst) SLANG_RELEASE_ASSERT(args.getCount() == genericSubst->args.getCount()); for (Index aa = 0; aa < argCount; ++aa) { - if (!args[aa]->equalsVal(genericSubst->args[aa].Ptr())) + if (!args[aa]->equalsVal(genericSubst->args[aa])) return false; } if (!outer) return !genericSubst->outer; - if (!outer->equals(genericSubst->outer.Ptr())) + if (!outer->equals(genericSubst->outer)) return false; return true; @@ -114,14 +114,14 @@ HashCode GenericSubstitution::_getHashCodeOverride() const // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ThisTypeSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr ThisTypeSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr substOuter, int* ioDiff) +Substitutions* ThisTypeSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { int diff = 0; if (substOuter != outer) diff++; // NOTE: Must use .as because we must have a smart pointer here to keep in scope. - auto substWitness = witness->substituteImpl(astBuilder, substSet, &diff).as(); + auto substWitness = as(witness->substituteImpl(astBuilder, substSet, &diff)); if (!diff) return this; @@ -165,7 +165,7 @@ HashCode ThisTypeSubstitution::_getHashCodeOverride() const // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GlobalGenericParamSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr GlobalGenericParamSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr substOuter, int* ioDiff) +Substitutions* GlobalGenericParamSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { // if we find a GlobalGenericParamSubstitution in subst that references the same type_param decl // return a copy of that GlobalGenericParamSubstitution @@ -173,7 +173,7 @@ RefPtr GlobalGenericParamSubstitution::_applySubstitutionsShallow if (substOuter != outer) diff++; - auto substActualType = actualType->substituteImpl(astBuilder, substSet, &diff).as(); + auto substActualType = as(actualType->substituteImpl(astBuilder, substSet, &diff)); List substConstraintArgs; for (auto constraintArg : constraintArgs) @@ -190,7 +190,7 @@ RefPtr GlobalGenericParamSubstitution::_applySubstitutionsShallow (*ioDiff)++; - RefPtr substSubst = astBuilder->create(); + GlobalGenericParamSubstitution* substSubst = astBuilder->create(); substSubst->paramDecl = paramDecl; substSubst->actualType = substActualType; substSubst->constraintArgs = substConstraintArgs; -- cgit v1.2.3