From c2d31347ea06c768045e7c503ef0188e0e5356de Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 28 May 2020 14:01:51 -0400 Subject: WIP: ASTBuilder (#1358) * Compiles. * Small tidy up around session/ASTBuilder. * Tests are now passing. * Fix Visual Studio project. * Fix using new X to use builder when protectedness of Ctor is not enough. Substitute->substitute * Add some missing ast nodes created outside of ASTBuilder. * Compile time check that ASTBuilder is making an AST type. * Moced findClasInfo and findSyntaxClass (essentially the same thing) to SharedASTBuilder from Session. --- source/slang/slang-check-conversion.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'source/slang/slang-check-conversion.cpp') diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index e514caebf..dfcf7ece2 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -310,9 +310,8 @@ namespace Slang // We have a new type for the conversion, based on what // we learned. - toType = getSession()->getArrayType( - toElementType, - new ConstantIntVal(elementCount)); + toType = m_astBuilder->getArrayType(toElementType, + m_astBuilder->create(elementCount)); } } else if(auto toMatrixType = as(toType)) @@ -383,7 +382,7 @@ namespace Slang { RefPtr coercedArg; bool argResult = _readValueFromInitializerList( - GetType(fieldDeclRef), + GetType(m_astBuilder, fieldDeclRef), outToExpr ? &coercedArg : nullptr, fromInitializerListExpr, ioArgIndex); @@ -418,7 +417,7 @@ namespace Slang // if(outToExpr) { - auto toInitializerListExpr = new InitializerListExpr(); + auto toInitializerListExpr = m_astBuilder->create(); toInitializerListExpr->loc = fromInitializerListExpr->loc; toInitializerListExpr->type = QualType(toType); toInitializerListExpr->args = coercedArgs; @@ -575,7 +574,7 @@ namespace Slang RefPtr derefExpr; if(outToExpr) { - derefExpr = new DerefExpr(); + derefExpr = m_astBuilder->create(); derefExpr->base = fromExpr; derefExpr->type = QualType(fromElementType); } @@ -814,7 +813,7 @@ namespace Slang RefPtr SemanticsVisitor::createImplicitCastExpr() { - return new ImplicitCastExpr(); + return m_astBuilder->create(); } RefPtr SemanticsVisitor::CreateImplicitCastExpr( @@ -823,9 +822,9 @@ namespace Slang { RefPtr castExpr = createImplicitCastExpr(); - auto typeType = getTypeType(toType); + auto typeType = m_astBuilder->getTypeType(toType); - auto typeExpr = new SharedTypeExpr(); + auto typeExpr = m_astBuilder->create(); typeExpr->type.type = typeType; typeExpr->base.type = toType; @@ -841,7 +840,7 @@ namespace Slang RefPtr fromExpr, RefPtr witness) { - RefPtr expr = new CastToInterfaceExpr(); + RefPtr expr = m_astBuilder->create(); expr->loc = fromExpr->loc; expr->type = QualType(toType); expr->valueArg = fromExpr; @@ -866,7 +865,7 @@ namespace Slang // really shouldn't *change* the expression that is passed in, but should // introduce new AST nodes to coerce its value to a different type... return CreateImplicitCastExpr( - getSession()->getErrorType(), + m_astBuilder->getErrorType(), fromExpr); } return expr; -- cgit v1.2.3