OLD | NEW |
(Empty) | |
| 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 */ |
| 7 |
| 8 #ifndef SKSL_CONSTRUCTOR |
| 9 #define SKSL_CONSTRUCTOR |
| 10 |
| 11 #include "SkSLExpression.h" |
| 12 |
| 13 namespace SkSL { |
| 14 |
| 15 /** |
| 16 * Represents the construction of a compound type, such as "vec2(x, y)". |
| 17 */ |
| 18 struct Constructor : public Expression { |
| 19 Constructor(Position position, std::shared_ptr<Type> type, |
| 20 std::vector<std::unique_ptr<Expression>> arguments) |
| 21 : INHERITED(position, kConstructor_Kind, std::move(type)) |
| 22 , fArguments(std::move(arguments)) {} |
| 23 |
| 24 std::string description() const override { |
| 25 std::string result = fType->description() + "("; |
| 26 std::string separator = ""; |
| 27 for (size_t i = 0; i < fArguments.size(); i++) { |
| 28 result += separator; |
| 29 result += fArguments[i]->description(); |
| 30 separator = ", "; |
| 31 } |
| 32 result += ")"; |
| 33 return result; |
| 34 } |
| 35 |
| 36 bool isConstant() const override { |
| 37 for (size_t i = 0; i < fArguments.size(); i++) { |
| 38 if (!fArguments[i]->isConstant()) { |
| 39 return false; |
| 40 } |
| 41 } |
| 42 return true; |
| 43 } |
| 44 |
| 45 const std::vector<std::unique_ptr<Expression>> fArguments; |
| 46 |
| 47 typedef Expression INHERITED; |
| 48 }; |
| 49 |
| 50 } // namespace |
| 51 |
| 52 #endif |
OLD | NEW |