mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
Add a new Record::getValueAsCode method to mirror the other getValueAs*
methods. Use it to simplify some code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -773,6 +773,18 @@ DagInit *Record::getValueAsDag(const std::string &FieldName) const {
|
||||
"' does not have a dag initializer!";
|
||||
}
|
||||
|
||||
std::string Record::getValueAsCode(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 (const CodeInit *CI = dynamic_cast<const CodeInit*>(R->getValue()))
|
||||
return CI->getValue();
|
||||
throw "Record `" + getName() + "', field `" + FieldName +
|
||||
"' does not have a code initializer!";
|
||||
}
|
||||
|
||||
|
||||
void RecordKeeper::dump() const { std::cerr << *this; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user