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-ast-substitutions.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-ast-substitutions.cpp')
| -rw-r--r-- | source/slang/slang-ast-substitutions.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
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> Substitutions::applySubstitutionsShallow(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr<Substitutions> 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> Substitutions::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr<Substitutions> 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<Substitutions>(); + //return Substitutions*(); } bool Substitutions::_equalsOverride(Substitutions* subst) @@ -48,13 +48,13 @@ HashCode Substitutions::_getHashCodeOverride() const // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GenericSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr<Substitutions> GenericSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr<Substitutions> substOuter, int* ioDiff) +Substitutions* GenericSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, Substitutions* substOuter, int* ioDiff) { int diff = 0; if (substOuter != outer) diff++; - List<RefPtr<Val>> substArgs; + List<Val*> 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<Substitutions> ThisTypeSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr<Substitutions> 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<SubtypeWitness>(); + auto substWitness = as<SubtypeWitness>(witness->substituteImpl(astBuilder, substSet, &diff)); if (!diff) return this; @@ -165,7 +165,7 @@ HashCode ThisTypeSubstitution::_getHashCodeOverride() const // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GlobalGenericParamSubstitution !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -RefPtr<Substitutions> GlobalGenericParamSubstitution::_applySubstitutionsShallowOverride(ASTBuilder* astBuilder, SubstitutionSet substSet, RefPtr<Substitutions> 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<Substitutions> GlobalGenericParamSubstitution::_applySubstitutionsShallow if (substOuter != outer) diff++; - auto substActualType = actualType->substituteImpl(astBuilder, substSet, &diff).as<Type>(); + auto substActualType = as<Type>(actualType->substituteImpl(astBuilder, substSet, &diff)); List<ConstraintArg> substConstraintArgs; for (auto constraintArg : constraintArgs) @@ -190,7 +190,7 @@ RefPtr<Substitutions> GlobalGenericParamSubstitution::_applySubstitutionsShallow (*ioDiff)++; - RefPtr<GlobalGenericParamSubstitution> substSubst = astBuilder->create<GlobalGenericParamSubstitution>(); + GlobalGenericParamSubstitution* substSubst = astBuilder->create<GlobalGenericParamSubstitution>(); substSubst->paramDecl = paramDecl; substSubst->actualType = substActualType; substSubst->constraintArgs = substConstraintArgs; |
