/** * A block of multiple statements functioning as a single statement.
*/ class Block final : public Statement { public: inlinestatic constexpr Kind kIRNodeKind = Kind::kBlock;
// "kBracedScope" represents an actual language-level block. Other kinds of block are used to // pass around multiple statements as if they were a single unit, with no semantic impact. enumclass Kind {
kUnbracedBlock, // Represents a group of statements without curly braces.
kBracedScope, // Represents a language-level Block, with curly braces.
kCompoundStatement, // A block which conceptually represents a single statement, such as // `int a, b;`. (SkSL represents this internally as two statements: // `int a; int b;`) Allowed to optimize away to its interior Statement. // Treated as a single statement by the debugger.
};
// Make is allowed to simplify compound statements. For a single-statement unscoped Block, // Make can return the Statement as-is. For an empty unscoped Block, Make can return Nop. static std::unique_ptr<Statement> Make(Position pos,
StatementArray statements,
Kind kind = Kind::kBracedScope,
std::unique_ptr<SymbolTable> symbols = nullptr);
// MakeCompoundStatement wraps two Statements into a single compound-statement Block. // If either statement is empty, no Block will be created; the non-empty Statement is returned. // If the first Statement is _already_ a compound-statement Block, the second statement will be // appended to that block. static std::unique_ptr<Statement> MakeCompoundStatement(std::unique_ptr<Statement> existing,
std::unique_ptr<Statement> additional);
// MakeBlock always makes a real Block object. This is important because many callers rely on // Blocks specifically; e.g. a function body must be a scoped Block, nothing else will do. static std::unique_ptr<Block> MakeBlock(Position pos,
StatementArray statements,
Kind kind = Kind::kBracedScope,
std::unique_ptr<SymbolTable> symbols = nullptr);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.