/src/skia/src/sksl/ir/SkSLExpression.cpp
Line | Count | Source (jump to first uncovered line) |
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 "src/sksl/SkSLBuiltinTypes.h" |
11 | | #include "src/sksl/SkSLContext.h" |
12 | | #include "src/sksl/SkSLDefines.h" |
13 | | #include "src/sksl/SkSLErrorReporter.h" |
14 | | #include "src/sksl/SkSLOperator.h" |
15 | | |
16 | | namespace SkSL { |
17 | | |
18 | 267k | std::string Expression::description() const { |
19 | 267k | return this->description(OperatorPrecedence::kExpression); |
20 | 267k | } |
21 | | |
22 | 8.67M | bool Expression::isIncomplete(const Context& context) const { |
23 | 8.67M | switch (this->kind()) { |
24 | 14.6k | case Kind::kFunctionReference: |
25 | 14.6k | context.fErrors->error(fPosition.after(), "expected '(' to begin function call"); |
26 | 14.6k | return true; |
27 | | |
28 | 4.75k | case Kind::kMethodReference: |
29 | 4.75k | context.fErrors->error(fPosition.after(), "expected '(' to begin method call"); |
30 | 4.75k | return true; |
31 | | |
32 | 15.2k | case Kind::kTypeReference: |
33 | 15.2k | context.fErrors->error(fPosition.after(), |
34 | 15.2k | "expected '(' to begin constructor invocation"); |
35 | 15.2k | return true; |
36 | | |
37 | 1.05M | case Kind::kVariableReference: |
38 | 1.05M | if (this->type().matches(*context.fTypes.fSkCaps)) { |
39 | 1.81k | context.fErrors->error(fPosition, "invalid expression"); |
40 | 1.81k | return true; |
41 | 1.81k | } |
42 | 1.05M | return false; |
43 | | |
44 | 7.58M | default: |
45 | 7.58M | return false; |
46 | 8.67M | } |
47 | 8.67M | } |
48 | | |
49 | 4.22M | ExpressionArray ExpressionArray::clone() const { |
50 | 4.22M | ExpressionArray cloned; |
51 | 4.22M | cloned.reserve_exact(this->size()); |
52 | 8.60M | for (const std::unique_ptr<Expression>& expr : *this) { |
53 | 8.60M | cloned.push_back(expr ? expr->clone() : nullptr); |
54 | 8.60M | } |
55 | 4.22M | return cloned; |
56 | 4.22M | } |
57 | | |
58 | | } // namespace SkSL |