зеркало из https://github.com/mozilla/pjs.git
Fix conditional expressions (401405, r=mrbkap).
This commit is contained in:
Родитель
d93da83113
Коммит
456558695a
|
@ -499,7 +499,7 @@ function execute(n, x) {
|
||||||
putValue(r, v, n[0]);
|
putValue(r, v, n[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONDITIONAL:
|
case HOOK:
|
||||||
v = getValue(execute(n[0], x)) ? getValue(execute(n[1], x))
|
v = getValue(execute(n[0], x)) ? getValue(execute(n[1], x))
|
||||||
: getValue(execute(n[2], x));
|
: getValue(execute(n[2], x));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -642,7 +642,7 @@ function ParenExpression(t, x) {
|
||||||
var opPrecedence = {
|
var opPrecedence = {
|
||||||
SEMICOLON: 0,
|
SEMICOLON: 0,
|
||||||
COMMA: 1,
|
COMMA: 1,
|
||||||
ASSIGN: 2, HOOK: 2, COLON: 2, CONDITIONAL: 2,
|
ASSIGN: 2, HOOK: 2, COLON: 2,
|
||||||
// The above all have to have the same precedence, see bug 330975.
|
// The above all have to have the same precedence, see bug 330975.
|
||||||
OR: 4,
|
OR: 4,
|
||||||
AND: 5,
|
AND: 5,
|
||||||
|
@ -668,7 +668,7 @@ for (i in opPrecedence)
|
||||||
var opArity = {
|
var opArity = {
|
||||||
COMMA: -2,
|
COMMA: -2,
|
||||||
ASSIGN: 2,
|
ASSIGN: 2,
|
||||||
CONDITIONAL: 3,
|
HOOK: 3,
|
||||||
OR: 2,
|
OR: 2,
|
||||||
AND: 2,
|
AND: 2,
|
||||||
BITWISE_OR: 2,
|
BITWISE_OR: 2,
|
||||||
|
@ -751,7 +751,6 @@ loop:
|
||||||
n = operators.top();
|
n = operators.top();
|
||||||
if (n.type != HOOK)
|
if (n.type != HOOK)
|
||||||
throw t.newSyntaxError("Invalid label");
|
throw t.newSyntaxError("Invalid label");
|
||||||
n.type = CONDITIONAL;
|
|
||||||
--x.hookLevel;
|
--x.hookLevel;
|
||||||
} else {
|
} else {
|
||||||
operators.push(new Node(t));
|
operators.push(new Node(t));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче