aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen/Record.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-01 04:46:24 +0000
committerChris Lattner <sabre@nondot.org>2003-08-01 04:46:24 +0000
commit6f334ad8f5c9319b334e2ba68b89d0dd46156788 (patch)
tree45f1dc9731297510db825f999a327b83a4e21a39 /utils/TableGen/Record.cpp
parent1d1adea4937aa5c7b4bd0aa0463fe38fcdd22c7e (diff)
downloadexternal_llvm-6f334ad8f5c9319b334e2ba68b89d0dd46156788.zip
external_llvm-6f334ad8f5c9319b334e2ba68b89d0dd46156788.tar.gz
external_llvm-6f334ad8f5c9319b334e2ba68b89d0dd46156788.tar.bz2
Add new getValueAsBitsInit 'high-level' method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/Record.cpp')
-rw-r--r--utils/TableGen/Record.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index f282e4b..acb61ec 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -468,6 +468,23 @@ std::string Record::getValueAsString(const std::string &FieldName) const {
"' does not have a string initializer!";
}
+/// getValueAsBitsInit - This method looks up the specified field and returns
+/// its value as a BitsInit, throwing an exception if the field does not exist
+/// or if the value is not the right type.
+///
+BitsInit *Record::getValueAsBitsInit(const std::string &FieldName) const {
+ const RecordVal *R = getValue(FieldName);
+ if (R == 0 || R->getValue() == 0)
+ throw "Record '" + R->getName() + "' does not have a field named '" +
+ FieldName + "!\n";
+
+ if (BitsInit *BI = dynamic_cast<BitsInit*>(R->getValue()))
+ return BI;
+ throw "Record '" + R->getName() + "', field '" + FieldName +
+ "' does not have a BitsInit initializer!";
+}
+
+
void RecordKeeper::dump() const { std::cerr << *this; }