Intel SPMD Program Compiler  1.12.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
AssertStmt Class Reference

Representation of an assert statement in the program. More...

#include <stmt.h>

Inheritance diagram for AssertStmt:
Inheritance graph
Collaboration diagram for AssertStmt:
Collaboration graph

Public Member Functions

 AssertStmt (const std::string &msg, Expr *e, SourcePos p)
void EmitCode (FunctionEmitContext *ctx) const
void Print (int indent) const
StmtTypeCheck ()
int EstimateCost () const
- Public Member Functions inherited from Stmt
 Stmt (SourcePos p, unsigned scid)
virtual StmtOptimize ()
- Public Member Functions inherited from ASTNode
 ASTNode (SourcePos p, unsigned scid)
virtual ~ASTNode ()
unsigned getValueID () const

Static Public Member Functions

static bool classof (AssertStmt const *)
static bool classof (ASTNode const *N)
- Static Public Member Functions inherited from Stmt
static bool classof (Stmt const *)
static bool classof (ASTNode const *N)
- Static Public Member Functions inherited from ASTNode
static bool classof (ASTNode const *)

Public Attributes

const std::string message
- Public Attributes inherited from ASTNode
SourcePos pos

Additional Inherited Members

- Public Types inherited from ASTNode
enum  ASTNodeTy {
  AddressOfExprID, AssignExprID, BinaryExprID, ConstExprID,
  DerefExprID, PtrDerefExprID, RefDerefExprID, ExprListID,
  FunctionCallExprID, FunctionSymbolExprID, IndexExprID, StructMemberExprID,
  VectorMemberExprID, NewExprID, NullPointerExprID, ReferenceExprID,
  SelectExprID, SizeOfExprID, SymbolExprID, SyncExprID,
  TypeCastExprID, UnaryExprID, MaxExprID, AssertStmtID,
  BreakStmtID, CaseStmtID, ContinueStmtID, DeclStmtID,
  DefaultStmtID, DeleteStmtID, DoStmtID, ExprStmtID,
  ForeachActiveStmtID, ForeachStmtID, ForeachUniqueStmtID, ForStmtID,
  GotoStmtID, IfStmtID, LabeledStmtID, PrintStmtID,
  ReturnStmtID, StmtListID, SwitchStmtID, UnmaskedStmtID

Detailed Description

Representation of an assert statement in the program.

Like print() above, since we don't have strings as first-class types in the language, we need to do some gymnastics to support it. Like assert() in C, assert() checks the given condition and prints an error and calls abort if the condition fails. For varying conditions, the assert triggers if it's true for any of the program instances.

Definition at line 499 of file stmt.h.

Constructor & Destructor Documentation

◆ AssertStmt()

AssertStmt::AssertStmt ( const std::string &  msg,
Expr e,
SourcePos  p 

Definition at line 3097 of file stmt.cpp.

Member Function Documentation

◆ classof() [1/2]

static bool AssertStmt::classof ( AssertStmt const *  )

Definition at line 503 of file stmt.h.

◆ classof() [2/2]

static bool AssertStmt::classof ( ASTNode const *  N)

◆ EmitCode()

void AssertStmt::EmitCode ( FunctionEmitContext ctx) const

◆ EstimateCost()

int AssertStmt::EstimateCost ( ) const

Estimate the execution cost of the node (not including the cost of the children. The value returned should be based on the COST_* enumerant values defined in ispc.h.

Implements ASTNode.

Definition at line 3152 of file stmt.cpp.

References COST_ASSERT.

◆ Print()

void AssertStmt::Print ( int  indent) const

Print a representation of the statement (and any children AST nodes) to standard output. This method is used for debuggins.

Implements Stmt.

Definition at line 3138 of file stmt.cpp.

References message.

◆ TypeCheck()

Stmt * AssertStmt::TypeCheck ( )

Type checking should be performed by the node when this method is called. In the event of an error, a NULL value may be returned. As with ASTNode::Optimize(), the caller should store the returned pointer in place of the original ASTNode *.

Implements Stmt.

Definition at line 3140 of file stmt.cpp.

References expr, Expr::GetType(), Type::IsUniformType(), TypeConvertExpr(), AtomicType::UniformBool, and AtomicType::VaryingBool.

Member Data Documentation

◆ expr

Expr* AssertStmt::expr

The expression to be evaluated (that is asserted to be true).

Definition at line 515 of file stmt.h.

Referenced by EmitCode(), TypeCheck(), and WalkAST().

◆ message

const std::string AssertStmt::message

Message to print if the assertion fails.

Definition at line 513 of file stmt.h.

Referenced by EmitCode(), and Print().

The documentation for this class was generated from the following files: