aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/expr
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-05 07:33:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-05 07:33:39 +0000
commite5620b87e1227fb97d08abe85b2f47c14ceae3cc (patch)
tree8727826b329ced4cbcf290b1a82f1ba0c569d25e /include/expr
parenta5bc7ad15dba351ca2865858f1034dcf4aeead0e (diff)
downloadklee-e5620b87e1227fb97d08abe85b2f47c14ceae3cc.tar.gz
llvm::Casting support for Kleaver AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/expr')
-rw-r--r--include/expr/Parser.h61
1 files changed, 58 insertions, 3 deletions
diff --git a/include/expr/Parser.h b/include/expr/Parser.h
index 7634d66a..08ec66aa 100644
--- a/include/expr/Parser.h
+++ b/include/expr/Parser.h
@@ -38,11 +38,33 @@ namespace expr {
/// Decl - Base class for top level declarations.
class Decl {
public:
- Decl();
+ enum DeclKind {
+ ArrayDeclKind,
+ ExprVarDeclKind,
+ VersionVarDeclKind,
+ QueryCommandDeclKind,
+
+ DeclKindLast = QueryCommandDeclKind,
+ VarDeclKindFirst = ExprVarDeclKind,
+ VarDeclKindLast = VersionVarDeclKind,
+ CommandDeclKindFirst = QueryCommandDeclKind,
+ CommandDeclKindLast = QueryCommandDeclKind
+ };
+
+ private:
+ DeclKind Kind;
+
+ public:
+ Decl(DeclKind _Kind);
virtual ~Decl() {}
+ /// getKind - Get the decl kind.
+ DeclKind getKind() const { return Kind; }
+
/// dump - Dump the AST node to stderr.
virtual void dump() = 0;
+
+ static bool classof(const Decl *) { return true; }
};
/// ArrayDecl - Array declarations.
@@ -78,6 +100,11 @@ namespace expr {
InputIterator ContentsEnd=InputIterator())
: Name(_Name), Size(_Size), Domain(_Domain), Range(_Range),
Contents(ContentsBegin, ContentsEnd) {}
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == Decl::ArrayDeclKind;
+ }
+ static bool classof(const ArrayDecl *) { return true; }
};
/// VarDecl - Variable declarations, used to associate names to
@@ -88,24 +115,46 @@ namespace expr {
class VarDecl : public Decl {
public:
const Identifier *Name;
+
+ static bool classof(const Decl *D) {
+ return (Decl::VarDeclKindFirst <= D->getKind() &&
+ D->getKind() <= Decl::VarDeclKindLast);
+ }
+ static bool classof(const VarDecl *) { return true; }
};
/// ExprVarDecl - Expression variable declarations.
class ExprVarDecl : public VarDecl {
public:
ExprHandle Value;
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == Decl::ExprVarDeclKind;
+ }
+ static bool classof(const ExprVarDecl *) { return true; }
};
/// VersionVarDecl - Array version variable declarations.
class VersionVarDecl : public VarDecl {
public:
VersionHandle Value;
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == Decl::VersionVarDeclKind;
+ }
+ static bool classof(const VersionVarDecl *) { return true; }
};
/// CommandDecl - Base class for language commands.
class CommandDecl : public Decl {
public:
- const Identifier *Name;
+ CommandDecl(DeclKind _Kind) : Decl(_Kind) {}
+
+ static bool classof(const Decl *D) {
+ return (Decl::CommandDeclKindFirst <= D->getKind() &&
+ D->getKind() <= Decl::CommandDeclKindLast);
+ }
+ static bool classof(const CommandDecl *) { return true; }
};
/// QueryCommand - Query commands.
@@ -140,10 +189,16 @@ namespace expr {
QueryCommand(InputIterator ConstraintsBegin,
InputIterator ConstraintsEnd,
ExprHandle _Query)
- : Constraints(ConstraintsBegin, ConstraintsEnd),
+ : CommandDecl(QueryCommandDeclKind),
+ Constraints(ConstraintsBegin, ConstraintsEnd),
Query(_Query) {}
virtual void dump();
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == QueryCommandDeclKind;
+ }
+ static bool classof(const QueryCommand *) { return true; }
};
/// Parser - Public interface for parsing a .pc language file.