Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 Google LLC |
| 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_DSL_EXPRESSION |
| 9 | #define SKSL_DSL_EXPRESSION |
| 10 | |
Ethan Nicholas | d0f4d0d | 2021-06-23 13:51:55 -0400 | [diff] [blame] | 11 | #include "include/core/SkStringView.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 12 | #include "include/core/SkTypes.h" |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 13 | #include "include/private/SkTArray.h" |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 14 | #include "include/sksl/DSLWrapper.h" |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 15 | #include "include/sksl/SkSLErrorReporter.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 16 | |
| 17 | #include <cstdint> |
| 18 | #include <memory> |
| 19 | |
| 20 | namespace SkSL { |
| 21 | |
| 22 | class Expression; |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 23 | class Type; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 24 | |
| 25 | namespace dsl { |
| 26 | |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 27 | class DSLPossibleExpression; |
Ethan Nicholas | cfefec0 | 2021-02-09 15:22:57 -0500 | [diff] [blame] | 28 | class DSLStatement; |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 29 | class DSLType; |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 30 | class DSLVarBase; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Represents an expression such as 'cos(x)' or 'a + b'. |
| 34 | */ |
| 35 | class DSLExpression { |
| 36 | public: |
| 37 | DSLExpression(const DSLExpression&) = delete; |
| 38 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 39 | DSLExpression(DSLExpression&&); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 40 | |
| 41 | DSLExpression(); |
| 42 | |
| 43 | /** |
| 44 | * Creates an expression representing a literal float. |
| 45 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 46 | DSLExpression(float value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Creates an expression representing a literal float. |
| 50 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 51 | DSLExpression(double value, PositionInfo pos = PositionInfo::Capture()) |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 52 | : DSLExpression((float) value) {} |
| 53 | |
| 54 | /** |
| 55 | * Creates an expression representing a literal int. |
| 56 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 57 | DSLExpression(int value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 58 | |
| 59 | /** |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 60 | * Creates an expression representing a literal int. |
| 61 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 62 | DSLExpression(int64_t value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 63 | |
| 64 | /** |
Ethan Nicholas | b83199e | 2021-05-03 14:25:35 -0400 | [diff] [blame] | 65 | * Creates an expression representing a literal uint. |
| 66 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 67 | DSLExpression(unsigned int value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b83199e | 2021-05-03 14:25:35 -0400 | [diff] [blame] | 68 | |
| 69 | /** |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 70 | * Creates an expression representing a literal bool. |
| 71 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 72 | DSLExpression(bool value, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 73 | |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 74 | /** |
| 75 | * Creates an expression representing a variable reference. |
| 76 | */ |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 77 | DSLExpression(DSLVarBase& var, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 707d315 | 2021-03-25 17:49:08 -0400 | [diff] [blame] | 78 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 79 | DSLExpression(DSLVarBase&& var, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 80 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 81 | DSLExpression(DSLPossibleExpression expr, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 82 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 83 | explicit DSLExpression(std::unique_ptr<SkSL::Expression> expression); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 84 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 85 | static DSLExpression Poison(PositionInfo pos = PositionInfo::Capture()); |
| 86 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 87 | ~DSLExpression(); |
| 88 | |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 89 | DSLType type(); |
| 90 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 91 | /** |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 92 | * Overloads the '=' operator to create an SkSL assignment statement. |
| 93 | */ |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 94 | DSLPossibleExpression operator=(DSLExpression other); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 95 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 96 | DSLExpression x(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 97 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 98 | DSLExpression y(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 99 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 100 | DSLExpression z(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 101 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 102 | DSLExpression w(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 103 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 104 | DSLExpression r(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 105 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 106 | DSLExpression g(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 107 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 108 | DSLExpression b(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 109 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 110 | DSLExpression a(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 68c77d4 | 2021-01-26 14:31:29 -0500 | [diff] [blame] | 111 | |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 112 | /** |
Ethan Nicholas | bf79dff | 2021-02-11 15:18:31 -0500 | [diff] [blame] | 113 | * Creates an SkSL struct field access expression. |
| 114 | */ |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 115 | DSLExpression field(skstd::string_view name, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | bf79dff | 2021-02-11 15:18:31 -0500 | [diff] [blame] | 116 | |
| 117 | /** |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 118 | * Creates an SkSL array index expression. |
| 119 | */ |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 120 | DSLPossibleExpression operator[](DSLExpression index); |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 121 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 122 | DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args, |
| 123 | PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 124 | |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 125 | /** |
| 126 | * Returns true if this object contains an expression. DSLExpressions which were created with |
| 127 | * the empty constructor or which have already been release()ed are not valid. DSLExpressions |
| 128 | * created with errors are still considered valid (but contain a poison value). |
| 129 | */ |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 130 | bool valid() const { |
| 131 | return fExpression != nullptr; |
| 132 | } |
| 133 | |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 134 | void swap(DSLExpression& other); |
| 135 | |
Ethan Nicholas | 04be339 | 2021-01-26 10:07:01 -0500 | [diff] [blame] | 136 | /** |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 137 | * Invalidates this object and returns the SkSL expression it represents. It is an error to call |
| 138 | * this on an invalid DSLExpression. |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 139 | */ |
| 140 | std::unique_ptr<SkSL::Expression> release(); |
| 141 | |
| 142 | private: |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 143 | /** |
| 144 | * Calls release if this expression is valid, otherwise returns null. |
| 145 | */ |
| 146 | std::unique_ptr<SkSL::Expression> releaseIfValid(); |
| 147 | |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 148 | /** |
| 149 | * Invalidates this object and returns the SkSL expression it represents coerced to the |
| 150 | * specified type. If the expression cannot be coerced, reports an error and returns null. |
| 151 | */ |
| 152 | std::unique_ptr<SkSL::Expression> coerceAndRelease(const SkSL::Type& type); |
| 153 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 154 | std::unique_ptr<SkSL::Expression> fExpression; |
| 155 | |
Ethan Nicholas | 840f581 | 2021-02-16 13:02:57 -0500 | [diff] [blame] | 156 | friend DSLExpression SampleChild(int index, DSLExpression coords); |
| 157 | |
Ethan Nicholas | d6b6f3e | 2021-01-22 15:18:25 -0500 | [diff] [blame] | 158 | friend class DSLCore; |
Ethan Nicholas | 63f75fc | 2021-02-23 12:05:49 -0500 | [diff] [blame] | 159 | friend class DSLFunction; |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 160 | friend class DSLPossibleExpression; |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 161 | friend class DSLVarBase; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 162 | friend class DSLWriter; |
Ethan Nicholas | a1a0b92 | 2021-05-04 12:22:02 -0400 | [diff] [blame] | 163 | template<typename T> friend class DSLWrapper; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 164 | }; |
| 165 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 166 | DSLPossibleExpression operator+(DSLExpression left, DSLExpression right); |
Ethan Nicholas | b14b636 | 2021-03-08 17:07:58 -0500 | [diff] [blame] | 167 | DSLPossibleExpression operator+(DSLExpression expr); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 168 | DSLPossibleExpression operator+=(DSLExpression left, DSLExpression right); |
| 169 | DSLPossibleExpression operator-(DSLExpression left, DSLExpression right); |
Ethan Nicholas | b14b636 | 2021-03-08 17:07:58 -0500 | [diff] [blame] | 170 | DSLPossibleExpression operator-(DSLExpression expr); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 171 | DSLPossibleExpression operator-=(DSLExpression left, DSLExpression right); |
| 172 | DSLPossibleExpression operator*(DSLExpression left, DSLExpression right); |
| 173 | DSLPossibleExpression operator*=(DSLExpression left, DSLExpression right); |
| 174 | DSLPossibleExpression operator/(DSLExpression left, DSLExpression right); |
| 175 | DSLPossibleExpression operator/=(DSLExpression left, DSLExpression right); |
| 176 | DSLPossibleExpression operator%(DSLExpression left, DSLExpression right); |
| 177 | DSLPossibleExpression operator%=(DSLExpression left, DSLExpression right); |
| 178 | DSLPossibleExpression operator<<(DSLExpression left, DSLExpression right); |
| 179 | DSLPossibleExpression operator<<=(DSLExpression left, DSLExpression right); |
| 180 | DSLPossibleExpression operator>>(DSLExpression left, DSLExpression right); |
| 181 | DSLPossibleExpression operator>>=(DSLExpression left, DSLExpression right); |
| 182 | DSLPossibleExpression operator&&(DSLExpression left, DSLExpression right); |
| 183 | DSLPossibleExpression operator||(DSLExpression left, DSLExpression right); |
| 184 | DSLPossibleExpression operator&(DSLExpression left, DSLExpression right); |
| 185 | DSLPossibleExpression operator&=(DSLExpression left, DSLExpression right); |
| 186 | DSLPossibleExpression operator|(DSLExpression left, DSLExpression right); |
| 187 | DSLPossibleExpression operator|=(DSLExpression left, DSLExpression right); |
| 188 | DSLPossibleExpression operator^(DSLExpression left, DSLExpression right); |
| 189 | DSLPossibleExpression operator^=(DSLExpression left, DSLExpression right); |
Ethan Nicholas | 2ab47c9 | 2021-07-19 12:30:37 -0400 | [diff] [blame] | 190 | DSLPossibleExpression LogicalXor(DSLExpression left, DSLExpression right); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 191 | DSLPossibleExpression operator,(DSLExpression left, DSLExpression right); |
Ethan Nicholas | db2326b | 2021-04-19 10:55:18 -0400 | [diff] [blame] | 192 | DSLPossibleExpression operator,(DSLPossibleExpression left, DSLExpression right); |
| 193 | DSLPossibleExpression operator,(DSLExpression left, DSLPossibleExpression right); |
| 194 | DSLPossibleExpression operator,(DSLPossibleExpression left, DSLPossibleExpression right); |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 195 | DSLPossibleExpression operator==(DSLExpression left, DSLExpression right); |
| 196 | DSLPossibleExpression operator!=(DSLExpression left, DSLExpression right); |
| 197 | DSLPossibleExpression operator>(DSLExpression left, DSLExpression right); |
| 198 | DSLPossibleExpression operator<(DSLExpression left, DSLExpression right); |
| 199 | DSLPossibleExpression operator>=(DSLExpression left, DSLExpression right); |
| 200 | DSLPossibleExpression operator<=(DSLExpression left, DSLExpression right); |
| 201 | DSLPossibleExpression operator!(DSLExpression expr); |
| 202 | DSLPossibleExpression operator~(DSLExpression expr); |
| 203 | DSLPossibleExpression operator++(DSLExpression expr); |
| 204 | DSLPossibleExpression operator++(DSLExpression expr, int); |
| 205 | DSLPossibleExpression operator--(DSLExpression expr); |
| 206 | DSLPossibleExpression operator--(DSLExpression expr, int); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 207 | |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 208 | /** |
| 209 | * Represents an Expression which may have failed and/or have pending errors to report. Converting a |
| 210 | * PossibleExpression into an Expression requires PositionInfo so that any pending errors can be |
| 211 | * reported at the correct position. |
| 212 | * |
| 213 | * PossibleExpression is used instead of Expression in situations where it is not possible to |
| 214 | * capture the PositionInfo at the time of Expression construction (notably in operator overloads, |
| 215 | * where we cannot add default parameters). |
| 216 | */ |
| 217 | class DSLPossibleExpression { |
| 218 | public: |
| 219 | DSLPossibleExpression(std::unique_ptr<SkSL::Expression> expression); |
| 220 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 221 | DSLPossibleExpression(DSLPossibleExpression&& other); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 222 | |
| 223 | ~DSLPossibleExpression(); |
| 224 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 225 | bool valid() const { |
| 226 | return fExpression != nullptr; |
| 227 | } |
| 228 | |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 229 | /** |
| 230 | * Reports any pending errors at the specified position. |
| 231 | */ |
| 232 | void reportErrors(PositionInfo pos); |
| 233 | |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 234 | DSLType type(); |
| 235 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 236 | DSLExpression x(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 237 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 238 | DSLExpression y(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 239 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 240 | DSLExpression z(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 241 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 242 | DSLExpression w(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 243 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 244 | DSLExpression r(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 245 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 246 | DSLExpression g(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 247 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 248 | DSLExpression b(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 249 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 250 | DSLExpression a(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 251 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 252 | DSLExpression field(skstd::string_view name, PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 253 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 254 | DSLPossibleExpression operator=(DSLExpression expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 255 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 256 | DSLPossibleExpression operator=(int expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 257 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 258 | DSLPossibleExpression operator=(float expr); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 259 | |
Ethan Nicholas | a60cc3e | 2021-04-23 16:15:11 -0400 | [diff] [blame] | 260 | DSLPossibleExpression operator=(double expr); |
| 261 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 262 | DSLPossibleExpression operator[](DSLExpression index); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 263 | |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 264 | DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args, |
| 265 | PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 266 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 267 | DSLPossibleExpression operator++(); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 268 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 269 | DSLPossibleExpression operator++(int); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 270 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 271 | DSLPossibleExpression operator--(); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 272 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 273 | DSLPossibleExpression operator--(int); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 274 | |
Ethan Nicholas | a2fd01c | 2021-08-12 11:41:59 -0400 | [diff] [blame] | 275 | std::unique_ptr<SkSL::Expression> release(PositionInfo pos = PositionInfo::Capture()); |
Ethan Nicholas | b956304 | 2021-02-25 09:45:49 -0500 | [diff] [blame] | 276 | |
| 277 | private: |
| 278 | std::unique_ptr<SkSL::Expression> fExpression; |
| 279 | |
| 280 | friend class DSLExpression; |
| 281 | }; |
| 282 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 283 | } // namespace dsl |
| 284 | |
| 285 | } // namespace SkSL |
| 286 | |
| 287 | #endif |