mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-13 23:17:57 +00:00
Bug 696941 - Privatize Token::u::dval. r=cdleary
This commit is contained in:
parent
2b6d3e6f09
commit
a81490ead7
@ -7240,7 +7240,7 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
pn3 = NullaryNode::create(tc);
|
||||
if (!pn3)
|
||||
return NULL;
|
||||
pn3->pn_dval = tokenStream.currentToken().t_dval;
|
||||
pn3->pn_dval = tokenStream.currentToken().number();
|
||||
if (!js_ValueToAtom(context, DoubleValue(pn3->pn_dval), &atom))
|
||||
return NULL;
|
||||
break;
|
||||
@ -7266,7 +7266,7 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
pn3 = NullaryNode::create(tc);
|
||||
if (!pn3)
|
||||
return NULL;
|
||||
pn3->pn_dval = tokenStream.currentToken().t_dval;
|
||||
pn3->pn_dval = tokenStream.currentToken().number();
|
||||
if (!js_ValueToAtom(context, DoubleValue(pn3->pn_dval), &atom))
|
||||
return NULL;
|
||||
} else {
|
||||
@ -7412,7 +7412,7 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
pn = UnaryNode::create(tc);
|
||||
if (!pn)
|
||||
return NULL;
|
||||
pn->pn_num = (jsint) tokenStream.currentToken().t_dval;
|
||||
pn->pn_num = tokenStream.currentToken().sharpNumber();
|
||||
tt = tokenStream.getToken(TSF_OPERAND);
|
||||
pn->pn_kid = primaryExpr(tt, JS_FALSE);
|
||||
if (!pn->pn_kid)
|
||||
@ -7436,7 +7436,7 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
return NULL;
|
||||
if (!tc->ensureSharpSlots())
|
||||
return NULL;
|
||||
pn->pn_num = (jsint) tokenStream.currentToken().t_dval;
|
||||
pn->pn_num = tokenStream.currentToken().sharpNumber();
|
||||
break;
|
||||
#endif /* JS_HAS_SHARP_VARS */
|
||||
|
||||
@ -7667,7 +7667,7 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
|
||||
if (!pn)
|
||||
return NULL;
|
||||
pn->setOp(JSOP_DOUBLE);
|
||||
pn->pn_dval = tokenStream.currentToken().t_dval;
|
||||
pn->pn_dval = tokenStream.currentToken().number();
|
||||
break;
|
||||
|
||||
case TOK_PRIMARY:
|
||||
|
@ -1713,7 +1713,7 @@ TokenStream::getTokenInternal()
|
||||
if (!js_strtod(cx, numStart, userbuf.addressOfNextRawChar(), &dummy, &dval))
|
||||
goto error;
|
||||
}
|
||||
tp->t_dval = dval;
|
||||
tp->setNumber(dval);
|
||||
tt = TOK_NUMBER;
|
||||
goto out;
|
||||
}
|
||||
@ -1799,7 +1799,7 @@ TokenStream::getTokenInternal()
|
||||
const jschar *dummy;
|
||||
if (!GetPrefixInteger(cx, numStart, userbuf.addressOfNextRawChar(), radix, &dummy, &dval))
|
||||
goto error;
|
||||
tp->t_dval = dval;
|
||||
tp->setNumber(dval);
|
||||
tt = TOK_NUMBER;
|
||||
goto out;
|
||||
}
|
||||
@ -2071,9 +2071,8 @@ TokenStream::getTokenInternal()
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
tp->t_dval = (jsdouble) n;
|
||||
if (cx->hasStrictOption() &&
|
||||
(c == '=' || c == '#')) {
|
||||
tp->setSharpNumber(uint16(n));
|
||||
if (cx->hasStrictOption() && (c == '=' || c == '#')) {
|
||||
char buf[20];
|
||||
JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
|
||||
if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
|
@ -265,14 +265,15 @@ struct Token {
|
||||
JSAtom *atom; /* potentially-numeric atom */
|
||||
} n;
|
||||
} s;
|
||||
class { /* pair for <?target data?> XML PI */
|
||||
friend struct Token;
|
||||
|
||||
private:
|
||||
friend struct Token;
|
||||
struct { /* pair for <?target data?> XML PI */
|
||||
JSAtom *data; /* auxiliary atom table entry */
|
||||
PropertyName *target; /* main atom table entry */
|
||||
} xmlpi;
|
||||
jsdouble dval; /* floating point number */
|
||||
private:
|
||||
friend struct Token;
|
||||
uint16 sharpNumber; /* sharp variable number: #1# or #1= */
|
||||
jsdouble number; /* floating point number */
|
||||
RegExpFlag reflags; /* regexp flags, use tokenbuf to access
|
||||
regexp chars */
|
||||
} u;
|
||||
@ -306,6 +307,14 @@ struct Token {
|
||||
u.reflags = flags;
|
||||
}
|
||||
|
||||
void setSharpNumber(uint16 sharpNum) {
|
||||
u.sharpNumber = sharpNum;
|
||||
}
|
||||
|
||||
void setNumber(jsdouble n) {
|
||||
u.number = n;
|
||||
}
|
||||
|
||||
/* Type-safe accessors */
|
||||
|
||||
PropertyName *name() const {
|
||||
@ -338,10 +347,19 @@ struct Token {
|
||||
JS_ASSERT((u.reflags & AllFlags) == u.reflags);
|
||||
return u.reflags;
|
||||
}
|
||||
|
||||
uint16 sharpNumber() const {
|
||||
JS_ASSERT(type == TOK_DEFSHARP || type == TOK_USESHARP);
|
||||
return u.sharpNumber;
|
||||
}
|
||||
|
||||
jsdouble number() const {
|
||||
JS_ASSERT(type == TOK_NUMBER);
|
||||
return u.number;
|
||||
}
|
||||
};
|
||||
|
||||
#define t_op u.s.op
|
||||
#define t_dval u.dval
|
||||
|
||||
enum TokenStreamFlags
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user