PP: Remove second parsing of numbers recorded in macros; save/use original.

This partly addresses #1228 and #234 by reducing usage of strtod (or atof).
There is now only place to parse a floating-point number.
This commit is contained in:
John Kessenich 2018-05-24 18:24:06 -06:00
parent 1ea1b13f38
commit 6c52f8968c
2 changed files with 103 additions and 119 deletions

17
glslang/MachineIndependent/preprocessor/PpContext.h Normal file → Executable file
View file

@ -92,13 +92,16 @@ namespace glslang {
class TPpToken {
public:
TPpToken() : space(false), i64val(0)
TPpToken() { clear(); }
void clear()
{
space = false;
i64val = 0;
loc.init();
name[0] = 0;
}
// This is used for comparing macro definitions, so checks what is relevant for that.
// Used for comparing macro definitions, so checks what is relevant for that.
bool operator==(const TPpToken& right)
{
return space == right.space &&
@ -108,15 +111,17 @@ public:
bool operator!=(const TPpToken& right) { return ! operator==(right); }
TSourceLoc loc;
bool space; // true if a space (for white space or a removed comment) should also be recognized, in front of the token returned
// True if a space (for white space or a removed comment) should also be
// recognized, in front of the token returned:
bool space;
// Numeric value of the token:
union {
int ival;
double dval;
long long i64val;
};
char name[MaxTokenLength + 1];
// Text string of the token:
char name[MaxTokenLength + 1];
};
class TStringAtomMap {