Fix parse of preincrement / predecrement, applied to 'obj.prop'-like expressions.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
committed by
Evgeny Gavrin
parent
6fe78cc994
commit
0e8cb596d7
@@ -1041,7 +1041,12 @@ parse_left_hand_side_expression (operand *this_arg, operand *prop)
|
|||||||
: left_hand_side_expression ('++' | '--')?
|
: left_hand_side_expression ('++' | '--')?
|
||||||
; */
|
; */
|
||||||
static operand
|
static operand
|
||||||
parse_postfix_expression (void)
|
parse_postfix_expression (operand *out_this_arg_gl_p, /**< out: if expression evaluates to object-based
|
||||||
|
* reference - the reference's base;
|
||||||
|
* otherwise - empty operand */
|
||||||
|
operand *out_prop_gl_p) /**< out: if expression evaluates to object-based
|
||||||
|
* reference - the reference's name;
|
||||||
|
* otherwise - empty operand */
|
||||||
{
|
{
|
||||||
operand this_arg = empty_operand (), prop = empty_operand ();
|
operand this_arg = empty_operand (), prop = empty_operand ();
|
||||||
operand expr = parse_left_hand_side_expression (&this_arg, &prop);
|
operand expr = parse_left_hand_side_expression (&this_arg, &prop);
|
||||||
@@ -1079,8 +1084,18 @@ parse_postfix_expression (void)
|
|||||||
lexer_save_token (tok);
|
lexer_save_token (tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out_this_arg_gl_p != NULL)
|
||||||
|
{
|
||||||
|
*out_this_arg_gl_p = this_arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out_prop_gl_p != NULL)
|
||||||
|
{
|
||||||
|
*out_prop_gl_p = prop;
|
||||||
|
}
|
||||||
|
|
||||||
return expr;
|
return expr;
|
||||||
}
|
} /* parse_postfix_expression */
|
||||||
|
|
||||||
/* unary_expression
|
/* unary_expression
|
||||||
: postfix_expression
|
: postfix_expression
|
||||||
@@ -1172,7 +1187,7 @@ parse_unary_expression (operand *this_arg_gl, operand *prop_gl)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
expr = parse_postfix_expression ();
|
expr = parse_postfix_expression (&this_arg, &prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,3 +36,10 @@ assert(c == 21);
|
|||||||
|
|
||||||
c = a--;
|
c = a--;
|
||||||
assert(c == 22);
|
assert(c == 22);
|
||||||
|
|
||||||
|
var o = { p : 1 };
|
||||||
|
|
||||||
|
assert (++o.p === 2);
|
||||||
|
assert (o.p === 2);
|
||||||
|
assert (--o.p === 1);
|
||||||
|
assert (o.p === 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user