mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add new Record::getValueAsBit method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -579,6 +579,22 @@ Record *Record::getValueAsDef(const std::string &FieldName) const {
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
/// getValueAsBit - This method looks up the specified field and returns its
|
||||
/// value as a bit, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
///
|
||||
bool Record::getValueAsBit(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 (BitInit *DI = dynamic_cast<BitInit*>(R->getValue()))
|
||||
return DI->getValue();
|
||||
throw "Record '" + R->getName() + "', field '" + FieldName +
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
|
||||
void RecordKeeper::dump() const { std::cerr << *this; }
|
||||
|
||||
|
Reference in New Issue
Block a user