Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
SkSL::Parser Class Reference

#include <SkSLParser.h>

Classes

class  AutoDepth
 
class  AutoSymbolTable
 
class  Checkpoint
 

Public Member Functions

 Parser (Compiler *compiler, const ProgramSettings &settings, ProgramKind kind, std::unique_ptr< std::string > text)
 
 ~Parser ()
 
std::unique_ptr< ProgramprogramInheritingFrom (const Module *module)
 
std::unique_ptr< ModulemoduleInheritingFrom (const Module *parentModule)
 
std::string_view text (Token token)
 
Position position (Token token)
 

Detailed Description

Consumes .sksl text and converts it into an IR tree, encapsulated in a Program.

Definition at line 45 of file SkSLParser.h.

Constructor & Destructor Documentation

◆ Parser()

SkSL::Parser::Parser ( Compiler compiler,
const ProgramSettings settings,
ProgramKind  kind,
std::unique_ptr< std::string >  text 
)

Definition at line 218 of file SkSLParser.cpp.

222 : fCompiler(*compiler)
223 , fSettings(settings)
224 , fKind(kind)
225 , fText(std::move(text))
226 , fPushback(Token::Kind::TK_NONE, /*offset=*/-1, /*length=*/-1) {
227 fLexer.start(*fText);
228}
void start(std::string_view text)
Definition: SkSLLexer.h:125
std::string_view text(Token token)
Definition: SkSLParser.cpp:376

◆ ~Parser()

SkSL::Parser::~Parser ( )
default

Member Function Documentation

◆ moduleInheritingFrom()

std::unique_ptr< SkSL::Module > SkSL::Parser::moduleInheritingFrom ( const Module parentModule)

Definition at line 418 of file SkSLParser.cpp.

418 {
419 this->declarations();
420 this->symbolTable()->takeOwnershipOfString(std::move(*fText));
421 auto result = std::make_unique<SkSL::Module>();
422 result->fParent = parentModule;
423 result->fSymbols = std::move(fCompiler.fGlobalSymbols);
424 result->fElements = std::move(fProgramElements);
425 return result;
426}
const std::string * takeOwnershipOfString(std::string n)
GAsyncResult * result

◆ position()

Position SkSL::Parser::position ( Token  token)

Definition at line 380 of file SkSLParser.cpp.

380 {
381 if (t.fOffset >= 0) {
382 return Position::Range(t.fOffset, t.fOffset + t.fLength);
383 } else {
384 return Position();
385 }
386}
static Position Range(int startOffset, int endOffset)
Definition: SkSLPosition.h:24

◆ programInheritingFrom()

std::unique_ptr< Program > SkSL::Parser::programInheritingFrom ( const Module module)

Definition at line 407 of file SkSLParser.cpp.

407 {
408 this->declarations();
409 std::unique_ptr<Program> result;
410 if (fCompiler.errorReporter().errorCount() == 0) {
411 result = fCompiler.releaseProgram(std::move(fText), std::move(fProgramElements));
412 } else {
413 fProgramElements.clear();
414 }
415 return result;
416}
ErrorReporter & errorReporter()
Definition: SkSLCompiler.h:132

◆ text()

std::string_view SkSL::Parser::text ( Token  token)

Definition at line 376 of file SkSLParser.cpp.

376 {
377 return std::string_view(fText->data() + token.fOffset, token.fLength);
378}

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