Intel SPMD Program Compiler  1.9.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
ASTNode Class Referenceabstract

Abstract base class for nodes in the abstract syntax tree (AST). More...

#include <ast.h>

Inheritance diagram for ASTNode:
Inheritance graph
[legend]
Collaboration diagram for ASTNode:
Collaboration graph
[legend]

Public Types

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
}
 

Public Member Functions

 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
virtual ASTNodeOptimize ()=0
 
virtual ASTNodeTypeCheck ()=0
 
virtual int EstimateCost () const =0
 
unsigned getValueID () const
 

Static Public Member Functions

static bool classof (ASTNode const *)
 

Public Attributes

SourcePos pos
 

Private Attributes

const unsigned char SubclassID
 

Detailed Description

Abstract base class for nodes in the abstract syntax tree (AST).

This class defines a basic interface that all abstract syntax tree (AST) nodes must implement. The base classes for both expressions (Expr) and statements (Stmt) inherit from this class.

Definition at line 50 of file ast.h.

Member Enumeration Documentation

An enumeration for keeping track of the concrete subclass of Value that is actually instantiated.

Enumerator
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 

Definition at line 81 of file ast.h.

Constructor & Destructor Documentation

ASTNode::ASTNode ( SourcePos  p,
unsigned  scid 
)
inline

Definition at line 53 of file ast.h.

ASTNode::~ASTNode ( )
virtual

Definition at line 50 of file ast.cpp.

Member Function Documentation

static bool ASTNode::classof ( ASTNode const *  )
inlinestatic

Definition at line 138 of file ast.h.

virtual int ASTNode::EstimateCost ( ) const
pure virtual
unsigned ASTNode::getValueID ( ) const
inline
virtual ASTNode* ASTNode::Optimize ( )
pure virtual

The Optimize() method should perform any appropriate early-stage optimizations on the node (e.g. constant folding). This method will be called after the node's children have already been optimized, and the caller will store the returned ASTNode * in place of the original node. This method should return NULL if an error is encountered during optimization.

Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, LabeledStmt, GotoStmt, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, UnaryExpr, DeclStmt, Expr, and Stmt.

Referenced by lOptimizeNode().

virtual ASTNode* ASTNode::TypeCheck ( )
pure virtual

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 *.

Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, DeleteStmt, PtrDerefExpr, AssertStmt, ReferenceExpr, PrintStmt, TypeCastExpr, StmtList, LabeledStmt, GotoStmt, ConstExpr, SwitchStmt, DefaultStmt, CaseStmt, ReturnStmt, MemberExpr, UnmaskedStmt, ForeachUniqueStmt, IndexExpr, ForeachActiveStmt, FunctionCallExpr, ForeachStmt, ExprList, ContinueStmt, BreakStmt, SelectExpr, AssignExpr, ForStmt, DoStmt, BinaryExpr, IfStmt, UnaryExpr, DeclStmt, Expr, ExprStmt, and Stmt.

Referenced by lTypeCheckNode().

Member Data Documentation

SourcePos ASTNode::pos

All AST nodes must track the file position where they are defined.

Definition at line 77 of file ast.h.

Referenced by Module::AddFunctionDefinition(), Module::AddGlobalVariable(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), Function::emitCode(), ExprStmt::EmitCode(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), BreakStmt::EmitCode(), ContinueStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ReturnStmt::EmitCode(), CaseStmt::EmitCode(), DefaultStmt::EmitCode(), SwitchStmt::EmitCode(), GotoStmt::EmitCode(), LabeledStmt::EmitCode(), StmtList::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), Function::GenerateIR(), SelectExpr::GetType(), FunctionCallExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), TypeCastExpr::GetValue(), FunctionEmitContext::initLabelBBlocks(), InitSymbol(), lArrayToPointer(), lCheckIndicesVersusBounds(), lConstFoldBinaryArithOp(), lConstFoldBinaryIntOp(), lConstFoldBinaryLogicalOp(), lConstFoldBoolBinaryOp(), lCreateBinaryOperatorCall(), lDoTypeConv(), lEmitOpAssign(), lEmitPrePostIncDec(), lProcessPrintArg(), lSwitchASTPreVisit(), UnaryExpr::Optimize(), BinaryExpr::Optimize(), SelectExpr::Optimize(), PossiblyResolveFunctionOverloads(), ExprStmt::Print(), DeclStmt::Print(), IfStmt::Print(), DoStmt::Print(), ForStmt::Print(), BreakStmt::Print(), ContinueStmt::Print(), ForeachStmt::Print(), ForeachActiveStmt::Print(), ForeachUniqueStmt::Print(), UnmaskedStmt::Print(), ReturnStmt::Print(), CaseStmt::Print(), DefaultStmt::Print(), SwitchStmt::Print(), StmtList::Print(), UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), LabeledStmt::TypeCheck(), TypeCastExpr::TypeCheck(), DeleteStmt::TypeCheck(), AddressOfExpr::TypeCheck(), and TypeConvertExpr().

const unsigned char ASTNode::SubclassID
private

Definition at line 51 of file ast.h.

Referenced by getValueID().


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