Skip to content

Commit 142f79c

Browse files
authored
Properly handle CBC_PUSH_THIS_LITERAL for unary lvalue operations (#3054)
This patch fixes #3048. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 4afcc70 commit 142f79c

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

jerry-core/parser/js/js-parser-expr.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ static void
8383
parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
8484
cbc_opcode_t opcode) /**< opcode */
8585
{
86-
if (PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode)
86+
if ((PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode)
87+
|| context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL)
8788
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
8889
{
8990
if (context_p->status_flags & PARSER_IS_STRICT)
@@ -124,6 +125,13 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
124125
CBC_DELETE_IDENT_PUSH_RESULT,
125126
context_p->last_cbc.value);
126127
}
128+
else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL)
129+
{
130+
context_p->last_cbc_opcode = CBC_PUSH_THIS;
131+
parser_emit_cbc_literal (context_p,
132+
CBC_DELETE_IDENT_PUSH_RESULT,
133+
context_p->lit_object.index);
134+
}
127135
else
128136
{
129137
JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS);
@@ -149,6 +157,13 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
149157
(uint16_t) (opcode + CBC_UNARY_LVALUE_WITH_IDENT),
150158
context_p->last_cbc.value);
151159
}
160+
else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL)
161+
{
162+
context_p->last_cbc_opcode = CBC_PUSH_THIS;
163+
parser_emit_cbc_literal (context_p,
164+
(uint16_t) (opcode + CBC_UNARY_LVALUE_WITH_IDENT),
165+
context_p->lit_object.index);
166+
}
152167
else
153168
{
154169
JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS);
@@ -164,14 +179,6 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
164179
JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_PROP, opcode));
165180
context_p->last_cbc_opcode = (uint16_t) opcode;
166181
}
167-
else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL
168-
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
169-
{
170-
context_p->last_cbc_opcode = CBC_PUSH_THIS;
171-
parser_emit_cbc_literal (context_p,
172-
(uint16_t) (opcode + CBC_UNARY_LVALUE_WITH_IDENT),
173-
context_p->lit_object.index);
174-
}
175182
else
176183
{
177184
switch (context_p->last_cbc_opcode)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
this[delete $];

0 commit comments

Comments
 (0)