@@ -628,25 +628,23 @@ dump_prop_setter_or_triple_address_res (vm_op_t opcode,
628628 jsp_operand_t res,
629629 jsp_operand_t op)
630630{
631- const op_meta last = STACK_TOP (prop_getters);
632- if (last.op .op_idx == VM_OP_PROP_GETTER)
631+ if (res.is_register_operand ())
633632 {
633+ /*
634+ * Left-hand-side must be a member expression and corresponding prop_getter
635+ * op is on top of the stack.
636+ */
637+ const op_meta last = STACK_TOP (prop_getters);
638+ JERRY_ASSERT (last.op .op_idx == VM_OP_PROP_GETTER);
639+
634640 res = dump_triple_address_and_prop_setter_res (opcode, last, op);
641+
642+ STACK_DROP (prop_getters, 1 );
635643 }
636644 else
637645 {
638- if (res.is_register_operand ())
639- {
640- /*
641- * FIXME:
642- * Implement correct handling of references through parser operands
643- */
644- PARSE_ERROR (JSP_EARLY_ERROR_REFERENCE, " Invalid left-hand-side expression" , LIT_ITERATOR_POS_ZERO);
645- }
646-
647646 dump_triple_address (opcode, res, res, op);
648647 }
649- STACK_DROP (prop_getters, 1 );
650648 return res;
651649}
652650
@@ -1865,37 +1863,60 @@ rewrite_jump_to_end (void)
18651863}
18661864
18671865void
1868- start_dumping_assignment_expression (void )
1866+ start_dumping_assignment_expression (jsp_operand_t lhs, locus loc __attr_unused___ )
18691867{
1870- const op_meta last = last_dumped_op_meta ();
1871- if (last.op .op_idx == VM_OP_PROP_GETTER)
1868+ if (lhs.is_register_operand ())
18721869 {
1873- serializer_set_writing_position ((vm_instr_counter_t ) (serializer_get_current_instr_counter () - 1 ));
1870+ /*
1871+ * Having left-handside of assignment expression as a temporary register
1872+ * means it's either a member expression or something else. Under the condition,
1873+ * only member expression could be a L-value for assignment expression, otherwise
1874+ * it's an invalid lhs expression.
1875+ */
1876+
1877+ const op_meta last = last_dumped_op_meta ();
1878+
1879+ if (last.op .op_idx == VM_OP_PROP_GETTER)
1880+ {
1881+ /*
1882+ * If lhs is a member expression, last dumped op code should be
1883+ * prop_getter. For we are going to use the expression as L-value, it will
1884+ * be a prop_setter later, save the op to stack.
1885+ */
1886+ serializer_set_writing_position ((vm_instr_counter_t ) (serializer_get_current_instr_counter () - 1 ));
1887+ STACK_PUSH (prop_getters, last);
1888+ }
1889+ else
1890+ {
1891+ /*
1892+ * If lhs is a temporary register operand but not a member expression, It
1893+ * is an invalid left-hand-side expression.
1894+ */
1895+ PARSE_ERROR (JSP_EARLY_ERROR_REFERENCE, " Invalid left-hand-side expression" , loc);
1896+ }
18741897 }
1875- STACK_PUSH (prop_getters, last);
18761898}
18771899
18781900jsp_operand_t
18791901dump_prop_setter_or_variable_assignment_res (jsp_operand_t res, jsp_operand_t op)
18801902{
1881- const op_meta last = STACK_TOP (prop_getters);
1882- if (last.op .op_idx == VM_OP_PROP_GETTER)
1903+ if (res.is_register_operand ())
18831904 {
1905+ /*
1906+ * Left-hand-side must be a member expression and corresponding prop_getter
1907+ * op is on top of the stack.
1908+ */
1909+ const op_meta last = STACK_TOP (prop_getters);
1910+ JERRY_ASSERT (last.op .op_idx == VM_OP_PROP_GETTER);
1911+
18841912 dump_prop_setter_op_meta (last, op);
1913+
1914+ STACK_DROP (prop_getters, 1 );
18851915 }
18861916 else
18871917 {
1888- if (res.is_register_operand ())
1889- {
1890- /*
1891- * FIXME:
1892- * Implement correct handling of references through parser operands
1893- */
1894- PARSE_ERROR (JSP_EARLY_ERROR_REFERENCE, " Invalid left-hand-side expression" , LIT_ITERATOR_POS_ZERO);
1895- }
18961918 dump_variable_assignment (res, op);
18971919 }
1898- STACK_DROP (prop_getters, 1 );
18991920 return op;
19001921}
19011922
0 commit comments