From 9ba8ce30f8314a79169e6d9cfa12e5db7239693f Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 16 Jun 2017 09:09:09 -0700 Subject: Bug fix: handle unchecked operator application in emit logic When in rewriter mode, the emit logic will never see function applications inside function bodies, but it *will* see function application expressions at global scope, and some of these expressions might be unchecked. The challenge here is that even simple math operations now show up as function calls, so we need a bit of special-case logic to detect unchecked calls and then emit them using the syntax they were written with (e.g., use infix syntax if they were written as an infix expression). --- source/slang/parser.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/slang/parser.cpp') diff --git a/source/slang/parser.cpp b/source/slang/parser.cpp index 29b02f816..b8997b1d7 100644 --- a/source/slang/parser.cpp +++ b/source/slang/parser.cpp @@ -1302,7 +1302,7 @@ namespace Slang auto expr = new VarExpressionSyntaxNode(); expr->scope = parser->currentScope.Ptr(); expr->Position = decl->getNameToken().Position; - expr->Variable = decl->getName(); + expr->name = decl->getName(); return expr; } @@ -1347,7 +1347,7 @@ namespace Slang auto basicType = new VarExpressionSyntaxNode(); basicType->scope = parser->currentScope.Ptr(); basicType->Position = typeName.Position; - basicType->Variable = typeName.Content; + basicType->name = typeName.Content; RefPtr typeExpr = basicType; @@ -1659,13 +1659,13 @@ namespace Slang // Construct a type expression to reference the buffer data type auto bufferDataTypeExpr = new VarExpressionSyntaxNode(); bufferDataTypeExpr->Position = bufferDataTypeDecl->Position; - bufferDataTypeExpr->Variable = bufferDataTypeDecl->Name.Content; + bufferDataTypeExpr->name = bufferDataTypeDecl->Name.Content; bufferDataTypeExpr->scope = parser->currentScope.Ptr(); // Construct a type exrpession to reference the type constructor auto bufferWrapperTypeExpr = new VarExpressionSyntaxNode(); bufferWrapperTypeExpr->Position = bufferWrapperTypeNamePos; - bufferWrapperTypeExpr->Variable = bufferWrapperTypeName; + bufferWrapperTypeExpr->name = bufferWrapperTypeName; // Always need to look this up in the outer scope, // so that it won't collide with, e.g., a local variable called `ConstantBuffer` @@ -1812,13 +1812,13 @@ namespace Slang // Construct a type expression to reference the buffer data type auto blockDataTypeExpr = new VarExpressionSyntaxNode(); blockDataTypeExpr->Position = blockDataTypeDecl->Position; - blockDataTypeExpr->Variable = blockDataTypeDecl->Name.Content; + blockDataTypeExpr->name = blockDataTypeDecl->Name.Content; blockDataTypeExpr->scope = parser->currentScope.Ptr(); // Construct a type exrpession to reference the type constructor auto blockWrapperTypeExpr = new VarExpressionSyntaxNode(); blockWrapperTypeExpr->Position = pos; - blockWrapperTypeExpr->Variable = blockWrapperTypeName; + blockWrapperTypeExpr->name = blockWrapperTypeName; // Always need to look this up in the outer scope, // so that it won't collide with, e.g., a local variable called `ConstantBuffer` blockWrapperTypeExpr->scope = parser->outerScope; @@ -2894,7 +2894,7 @@ parser->ReadToken(TokenType::Comma); } auto opExpr = new VarExpressionSyntaxNode(); - opExpr->Variable = opToken.Content; + opExpr->name = opToken.Content; opExpr->scope = parser->currentScope; opExpr->Position = opToken.Position; @@ -3060,7 +3060,7 @@ parser->ReadToken(TokenType::Comma); varExpr->scope = currentScope.Ptr(); FillPosition(varExpr.Ptr()); auto token = ReadToken(TokenType::Identifier); - varExpr->Variable = token.Content; + varExpr->name = token.Content; rs = varExpr; } @@ -3125,7 +3125,7 @@ parser->ReadToken(TokenType::Comma); FillPosition(memberExpr.Ptr()); memberExpr->BaseExpression = rs; ReadToken(TokenType::Dot); - memberExpr->MemberName = ReadToken(TokenType::Identifier).Content; + memberExpr->name = ReadToken(TokenType::Identifier).Content; rs = memberExpr; } } -- cgit v1.2.3