MCPcopy Index your code
hub / github.com/gpujs/gpu.js / astWhileStatement

Method astWhileStatement

src/backend/web-gl/function-node.js:708–722  ·  view source on GitHub ↗

* @desc Parses the abstract syntax tree for *while* loop * @param {Object} whileNode - An ast Node * @param {Array} retArr - return array string * @returns {Array} the parsed webgl string

(whileNode, retArr)

Source from the content-addressed store, hash-verified

706 * @returns {Array} the parsed webgl string
707 */
708 astWhileStatement(whileNode, retArr) {
709 if (whileNode.type !== 'WhileStatement') {
710 throw this.astErrorOutput('Invalid while statement', whileNode);
711 }
712
713 const iVariableName = this.getInternalVariableName('safeI');
714 retArr.push(`for (int ${iVariableName}=0;${iVariableName}<LOOP_MAX;${iVariableName}++){\n`);
715 retArr.push('if (!');
716 this.astGeneric(whileNode.test, retArr);
717 retArr.push(') break;\n');
718 this.astGeneric(whileNode.body, retArr);
719 retArr.push('}\n');
720
721 return retArr;
722 }
723
724 /**
725 * @desc Parses the abstract syntax tree for *do while* loop

Callers

nothing calls this directly

Calls 3

astErrorOutputMethod · 0.80
astGenericMethod · 0.80

Tested by

no test coverage detected