* @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)
| 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 |
nothing calls this directly
no test coverage detected