summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-17 09:49:32 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-17 09:49:32 -0700
commit782e6f0f675fd858acfdc66e5ea1fa46a646df71 (patch)
tree6c388f41dd67cb70370baba9ce85047366a5ca59 /source
parentf23738e58dadcaab0503c6cba1d9c7819153080a (diff)
Add emit logic for generic app expressions
Work on #105 These can occur in unchecked code (or code that had a semantic error), so we need to be able to handle them.
Diffstat (limited to 'source')
-rw-r--r--source/slang/emit.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 7ffce2acd..8c6a46196 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1495,14 +1495,28 @@ struct EmitVisitor
outerPrec.rightPrecedence = rightPrec;
}
+ void visitGenericAppExpr(GenericAppExpr* expr, ExprEmitArg const& arg)
+ {
+ auto prec = kEOp_Postfix;
+ auto outerPrec = arg.outerPrec;
+ bool needClose = MaybeEmitParens(outerPrec, prec);
-#define UNEXPECTED(NAME) \
- void visit##NAME(NAME*, ExprEmitArg const&) \
- { Emit(#NAME); }
-
- UNEXPECTED(GenericAppExpr);
+ EmitExprWithPrecedence(expr->FunctionExpr, leftSide(outerPrec, prec));
+ Emit("<");
+ bool first = true;
+ for(auto aa : expr->Arguments)
+ {
+ if(!first) Emit(", ");
+ EmitExpr(aa);
+ first = false;
+ }
+ Emit(" >");
-#undef UNEXPECTED
+ if(needClose)
+ {
+ Emit(")");
+ }
+ }
void visitSharedTypeExpr(SharedTypeExpr* expr, ExprEmitArg const&)
{