Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | List of all members
SkSL::CountReturnsWithLimit Class Reference
Inheritance diagram for SkSL::CountReturnsWithLimit:
SkSL::ProgramVisitor SkSL::TProgramVisitor< ProgramVisitorTypes >

Public Types

using INHERITED = ProgramVisitor
 

Public Member Functions

 CountReturnsWithLimit (const FunctionDefinition &funcDef, int limit)
 
bool visitExpression (const Expression &expr) override
 
bool visitStatement (const Statement &stmt) override
 
- Public Member Functions inherited from SkSL::ProgramVisitor
bool visit (const Program &program)
 
- Public Member Functions inherited from SkSL::TProgramVisitor< ProgramVisitorTypes >
virtual ~TProgramVisitor ()=default
 

Public Attributes

int fNumReturns = 0
 
int fDeepestReturn = 0
 
int fLimit = 0
 
int fScopedBlockDepth = 0
 
bool fVariablesInBlocks = false
 

Additional Inherited Members

- Protected Member Functions inherited from SkSL::TProgramVisitor< ProgramVisitorTypes >
virtual bool visitExpression (typename T::Expression &expression)
 
virtual bool visitStatement (typename T::Statement &statement)
 
virtual bool visitProgramElement (typename T::ProgramElement &programElement)
 
virtual bool visitExpressionPtr (typename T::UniquePtrExpression &expr)=0
 
virtual bool visitStatementPtr (typename T::UniquePtrStatement &stmt)=0
 

Detailed Description

Definition at line 65 of file SkSLGetReturnComplexity.cpp.

Member Typedef Documentation

◆ INHERITED

Definition at line 113 of file SkSLGetReturnComplexity.cpp.

Constructor & Destructor Documentation

◆ CountReturnsWithLimit()

SkSL::CountReturnsWithLimit::CountReturnsWithLimit ( const FunctionDefinition funcDef,
int  limit 
)
inline

Definition at line 67 of file SkSLGetReturnComplexity.cpp.

67 : fLimit(limit) {
68 this->visitProgramElement(funcDef);
69 }
virtual bool visitProgramElement(typename T::ProgramElement &programElement)

Member Function Documentation

◆ visitExpression()

bool SkSL::CountReturnsWithLimit::visitExpression ( const Expression expr)
inlineoverride

Definition at line 71 of file SkSLGetReturnComplexity.cpp.

71 {
72 // Do not recurse into expressions.
73 return false;
74 }

◆ visitStatement()

bool SkSL::CountReturnsWithLimit::visitStatement ( const Statement stmt)
inlineoverride

Definition at line 76 of file SkSLGetReturnComplexity.cpp.

76 {
77 switch (stmt.kind()) {
78 case Statement::Kind::kReturn: {
81 return (fNumReturns >= fLimit) || INHERITED::visitStatement(stmt);
82 }
83 case Statement::Kind::kVarDeclaration: {
84 if (fScopedBlockDepth > 1) {
85 fVariablesInBlocks = true;
86 }
87 return INHERITED::visitStatement(stmt);
88 }
89 case Statement::Kind::kBlock: {
90 int depthIncrement = stmt.as<Block>().isScope() ? 1 : 0;
91 fScopedBlockDepth += depthIncrement;
93 fScopedBlockDepth -= depthIncrement;
94 if (fNumReturns == 0 && fScopedBlockDepth <= 1) {
95 // If closing this block puts us back at the top level, and we haven't
96 // encountered any return statements yet, any vardecls we may have encountered
97 // up until this point can be ignored. They are out of scope now, and they were
98 // never used in a return statement.
99 fVariablesInBlocks = false;
100 }
101 return result;
102 }
103 default:
104 return INHERITED::visitStatement(stmt);
105 }
106 }
virtual bool visitStatement(typename T::Statement &statement)
GAsyncResult * result
static float max(float r, float g, float b)
Definition: hsl.cpp:49

Member Data Documentation

◆ fDeepestReturn

int SkSL::CountReturnsWithLimit::fDeepestReturn = 0

Definition at line 109 of file SkSLGetReturnComplexity.cpp.

◆ fLimit

int SkSL::CountReturnsWithLimit::fLimit = 0

Definition at line 110 of file SkSLGetReturnComplexity.cpp.

◆ fNumReturns

int SkSL::CountReturnsWithLimit::fNumReturns = 0

Definition at line 108 of file SkSLGetReturnComplexity.cpp.

◆ fScopedBlockDepth

int SkSL::CountReturnsWithLimit::fScopedBlockDepth = 0

Definition at line 111 of file SkSLGetReturnComplexity.cpp.

◆ fVariablesInBlocks

bool SkSL::CountReturnsWithLimit::fVariablesInBlocks = false

Definition at line 112 of file SkSLGetReturnComplexity.cpp.


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