summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-06-21 11:18:33 -0700
committerTim Foley <tfoley@nvidia.com>2017-06-21 11:59:52 -0700
commitbdfe06d2c1fd4a950dd8dbcb235bcf3a719632b0 (patch)
tree917a47c34d62736b39e7d92a264553ee258f3b90 /source/slang
parent7f7864e80e8b5631ba5ec1aa9657fdaf1b4adb06 (diff)
Emit: Add support for `while` and `do {} while` statements
These were being passed over by the emit logic because I didn't have tests that used them.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/emit.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index c531a0a77..eae9cd052 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -1719,6 +1719,27 @@ static void EmitStmt(EmitContext* context, RefPtr<StatementSyntaxNode> stmt)
EmitBlockStmt(context, forStmt->Statement);
return;
}
+ else if (auto whileStmt = stmt.As<WhileStatementSyntaxNode>())
+ {
+ EmitLoopAttributes(context, whileStmt);
+
+ Emit(context, "while(");
+ EmitExpr(context, whileStmt->Predicate);
+ Emit(context, ")\n");
+ EmitBlockStmt(context, whileStmt->Statement);
+ return;
+ }
+ else if (auto doWhileStmt = stmt.As<DoWhileStatementSyntaxNode>())
+ {
+ EmitLoopAttributes(context, doWhileStmt);
+
+ Emit(context, "do(");
+ EmitBlockStmt(context, doWhileStmt->Statement);
+ Emit(context, " while(");
+ EmitExpr(context, doWhileStmt->Predicate);
+ Emit(context, ")\n");
+ return;
+ }
else if (auto discardStmt = stmt.As<DiscardStatementSyntaxNode>())
{
Emit(context, "discard;\n");