Id's fo Expr-inherited classes

This commit is contained in:
Anton Mitrokhin
2015-07-09 12:38:58 +03:00
parent 3ec674a820
commit 26a93bc733
13 changed files with 205 additions and 182 deletions

23
ast.h
View File

@@ -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