Fixed error in lexing hexadecimal literals
git-svn-id: svn://10.0.0.236/trunk@102973 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
9ba42a9da0
commit
0d9075ada0
@ -336,6 +336,7 @@ bool JS::Lexer::lexIdentifier(String &s, bool allowLeadingDigit)
|
||||
bool JS::Lexer::lexNumeral()
|
||||
{
|
||||
int hasDecimalPoint = 0;
|
||||
bool hexadecimal = false;
|
||||
String &s = nextToken->chars;
|
||||
uint digit;
|
||||
|
||||
@ -348,6 +349,7 @@ bool JS::Lexer::lexNumeral()
|
||||
size_t pos = reader.getPos();
|
||||
char16 ch2 = getChar();
|
||||
if (isASCIIHexDigit(ch2, digit)) {
|
||||
hexadecimal = true;
|
||||
reader.recordChar(ch);
|
||||
do {
|
||||
reader.recordChar(ch2);
|
||||
@ -394,7 +396,7 @@ bool JS::Lexer::lexNumeral()
|
||||
const char16 *sBegin = s.data();
|
||||
const char16 *sEnd = sBegin + s.size();
|
||||
const char16 *numEnd;
|
||||
nextToken->value = stringToDouble(sBegin, sEnd, numEnd);
|
||||
nextToken->value = hexadecimal ? stringToInteger(sBegin, sEnd, numEnd, 16) : stringToDouble(sBegin, sEnd, numEnd);
|
||||
ASSERT(numEnd == sEnd);
|
||||
reader.unget();
|
||||
ASSERT(ch == reader.peek());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
@ -17,7 +17,7 @@
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
@ -77,20 +77,15 @@ namespace JavaScript {
|
||||
class BigInt {
|
||||
enum {maxLgGrossSize = 15}; // Maximum value of lg2(grossSize)
|
||||
static uint32 *freeLists[maxLgGrossSize+1];
|
||||
|
||||
|
||||
uint lgGrossSize; // lg2(grossSize)
|
||||
public:
|
||||
bool negative; // True if negative. Ignored by most
|
||||
// BigInt routines!
|
||||
bool negative; // True if negative. Ignored by most BigInt routines!
|
||||
private:
|
||||
uint32 grossSize; // Number of words allocated for <words>
|
||||
uint32 size; // Actual number of words. If the
|
||||
// number is nonzero, the most
|
||||
// significant word must be nonzero.
|
||||
// If the number is zero, then size is
|
||||
// also 0.
|
||||
uint32 *words; // <size> words of the number, in
|
||||
// little endian order
|
||||
uint32 size; // Actual number of words. If the number is nonzero, the most significant word must be nonzero.
|
||||
// If the number is zero, then size is also 0.
|
||||
uint32 *words; // <size> words of the number, in little endian order
|
||||
void allocate(uint lgGrossSize);
|
||||
void recycle();
|
||||
void initCopy(const BigInt &b);
|
||||
@ -101,7 +96,7 @@ namespace JavaScript {
|
||||
BigInt(const BigInt &b) {initCopy(b);}
|
||||
void operator=(const BigInt &b) {ASSERT(!words); initCopy(b);}
|
||||
~BigInt() {if (words) recycle();}
|
||||
|
||||
|
||||
void setLgGrossSize(uint lgGrossSize);
|
||||
void init(uint32 i);
|
||||
void init(double d, int32 &e, int32 &bits);
|
||||
@ -118,7 +113,7 @@ namespace JavaScript {
|
||||
double b2d(int32 &e) const;
|
||||
double ratio(const BigInt &denominator) const;
|
||||
void s2b(const char *s, int32 nd0, int32 nd, uint32 y9);
|
||||
|
||||
|
||||
uint32 nWords() const {return size;}
|
||||
uint32 word(uint32 i) const {ASSERT(i < size); return words[i];}
|
||||
};
|
||||
@ -137,15 +132,11 @@ namespace JavaScript {
|
||||
//
|
||||
// Keep this in sync with doubleToAsciiModes[].
|
||||
enum DToStrMode {
|
||||
dtosStandard, // Either fixed or exponential format; round-trip
|
||||
dtosStandardExponential, // Always exponential format; round-trip
|
||||
dtosFixed, // Round to <precision> digits after the
|
||||
// decimal point; exponential if number is
|
||||
// large
|
||||
dtosExponential, // Always exponential format; <precision>
|
||||
// significant digits
|
||||
dtosPrecision // Either fixed or exponential format;
|
||||
// <precision> significant digits
|
||||
dtosStandard, // Either fixed or exponential format; round-trip
|
||||
dtosStandardExponential, // Always exponential format; round-trip
|
||||
dtosFixed, // Round to <precision> digits after the decimal point; exponential if number is large
|
||||
dtosExponential, // Always exponential format; <precision> significant digits
|
||||
dtosPrecision // Either fixed or exponential format; <precision> significant digits
|
||||
};
|
||||
|
||||
|
||||
@ -168,24 +159,15 @@ namespace JavaScript {
|
||||
const int dtobasesBufferSize = 1078;
|
||||
|
||||
double strToDouble(const char *str, const char *&numEnd);
|
||||
double stringToDouble(const char16 *str, const char16 *strEnd,
|
||||
const char16 *&numEnd);
|
||||
double stringToInteger(const char16 *str, const char16 *strEnd,
|
||||
const char16 *&numEnd, uint base);
|
||||
double stringToDouble(const char16 *str, const char16 *strEnd, const char16 *&numEnd);
|
||||
double stringToInteger(const char16 *str, const char16 *strEnd, const char16 *&numEnd, uint base);
|
||||
|
||||
char *doubleToStr(char *buffer, size_t bufferSize, double value,
|
||||
DToStrMode mode, int precision);
|
||||
char *doubleToStr(char *buffer, size_t bufferSize, double value, DToStrMode mode, int precision);
|
||||
size_t doubleToBaseStr(char *buffer, double value, uint base);
|
||||
void appendDouble(String &dst, double value,
|
||||
DToStrMode mode = dtosStandard, int precision = 0);
|
||||
inline String &operator+=(String &s, double value) {
|
||||
appendDouble(s, value); return s;
|
||||
}
|
||||
void printDouble(Formatter &f, double value,
|
||||
DToStrMode mode = dtosStandard, int precision = 0);
|
||||
inline Formatter &operator<<(Formatter &f, double value) {
|
||||
printDouble(f, value); return f;
|
||||
}
|
||||
void appendDouble(String &dst, double value, DToStrMode mode = dtosStandard, int precision = 0);
|
||||
inline String &operator+=(String &s, double value) {appendDouble(s, value); return s;}
|
||||
void printDouble(Formatter &f, double value, DToStrMode mode = dtosStandard, int precision = 0);
|
||||
inline Formatter &operator<<(Formatter &f, double value) {printDouble(f, value); return f;}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user