Skip to content

Commit 2bee76d

Browse files
committed
Add support for while loops
1 parent 96e91cc commit 2bee76d

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/backend/functionNode_webgl.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,25 +373,24 @@ var functionNode_webgl = (function() {
373373
///
374374
/// @returns the prased openclgl string
375375
function ast_WhileStatement(whileNode, retArr, funcParam) {
376-
throw ast_errorOutput(
377-
"While statements are not allowed",
378-
ast, funcParam
379-
);
380-
381-
/*
382376
if (whileNode.type != "WhileStatement") {
383377
throw ast_errorOutput(
384378
"Invalid while statment",
385379
ast, funcParam
386380
);
387381
}
388-
retArr.push("while (");
382+
383+
retArr.push("for (float i=0.0; i<LOOP_MAX; i++) {");
384+
retArr.push("if (");
389385
ast_generic(whileNode.test, retArr, funcParam);
390386
retArr.push(") {\n");
391387
ast_generic(whileNode.body, retArr, funcParam);
388+
retArr.push("} else {\n");
389+
retArr.push("break;\n");
392390
retArr.push("}\n");
391+
retArr.push("}\n");
392+
393393
return retArr;
394-
*/
395394
}
396395

397396
function ast_AssignmentExpression(assNode, retArr, funcParam) {

0 commit comments

Comments
 (0)