public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
        {
            AppendNodeComment(fileManager);

            // Check condition
            this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            // If the condition is false, jump to the else-statement (exit label if else-statement is null)
            string elseLabel = codeGeneratorHelper.GenerateNextLabel();
            fileManager.Output.Append(Macro.JumpOnFalse(elseLabel));

            // Then-statement
            this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            // On existing else-statement jump over it
            string outLabel = null;
            if (this._children[2] != null)
            {
                outLabel = codeGeneratorHelper.GenerateNextLabel();
                fileManager.Output.Append(Macro.Jump(outLabel));
            }

            // Generate else label
            fileManager.Output.Append(Macro.Label(elseLabel));

            // Else-statement and exit label
            if (this._children[2] != null)
            {
                this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
                fileManager.Output.Append(Macro.Label(outLabel));
            }
        }
        public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
        {
            AppendNodeComment(fileManager);

            // Generate loop start label
            string startLabel = codeGeneratorHelper.GenerateNextLabel();
            fileManager.Output.Append(Macro.Label(startLabel));

            // Check condition and jump out if false
            this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);
            string outLabel = codeGeneratorHelper.GenerateNextLabel();
            fileManager.Output.Append(Macro.JumpOnFalse(outLabel));

            // Loop body
            this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            // Jump back to condition check
            fileManager.Output.Append(Macro.Jump(startLabel));

            // Generate loop end label
            fileManager.Output.Append(Macro.Label(outLabel));
        }
        public override void GenerateCode(FileManager fileManager, SymbolTable symbolTable, CodeGeneratorHelper codeGeneratorHelper)
        {
            AppendNodeComment(fileManager);

            this._children[0].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            string elseLabel = codeGeneratorHelper.GenerateNextLabel();
            fileManager.Output.Append(Macro.JumpOnFalse(elseLabel));

            this._children[1].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            string fiiLabel = codeGeneratorHelper.GenerateNextLabel();
            fileManager.Output.Append(Macro.Jump(fiiLabel));
            fileManager.Output.Append(Macro.Label(elseLabel));

            this._children[2].GenerateCode(fileManager, symbolTable, codeGeneratorHelper);

            fileManager.Output.Append(Macro.Label(fiiLabel));
        }