[vmkit-commits] [vmkit] r86539 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Nov 9 05:42:54 PST 2009
Author: geoffray
Date: Mon Nov 9 07:42:53 2009
New Revision: 86539
URL: http://llvm.org/viewvc/llvm-project?rev=86539&view=rev
Log:
Read annotations!
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=86539&r1=86538&r2=86539&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Nov 9 07:42:53 2009
@@ -30,6 +30,7 @@
using namespace jnjvm;
+const UTF8* Attribut::annotationsAttribut = 0;
const UTF8* Attribut::codeAttribut = 0;
const UTF8* Attribut::exceptionsAttribut = 0;
const UTF8* Attribut::constantAttribut = 0;
@@ -1683,3 +1684,35 @@
nbSecondaryTypes = 0;
offset = getCacheIndex() + 1;
}
+
+void AnnotationReader::readAnnotation() {
+ uint16 typeIndex = reader.readU2();
+ uint16 numPairs = reader.readU2();
+
+ for (uint16 j = 0; j < numPairs; ++j) {
+ uint16 nameIndex = reader.readU2();
+ readElementValue();
+ }
+ AnnotationNameIndex = typeIndex;
+}
+
+void AnnotationReader::readElementValue() {
+ uint8 tag = reader.readU1();
+ if ((tag == 'B') || (tag == 'C') || (tag == 'D') || (tag == 'F') ||
+ (tag == 'J') || (tag == 'S') || (tag == 'I') || (tag == 'Z') ||
+ (tag == 's')) {
+ uint16 constValue = reader.readU2();
+ } else if (tag == 'e') {
+ uint16 typeName = reader.readU2();
+ uint16 constName = reader.readU2();
+ } else if (tag == 'c') {
+ uint16 classInfoIndex = reader.readU2();
+ } else if (tag == '@') {
+ readAnnotation();
+ } else if (tag == '[') {
+ uint16 numValues = reader.readU2();
+ for (uint32 i = 0; i < numValues; ++i) {
+ readElementValue();
+ }
+ }
+}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=86539&r1=86538&r2=86539&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Mon Nov 9 07:42:53 2009
@@ -58,6 +58,18 @@
#define erroneous 6 /// The class is in an erroneous state.
+class AnnotationReader {
+public:
+ Reader& reader;
+ Class* cl;
+ uint16 AnnotationNameIndex;
+
+ AnnotationReader(Reader& R, Class* C) : reader(R), cl(C),
+ AnnotationNameIndex(0) {}
+ void readAnnotation();
+ void readElementValue();
+};
+
/// Attribut - This class represents JVM attributes to Java class, methods and
/// fields located in the .class file.
///
@@ -86,6 +98,11 @@
/// finding the bytecode of a method in the .class file.
//
static const UTF8* codeAttribut;
+
+ /// annotationsAttribut - The "RuntimeVisibleAnnotations" JVM attribut.
+ /// This is a method attribut for getting the runtime annotations.
+ //
+ static const UTF8* annotationsAttribut;
/// exceptionsAttribut - The "Exceptions" attribut. This is a method
/// attribut for finding the exception table of a method in the .class
More information about the vmkit-commits
mailing list