1 /* 2 * Copyright 2021 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 #include "src/sksl/ir/SkSLExpression.h" 9 10 #include "include/private/SkSLDefines.h" 11 #include "include/sksl/SkSLErrorReporter.h" 12 #include "include/sksl/SkSLOperator.h" 13 #include "src/sksl/SkSLContext.h" 14 15 namespace SkSL { 16 description() const17std::string Expression::description() const { 18 return this->description(OperatorPrecedence::kTopLevel); 19 } 20 isIncomplete(const Context & context) const21bool Expression::isIncomplete(const Context& context) const { 22 switch (this->kind()) { 23 case Kind::kFunctionReference: 24 context.fErrors->error(fPosition.after(), "expected '(' to begin function call"); 25 return true; 26 27 case Kind::kMethodReference: 28 context.fErrors->error(fPosition.after(), "expected '(' to begin method call"); 29 return true; 30 31 case Kind::kTypeReference: 32 context.fErrors->error(fPosition.after(), 33 "expected '(' to begin constructor invocation"); 34 return true; 35 36 default: 37 return false; 38 } 39 } 40 clone() const41ExpressionArray ExpressionArray::clone() const { 42 ExpressionArray cloned; 43 cloned.reserve_back(this->size()); 44 for (const std::unique_ptr<Expression>& expr : *this) { 45 cloned.push_back(expr ? expr->clone() : nullptr); 46 } 47 return cloned; 48 } 49 50 } // namespace SkSL 51