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

Alkis Evlogimenos alkis at cs.uiuc.edu
Sat Feb 12 12:39:33 PST 2005



Changes in directory llvm-java/lib/ClassFile:

ClassFile.cpp updated: 1.39 -> 1.40
---
Log message:

Now that we have parent pointers, shrink the Field and Method classes
a bit by storing indices to the constant pool instead of pointers to
the constants themselves. While we are at it introduce a
non-instanciable class Member that both Field and Method inherit from.


---
Diffs of the changes:  (+22 -24)

 ClassFile.cpp |   46 ++++++++++++++++++++++------------------------
 1 files changed, 22 insertions(+), 24 deletions(-)


Index: llvm-java/lib/ClassFile/ClassFile.cpp
diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.39 llvm-java/lib/ClassFile/ClassFile.cpp:1.40
--- llvm-java/lib/ClassFile/ClassFile.cpp:1.39	Sat Feb 12 14:17:57 2005
+++ llvm-java/lib/ClassFile/ClassFile.cpp	Sat Feb 12 14:38:41 2005
@@ -544,25 +544,32 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Member implementation
+Member::Member(const ClassFile* parent, std::istream& is)
+  : parent_(parent),
+    accessFlags_(readU2(is)),
+    nameIdx_(readU2(is)),
+    descriptorIdx_(readU2(is))
+{
+  readAttributes(attributes_, parent_, is);
+}
+
+Member::~Member()
+{
+  for_each(attributes_.begin(), attributes_.end(), deleter<Attribute>);
+}
+
+//===----------------------------------------------------------------------===//
 // Field implementation
 Field::Field(const ClassFile* parent, std::istream& is)
-  : parent_(parent)
+  : Member(parent, is)
 {
-  accessFlags_ = readU2(is);
-  name_ = parent_->getConstantUtf8(readU2(is));
-  if (!name_)
-    throw ClassFileSemanticError(
-      "Representation of field name is not of type ConstantUtf8");
-  descriptor_ = parent_->getConstantUtf8(readU2(is));
-  if (!descriptor_)
-    throw ClassFileSemanticError(
-      "Representation of field descriptor is not of type ConstantUtf8");
-  readAttributes(attributes_, parent_, is);
+
 }
 
 Field::~Field()
 {
-  for_each(attributes_.begin(), attributes_.end(), deleter<Attribute>);
+
 }
 
 std::ostream& Field::dump(std::ostream& os) const
@@ -594,23 +601,14 @@
 //===----------------------------------------------------------------------===//
 // Method implementation
 Method::Method(const ClassFile* parent, std::istream& is)
-  : parent_(parent)
+  : Member(parent, is)
 {
-  accessFlags_ = readU2(is);
-  name_ = parent_->getConstantUtf8(readU2(is));
-  if (!name_)
-    throw ClassFileSemanticError(
-      "Representation of method name is not of type ConstantUtf8");
-  descriptor_ = parent_->getConstantUtf8(readU2(is));
-  if (!descriptor_)
-    throw ClassFileSemanticError(
-      "Representation of method descriptor is not of type ConstantUtf8");
-  readAttributes(attributes_, parent_, is);
+
 }
 
 Method::~Method()
 {
-  for_each(attributes_.begin(), attributes_.end(), deleter<Attribute>);
+
 }
 
 std::ostream& Method::dump(std::ostream& os) const






More information about the llvm-commits mailing list