slang::ast::ASTContext class

Contains required context for binding syntax nodes with symbols to form an AST. Expressions, statements, timing controls, constraints, and assertion items all use this for creation.

Public types

struct AssertionInstanceDetails
Information required to instantiate a sequence or property instance.
struct RandomizeDetails

Public functions

auto requireSimpleExpr(const syntax::PropertyExprSyntax& expr) const -> const syntax::ExpressionSyntax*
auto getRandMode(const Symbol& symbol) const -> RandMode
void addAssertionBacktrace(Diagnostic& diag) const

Public variables

not_null<const Scope*> scope
The scope where the AST creation is occurring.
SymbolIndex lookupIndex
The location to use when looking up names.
bitmask<ASTFlags> flags
Various flags that control how AST creation is performed.
const TempVarSymbol* firstTempVar
const RandomizeDetails* randomizeDetails
const AssertionInstanceDetails* assertionInstance

Function documentation

const syntax::ExpressionSyntax* slang::ast::ASTContext::requireSimpleExpr(const syntax::PropertyExprSyntax& expr) const

Subroutine argument expressions are parsed as property expressions, since we don't know up front whether they will be used to instantiate a property or a sequence or are actually for a subroutine. This method unwraps for the case where we are calling a subroutine.

RandMode slang::ast::ASTContext::getRandMode(const Symbol& symbol) const

Gets the rand mode for the given symbol, taking into account any randomize scope that may be active in this context.

void slang::ast::ASTContext::addAssertionBacktrace(Diagnostic& diag) const

If this context is within an assertion instance, report a backtrace of how that instance was expanded to the given diagnostic; otherwise, do nothing.

Variable documentation

const TempVarSymbol* slang::ast::ASTContext::firstTempVar

If any temporary variables have been materialized in this context, contains a pointer to the first one along with a linked list of any others that may be active. Otherwise nullptr.

const RandomizeDetails* slang::ast::ASTContext::randomizeDetails

If this context is for creating an inline constraint block for a randomize function call, this points to information about the scope. Name lookups happen inside the class scope before going through the normal local lookup, for example.

const AssertionInstanceDetails* slang::ast::ASTContext::assertionInstance

If this context is for creating an instantiation of a sequence or property this points to information about that instantiation.