From bdfe06d2c1fd4a950dd8dbcb235bcf3a719632b0 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 21 Jun 2017 11:18:33 -0700 Subject: 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. --- source/slang/emit.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/emit.cpp') 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 stmt) EmitBlockStmt(context, forStmt->Statement); return; } + else if (auto whileStmt = stmt.As()) + { + EmitLoopAttributes(context, whileStmt); + + Emit(context, "while("); + EmitExpr(context, whileStmt->Predicate); + Emit(context, ")\n"); + EmitBlockStmt(context, whileStmt->Statement); + return; + } + else if (auto doWhileStmt = stmt.As()) + { + 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()) { Emit(context, "discard;\n"); -- cgit v1.2.3