| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SKSL_CONTEXT | 8 #ifndef SKSL_CONTEXT |
| 9 #define SKSL_CONTEXT | 9 #define SKSL_CONTEXT |
| 10 | 10 |
| 11 #include "ir/SkSLType.h" | 11 #include "ir/SkSLType.h" |
| 12 #include "ir/SkSLExpression.h" |
| 12 | 13 |
| 13 namespace SkSL { | 14 namespace SkSL { |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * Contains compiler-wide objects, which currently means the core types. | 17 * Contains compiler-wide objects, which currently means the core types. |
| 17 */ | 18 */ |
| 18 class Context { | 19 class Context { |
| 19 public: | 20 public: |
| 20 Context() | 21 Context() |
| 21 : fVoid_Type(new Type("void")) | 22 : fVoid_Type(new Type("void")) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 fVec4_Type.get() })) | 108 fVec4_Type.get() })) |
| 108 , fGVec_Type(new Type("$gvec")) | 109 , fGVec_Type(new Type("$gvec")) |
| 109 , fGVec2_Type(new Type("$gvec2")) | 110 , fGVec2_Type(new Type("$gvec2")) |
| 110 , fGVec3_Type(new Type("$gvec3")) | 111 , fGVec3_Type(new Type("$gvec3")) |
| 111 , fGVec4_Type(new Type("$gvec4", static_type(*fVec4_Type))) | 112 , fGVec4_Type(new Type("$gvec4", static_type(*fVec4_Type))) |
| 112 , fDVec_Type(new Type("$dvec")) | 113 , fDVec_Type(new Type("$dvec")) |
| 113 , fIVec_Type(new Type("$ivec")) | 114 , fIVec_Type(new Type("$ivec")) |
| 114 , fUVec_Type(new Type("$uvec")) | 115 , fUVec_Type(new Type("$uvec")) |
| 115 , fBVec_Type(new Type("$bvec", { fBVec2_Type.get(), fBVec2_Type.get(), fBVec
3_Type.get(), | 116 , fBVec_Type(new Type("$bvec", { fBVec2_Type.get(), fBVec2_Type.get(), fBVec
3_Type.get(), |
| 116 fBVec4_Type.get() })) | 117 fBVec4_Type.get() })) |
| 117 , fInvalid_Type(new Type("<INVALID>")) {} | 118 , fInvalid_Type(new Type("<INVALID>")) |
| 119 , fDefined_Expression(new Defined(*fInvalid_Type)) {} |
| 118 | 120 |
| 119 static std::vector<const Type*> static_type(const Type& t) { | 121 static std::vector<const Type*> static_type(const Type& t) { |
| 120 return { &t, &t, &t, &t }; | 122 return { &t, &t, &t, &t }; |
| 121 } | 123 } |
| 122 | 124 |
| 123 const std::unique_ptr<Type> fVoid_Type; | 125 const std::unique_ptr<Type> fVoid_Type; |
| 124 | 126 |
| 125 const std::unique_ptr<Type> fDouble_Type; | 127 const std::unique_ptr<Type> fDouble_Type; |
| 126 const std::unique_ptr<Type> fDVec2_Type; | 128 const std::unique_ptr<Type> fDVec2_Type; |
| 127 const std::unique_ptr<Type> fDVec3_Type; | 129 const std::unique_ptr<Type> fDVec3_Type; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 const std::unique_ptr<Type> fGVec2_Type; | 217 const std::unique_ptr<Type> fGVec2_Type; |
| 216 const std::unique_ptr<Type> fGVec3_Type; | 218 const std::unique_ptr<Type> fGVec3_Type; |
| 217 const std::unique_ptr<Type> fGVec4_Type; | 219 const std::unique_ptr<Type> fGVec4_Type; |
| 218 const std::unique_ptr<Type> fDVec_Type; | 220 const std::unique_ptr<Type> fDVec_Type; |
| 219 const std::unique_ptr<Type> fIVec_Type; | 221 const std::unique_ptr<Type> fIVec_Type; |
| 220 const std::unique_ptr<Type> fUVec_Type; | 222 const std::unique_ptr<Type> fUVec_Type; |
| 221 | 223 |
| 222 const std::unique_ptr<Type> fBVec_Type; | 224 const std::unique_ptr<Type> fBVec_Type; |
| 223 | 225 |
| 224 const std::unique_ptr<Type> fInvalid_Type; | 226 const std::unique_ptr<Type> fInvalid_Type; |
| 227 |
| 228 // dummy expression used to mark that a variable has a value during dataflow
analysis (when it |
| 229 // could have several different values, or the analyzer is otherwise unable
to assign it a |
| 230 // specific expression) |
| 231 const std::unique_ptr<Expression> fDefined_Expression; |
| 232 |
| 233 private: |
| 234 class Defined : public Expression { |
| 235 public: |
| 236 Defined(const Type& type) |
| 237 : INHERITED(Position(), kDefined_Kind, type) {} |
| 238 |
| 239 virtual std::string description() const override { |
| 240 return "<defined>"; |
| 241 } |
| 242 |
| 243 typedef Expression INHERITED; |
| 244 }; |
| 225 }; | 245 }; |
| 226 | 246 |
| 227 } // namespace | 247 } // namespace |
| 228 | 248 |
| 229 #endif | 249 #endif |
| OLD | NEW |