diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-08 17:04:31 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-08 18:22:26 -0700 |
| commit | 6233f9b35f1901ca33c53ce37f9b1517e91e1d79 (patch) | |
| tree | ba7171bfe69a81a8425795e77f75a093a7a95e90 /source/slang/emit.cpp | |
| parent | c77c0390d8da6c1769e0a9c5b2f862b3598d9b8f (diff) | |
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.
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index a1d95ca7e..a8c0083c1 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2031,18 +2031,15 @@ struct EmitVisitor if(needClose) Emit(")"); } - void visitTypeCastExpressionSyntaxNode(TypeCastExpressionSyntaxNode* castExpr, ExprEmitArg const& arg) + void visitHiddenImplicitCastExpr(HiddenImplicitCastExpr* castExpr, ExprEmitArg const& arg) { - if (context->isRewrite) - { - if (dynamic_cast<ImplicitCastExpr*>(castExpr)) - { - // This was an implicit cast, so don't try to output it - ExprVisitorWithArg::dispatch(castExpr->Expression, arg); - return; - } - } + // This was an implicit cast inserted in code parsed in "rewriter" mode, + // so we don't want to output it and change what the user's code looked like. + ExprVisitorWithArg::dispatch(castExpr->Expression, arg); + } + void visitTypeCastExpressionSyntaxNode(TypeCastExpressionSyntaxNode* castExpr, ExprEmitArg const& arg) + { bool needClose = false; switch(context->shared->target) { |
