Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Dawn & Tint Authors |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 2 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are met: |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 5 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | // 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | // list of conditions and the following disclaimer. |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 8 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | // this list of conditions and the following disclaimer in the documentation |
| 11 | // and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // 3. Neither the name of the copyright holder nor the names of its |
| 14 | // contributors may be used to endorse or promote products derived from |
| 15 | // this software without specific prior written permission. |
| 16 | // |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 27 | |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 28 | #ifndef SRC_TINT_LANG_WGSL_WRITER_AST_PRINTER_AST_PRINTER_H_ |
| 29 | #define SRC_TINT_LANG_WGSL_WRITER_AST_PRINTER_AST_PRINTER_H_ |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 30 | |
Ben Clayton | edc51ab | 2023-08-08 07:58:19 +0000 | [diff] [blame] | 31 | #include "src/tint/lang/core/binary_op.h" |
Ben Clayton | 7fd1c2a | 2023-08-01 00:37:35 +0000 | [diff] [blame] | 32 | #include "src/tint/utils/generator/text_generator.h" |
dan sinclair | 22b4dd2 | 2023-07-21 00:40:07 +0000 | [diff] [blame] | 33 | #include "src/tint/utils/text/string_stream.h" |
Ben Clayton | 5ed099a | 2023-07-25 18:52:03 +0000 | [diff] [blame] | 34 | |
| 35 | // Forward declarations |
Ben Clayton | ae18c41 | 2023-07-29 13:00:40 +0000 | [diff] [blame] | 36 | namespace tint { |
| 37 | class Program; |
| 38 | } |
Ben Clayton | 5ed099a | 2023-07-25 18:52:03 +0000 | [diff] [blame] | 39 | namespace tint::ast { |
| 40 | class AssignmentStatement; |
| 41 | class Attribute; |
| 42 | class BinaryExpression; |
Ben Clayton | 5ed099a | 2023-07-25 18:52:03 +0000 | [diff] [blame] | 43 | class BitcastExpression; |
| 44 | class BlockStatement; |
| 45 | class BlockStatement; |
| 46 | class BreakIfStatement; |
| 47 | class BreakStatement; |
| 48 | class CallExpression; |
| 49 | class CaseStatement; |
| 50 | class CompoundAssignmentStatement; |
| 51 | class ConstAssert; |
| 52 | class ContinueStatement; |
| 53 | struct DiagnosticControl; |
| 54 | class DiscardStatement; |
| 55 | class Enable; |
| 56 | class Expression; |
| 57 | class ForLoopStatement; |
| 58 | class Function; |
| 59 | class Identifier; |
| 60 | class IdentifierExpression; |
| 61 | class IfStatement; |
| 62 | class IncrementDecrementStatement; |
| 63 | class IndexAccessorExpression; |
| 64 | class LiteralExpression; |
| 65 | class LoopStatement; |
| 66 | class MemberAccessorExpression; |
James Price | bdbeb35 | 2023-11-02 15:03:02 +0000 | [diff] [blame] | 67 | class Requires; |
Ben Clayton | 5ed099a | 2023-07-25 18:52:03 +0000 | [diff] [blame] | 68 | class ReturnStatement; |
| 69 | class Statement; |
| 70 | class Statement; |
| 71 | class Statement; |
| 72 | class Struct; |
| 73 | class SwitchStatement; |
| 74 | class TypeDecl; |
| 75 | class UnaryOpExpression; |
| 76 | class Variable; |
| 77 | class WhileStatement; |
| 78 | } // namespace tint::ast |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 79 | |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 80 | namespace tint::core { |
Ben Clayton | 0f8b6ef | 2023-08-10 14:12:42 +0000 | [diff] [blame] | 81 | enum class TexelFormat : uint8_t; |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 82 | } // namespace tint::core |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 83 | |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 84 | namespace tint::wgsl::writer { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 85 | |
| 86 | /// Implementation class for WGSL generator |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 87 | class ASTPrinter : public tint::TextGenerator { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 88 | public: |
| 89 | /// Constructor |
| 90 | /// @param program the program |
Ben Clayton | 5ed5cc4 | 2023-09-22 10:31:04 +0000 | [diff] [blame] | 91 | explicit ASTPrinter(const Program& program); |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 92 | ~ASTPrinter() override; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 93 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 94 | /// Generates the result data |
James Price | d3a56cb | 2023-08-02 19:46:00 +0000 | [diff] [blame] | 95 | /// @returns true on successful generation, false otherwise |
| 96 | bool Generate(); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 97 | |
James Price | e8ea579 | 2023-01-24 21:01:36 +0000 | [diff] [blame] | 98 | /// Handles generating a diagnostic control |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 99 | /// @param out the output stream |
James Price | e8ea579 | 2023-01-24 21:01:36 +0000 | [diff] [blame] | 100 | /// @param diagnostic the diagnostic control node |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 101 | void EmitDiagnosticControl(StringStream& out, const ast::DiagnosticControl& diagnostic); |
James Price | e8ea579 | 2023-01-24 21:01:36 +0000 | [diff] [blame] | 102 | /// Handles generating an enable directive |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 103 | /// @param enable the enable node |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 104 | void EmitEnable(const ast::Enable* enable); |
James Price | bdbeb35 | 2023-11-02 15:03:02 +0000 | [diff] [blame] | 105 | /// Handles generating a requires directive |
| 106 | /// @param req the requires node |
| 107 | void EmitRequires(const ast::Requires* req); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 108 | /// Handles generating a declared type |
| 109 | /// @param ty the declared type to generate |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 110 | void EmitTypeDecl(const ast::TypeDecl* ty); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 111 | /// Handles an index accessor expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 112 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 113 | /// @param expr the expression to emit |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 114 | void EmitIndexAccessor(StringStream& out, const ast::IndexAccessorExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 115 | /// Handles an assignment statement |
| 116 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 117 | void EmitAssign(const ast::AssignmentStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 118 | /// Handles generating a binary expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 119 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 120 | /// @param expr the binary expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 121 | void EmitBinary(StringStream& out, const ast::BinaryExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 122 | /// Handles generating a binary operator |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 123 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 124 | /// @param op the binary operator |
Ben Clayton | edc51ab | 2023-08-08 07:58:19 +0000 | [diff] [blame] | 125 | void EmitBinaryOp(StringStream& out, const core::BinaryOp op); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 126 | /// Handles a block statement |
| 127 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 128 | void EmitBlock(const ast::BlockStatement* stmt); |
James Price | d9f6596 | 2023-02-01 23:14:10 +0000 | [diff] [blame] | 129 | /// Handles emitting the start of a block statement (including attributes) |
| 130 | /// @param out the output stream to write the header to |
| 131 | /// @param stmt the block statement to emit the header for |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 132 | void EmitBlockHeader(StringStream& out, const ast::BlockStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 133 | /// Handles a break statement |
| 134 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 135 | void EmitBreak(const ast::BreakStatement* stmt); |
dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 136 | /// Handles a break-if statement |
| 137 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 138 | void EmitBreakIf(const ast::BreakIfStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 139 | /// Handles generating a call expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 140 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 141 | /// @param expr the call expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 142 | void EmitCall(StringStream& out, const ast::CallExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 143 | /// Handles a case statement |
| 144 | /// @param stmt the statement |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 145 | void EmitCase(const ast::CaseStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 146 | /// Handles a compound assignment statement |
| 147 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 148 | void EmitCompoundAssign(const ast::CompoundAssignmentStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 149 | /// Handles generating a literal expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 150 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 151 | /// @param expr the literal expression expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 152 | void EmitLiteral(StringStream& out, const ast::LiteralExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 153 | /// Handles a continue statement |
| 154 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 155 | void EmitContinue(const ast::ContinueStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 156 | /// Handles generate an Expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 157 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 158 | /// @param expr the expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 159 | void EmitExpression(StringStream& out, const ast::Expression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 160 | /// Handles generating a function |
| 161 | /// @param func the function to generate |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 162 | void EmitFunction(const ast::Function* func); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 163 | /// Handles generating an identifier expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 164 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 165 | /// @param expr the identifier expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 166 | void EmitIdentifier(StringStream& out, const ast::IdentifierExpression* expr); |
Ben Clayton | 1131d31 | 2023-02-10 19:24:24 +0000 | [diff] [blame] | 167 | /// Handles generating an identifier |
| 168 | /// @param out the output of the expression stream |
| 169 | /// @param ident the identifier |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 170 | void EmitIdentifier(StringStream& out, const ast::Identifier* ident); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 171 | /// Handles an if statement |
| 172 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 173 | void EmitIf(const ast::IfStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 174 | /// Handles an increment/decrement statement |
| 175 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 176 | void EmitIncrementDecrement(const ast::IncrementDecrementStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 177 | /// Handles generating a discard statement |
| 178 | /// @param stmt the discard statement |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 179 | void EmitDiscard(const ast::DiscardStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 180 | /// Handles a loop statement |
| 181 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 182 | void EmitLoop(const ast::LoopStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 183 | /// Handles a for-loop statement |
| 184 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 185 | void EmitForLoop(const ast::ForLoopStatement* stmt); |
dan sinclair | 49d1a2d | 2022-06-16 12:01:27 +0000 | [diff] [blame] | 186 | /// Handles a while statement |
| 187 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 188 | void EmitWhile(const ast::WhileStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 189 | /// Handles a member accessor expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 190 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 191 | /// @param expr the member accessor expression |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 192 | void EmitMemberAccessor(StringStream& out, const ast::MemberAccessorExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 193 | /// Handles return statements |
| 194 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 195 | void EmitReturn(const ast::ReturnStatement* stmt); |
Ben Clayton | c98d57d | 2023-01-24 14:59:43 +0000 | [diff] [blame] | 196 | /// Handles const assertion statements |
Ben Clayton | b4744ac | 2022-08-03 07:01:08 +0000 | [diff] [blame] | 197 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 198 | void EmitConstAssert(const ast::ConstAssert* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 199 | /// Handles statement |
| 200 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 201 | void EmitStatement(const ast::Statement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 202 | /// Handles a statement list |
| 203 | /// @param stmts the statements to emit |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 204 | void EmitStatements(VectorRef<const ast::Statement*> stmts); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 205 | /// Handles a statement list with an increased indentation |
| 206 | /// @param stmts the statements to emit |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 207 | void EmitStatementsWithIndent(VectorRef<const ast::Statement*> stmts); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 208 | /// Handles generating a switch statement |
| 209 | /// @param stmt the statement to emit |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 210 | void EmitSwitch(const ast::SwitchStatement* stmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 211 | /// Handles generating a struct declaration |
| 212 | /// @param str the struct |
dan sinclair | 27c7722 | 2023-04-13 02:57:27 +0000 | [diff] [blame] | 213 | void EmitStructType(const ast::Struct* str); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 214 | /// Handles emitting an image format |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 215 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 216 | /// @param fmt the format to generate |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 217 | void EmitImageFormat(StringStream& out, const core::TexelFormat fmt); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 218 | /// Handles a unary op expression |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 219 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 220 | /// @param expr the expression to emit |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 221 | void EmitUnaryOp(StringStream& out, const ast::UnaryOpExpression* expr); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 222 | /// Handles generating a variable |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 223 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 224 | /// @param var the variable to generate |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 225 | void EmitVariable(StringStream& out, const ast::Variable* var); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 226 | /// Handles generating a attribute list |
Ben Clayton | 971318f | 2023-02-14 13:52:43 +0000 | [diff] [blame] | 227 | /// @param out the output stream |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 228 | /// @param attrs the attribute list |
dan sinclair | bae54e7 | 2023-07-28 15:01:54 +0000 | [diff] [blame] | 229 | void EmitAttributes(StringStream& out, VectorRef<const ast::Attribute*> attrs); |
Ben Clayton | 5ed099a | 2023-07-25 18:52:03 +0000 | [diff] [blame] | 230 | |
| 231 | private: |
Ben Clayton | 5ed5cc4 | 2023-09-22 10:31:04 +0000 | [diff] [blame] | 232 | const Program& program_; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 233 | }; |
| 234 | |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 235 | } // namespace tint::wgsl::writer |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 236 | |
dan sinclair | c1bf225 | 2023-07-26 17:38:29 +0000 | [diff] [blame] | 237 | #endif // SRC_TINT_LANG_WGSL_WRITER_AST_PRINTER_AST_PRINTER_H_ |