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

Alkis Evlogimenos alkis at cs.uiuc.edu
Thu Jul 8 19:01:00 PDT 2004


Changes in directory llvm-java/lib/ClassFile:

ClassFile.cpp updated: 1.13 -> 1.14

---
Log message:

Add map from name+descriptor to method for easy method lookup.


---
Diffs of the changes:  (+26 -1)

Index: llvm-java/lib/ClassFile/ClassFile.cpp
diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.13 llvm-java/lib/ClassFile/ClassFile.cpp:1.14
--- llvm-java/lib/ClassFile/ClassFile.cpp:1.13	Tue Jul  6 08:31:34 2004
+++ llvm-java/lib/ClassFile/ClassFile.cpp	Thu Jul  8 19:00:26 2004
@@ -186,7 +186,7 @@
             return filename;
     }
 
-    throw ClassFileSemanticError("Class " + classname + " not found");
+    throw ClassNotFoundException("Class " + classname + " not found");
 }
 
 const ClassFile* ClassFile::getClassFile(const std::string& classname)
@@ -221,6 +221,17 @@
     readFields(fields_, cPool_, is);
     readMethods(methods_, cPool_, is);
     readAttributes(attributes_, cPool_, is);
+    for (Methods::const_iterator
+             i = methods_.begin(), e = methods_.end(); i != e; ++i)
+        n2mMap_.insert(
+            std::make_pair(
+                (*i)->getName()->str() + (*i)->getDescriptor()->str(), *i));
+}
+
+const Method* ClassFile::getMethod(const std::string& nameAndDescr) const
+{
+    Name2MethodMap::const_iterator it = n2mMap_.find(nameAndDescr);
+    return it == n2mMap_.end() ? NULL : it->second;
 }
 
 ClassFile::~ClassFile()
@@ -290,6 +301,20 @@
 }
 
 //===----------------------------------------------------------------------===//
+// ClassNotFoundException implementation
+ClassNotFoundException::~ClassNotFoundException() throw()
+{
+
+}
+
+//===----------------------------------------------------------------------===//
+// InvocationTargetException implementation
+InvocationTargetException::~InvocationTargetException() throw()
+{
+
+}
+
+//===----------------------------------------------------------------------===//
 // Constant implementation
 Constant* Constant::readConstant(const ConstantPool& cp,
                                  std::istream& is)





More information about the llvm-commits mailing list