#include "src/sksl/SkSLParser.h"
#include "include/core/SkSpan.h"
#include "include/private/base/SkTArray.h"
#include "include/sksl/SkSLVersion.h"
#include "src/base/SkEnumBitMask.h"
#include "src/base/SkNoDestructor.h"
#include "src/core/SkTHash.h"
#include "src/sksl/SkSLBuiltinTypes.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLConstantFolder.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/SkSLErrorReporter.h"
#include "src/sksl/SkSLModule.h"
#include "src/sksl/SkSLOperator.h"
#include "src/sksl/SkSLString.h"
#include "src/sksl/ir/SkSLBinaryExpression.h"
#include "src/sksl/ir/SkSLBlock.h"
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"
#include "src/sksl/ir/SkSLDoStatement.h"
#include "src/sksl/ir/SkSLExpression.h"
#include "src/sksl/ir/SkSLExpressionStatement.h"
#include "src/sksl/ir/SkSLExtension.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/SkSLFunctionPrototype.h"
#include "src/sksl/ir/SkSLIfStatement.h"
#include "src/sksl/ir/SkSLIndexExpression.h"
#include "src/sksl/ir/SkSLInterfaceBlock.h"
#include "src/sksl/ir/SkSLLayout.h"
#include "src/sksl/ir/SkSLLiteral.h"
#include "src/sksl/ir/SkSLModifierFlags.h"
#include "src/sksl/ir/SkSLModifiersDeclaration.h"
#include "src/sksl/ir/SkSLNop.h"
#include "src/sksl/ir/SkSLPoison.h"
#include "src/sksl/ir/SkSLPostfixExpression.h"
#include "src/sksl/ir/SkSLPrefixExpression.h"
#include "src/sksl/ir/SkSLProgram.h"
#include "src/sksl/ir/SkSLProgramElement.h"
#include "src/sksl/ir/SkSLReturnStatement.h"
#include "src/sksl/ir/SkSLStatement.h"
#include "src/sksl/ir/SkSLStructDefinition.h"
#include "src/sksl/ir/SkSLSwitchStatement.h"
#include "src/sksl/ir/SkSLSwizzle.h"
#include "src/sksl/ir/SkSLSymbol.h"
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/ir/SkSLTernaryExpression.h"
#include "src/sksl/ir/SkSLType.h"
#include "src/sksl/ir/SkSLTypeReference.h"
#include "src/sksl/ir/SkSLVarDeclarations.h"
#include "src/sksl/ir/SkSLVariable.h"
#include <algorithm>
#include <climits>
#include <initializer_list>
#include <memory>
#include <utility>
#include <vector>
usingnamespaceskia_private;
namespace SkSL {
static constexpr int kMaxParseDepth = …;
static ModifierFlags parse_modifier_token(Token::Kind token) { … }
class Parser::AutoDepth { … };
class Parser::AutoSymbolTable { … };
class Parser::Checkpoint { … };
Parser::Parser(Compiler* compiler,
const ProgramSettings& settings,
ProgramKind kind,
std::unique_ptr<std::string> text)
: … { … }
Parser::~Parser() = default;
SymbolTable* Parser::symbolTable() { … }
Token Parser::nextRawToken() { … }
static bool is_whitespace(Token::Kind kind) { … }
bool Parser::expectNewline() { … }
Token Parser::nextToken() { … }
void Parser::pushback(Token t) { … }
Token Parser::peek() { … }
bool Parser::checkNext(Token::Kind kind, Token* result) { … }
bool Parser::expect(Token::Kind kind, const char* expected, Token* result) { … }
bool Parser::expectIdentifier(Token* result) { … }
bool Parser::checkIdentifier(Token* result) { … }
std::string_view Parser::text(Token token) { … }
Position Parser::position(Token t) { … }
void Parser::error(Token token, std::string_view msg) { … }
void Parser::error(Position position, std::string_view msg) { … }
Position Parser::rangeFrom(Position start) { … }
Position Parser::rangeFrom(Token start) { … }
std::unique_ptr<Program> Parser::programInheritingFrom(const SkSL::Module* module) { … }
std::unique_ptr<SkSL::Module> Parser::moduleInheritingFrom(const SkSL::Module* parentModule) { … }
void Parser::declarations() { … }
void Parser::extensionDirective(Position start) { … }
void Parser::versionDirective(Position start, bool allowVersion) { … }
void Parser::directive(bool allowVersion) { … }
bool Parser::modifiersDeclarationEnd(const SkSL::Modifiers& mods) { … }
bool Parser::declaration() { … }
bool Parser::functionDeclarationEnd(Position start,
Modifiers& modifiers,
const Type* returnType,
const Token& name) { … }
bool Parser::prototypeFunction(SkSL::FunctionDeclaration* decl) { … }
bool Parser::defineFunction(SkSL::FunctionDeclaration* decl) { … }
bool Parser::arraySize(SKSL_INT* outResult) { … }
const Type* Parser::arrayType(const Type* base, int count, Position pos) { … }
const Type* Parser::unsizedArrayType(const Type* base, Position pos) { … }
bool Parser::parseArrayDimensions(Position pos, const Type** type) { … }
bool Parser::parseInitializer(Position pos, std::unique_ptr<Expression>* initializer) { … }
void Parser::addGlobalVarDeclaration(std::unique_ptr<VarDeclaration> decl) { … }
void Parser::globalVarDeclarationEnd(Position pos,
const Modifiers& mods,
const Type* baseType,
Token name) { … }
std::unique_ptr<Statement> Parser::localVarDeclarationEnd(Position pos,
const Modifiers& mods,
const Type* baseType,
Token name) { … }
std::unique_ptr<Statement> Parser::varDeclarationsOrExpressionStatement() { … }
bool Parser::varDeclarationsPrefix(VarDeclarationsPrefix* prefixData) { … }
std::unique_ptr<Statement> Parser::varDeclarations() { … }
const Type* Parser::structDeclaration() { … }
void Parser::structVarDeclaration(Position start, const Modifiers& modifiers) { … }
bool Parser::parameter(std::unique_ptr<SkSL::Variable>* outParam) { … }
int Parser::layoutInt() { … }
std::string_view Parser::layoutIdentifier() { … }
SkSL::Layout Parser::layout() { … }
Modifiers Parser::modifiers() { … }
std::unique_ptr<Statement> Parser::statementOrNop(Position pos, std::unique_ptr<Statement> stmt) { … }
std::unique_ptr<Statement> Parser::statement(bool bracesIntroduceNewScope) { … }
const Type* Parser::findType(Position pos,
Modifiers* modifiers,
std::string_view name) { … }
const Type* Parser::type(Modifiers* modifiers) { … }
bool Parser::interfaceBlock(const Modifiers& modifiers) { … }
std::unique_ptr<Statement> Parser::ifStatement() { … }
std::unique_ptr<Statement> Parser::doStatement() { … }
std::unique_ptr<Statement> Parser::whileStatement() { … }
bool Parser::switchCaseBody(ExpressionArray* values,
StatementArray* caseBlocks,
std::unique_ptr<Expression> caseValue) { … }
bool Parser::switchCase(ExpressionArray* values, StatementArray* caseBlocks) { … }
std::unique_ptr<Statement> Parser::switchStatement() { … }
static Position range_of_at_least_one_char(int start, int end) { … }
std::unique_ptr<Statement> Parser::forStatement() { … }
std::unique_ptr<Statement> Parser::returnStatement() { … }
std::unique_ptr<Statement> Parser::breakStatement() { … }
std::unique_ptr<Statement> Parser::continueStatement() { … }
std::unique_ptr<Statement> Parser::discardStatement() { … }
std::unique_ptr<Statement> Parser::block(bool introduceNewScope,
std::unique_ptr<SymbolTable>* adoptExistingSymbolTable) { … }
std::unique_ptr<Statement> Parser::expressionStatement() { … }
std::unique_ptr<Expression> Parser::poison(Position pos) { … }
std::unique_ptr<Expression> Parser::expressionOrPoison(Position pos,
std::unique_ptr<Expression> expr) { … }
bool Parser::operatorRight(Parser::AutoDepth& depth,
Operator::Kind op,
BinaryParseFn rightFn,
std::unique_ptr<Expression>& expr) { … }
std::unique_ptr<Expression> Parser::expression() { … }
std::unique_ptr<Expression> Parser::assignmentExpression() { … }
std::unique_ptr<Expression> Parser::ternaryExpression() { … }
std::unique_ptr<Expression> Parser::logicalOrExpression() { … }
std::unique_ptr<Expression> Parser::logicalXorExpression() { … }
std::unique_ptr<Expression> Parser::logicalAndExpression() { … }
std::unique_ptr<Expression> Parser::bitwiseOrExpression() { … }
std::unique_ptr<Expression> Parser::bitwiseXorExpression() { … }
std::unique_ptr<Expression> Parser::bitwiseAndExpression() { … }
std::unique_ptr<Expression> Parser::equalityExpression() { … }
std::unique_ptr<Expression> Parser::relationalExpression() { … }
std::unique_ptr<Expression> Parser::shiftExpression() { … }
std::unique_ptr<Expression> Parser::additiveExpression() { … }
std::unique_ptr<Expression> Parser::multiplicativeExpression() { … }
std::unique_ptr<Expression> Parser::unaryExpression() { … }
std::unique_ptr<Expression> Parser::postfixExpression() { … }
std::unique_ptr<Expression> Parser::swizzle(Position pos,
std::unique_ptr<Expression> base,
std::string_view swizzleMask,
Position maskPos) { … }
std::unique_ptr<Expression> Parser::call(Position pos,
std::unique_ptr<Expression> base,
ExpressionArray args) { … }
std::unique_ptr<Expression> Parser::suffix(std::unique_ptr<Expression> base) { … }
std::unique_ptr<Expression> Parser::term() { … }
bool Parser::intLiteral(SKSL_INT* dest) { … }
bool Parser::floatLiteral(SKSL_FLOAT* dest) { … }
bool Parser::boolLiteral(bool* dest) { … }
bool Parser::identifier(std::string_view* dest) { … }
}