[llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h
Alkis Evlogimenos
alkis at cs.uiuc.edu
Fri Apr 16 18:08:01 PDT 2004
Changes in directory llvm-java/include/llvm/Java:
ClassFile.h updated: 1.2 -> 1.3
---
Log message:
Fix several parsing bugs.
Add ClassFileSemanticError exception class.
Add operator<< for all classes.
---
Diffs of the changes: (+42 -7)
Index: llvm-java/include/llvm/Java/ClassFile.h
diff -u llvm-java/include/llvm/Java/ClassFile.h:1.2 llvm-java/include/llvm/Java/ClassFile.h:1.3
--- llvm-java/include/llvm/Java/ClassFile.h:1.2 Thu Apr 15 23:03:45 2004
+++ llvm-java/include/llvm/Java/ClassFile.h Fri Apr 16 18:07:19 2004
@@ -96,6 +96,10 @@
ClassFile(std::istream& is);
};
+ inline std::ostream& operator<<(std::ostream& os, const ClassFile& c) {
+ return c.dump(os);
+ }
+
class Constant {
protected:
const ClassFile::ConstantPool& cPool_;
@@ -123,9 +127,13 @@
virtual ~Constant();
- virtual std::ostream& dump(std::ostream& os) const;
+ virtual std::ostream& dump(std::ostream& os) const = 0;
};
+ inline std::ostream& operator<<(std::ostream& os, const Constant& c) {
+ return c.dump(os);
+ }
+
class ConstantClass : public Constant {
uint16_t nameIdx_;
public:
@@ -133,6 +141,7 @@
const ConstantUtf8* getName() const {
return (const ConstantUtf8*) cPool_[nameIdx_];
}
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantMemberRef : public Constant {
@@ -148,6 +157,7 @@
const ConstantNameAndType* getNameAndType() const {
return (const ConstantNameAndType*) cPool_[nameAndTypeIdx_];
}
+ std::ostream& dump(std::ostream& os) const;
};
struct ConstantFieldRef : public ConstantMemberRef {
@@ -173,6 +183,7 @@
const ConstantUtf8* getValue() const {
return (const ConstantUtf8*) cPool_[stringIdx_];
}
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantInteger : public Constant {
@@ -180,6 +191,7 @@
public:
ConstantInteger(const ClassFile::ConstantPool& cp, std::istream& is);
int32_t getValue() const { return value_; }
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantFloat : public Constant {
@@ -187,6 +199,7 @@
public:
ConstantFloat(const ClassFile::ConstantPool& cp, std::istream& is);
float getValue() const { return value_; }
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantLong : public Constant {
@@ -194,6 +207,7 @@
public:
ConstantLong(const ClassFile::ConstantPool& cp, std::istream& is);
int64_t getValue() const { return value_; }
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantDouble : public Constant {
@@ -201,6 +215,7 @@
public:
ConstantDouble(const ClassFile::ConstantPool& cp, std::istream& is);
double getValue() const { return value_; }
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantNameAndType : public Constant {
@@ -214,24 +229,24 @@
const ConstantUtf8* getDescriptor() const {
return (const ConstantUtf8*) cPool_[descriptorIdx_];
}
+ std::ostream& dump(std::ostream& os) const;
};
class ConstantUtf8 : public Constant {
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_; }
+ std::ostream& dump(std::ostream& os) const;
};
class Field {
- public:
- typedef std::vector<Attribute*> Attributes;
-
private:
uint16_t accessFlags_;
ConstantUtf8* name_;
ConstantUtf8* descriptor_;
- Attributes attrs_;
+ ClassFile::Attributes attributes_;
Field(const ClassFile::ConstantPool& cp, std::istream& is);
@@ -250,16 +265,20 @@
bool isTransient() const { return accessFlags_ & ACC_TRANSIENT; }
ConstantUtf8* getName() const { return name_; }
- ConstantUtf8* getDescriptorIdx() const { return descriptor_; }
+ ConstantUtf8* getDescriptor() const { return descriptor_; }
std::ostream& dump(std::ostream& os) const;
};
+ inline std::ostream& operator<<(std::ostream& os, const Field& f) {
+ return f.dump(os);
+ }
+
class Method {
uint16_t accessFlags_;
ConstantUtf8* name_;
ConstantUtf8* descriptor_;
- ClassFile::Attributes attrs_;
+ ClassFile::Attributes attributes_;
Method(const ClassFile::ConstantPool& cp, std::istream& is);
@@ -285,6 +304,10 @@
std::ostream& dump(std::ostream& os) const;
};
+ inline std::ostream& operator<<(std::ostream& os, const Method& m) {
+ return m.dump(os);
+ }
+
class Attribute {
ConstantUtf8* name_;
@@ -300,11 +323,23 @@
std::ostream& dump(std::ostream& os) const;
};
+ inline std::ostream& operator<<(std::ostream& os, const Attribute& a) {
+ return a.dump(os);
+ }
+
class ClassFileParseError : public std::exception {
std::string msg_;
public:
explicit ClassFileParseError(const std::string& msg) : msg_(msg) { }
virtual ~ClassFileParseError() throw();
+ virtual const char* what() const throw() { return msg_.c_str(); }
+ };
+
+ class ClassFileSemanticError : public std::exception {
+ std::string msg_;
+ public:
+ explicit ClassFileSemanticError(const std::string& msg) : msg_(msg) { }
+ virtual ~ClassFileSemanticError() throw();
virtual const char* what() const throw() { return msg_.c_str(); }
};
More information about the llvm-commits
mailing list