From 6233f9b35f1901ca33c53ce37f9b1517e91e1d79 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Sat, 8 Jul 2017 17:04:31 -0700 Subject: Revise how hidden implicit casts are recognized. The old approach used an `isRewriter` flag in the emit logic, but I kind of need that flag to go away. Instead, I now how the semantic checking pass detect whether an implicitly-generated type cast is in rewriter code, and if so it uses the new `HiddenImplicitCastExpr` AST node. The emit logic then looks for that specific node and eliminates it. --- source/slang/check.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/slang/check.cpp') diff --git a/source/slang/check.cpp b/source/slang/check.cpp index f21f9480c..556f141c0 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -987,7 +987,19 @@ namespace Slang RefPtr toType, RefPtr fromExpr) { - auto castExpr = new ImplicitCastExpr(); + // In "rewrite" mode, we will generate a different syntax node + // to indicate that this type-cast was implicitly generated + // by the compiler, and shouldn't appear in the output code. + RefPtr castExpr; + if (isRewriteMode()) + { + castExpr = new HiddenImplicitCastExpr(); + } + else + { + castExpr = new ImplicitCastExpr(); + } + castExpr->Position = fromExpr->Position; castExpr->TargetType.type = toType; castExpr->Type = QualType(toType); -- cgit v1.2.3