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-modifier.cpp | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'source/slang/slang-check-modifier.cpp') diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index 75a75ad69..d8877b9d1 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -11,13 +11,13 @@ namespace Slang { - RefPtr SemanticsVisitor::checkConstantIntVal( - RefPtr expr) + ConstantIntVal* SemanticsVisitor::checkConstantIntVal( + Expr* expr) { // First type-check the expression as normal expr = CheckExpr(expr); - auto intVal = CheckIntegerConstantExpression(expr.Ptr()); + auto intVal = CheckIntegerConstantExpression(expr); if(!intVal) return nullptr; @@ -30,13 +30,13 @@ namespace Slang return constIntVal; } - RefPtr SemanticsVisitor::checkConstantEnumVal( - RefPtr expr) + ConstantIntVal* SemanticsVisitor::checkConstantEnumVal( + Expr* expr) { // First type-check the expression as normal expr = CheckExpr(expr); - auto intVal = CheckEnumConstantExpression(expr.Ptr()); + auto intVal = CheckEnumConstantExpression(expr); if(!intVal) return nullptr; @@ -52,7 +52,7 @@ namespace Slang // Check an expression, coerce it to the `String` type, and then // ensure that it has a literal (not just compile-time constant) value. bool SemanticsVisitor::checkLiteralStringVal( - RefPtr expr, + Expr* expr, String* outVal) { // TODO: This should actually perform semantic checking, etc., @@ -138,12 +138,12 @@ namespace Slang // We will now synthesize a new `AttributeDecl` to mirror // what was declared on the `struct` type. // - RefPtr attrDecl = m_astBuilder->create(); + AttributeDecl* attrDecl = m_astBuilder->create(); attrDecl->nameAndLoc.name = attributeName; attrDecl->nameAndLoc.loc = structDecl->nameAndLoc.loc; attrDecl->loc = structDecl->loc; - RefPtr targetModifier = m_astBuilder->create(); + AttributeTargetModifier* targetModifier = m_astBuilder->create(); targetModifier->syntaxClass = attrUsageAttr->targetSyntaxClass; targetModifier->loc = attrUsageAttr->loc; addModifier(attrDecl, targetModifier); @@ -167,7 +167,7 @@ namespace Slang { ensureDecl(varMember, DeclCheckState::CanUseTypeOfValueDecl); - RefPtr paramDecl = m_astBuilder->create(); + ParamDecl* paramDecl = m_astBuilder->create(); paramDecl->nameAndLoc = member->nameAndLoc; paramDecl->type = varMember->type; paramDecl->loc = member->loc; @@ -230,7 +230,7 @@ namespace Slang return true; } - bool SemanticsVisitor::getAttributeTargetSyntaxClasses(SyntaxClass & cls, uint32_t typeFlags) + bool SemanticsVisitor::getAttributeTargetSyntaxClasses(SyntaxClass & cls, uint32_t typeFlags) { if (typeFlags == (int)UserDefinedAttributeTargets::Struct) { @@ -250,7 +250,7 @@ namespace Slang return false; } - bool SemanticsVisitor::validateAttribute(RefPtr attr, AttributeDecl* attribClassDecl) + bool SemanticsVisitor::validateAttribute(Attribute* attr, AttributeDecl* attribClassDecl) { if(auto numThreadsAttr = as(attr)) { @@ -401,7 +401,7 @@ namespace Slang uint32_t targetClassId = (uint32_t)UserDefinedAttributeTargets::None; if (attr->args.getCount() == 1) { - RefPtr outIntVal; + //IntVal* outIntVal; if (auto cInt = checkConstantEnumVal(attr->args[0])) { targetClassId = (uint32_t)(cInt->value); @@ -522,7 +522,7 @@ namespace Slang return true; } - RefPtr SemanticsVisitor::checkAttribute( + AttributeBase* SemanticsVisitor::checkAttribute( UncheckedAttribute* uncheckedAttr, ModifiableSyntaxNode* attrTarget) { @@ -544,8 +544,8 @@ namespace Slang } // Manage scope - RefPtr attrInstance = attrDecl->syntaxClass.createInstance(m_astBuilder); - auto attr = attrInstance.as(); + NodeBase* attrInstance = attrDecl->syntaxClass.createInstance(m_astBuilder); + auto attr = as(attrInstance); if(!attr) { SLANG_DIAGNOSE_UNEXPECTED(getSink(), attrDecl, "attribute class did not yield an attribute object"); @@ -637,8 +637,8 @@ namespace Slang return attr; } - RefPtr SemanticsVisitor::checkModifier( - RefPtr m, + Modifier* SemanticsVisitor::checkModifier( + Modifier* m, ModifiableSyntaxNode* syntaxNode) { if(auto hlslUncheckedAttribute = as(m)) @@ -673,10 +673,10 @@ namespace Slang // The process of checking a modifier may produce a new modifier in its place, // so we will build up a new linked list of modifiers that will replace // the old list. - RefPtr resultModifiers; - RefPtr* resultModifierLink = &resultModifiers; + Modifier* resultModifiers = nullptr; + Modifier** resultModifierLink = &resultModifiers; - RefPtr modifier = syntaxNode->modifiers.first; + Modifier* modifier = syntaxNode->modifiers.first; while(modifier) { // Because we are rewriting the list in place, we need to extract -- cgit v1.2.3