Add support to the parser to recognize floating point constants

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2001-07-15 00:17:01 +00:00
parent 2e35bedc82
commit 3d52b2fdcc
6 changed files with 874 additions and 794 deletions

View File

@@ -53,12 +53,14 @@ static inline void ThrowException(const string &message) {
//
struct ValID {
int Type; // 0 = number, 1 = name, 2 = const pool,
// 3 = unsigned const pool, 4 = const string
// 3 = unsigned const pool, 4 = const string,
// 5 = const fp
union {
int Num; // If it's a numeric reference
char *Name; // If it's a named reference. Memory must be free'd.
int64_t ConstPool64; // Constant pool reference. This is the value
uint64_t UConstPool64;// Unsigned constant pool reference.
double ConstPoolFP; // Floating point constant pool reference
};
static ValID create(int Num) {
@@ -81,6 +83,10 @@ struct ValID {
ValID D; D.Type = 4; D.Name = Name; return D;
}
static ValID create(double Val) {
ValID D; D.Type = 5; D.ConstPoolFP = Val; return D;
}
inline void destroy() {
if (Type == 1 || Type == 4) free(Name); // Free this strdup'd memory...
}
@@ -97,6 +103,7 @@ struct ValID {
case 0: return string("#") + itostr(Num);
case 1: return Name;
case 4: return string("\"") + Name + string("\"");
case 5: return ftostr(ConstPoolFP);
default: return string("%") + itostr(ConstPool64);
}
}