Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
SkSL::Symbol Class Reference

#include <SkSLSymbol.h>

Inheritance diagram for SkSL::Symbol:
SkSL::IRNode SkSL::Poolable SkSL::FieldSymbol SkSL::FunctionDeclaration SkSL::Type SkSL::Variable SkSL::AliasType SkSL::ArrayType SkSL::AtomicType SkSL::GenericType SkSL::LiteralType SkSL::MatrixType SkSL::SamplerType SkSL::ScalarType SkSL::StructType SkSL::TextureType SkSL::VectorType SkSL::ExtendedVariable

Public Types

using Kind = SymbolKind
 

Public Member Functions

 Symbol (Position pos, Kind kind, std::string_view name, const Type *type=nullptr)
 
 ~Symbol () override
 
std::unique_ptr< Expressioninstantiate (const Context &context, Position pos) const
 
const Typetype () const
 
Kind kind () const
 
std::string_view name () const
 
void setName (std::string_view newName)
 
- Public Member Functions inherited from SkSL::IRNode
virtual ~IRNode ()
 
virtual std::string description () const =0
 
 IRNode (const IRNode &)=delete
 
IRNodeoperator= (const IRNode &)=delete
 
Position position () const
 
void setPosition (Position p)
 
template<typename T >
bool is () const
 
template<typename T >
const Tas () const
 
template<typename T >
Tas ()
 

Additional Inherited Members

- Static Public Member Functions inherited from SkSL::Poolable
static void * operator new (const size_t size)
 
static void operator delete (void *ptr)
 
- Public Attributes inherited from SkSL::IRNode
Position fPosition
 
- Protected Member Functions inherited from SkSL::IRNode
 IRNode (Position position, int kind)
 
- Protected Attributes inherited from SkSL::IRNode
int fKind
 

Detailed Description

Represents a symbol table entry.

Definition at line 27 of file SkSLSymbol.h.

Member Typedef Documentation

◆ Kind

Definition at line 29 of file SkSLSymbol.h.

Constructor & Destructor Documentation

◆ Symbol()

SkSL::Symbol::Symbol ( Position  pos,
Kind  kind,
std::string_view  name,
const Type type = nullptr 
)
inline

Definition at line 31 of file SkSLSymbol.h.

32 : INHERITED(pos, (int) kind)
33 , fName(name)
34 , fType(type) {
35 SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
36 }
SkPoint pos
#define SkASSERT(cond)
Definition: SkAssert.h:116
std::string_view name() const
Definition: SkSLSymbol.h:51
Kind kind() const
Definition: SkSLSymbol.h:47
const Type & type() const
Definition: SkSLSymbol.h:42

◆ ~Symbol()

SkSL::Symbol::~Symbol ( )
inlineoverride

Definition at line 38 of file SkSLSymbol.h.

38{}

Member Function Documentation

◆ instantiate()

std::unique_ptr< Expression > SkSL::Symbol::instantiate ( const Context context,
Position  pos 
) const

Definition at line 24 of file SkSLSymbol.cpp.

24 {
25 switch (this->kind()) {
26 case Symbol::Kind::kFunctionDeclaration:
27 return std::make_unique<FunctionReference>(
28 context, pos, &this->as<FunctionDeclaration>());
29
30 case Symbol::Kind::kVariable: {
31 const Variable* var = &this->as<Variable>();
32 // default to kRead_RefKind; this will be corrected later if the variable is written to
34 }
36 const FieldSymbol* field = &this->as<FieldSymbol>();
38 pos, &field->owner(), VariableReference::RefKind::kRead);
39 return FieldAccess::Make(context,
40 pos,
41 std::move(base),
42 field->fieldIndex(),
43 FieldAccess::OwnerKind::kAnonymousInterfaceBlock);
44 }
46 return TypeReference::Convert(context, pos, &this->as<Type>());
47
48 default:
49 SkDEBUGFAILF("unsupported symbol type %d\n", fKind);
50 return nullptr;
51 }
52}
#define SkDEBUGFAILF(fmt,...)
Definition: SkAssert.h:119
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > base, int fieldIndex, OwnerKind ownerKind=OwnerKind::kDefault)
static std::unique_ptr< TypeReference > Convert(const Context &context, Position pos, const Type *type)
static std::unique_ptr< Expression > Make(Position pos, const Variable *variable, RefKind refKind=RefKind::kRead)

◆ kind()

Kind SkSL::Symbol::kind ( ) const
inline

Definition at line 47 of file SkSLSymbol.h.

47 {
48 return (Kind) fKind;
49 }

◆ name()

std::string_view SkSL::Symbol::name ( ) const
inline

Definition at line 51 of file SkSLSymbol.h.

51 {
52 return fName;
53 }

◆ setName()

void SkSL::Symbol::setName ( std::string_view  newName)
inline

Don't call this directly–use SymbolTable::renameSymbol instead!

Definition at line 58 of file SkSLSymbol.h.

58 {
59 fName = newName;
60 }

◆ type()

const Type & SkSL::Symbol::type ( ) const
inline

Definition at line 42 of file SkSLSymbol.h.

42 {
43 SkASSERT(fType);
44 return *fType;
45 }

The documentation for this class was generated from the following files: