Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLTypeReference.cpp
Go to the documentation of this file.
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
9
13
14namespace SkSL {
15
17 if (!context.fConfig->fIsBuiltinCode && type) {
18 if (type->isGeneric() || type->isLiteral()) {
19 context.fErrors->error(pos, "type '" + std::string(type->name()) + "' is generic");
20 return false;
21 }
22 if (!type->isAllowedInES2(context)) {
23 context.fErrors->error(pos, "type '" + std::string(type->name()) +"' is not supported");
24 return false;
25 }
26 }
27 return true;
28}
29
30std::unique_ptr<TypeReference> TypeReference::Convert(const Context& context,
32 const Type* type) {
33 return VerifyType(context, type, pos) ? TypeReference::Make(context, pos, type)
34 : nullptr;
35}
36
37std::unique_ptr<TypeReference> TypeReference::Make(const Context& context,
39 const Type* type) {
40 SkASSERT(type->isAllowedInES2(context));
41 return std::make_unique<TypeReference>(context, pos, type);
42}
43
44} // namespace SkSL
SkPoint pos
#define SkASSERT(cond)
Definition SkAssert.h:116
ErrorReporter * fErrors
Definition SkSLContext.h:36
ProgramConfig * fConfig
Definition SkSLContext.h:33
void error(Position position, std::string_view msg)
virtual const Type & type() const
std::string_view name() const
Definition SkSLSymbol.h:51
static bool VerifyType(const Context &context, const SkSL::Type *type, Position pos)
static std::unique_ptr< TypeReference > Convert(const Context &context, Position pos, const Type *type)
static std::unique_ptr< TypeReference > Make(const Context &context, Position pos, const Type *type)
bool isAllowedInES2(const Context &context) const
bool isGeneric() const
Definition SkSLType.h:500
virtual bool isLiteral() const
Definition SkSLType.h:516