mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877639 - Switch some code in frontend/FoldConstants.cpp from getOp() to getKind(). r=jwalden.
--HG-- extra : rebase_source : 97c448dc52660fc0257d81730b1c07eb2b89df40
This commit is contained in:
parent
5e57980546
commit
35b0ae8709
@ -203,39 +203,20 @@ enum Truthiness { Truthy, Falsy, Unknown };
|
||||
static Truthiness
|
||||
Boolish(ParseNode *pn)
|
||||
{
|
||||
switch (pn->getOp()) {
|
||||
case JSOP_DOUBLE:
|
||||
switch (pn->getKind()) {
|
||||
case PNK_NUMBER:
|
||||
return (pn->pn_dval != 0 && !IsNaN(pn->pn_dval)) ? Truthy : Falsy;
|
||||
|
||||
case JSOP_STRING:
|
||||
case PNK_STRING:
|
||||
return (pn->pn_atom->length() > 0) ? Truthy : Falsy;
|
||||
|
||||
#if JS_HAS_GENERATOR_EXPRS
|
||||
case JSOP_CALL:
|
||||
{
|
||||
/*
|
||||
* A generator expression as an if or loop condition has no effects, it
|
||||
* simply results in a truthy object reference. This condition folding
|
||||
* is needed for the decompiler. See bug 442342 and bug 443074.
|
||||
*/
|
||||
if (pn->pn_count != 1)
|
||||
return Unknown;
|
||||
ParseNode *pn2 = pn->pn_head;
|
||||
if (!pn2->isKind(PNK_FUNCTION))
|
||||
return Unknown;
|
||||
if (!(pn2->pn_funbox->inGenexpLambda))
|
||||
return Unknown;
|
||||
return Truthy;
|
||||
}
|
||||
#endif
|
||||
|
||||
case JSOP_DEFFUN:
|
||||
case JSOP_LAMBDA:
|
||||
case JSOP_TRUE:
|
||||
case PNK_TRUE:
|
||||
case PNK_FUNCTION:
|
||||
case PNK_GENEXP:
|
||||
return Truthy;
|
||||
|
||||
case JSOP_NULL:
|
||||
case JSOP_FALSE:
|
||||
case PNK_FALSE:
|
||||
case PNK_NULL:
|
||||
return Falsy;
|
||||
|
||||
default:
|
||||
@ -671,19 +652,19 @@ FoldConstants<FullParseHandler>(JSContext *cx, ParseNode **pnp,
|
||||
|
||||
/* Operate on one numeric constant. */
|
||||
d = pn1->pn_dval;
|
||||
switch (pn->getOp()) {
|
||||
case JSOP_BITNOT:
|
||||
switch (pn->getKind()) {
|
||||
case PNK_BITNOT:
|
||||
d = ~ToInt32(d);
|
||||
break;
|
||||
|
||||
case JSOP_NEG:
|
||||
case PNK_NEG:
|
||||
d = -d;
|
||||
break;
|
||||
|
||||
case JSOP_POS:
|
||||
case PNK_POS:
|
||||
break;
|
||||
|
||||
case JSOP_NOT:
|
||||
case PNK_NOT:
|
||||
if (d == 0 || IsNaN(d)) {
|
||||
pn->setKind(PNK_TRUE);
|
||||
pn->setOp(JSOP_TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user