Flutter Engine
The Flutter Engine
|
#include <SkSLSymbolTable.h>
Public Member Functions | |
SymbolTable (bool builtin) | |
SymbolTable (SymbolTable *parent, bool builtin) | |
std::unique_ptr< SymbolTable > | insertNewParent () |
const Symbol * | find (std::string_view name) const |
const Symbol * | findBuiltinSymbol (std::string_view name) const |
Symbol * | findMutable (std::string_view name) const |
std::unique_ptr< Expression > | instantiateSymbolRef (const Context &context, std::string_view name, Position pos) |
void | renameSymbol (const Context &context, Symbol *symbol, std::string_view newName) |
std::unique_ptr< Symbol > | removeSymbol (const Symbol *symbol) |
void | moveSymbolTo (SymbolTable *otherTable, Symbol *sym, const Context &context) |
bool | isType (std::string_view name) const |
bool | isBuiltinType (std::string_view name) const |
void | addWithoutOwnershipOrDie (Symbol *symbol) |
void | addWithoutOwnership (const Context &context, Symbol *symbol) |
template<typename T > | |
T * | add (const Context &context, std::unique_ptr< T > symbol) |
template<typename T > | |
T * | addOrDie (std::unique_ptr< T > symbol) |
void | injectWithoutOwnership (Symbol *symbol) |
template<typename T > | |
T * | inject (std::unique_ptr< T > symbol) |
template<typename T > | |
T * | takeOwnershipOfSymbol (std::unique_ptr< T > symbol) |
const Type * | addArrayDimension (const Context &context, const Type *type, int arraySize) |
template<typename Fn > | |
void | foreach (Fn &&fn) const |
bool | wouldShadowSymbolsFrom (const SymbolTable *other) const |
size_t | count () const |
bool | isBuiltin () const |
const std::string * | takeOwnershipOfString (std::string n) |
void | markModuleBoundary () |
Public Attributes | |
SymbolTable * | fParent = nullptr |
std::vector< std::unique_ptr< Symbol > > | fOwnedSymbols |
Maps identifiers to symbols.
Definition at line 35 of file SkSLSymbolTable.h.
|
inlineexplicit |
Definition at line 37 of file SkSLSymbolTable.h.
|
inlineexplicit |
Definition at line 40 of file SkSLSymbolTable.h.
|
inline |
Adds a symbol to this symbol table, conferring ownership. The symbol table will always be updated to reference the new symbol. If the symbol already exists, an error will be reported.
Definition at line 121 of file SkSLSymbolTable.h.
const Type * SkSL::SymbolTable::addArrayDimension | ( | const Context & | context, |
const Type * | type, | ||
int | arraySize | ||
) |
Given type = float
and arraySize = 5, creates the array type float[5]
in the symbol table. The created array type is returned. If zero is passed, the base type is returned unchanged.
Definition at line 173 of file SkSLSymbolTable.cpp.
Adds a symbol to this symbol table, conferring ownership. The symbol table will always be updated to reference the new symbol. If the symbol already exists, abort.
Definition at line 132 of file SkSLSymbolTable.h.
Definition at line 123 of file SkSLSymbolTable.cpp.
void SkSL::SymbolTable::addWithoutOwnershipOrDie | ( | Symbol * | symbol | ) |
Adds a symbol to this symbol table, without conferring ownership. The caller is responsible for keeping the Symbol alive throughout the lifetime of the program/module.
Definition at line 130 of file SkSLSymbolTable.cpp.
|
inline |
Definition at line 183 of file SkSLSymbolTable.h.
|
inline |
Looks up the requested symbol and returns a const pointer.
Definition at line 54 of file SkSLSymbolTable.h.
const Symbol * SkSL::SymbolTable::findBuiltinSymbol | ( | std::string_view | name | ) | const |
Looks up the requested symbol, only searching the built-in symbol tables. Always const.
Definition at line 38 of file SkSLSymbolTable.cpp.
|
inline |
Looks up the requested symbol and returns a mutable pointer. Use caution–mutating a symbol will have program-wide impact, and built-in symbol tables must never be mutated.
Definition at line 67 of file SkSLSymbolTable.h.
|
inline |
Definition at line 174 of file SkSLSymbolTable.h.
Forces a symbol into this symbol table, conferring ownership. Replaces any existing symbol with the same name, if one exists.
Definition at line 149 of file SkSLSymbolTable.h.
void SkSL::SymbolTable::injectWithoutOwnership | ( | Symbol * | symbol | ) |
Forces a symbol into this symbol table, without conferring ownership. Replaces any existing symbol with the same name, if one exists.
Definition at line 168 of file SkSLSymbolTable.cpp.
std::unique_ptr< SymbolTable > SkSL::SymbolTable::insertNewParent | ( | ) |
Creates a new, empty SymbolTable between this SymbolTable and its current parent. The new symbol table is returned, and is also accessible as this->fParent
. The original parent is accessible as this->fParent->fParent
.
Definition at line 20 of file SkSLSymbolTable.cpp.
std::unique_ptr< Expression > SkSL::SymbolTable::instantiateSymbolRef | ( | const Context & | context, |
std::string_view | name, | ||
Position | pos | ||
) |
Looks up the requested symbol and instantiates an Expression reference to it; will return a VariableReference, TypeReference, FunctionReference, FieldAccess, or nullptr.
Definition at line 194 of file SkSLSymbolTable.cpp.
|
inline |
Returns true if this is a built-in SymbolTable.
Definition at line 188 of file SkSLSymbolTable.h.
bool SkSL::SymbolTable::isBuiltinType | ( | std::string_view | name | ) | const |
Returns true if the name refers to a builtin type.
Definition at line 31 of file SkSLSymbolTable.cpp.
bool SkSL::SymbolTable::isType | ( | std::string_view | name | ) | const |
Returns true if the name refers to a type (user or built-in) in the current symbol table.
Definition at line 26 of file SkSLSymbolTable.cpp.
|
inline |
Indicates that this symbol table's parent is in a different module than this one.
Definition at line 197 of file SkSLSymbolTable.h.
void SkSL::SymbolTable::moveSymbolTo | ( | SymbolTable * | otherTable, |
Symbol * | sym, | ||
const Context & | context | ||
) |
Moves a symbol from this symbol table to another one. If this symbol table had ownership of the symbol, the ownership will be transferred as well. (If the symbol does not actually exist in this table at all, it will still be added to the other table.)
Definition at line 109 of file SkSLSymbolTable.cpp.
Removes a symbol from the symbol table. If this symbol table had ownership of the symbol, the symbol is returned (and can be deleted or reinserted as desired); if not, null is returned. In either event, the name will no longer correspond to the symbol.
Definition at line 93 of file SkSLSymbolTable.cpp.
void SkSL::SymbolTable::renameSymbol | ( | const Context & | context, |
Symbol * | symbol, | ||
std::string_view | newName | ||
) |
Assigns a new name to the passed-in symbol. The old name will continue to exist in the symbol table and point to the symbol.
Definition at line 78 of file SkSLSymbolTable.cpp.
const std::string * SkSL::SymbolTable::takeOwnershipOfString | ( | std::string | n | ) |
Definition at line 117 of file SkSLSymbolTable.cpp.
|
inline |
Confers ownership of a symbol without adding its name to the lookup table.
Definition at line 159 of file SkSLSymbolTable.h.
bool SkSL::SymbolTable::wouldShadowSymbolsFrom | ( | const SymbolTable * | other | ) | const |
Definition at line 45 of file SkSLSymbolTable.cpp.
std::vector<std::unique_ptr<Symbol> > SkSL::SymbolTable::fOwnedSymbols |
Definition at line 203 of file SkSLSymbolTable.h.
SymbolTable* SkSL::SymbolTable::fParent = nullptr |
Definition at line 201 of file SkSLSymbolTable.h.