#include "src/sksl/SkSLInliner.h"
#ifndef SK_ENABLE_OPTIMIZE_SIZE
#include "include/core/SkSpan.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkTArray.h"
#include "src/base/SkEnumBitMask.h"
#include "src/sksl/SkSLAnalysis.h"
#include "src/sksl/SkSLDefines.h"
#include "src/sksl/SkSLErrorReporter.h"
#include "src/sksl/SkSLOperator.h"
#include "src/sksl/SkSLPosition.h"
#include "src/sksl/analysis/SkSLProgramUsage.h"
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLChildCall.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
#include "src/sksl/ir/SkSLConstructorArrayCast.h"
#include "src/sksl/ir/SkSLConstructorCompound.h"
#include "src/sksl/ir/SkSLConstructorCompoundCast.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
#include "src/sksl/ir/SkSLConstructorStruct.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"
#include "src/sksl/ir/SkSLDoStatement.h"
#include "src/sksl/ir/SkSLEmptyExpression.h"
#include "src/sksl/ir/SkSLExpressionStatement.h"
#include "src/sksl/ir/SkSLFieldAccess.h"
#include "src/sksl/ir/SkSLForStatement.h"
#include "src/sksl/ir/SkSLFunctionCall.h"
#include "src/sksl/ir/SkSLFunctionDeclaration.h"
#include "src/sksl/ir/SkSLFunctionDefinition.h"
#include "src/sksl/ir/SkSLIRNode.h"
#include "src/sksl/ir/SkSLIfStatement.h"
#include "src/sksl/ir/SkSLIndexExpression.h"
#include "src/sksl/ir/SkSLModifierFlags.h"
#include "src/sksl/ir/SkSLNop.h"
#include "src/sksl/ir/SkSLPostfixExpression.h"
#include "src/sksl/ir/SkSLPrefixExpression.h"
#include "src/sksl/ir/SkSLProgramElement.h"
#include "src/sksl/ir/SkSLReturnStatement.h"
#include "src/sksl/ir/SkSLSetting.h"
#include "src/sksl/ir/SkSLStatement.h"
#include "src/sksl/ir/SkSLSwitchCase.h"
#include "src/sksl/ir/SkSLSwitchStatement.h"
#include "src/sksl/ir/SkSLSwizzle.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/ir/SkSLTernaryExpression.h"
#include "src/sksl/ir/SkSLType.h"
#include "src/sksl/ir/SkSLVarDeclarations.h"
#include "src/sksl/ir/SkSLVariable.h"
#include "src/sksl/ir/SkSLVariableReference.h"
#include "src/sksl/transform/SkSLTransform.h"
#include <algorithm>
#include <climits>
#include <cstddef>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
usingnamespaceskia_private;
namespace SkSL {
namespace {
static constexpr int kInlinedStatementLimit = …;
static bool is_scopeless_block(Statement* stmt) { … }
static std::unique_ptr<Statement>* find_parent_statement(
const std::vector<std::unique_ptr<Statement>*>& stmtStack) { … }
std::unique_ptr<Expression> clone_with_ref_kind(const Expression& expr,
VariableReference::RefKind refKind,
Position pos) { … }
}
const Variable* Inliner::RemapVariable(const Variable* variable,
const VariableRewriteMap* varMap) { … }
void Inliner::ensureScopedBlocks(Statement* inlinedBody, Statement* parentStmt) { … }
std::unique_ptr<Expression> Inliner::inlineExpression(Position pos,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForExpression,
const Expression& expression) { … }
std::unique_ptr<Statement> Inliner::inlineStatement(Position pos,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForStatement,
std::unique_ptr<Expression>* resultExpr,
Analysis::ReturnComplexity returnComplexity,
const Statement& statement,
const ProgramUsage& usage,
bool isBuiltinCode) { … }
static bool argument_needs_scratch_variable(const Expression* arg,
const Variable* param,
const ProgramUsage& usage) { … }
Inliner::InlinedCall Inliner::inlineCall(const FunctionCall& call,
SymbolTable* symbolTable,
const ProgramUsage& usage,
const FunctionDeclaration* caller) { … }
bool Inliner::isSafeToInline(const FunctionDefinition* functionDef, const ProgramUsage& usage) { … }
struct InlineCandidate { … };
struct InlineCandidateList { … };
class InlineCandidateAnalyzer { … };
static const FunctionDeclaration& candidate_func(const InlineCandidate& candidate) { … }
bool Inliner::functionCanBeInlined(const FunctionDeclaration& funcDecl,
const ProgramUsage& usage,
InlinabilityCache* cache) { … }
bool Inliner::candidateCanBeInlined(const InlineCandidate& candidate,
const ProgramUsage& usage,
InlinabilityCache* cache) { … }
int Inliner::getFunctionSize(const FunctionDeclaration& funcDecl, FunctionSizeCache* cache) { … }
void Inliner::buildCandidateList(const std::vector<std::unique_ptr<ProgramElement>>& elements,
SymbolTable* symbols,
ProgramUsage* usage,
InlineCandidateList* candidateList) { … }
bool Inliner::analyze(const std::vector<std::unique_ptr<ProgramElement>>& elements,
SymbolTable* symbols,
ProgramUsage* usage) { … }
}
#endif