Fix parse of delete operator.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-07-14 20:42:53 +03:00 committed by Evgeny Gavrin
parent c120433158
commit 73d082aa55
2 changed files with 21 additions and 34 deletions

View File

@ -1492,34 +1492,6 @@ dump_delete (operand res, operand op, bool is_strict, locus loc)
const op_meta last_op_meta = last_dumped_op_meta ();
switch (last_op_meta.op.op_idx)
{
case OPCODE (assignment):
{
if (last_op_meta.op.data.assignment.value_right == LITERAL_TO_REWRITE)
{
const operand var_op = literal_operand (last_op_meta.lit_id[2]);
syntax_check_delete (is_strict, loc);
switch (res.type)
{
case OPERAND_LITERAL:
{
const opcode_t opcode = getop_delete_var (LITERAL_TO_REWRITE, LITERAL_TO_REWRITE);
serializer_dump_op_meta (create_op_meta_110 (opcode, res.data.lit_id, var_op.data.lit_id));
break;
}
case OPERAND_TMP:
{
const opcode_t opcode = getop_delete_var (res.data.uid, LITERAL_TO_REWRITE);
serializer_dump_op_meta (create_op_meta_010 (opcode, var_op.data.lit_id));
break;
}
}
}
else
{
dump_boolean_assignment (res, true);
}
break;
}
case OPCODE (prop_getter):
{
const opcode_counter_t oc = (opcode_counter_t) (serializer_get_current_opcode_counter () - 1);
@ -1610,6 +1582,10 @@ dump_delete (operand res, operand op, bool is_strict, locus loc)
}
break;
}
default:
{
dump_boolean_assignment (res, true);
}
}
break;
}

View File

@ -12,17 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var a = 1;
assert (a === 1);
assert (delete a === false);
assert (a === 1);
/* argument is not reference */
assert (delete 0 === true);
assert (delete "0" === true);
assert (delete (a = 1) === true);
assert (delete delete a === true);
/* argument is unresolvable reference */
assert (delete undefined_variable === true);
/* argument is object-based reference */
var a = [1];
assert (a[0] === 1);
assert (delete a[0] === true);
assert (a[0] == undefined);
assert (delete 0 === true);
assert (delete "0" === true);
var b = {c:0};
assert (b.c === 0);
assert (delete b.c === true);
assert (b.c === undefined);
/* argument is lexical environment-based reference */
var a = 1;
assert (a === 1);
assert (delete a === false);
assert (a === 1);