slang::ast::Statement class

The base class for all statements in SystemVerilog.

Derived classes

class BlockStatement final
Represents a sequential or parallel block statement.
class BreakStatement final
Represents a break statement.
class CaseStatement final
Represents a case statement.
class ConcurrentAssertionStatement final
Represents a concurrent assertion statement.
class ConditionalStatement final
Represents a conditional statement.
class ContinueStatement final
Represents a continue statement.
class DisableForkStatement final
Represents a disable fork statement.
class DisableStatement final
Represents a disable statement.
class DoWhileLoopStatement final
Represents a do while loop statement.
class EmptyStatement final
Represents an empty statement, used as a placeholder or an anchor for attributes.
class EventTriggerStatement final
Represents an event triggering statement.
class ExpressionStatement final
Represents an expression that is executed as a standalone statement.
class ForLoopStatement final
Represents a for loop statement.
class ForeachLoopStatement final
Represents a foreach loop statement.
class ForeverLoopStatement final
Represents a forever loop statement.
class ImmediateAssertionStatement final
Represents an immediate assertion statement.
class InvalidStatement final
Represents an invalid statement.
class PatternCaseStatement final
Represents a pattern case statement.
class ProceduralAssignStatement final
Represents a procedural assign statement.
class ProceduralCheckerStatement final
Represents a procedural checker instantiation statement.
class ProceduralDeassignStatement final
Represents a procedural deassign statement.
class RandCaseStatement final
Represents a randcase statement.
class RandSequenceStatement final
Represents a randsequence statement.
class RepeatLoopStatement final
Represents a repeat loop statement.
class ReturnStatement final
Represents a return statement.
class StatementList final
Represents a list of statements.
class TimedStatement final
Represents a statement that has an associated timing control.
class VariableDeclStatement final
Represents a variable declaration in a statement context.
class WaitForkStatement final
Represents a wait fork statement.
class WaitOrderStatement final
Represents a wait_order statement.
class WaitStatement final
Represents a wait statement.
class WhileLoopStatement final
Represents a while loop statement.

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.
template<typename T>
auto as() -> T&
Casts this statement to the given concrete derived type.
template<typename T>
auto as() const -> const T&
Casts this statement to the given concrete derived type.
template<typename T>
auto as_if() -> T*
Tries to cast this statement to the given concrete derived type.
template<typename T>
auto as_if() const -> const T*
Tries to cast this statement to the given concrete derived type.
template<typename TVisitor, typename... Args>
auto visit(TVisitor&& visitor, Args && ... args) const -> decltype(auto)
Visits this statement's concrete derived type via the provided visitor object.

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.

template<typename T>
T& slang::ast::Statement::as()

Casts this statement to the given concrete derived type.

Asserts that the type is appropriate given this statement's kind.

template<typename T>
const T& slang::ast::Statement::as() const

Casts this statement to the given concrete derived type.

Asserts that the type is appropriate given this statement's kind.

template<typename T>
T* slang::ast::Statement::as_if()

Tries to cast this statement to the given concrete derived type.

If the type is not appropriate given this statement's kind, returns nullptr.

template<typename T>
const T* slang::ast::Statement::as_if() const

Tries to cast this statement to the given concrete derived type.

If the type is not appropriate given this statement's kind, returns nullptr.