slang::ast::Statement class

The base class for all statements in SystemVerilog.

Derived classes

class BlockStatement
Represents a sequential or parallel block statement.
class EmptyStatement
Represents an empty statement, used as a placeholder or an anchor for attributes.
class InvalidStatement
Represents an invalid statement, which is usually generated and inserted into a statement list due to violation of language semantics or type checking.
class StatementList
Represents a list of statements.

Public types

struct StatementContext
Additional information passed along during statement creation.
enum class EvalResult { Fail, Success, Return, Break, Continue, Disable }
Specifies possible results of evaluating a statement.

Public static functions

static auto bind(const StatementSyntax& syntax, const ASTContext& context, StatementContext& stmtCtx, bool inList = false, bool labelHandled = false) -> const Statement&
Binds a statement tree from the given syntax nodes.
static auto bindBlock(const StatementBlockSymbol& block, const syntax::SyntaxNode& syntax, const ASTContext& context, StatementContext& stmtCtx) -> const Statement&
Binds a statement tree that forms the contents of a block.
static auto bindItems(const syntax::SyntaxList<syntax::SyntaxNode>& items, const ASTContext& context, StatementContext& stmtCtx) -> const Statement&
Binds a list of statement items.
static auto createBlockItems(const Scope& scope, const StatementSyntax& syntax, bool labelHandled, SmallVector<const syntax::SyntaxNode*>& extraMembers) -> std::span<const StatementBlockSymbol*const>
Creates any symbols declared by the given statement syntax, such as local variables.
static auto createAndAddBlockItems(Scope& scope, const syntax::SyntaxList<syntax::SyntaxNode>& items) -> std::span<const StatementBlockSymbol*const>
Creates any symbols declared by the given list of syntax nodes, such as local variables, and ignores any statement syntax nodes.
static auto createAndAddBlockItems(Scope& scope, const StatementSyntax& syntax, bool labelHandled) -> std::span<const StatementBlockSymbol*const>
Creates any symbols declared by the given statement syntax, such as local variables.

Public functions

auto bad() const -> bool
Indicates whether the statement is invalid.
auto eval(EvalContext& context) const -> EvalResult
Evaluates the statement under the given evaluation context.

Public variables

StatementKind kind
The kind of statement; indicates the type of derived class.
const StatementSyntax* syntax
The syntax used to create this statement, if it was parsed from a source file.
SourceRange sourceRange
The source range of this statement, if it originated from source code.

Enum documentation

enum class slang::ast::Statement::EvalResult

Specifies possible results of evaluating a statement.

Enumerators
Fail

Evaluation totally failed and we should give up on any further processing.

Success

Evaluation succeeded.

Return

A return statement was invoked; we should exit the current function.

Break

A break statement was invoked; we should exit the current loop.

Continue

A continue statement was invoked; we should continue the current loop.

Disable

A disable statement was invoked; we should exit blocks until we find the target.

Function documentation

static std::span<const StatementBlockSymbol*const> slang::ast::Statement::createAndAddBlockItems(Scope& scope, const syntax::SyntaxList<syntax::SyntaxNode>& items)

Creates any symbols declared by the given list of syntax nodes, such as local variables, and ignores any statement syntax nodes.

The created symbols are added to the given scope.

static std::span<const StatementBlockSymbol*const> slang::ast::Statement::createAndAddBlockItems(Scope& scope, const StatementSyntax& syntax, bool labelHandled)

Creates any symbols declared by the given statement syntax, such as local variables.

The created symbols are added to the given scope.