• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 #include "src/sksl/ir/SkSLTypeReference.h"
9 
10 #include "include/core/SkTypes.h"
11 #include "include/sksl/SkSLErrorReporter.h"
12 
13 namespace SkSL {
14 
Convert(const Context & context,Position pos,const Type * type)15 std::unique_ptr<TypeReference> TypeReference::Convert(const Context& context,
16                                                       Position pos,
17                                                       const Type* type) {
18     if (!type->isAllowedInES2(context)) {
19         context.fErrors->error(pos, "type '" + type->displayName() + "' is not supported");
20         return nullptr;
21     }
22     return TypeReference::Make(context, pos, type);
23 }
24 
Make(const Context & context,Position pos,const Type * type)25 std::unique_ptr<TypeReference> TypeReference::Make(const Context& context,
26                                                    Position pos,
27                                                    const Type* type) {
28     SkASSERT(type->isAllowedInES2(context));
29     return std::make_unique<TypeReference>(context, pos, type);
30 }
31 
32 } // namespace SkSL
33