Skip to content

Commit 140982e

Browse files
committed
Fix PropertyName not to be resolved as a local variable
JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee [email protected] JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee [email protected]
1 parent 7022aa2 commit 140982e

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

jerry-core/parser/js/opcodes-dumper.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ dumper_try_replace_identifier_name_with_reg (scopes_tree tree, /**< a function s
325325
#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \
326326
if (opcode == VM_OP_ ## opcode_name_uppercase) \
327327
{ \
328-
JERRY_STATIC_ASSERT (((arg1_type) & VM_OP_ARG_TYPE_TYPE_OF_NEXT) == 0); \
329-
\
330328
/*
331329
* See also:
332330
* The loop below
333331
*/ \
334332
\
335333
JERRY_ASSERT ((opcode == VM_OP_ASSIGNMENT && (arg2_type) == VM_OP_ARG_TYPE_TYPE_OF_NEXT) \
336334
|| (opcode != VM_OP_ASSIGNMENT && ((arg2_type) & VM_OP_ARG_TYPE_TYPE_OF_NEXT) == 0)); \
335+
JERRY_ASSERT ((opcode == VM_OP_META && ((arg1_type) & VM_OP_ARG_TYPE_TYPE_OF_NEXT) != 0) \
336+
|| (opcode != VM_OP_META && ((arg1_type) & VM_OP_ARG_TYPE_TYPE_OF_NEXT) == 0)); \
337337
JERRY_STATIC_ASSERT (((arg3_type) & VM_OP_ARG_TYPE_TYPE_OF_NEXT) == 0); \
338338
args_num = 3; \
339339
}
@@ -343,7 +343,8 @@ dumper_try_replace_identifier_name_with_reg (scopes_tree tree, /**< a function s
343343
for (int arg_index = 0; arg_index < args_num; arg_index++)
344344
{
345345
/*
346-
* This is the only opcode with statically unspecified argument type (checked by assertions above)
346+
* 'assignment' and 'meta' are the only opcodes with statically unspecified argument type
347+
* (checked by assertions above)
347348
*/
348349
if (opcode == VM_OP_ASSIGNMENT
349350
&& arg_index == 1
@@ -352,6 +353,15 @@ dumper_try_replace_identifier_name_with_reg (scopes_tree tree, /**< a function s
352353
break;
353354
}
354355

356+
if (opcode == VM_OP_META
357+
&& (om.op.data.meta.type == OPCODE_META_TYPE_VARG_PROP_DATA
358+
|| om.op.data.meta.type == OPCODE_META_TYPE_VARG_PROP_GETTER
359+
|| om.op.data.meta.type == OPCODE_META_TYPE_VARG_PROP_SETTER)
360+
&& arg_index == 1)
361+
{
362+
continue;
363+
}
364+
355365
if (om.lit_id[arg_index].packed_value == lit_cp.packed_value)
356366
{
357367
om.lit_id[arg_index] = NOT_A_LITERAL;

jerry-core/vm/vm-opcodes.inc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ VM_OP_3 (reg_var_decl, REG_VAR_DECL,
298298
arg_regs_num, VM_OP_ARG_TYPE_INTEGER_CONST)
299299

300300
VM_OP_3 (meta, META,
301-
type, VM_OP_ARG_TYPE_INTEGER_CONST,
301+
type, VM_OP_ARG_TYPE_INTEGER_CONST |
302+
VM_OP_ARG_TYPE_TYPE_OF_NEXT,
302303
data_1, VM_OP_ARG_TYPE_INTEGER_CONST |
303304
VM_OP_ARG_TYPE_STRING |
304305
VM_OP_ARG_TYPE_VARIABLE,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
function f(a, b) {
17+
return {
18+
a: a,
19+
b: b
20+
};
21+
}
22+
23+
var o = f('1', '2');
24+
25+
assert(o.a == '1');
26+
assert(o.b == '2');

0 commit comments

Comments
 (0)