[llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Thu May 20 19:07:08 PDT 2004
Changes in directory llvm-java/lib/ClassFile:
ClassFile.cpp updated: 1.7 -> 1.8
---
Log message:
Add utility functions to easily access attributes.
---
Diffs of the changes: (+22 -1)
Index: llvm-java/lib/ClassFile/ClassFile.cpp
diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.7 llvm-java/lib/ClassFile/ClassFile.cpp:1.8
--- llvm-java/lib/ClassFile/ClassFile.cpp:1.7 Thu May 20 18:50:30 2004
+++ llvm-java/lib/ClassFile/ClassFile.cpp Thu May 20 19:05:59 2004
@@ -23,7 +23,7 @@
using namespace llvm::Java;
//===----------------------------------------------------------------------===//
-// Utility functions
+// Internal utility functions
namespace {
uint8_t readU1(std::istream& is) {
@@ -189,6 +189,27 @@
dumpCollection(attributes_, "Attribute", os);
return os;
+}
+
+//===----------------------------------------------------------------------===//
+// Utility functions
+const Attribute* llvm::Java::getAttribute(const Attributes& attrs,
+ const std::string& name)
+{
+ for (Attributes::const_iterator
+ i = attrs.begin(), e = attrs.end(); i != e; ++i) {
+ const Attribute* attr = *i;
+ if (attr->getName()->str() == name)
+ return attr;
+ }
+
+ return NULL;
+}
+
+const CodeAttribute* llvm::Java::getCodeAttribute(const Attributes& attrs)
+{
+ return static_cast<const CodeAttribute*>(
+ getAttribute(attrs, Attribute::CODE));
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list