Flutter Engine
The Flutter Engine
SkSLStructDefinition.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 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
16
17#include <utility>
18
19using namespace skia_private;
20
21namespace SkSL {
22
23std::unique_ptr<StructDefinition> StructDefinition::Convert(const Context& context,
25 std::string_view name,
26 TArray<Field> fields) {
27 std::unique_ptr<Type> ownedType = Type::MakeStructType(context, pos, name,
28 std::move(fields),
29 /*interfaceBlock=*/false);
30 const SkSL::Type* type = context.fSymbolTable->add(context, std::move(ownedType));
32}
33
34std::unique_ptr<StructDefinition> StructDefinition::Make(Position pos, const Type& type) {
35 return std::make_unique<SkSL::StructDefinition>(pos, type);
36}
37
38std::string StructDefinition::description() const {
39 std::string s = "struct ";
40 s += this->type().name();
41 s += " { ";
42 for (const auto& f : this->type().fields()) {
43 s += f.fLayout.description();
44 s += f.fModifierFlags.description();
45 s += ' ';
46 s += f.fType->description();
47 s += ' ';
48 s += f.fName;
49 s += "; ";
50 }
51 s += "};";
52 return s;
53}
54
55} // namespace SkSL
SkPoint pos
GLenum type
SymbolTable * fSymbolTable
Definition: SkSLContext.h:48
static std::unique_ptr< StructDefinition > Make(Position pos, const Type &type)
std::string description() const override
static std::unique_ptr< StructDefinition > Convert(const Context &context, Position pos, std::string_view name, skia_private::TArray< Field > fields)
const Type & type() const
T * add(const Context &context, std::unique_ptr< T > symbol)
std::string_view name() const
Definition: SkSLSymbol.h:51
static std::unique_ptr< Type > MakeStructType(const Context &context, Position pos, std::string_view name, skia_private::TArray< Field > fields, bool interfaceBlock=false)
struct MyStruct s
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32