Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkSL::SwitchCase Class Referencefinal

#include <SkSLSwitchCase.h>

Inheritance diagram for SkSL::SwitchCase:
SkSL::Statement SkSL::IRNode SkSL::Poolable

Public Member Functions

bool isDefault () const
 
SKSL_INT value () const
 
std::unique_ptr< Statement > & statement ()
 
const std::unique_ptr< Statement > & statement () const
 
std::string description () const override
 
- Public Member Functions inherited from SkSL::Statement
 Statement (Position pos, Kind kind)
 
Kind kind () const
 
virtual bool isEmpty () const
 
- 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 ()
 

Static Public Member Functions

static std::unique_ptr< SwitchCaseMake (Position pos, SKSL_INT value, std::unique_ptr< Statement > statement)
 
static std::unique_ptr< SwitchCaseMakeDefault (Position pos, std::unique_ptr< Statement > statement)
 
- Static Public Member Functions inherited from SkSL::Poolable
static void * operator new (const size_t size)
 
static void operator delete (void *ptr)
 

Static Public Attributes

static constexpr Kind kIRNodeKind = Kind::kSwitchCase
 

Additional Inherited Members

- Public Types inherited from SkSL::Statement
using Kind = StatementKind
 
- 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

A single case of a 'switch' statement.

Definition at line 26 of file SkSLSwitchCase.h.

Member Function Documentation

◆ description()

std::string SkSL::SwitchCase::description ( ) const
overridevirtual

Implements SkSL::IRNode.

Definition at line 25 of file SkSLSwitchCase.cpp.

25 {
26 return fDefault ? "default: \n" + fStatement->description()
27 : "case " + std::to_string(fValue) + ": \n" + fStatement->description();
28}
static SkString to_string(int n)
Definition: nanobench.cpp:119

◆ isDefault()

bool SkSL::SwitchCase::isDefault ( ) const
inline

Definition at line 37 of file SkSLSwitchCase.h.

37 {
38 return fDefault;
39 }

◆ Make()

std::unique_ptr< SwitchCase > SkSL::SwitchCase::Make ( Position  pos,
SKSL_INT  value,
std::unique_ptr< Statement statement 
)
static

Definition at line 12 of file SkSLSwitchCase.cpp.

14 {
15 return std::unique_ptr<SwitchCase>(new SwitchCase(pos, /*isDefault=*/false, value,
16 std::move(statement)));
17}
SkPoint pos
SKSL_INT value() const
std::unique_ptr< Statement > & statement()

◆ MakeDefault()

std::unique_ptr< SwitchCase > SkSL::SwitchCase::MakeDefault ( Position  pos,
std::unique_ptr< Statement statement 
)
static

Definition at line 19 of file SkSLSwitchCase.cpp.

20 {
21 return std::unique_ptr<SwitchCase>(new SwitchCase(pos, /*isDefault=*/true, /*value=*/-1,
22 std::move(statement)));
23}

◆ statement() [1/2]

std::unique_ptr< Statement > & SkSL::SwitchCase::statement ( )
inline

Definition at line 46 of file SkSLSwitchCase.h.

46 {
47 return fStatement;
48 }

◆ statement() [2/2]

const std::unique_ptr< Statement > & SkSL::SwitchCase::statement ( ) const
inline

Definition at line 50 of file SkSLSwitchCase.h.

50 {
51 return fStatement;
52 }

◆ value()

SKSL_INT SkSL::SwitchCase::value ( ) const
inline

Definition at line 41 of file SkSLSwitchCase.h.

41 {
42 SkASSERT(!this->isDefault());
43 return fValue;
44 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool isDefault() const

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::SwitchCase::kIRNodeKind = Kind::kSwitchCase
inlinestaticconstexpr

Definition at line 28 of file SkSLSwitchCase.h.


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