Id's fo Expr-inherited classes
This commit is contained in:
23
ast.h
23
ast.h
@@ -48,8 +48,9 @@
|
||||
(Expr) and statements (Stmt) inherit from this class.
|
||||
*/
|
||||
class ASTNode {
|
||||
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
|
||||
public:
|
||||
ASTNode(SourcePos p) : pos(p) { }
|
||||
ASTNode(SourcePos p, unsigned scid) : SubclassID(scid), pos(p) { }
|
||||
virtual ~ASTNode();
|
||||
|
||||
/** The Optimize() method should perform any appropriate early-stage
|
||||
@@ -74,12 +75,24 @@ public:
|
||||
/** All AST nodes must track the file position where they are
|
||||
defined. */
|
||||
SourcePos pos;
|
||||
|
||||
/** An enumeration for keeping track of the concrete subclass of Value
|
||||
that is actually instantiated.*/
|
||||
enum ASTNodeTy {
|
||||
ExprID,
|
||||
StmtID
|
||||
};
|
||||
|
||||
/** Return an ID for the concrete type of this object. This is used to
|
||||
implement the classof checks. This should not be used for any
|
||||
other purpose, as the values may change as ISPC evolves */
|
||||
unsigned getValueID() const {
|
||||
return SubclassID;
|
||||
}
|
||||
|
||||
static inline bool classof(ASTNode const*) { return true; }
|
||||
};
|
||||
|
||||
|
||||
/** Simple representation of the abstract syntax trees for all of the
|
||||
functions declared in a compilation unit.
|
||||
*/
|
||||
class AST {
|
||||
public:
|
||||
/** Add the AST for a function described by the given declaration
|
||||
|
||||
Reference in New Issue
Block a user