ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_ASTCALLSUFFIX |
| 9 | #define SKSL_ASTCALLSUFFIX |
| 10 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 11 | #include <vector> |
| 12 | #include "SkSLASTSuffix.h" |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 17 | * A parenthesized list of arguments following an expression, indicating a function call. |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 18 | */ |
| 19 | struct ASTCallSuffix : public ASTSuffix { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 20 | ASTCallSuffix(int offset, std::vector<std::unique_ptr<ASTExpression>> arguments) |
| 21 | : INHERITED(offset, ASTSuffix::kCall_Kind) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 22 | , fArguments(std::move(arguments)) {} |
| 23 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 24 | String description() const override { |
| 25 | String result("("); |
| 26 | String separator; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 27 | for (size_t i = 0; i < fArguments.size(); ++i) { |
| 28 | result += separator; |
| 29 | separator = ", "; |
| 30 | result += fArguments[i]->description(); |
| 31 | } |
| 32 | result += ")"; |
| 33 | return result; |
| 34 | } |
| 35 | |
| 36 | std::vector<std::unique_ptr<ASTExpression>> fArguments; |
| 37 | |
| 38 | typedef ASTSuffix INHERITED; |
| 39 | }; |
| 40 | |
| 41 | } // namespace |
| 42 | |
| 43 | #endif |