[llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp

Alkis Evlogimenos alkis at cs.uiuc.edu
Thu May 20 17:44:03 PDT 2004


Changes in directory llvm-java/lib/ClassFile:

ClassFile.cpp updated: 1.5 -> 1.6

---
Log message:

Implement Exceptions attribute.


---
Diffs of the changes:  (+25 -5)

Index: llvm-java/lib/ClassFile/ClassFile.cpp
diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.5 llvm-java/lib/ClassFile/ClassFile.cpp:1.6
--- llvm-java/lib/ClassFile/ClassFile.cpp:1.5	Thu May 20 17:20:15 2004
+++ llvm-java/lib/ClassFile/ClassFile.cpp	Thu May 20 17:42:15 2004
@@ -71,15 +71,16 @@
             cp.push_back(Constant::readConstant(cp, is));
     }
 
-    void readInterfaces(Classes& i, const ConstantPool& cp, std::istream& is)
+    void readClasses(Classes& i, const ConstantPool& cp, std::istream& is)
     {
         assert(i.empty() &&
-               "Should not call with a non-empty interfaces vector");
+               "Should not call with a non-empty classes vector");
         uint16_t count = readU2(is);
         i.reserve(count);
         while (count--) {
             ConstantClass* c = dynamic_cast<ConstantClass*>(cp[readU2(is)]);
-            if (!c) throw "FIXME: give better error message";
+            if (!c)
+                throw ClassFileSemanticError("ConstantClass expected");
             i.push_back(c);
         }
     }
@@ -156,7 +157,7 @@
     if (!superClass_)
         throw ClassFileSemanticError(
             "Representation of super class is not of type ConstantClass");
-    readInterfaces(interfaces_, cPool_, is);
+    readClasses(interfaces_, cPool_, is);
     readFields(fields_, cPool_, is);
     readMethods(methods_, cPool_, is);
     readAttributes(attributes_, cPool_, is);
@@ -505,7 +506,7 @@
 }
 
 //===----------------------------------------------------------------------===//
-// Attribute code
+// AttributeCode implementation
 AttributeCode::AttributeCode(ConstantUtf8* name,
                              const ConstantPool& cp,
                              std::istream& is)
@@ -565,4 +566,23 @@
               << "Start PC: " << startPc_ << '\n'
               << "End PC: " << endPc_ << '\n'
               << "Handler PC: " << handlerPc_;
+}
+
+//===----------------------------------------------------------------------===//
+// AttributeExceptions implementation
+AttributeExceptions::AttributeExceptions(ConstantUtf8* name,
+                                         const ConstantPool& cp,
+                                         std::istream& is)
+    : Attribute(name, cp, is)
+{
+    uint32_t length = readU4(is);
+    readClasses(exceptions_, cp, is);
+}
+
+std::ostream& AttributeExceptions::dump(std::ostream& is) const
+{
+    for (Classes::const_iterator
+             i = exceptions_.begin(), e = exceptions_.end(); i != e; ++i)
+        is << *i << ' ';
+    return is;
 }





More information about the llvm-commits mailing list