summaryrefslogtreecommitdiff
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-07 06:00:43 +0000
committerChris Lattner <sabre@nondot.org>2003-08-07 06:00:43 +0000
commit784a793636b7e766e868822c213ca96b0755b5c1 (patch)
tree45f8cf469ef4e515a7957a0b896076b3e93b8a6d /utils/TableGen/Record.cpp
parent018c9e4d2657d14d3c9eae683e7a977cda956d19 (diff)
downloadllvm-784a793636b7e766e868822c213ca96b0755b5c1.tar.gz
llvm-784a793636b7e766e868822c213ca96b0755b5c1.tar.bz2
llvm-784a793636b7e766e868822c213ca96b0755b5c1.tar.xz
Add new method getVAlueAsDag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 4032f40cdb..a76c55cfb6 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -613,10 +613,26 @@ bool Record::getValueAsBit(const std::string &FieldName) const {
throw "Record '" + getName() + "' does not have a field named '" +
FieldName + "!\n";
- if (BitInit *DI = dynamic_cast<BitInit*>(R->getValue()))
- return DI->getValue();
+ if (BitInit *BI = dynamic_cast<BitInit*>(R->getValue()))
+ return BI->getValue();
throw "Record '" + getName() + "', field '" + FieldName +
- "' does not have a list initializer!";
+ "' does not have a bit initializer!";
+}
+
+/// getValueAsDag - This method looks up the specified field and returns its
+/// value as an Dag, throwing an exception if the field does not exist or if
+/// the value is not the right type.
+///
+DagInit *Record::getValueAsDag(const std::string &FieldName) const {
+ const RecordVal *R = getValue(FieldName);
+ if (R == 0 || R->getValue() == 0)
+ throw "Record '" + getName() + "' does not have a field named '" +
+ FieldName + "!\n";
+
+ if (DagInit *DI = dynamic_cast<DagInit*>(R->getValue()))
+ return DI;
+ throw "Record '" + getName() + "', field '" + FieldName +
+ "' does not have a dag initializer!";
}