mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
Add convenient helper to obtain list of ints
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43993 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -866,6 +866,25 @@ int Record::getValueAsInt(const std::string &FieldName) const {
|
|||||||
"' does not have an int initializer!";
|
"' does not have an int initializer!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getValueAsListOfInts - This method looks up the specified field and returns
|
||||||
|
/// its value as a vector of integers, throwing an exception if the field does
|
||||||
|
/// not exist or if the value is not the right type.
|
||||||
|
///
|
||||||
|
std::vector<int>
|
||||||
|
Record::getValueAsListOfInts(const std::string &FieldName) const {
|
||||||
|
ListInit *List = getValueAsListInit(FieldName);
|
||||||
|
std::vector<int> Ints;
|
||||||
|
for (unsigned i = 0; i < List->getSize(); i++) {
|
||||||
|
if (IntInit *II = dynamic_cast<IntInit*>(List->getElement(i))) {
|
||||||
|
Ints.push_back(II->getValue());
|
||||||
|
} else {
|
||||||
|
throw "Record `" + getName() + "', field `" + FieldName +
|
||||||
|
"' does not have a list of ints initializer!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ints;
|
||||||
|
}
|
||||||
|
|
||||||
/// getValueAsDef - This method looks up the specified field and returns its
|
/// 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
|
/// value as a Record, throwing an exception if the field does not exist or if
|
||||||
/// the value is not the right type.
|
/// the value is not the right type.
|
||||||
|
|||||||
@@ -1047,6 +1047,12 @@ public:
|
|||||||
///
|
///
|
||||||
std::vector<Record*> getValueAsListOfDefs(const std::string &FieldName) const;
|
std::vector<Record*> getValueAsListOfDefs(const std::string &FieldName) const;
|
||||||
|
|
||||||
|
/// getValueAsListOfInts - This method looks up the specified field and returns
|
||||||
|
/// its value as a vector of integers, throwing an exception if the field does
|
||||||
|
/// not exist or if the value is not the right type.
|
||||||
|
///
|
||||||
|
std::vector<int> getValueAsListOfInts(const std::string &FieldName) const;
|
||||||
|
|
||||||
/// getValueAsDef - This method looks up the specified field and returns its
|
/// 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
|
/// value as a Record, throwing an exception if the field does not exist or if
|
||||||
/// the value is not the right type.
|
/// the value is not the right type.
|
||||||
|
|||||||
Reference in New Issue
Block a user