mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
Add new method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7502 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
14fef50bcf
commit
dbb295bd0d
@ -536,6 +536,23 @@ int Record::getValueAsInt(const std::string &FieldName) const {
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
/// getValueAsDef - This method looks up the specified field and returns its
|
||||
/// value as a Record, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
///
|
||||
Record *Record::getValueAsDef(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 (DefInit *DI = dynamic_cast<DefInit*>(R->getValue()))
|
||||
return DI->getDef();
|
||||
throw "Record '" + R->getName() + "', field '" + FieldName +
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
|
||||
void RecordKeeper::dump() const { std::cerr << *this; }
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK) {
|
||||
|
@ -626,6 +626,12 @@ public:
|
||||
///
|
||||
ListInit *getValueAsListInit(const std::string &FieldName) const;
|
||||
|
||||
/// getValueAsDef - This method looks up the specified field and returns its
|
||||
/// value as a Record, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
///
|
||||
Record *getValueAsDef(const std::string &FieldName) const;
|
||||
|
||||
/// getValueAsInt - This method looks up the specified field and returns its
|
||||
/// value as an int, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
|
@ -536,6 +536,23 @@ int Record::getValueAsInt(const std::string &FieldName) const {
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
/// getValueAsDef - This method looks up the specified field and returns its
|
||||
/// value as a Record, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
///
|
||||
Record *Record::getValueAsDef(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 (DefInit *DI = dynamic_cast<DefInit*>(R->getValue()))
|
||||
return DI->getDef();
|
||||
throw "Record '" + R->getName() + "', field '" + FieldName +
|
||||
"' does not have a list initializer!";
|
||||
}
|
||||
|
||||
|
||||
void RecordKeeper::dump() const { std::cerr << *this; }
|
||||
|
||||
std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK) {
|
||||
|
@ -626,6 +626,12 @@ public:
|
||||
///
|
||||
ListInit *getValueAsListInit(const std::string &FieldName) const;
|
||||
|
||||
/// getValueAsDef - This method looks up the specified field and returns its
|
||||
/// value as a Record, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
///
|
||||
Record *getValueAsDef(const std::string &FieldName) const;
|
||||
|
||||
/// getValueAsInt - This method looks up the specified field and returns its
|
||||
/// value as an int, throwing an exception if the field does not exist or if
|
||||
/// the value is not the right type.
|
||||
|
Loading…
Reference in New Issue
Block a user