[llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h
Alkis Evlogimenos
alkis at cs.uiuc.edu
Sat Apr 17 11:19:07 PDT 2004
Changes in directory llvm-java/include/llvm/Java:
ClassFile.h updated: 1.3 -> 1.4
---
Log message:
Fix memory leaks.
Add ConstantValue and Code attributes.
---
Diffs of the changes: (+89 -8)
Index: llvm-java/include/llvm/Java/ClassFile.h
diff -u llvm-java/include/llvm/Java/ClassFile.h:1.3 llvm-java/include/llvm/Java/ClassFile.h:1.4
--- llvm-java/include/llvm/Java/ClassFile.h:1.3 Fri Apr 16 18:07:19 2004
+++ llvm-java/include/llvm/Java/ClassFile.h Sat Apr 17 02:52:16 2004
@@ -57,6 +57,8 @@
public:
static ClassFile* readClassFile(std::istream& is);
+ ~ClassFile();
+
uint16_t getMinorVersion() const { return minorV_; }
uint16_t getMajorVersion() const { return majorV_; }
@@ -71,13 +73,13 @@
const ConstantClass* getThisClass() const { return thisClass_; }
const ConstantClass* getSuperClass() const { return superClass_; }
- const Interfaces& getInterfaces() const;
+ const Interfaces& getInterfaces() const { return interfaces_; }
- const Fields& getFields() const;
+ const Fields& getFields() const { return fields_; }
- const Methods& getMethods() const;
+ const Methods& getMethods() const { return methods_; }
- const Attributes& getAttributes() const;
+ const Attributes& getAttributes() const { return attributes_; }
std::ostream& dump(std::ostream& os) const;
@@ -236,8 +238,9 @@
std::string utf8_;
public:
ConstantUtf8(const ClassFile::ConstantPool& cp, std::istream& is);
- operator const std::string() const { return utf8_; }
- //const std::string& getUtf8() const { return utf8_; }
+ operator const char* const() const { return utf8_.c_str(); }
+ operator const std::string&() const { return utf8_; }
+
std::ostream& dump(std::ostream& os) const;
};
@@ -256,6 +259,8 @@
return new Field(cp, is);
}
+ ~Field();
+
bool isPublic() const { return accessFlags_ & ACC_PUBLIC; }
bool isPrivate() const { return accessFlags_ & ACC_PRIVATE; }
bool isProtected() const { return accessFlags_ & ACC_PROTECTED; }
@@ -266,6 +271,9 @@
ConstantUtf8* getName() const { return name_; }
ConstantUtf8* getDescriptor() const { return descriptor_; }
+ const ClassFile::Attributes& getAttributes() const {
+ return attributes_;
+ }
std::ostream& dump(std::ostream& os) const;
};
@@ -288,6 +296,8 @@
return new Method(cp, is);
}
+ ~Method();
+
bool isPublic() const { return accessFlags_ & ACC_PUBLIC; }
bool isPrivate() const { return accessFlags_ & ACC_PRIVATE; }
bool isProtected() const { return accessFlags_ & ACC_PROTECTED; }
@@ -300,6 +310,9 @@
ConstantUtf8* getName() const { return name_; }
ConstantUtf8* getDescriptor() const { return descriptor_; }
+ const ClassFile::Attributes& getAttributes() const {
+ return attributes_;
+ }
std::ostream& dump(std::ostream& os) const;
};
@@ -312,19 +325,87 @@
ConstantUtf8* name_;
protected:
- Attribute(const ClassFile::ConstantPool& cp, std::istream& is);
+ Attribute(ConstantUtf8* name,
+ const ClassFile::ConstantPool& cp,
+ std::istream& is);
public:
static Attribute* readAttribute(const ClassFile::ConstantPool& cp,
std::istream& is);
+ virtual ~Attribute();
+
ConstantUtf8* getName() const { return name_; }
- std::ostream& dump(std::ostream& os) const;
+ virtual std::ostream& dump(std::ostream& os) const;
};
inline std::ostream& operator<<(std::ostream& os, const Attribute& a) {
return a.dump(os);
+ }
+
+ class AttributeConstantValue : public Attribute {
+ Constant* value_;
+ public:
+ AttributeConstantValue(ConstantUtf8* name,
+ const ClassFile::ConstantPool& cp,
+ std::istream& is);
+
+ Constant* getValue() const { return value_; }
+
+ std::ostream& dump(std::ostream& os) const;
+ };
+
+ class AttributeCode : public Attribute {
+ public:
+ class Exception {
+ uint16_t startPc_;
+ uint16_t endPc_;
+ uint16_t handlerPc_;
+ ConstantClass* catchType_;
+
+ public:
+ Exception(const ClassFile::ConstantPool& cp, std::istream& is);
+
+ uint16_t getStartPc() const { return startPc_; }
+ uint16_t getEndPc() const { return endPc_; }
+ uint16_t getHandlerPc() const { return handlerPc_; }
+ ConstantClass* getCatchType() const { return catchType_; }
+
+ std::ostream& dump(std::ostream& os) const;
+ };
+
+ typedef std::vector<Exception*> Exceptions;
+
+ private:
+ uint16_t maxStack_;
+ uint16_t maxLocals_;
+ uint32_t codeSize_;
+ char* code_;
+ Exceptions exceptions_;
+ ClassFile::Attributes attributes_;
+
+ public:
+ AttributeCode(ConstantUtf8* name,
+ const ClassFile::ConstantPool& cp,
+ std::istream& is);
+ ~AttributeCode();
+ uint16_t getMaxStack() const { return maxStack_; }
+ uint16_t getMaxLocals() const { return maxLocals_; }
+ const char* getCode() const { return code_; }
+ uint32_t getCodeSize() const { return codeSize_; }
+ const Exceptions& getExceptions() const { return exceptions_; }
+ const ClassFile::Attributes& getAttributes() const {
+ return attributes_;
+ }
+
+ std::ostream& dump(std::ostream& os) const;
+
+ };
+
+ inline std::ostream& operator<<(std::ostream& os,
+ const AttributeCode::Exception& e) {
+ return e.dump(os);
}
class ClassFileParseError : public std::exception {
More information about the llvm-commits
mailing list