[llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Wed Jul 14 02:15:11 PDT 2004
Changes in directory llvm-java/lib/ClassFile:
ClassFile.cpp updated: 1.15 -> 1.16
---
Log message:
Add convinience methods for getting specific field or method Attributes.
---
Diffs of the changes: (+28 -0)
Index: llvm-java/lib/ClassFile/ClassFile.cpp
diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.15 llvm-java/lib/ClassFile/ClassFile.cpp:1.16
--- llvm-java/lib/ClassFile/ClassFile.cpp:1.15 Tue Jul 13 03:57:09 2004
+++ llvm-java/lib/ClassFile/ClassFile.cpp Wed Jul 14 04:15:01 2004
@@ -137,6 +137,14 @@
return os;
}
+ const Attribute* getAttribute(const Attributes& attributes,
+ const std::string& name) {
+ for (unsigned i = 0, e = attributes.size(); i != e; ++i)
+ if (attributes[i]->getName()->str() == name)
+ return attributes[i];
+
+ return NULL;
+ }
}
//===----------------------------------------------------------------------===//
@@ -509,6 +517,15 @@
return os;
}
+const ConstantValueAttribute* Field::getConstantValueAttribute() const
+{
+ if (!isStatic())
+ return NULL;
+
+ return (ConstantValueAttribute*) getAttribute(attributes_,
+ Attribute::CONSTANT_VALUE);
+}
+
//===----------------------------------------------------------------------===//
// Method implementation
Method::Method(const ConstantPool& cp, std::istream& is)
@@ -548,6 +565,17 @@
return os;
}
+const CodeAttribute* Method::getCodeAttribute() const
+{
+ return (CodeAttribute*) getAttribute(attributes_, Attribute::CODE);
+}
+
+const ExceptionsAttribute* Method::getExceptionsAttribute() const
+{
+ return (ExceptionsAttribute*) getAttribute(attributes_,
+ Attribute::EXCEPTIONS);
+}
+
//===----------------------------------------------------------------------===//
// Attribute implementation
const std::string Attribute::CONSTANT_VALUE = "ConstantValue";
More information about the llvm-commits
mailing list