• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/sksl/SkSLErrorReporter.h"
9 #include "src/sksl/SkSLContext.h"
10 #include "src/sksl/ir/SkSLExpression.h"
11 
12 namespace SkSL {
13 
isIncomplete(const Context & context) const14 bool Expression::isIncomplete(const Context& context) const {
15     switch (this->kind()) {
16         case Kind::kFunctionReference:
17         case Kind::kExternalFunctionReference:
18             context.fErrors->error(fLine, "expected '(' to begin function call");
19             return true;
20 
21         case Kind::kMethodReference:
22             context.fErrors->error(fLine, "expected '(' to begin method call");
23             return true;
24 
25         case Kind::kTypeReference:
26             context.fErrors->error(fLine, "expected '(' to begin constructor invocation");
27             return true;
28 
29         default:
30             return false;
31     }
32 }
33 
clone() const34 ExpressionArray ExpressionArray::clone() const {
35     ExpressionArray cloned;
36     cloned.reserve_back(this->count());
37     for (const std::unique_ptr<Expression>& expr : *this) {
38         cloned.push_back(expr ? expr->clone() : nullptr);
39     }
40     return cloned;
41 }
42 
43 }  // namespace SkSL
44