slang::ast::ScriptSession class

A helper class that allows evaluating arbitrary snippets of SystemVerilog source code and maintaining state across multiple eval calls.

Constructors, destructors, conversion operators

ScriptSession(Bag options = {}) explicit
Constructs a new ScriptSession.

Public functions

auto eval(std::string_view text) -> ConstantValue
Tries to evaluate the given snippet of SystemVerilog code and returns the result as a constant value.
auto evalExpression(const syntax::ExpressionSyntax& expr) -> ConstantValue
Tries to evaluate the given expression tree and returns the result as a constant value.
void evalStatement(const syntax::StatementSyntax& expr)
Tries to evaluate the given statement tree and returns the result as a constant value.
auto getDiagnostics() -> Diagnostics
Gets any diagnostics that have been issued during evaluation calls.

Public variables

Bag options
A bag of options to apply to the various evaluated snippets.
Compilation compilation
A compilation object that holds state across evaluation calls.
CompilationUnitSymbol& scope
A compilation unit that acts as a scope for evaluation.