Add support of array initialization like [1,,,'4']

This commit is contained in:
Ilmir Usmanov
2014-09-30 19:44:45 +04:00
parent 9d129e15dc
commit 6561c3fe6c
3 changed files with 23 additions and 1 deletions
+14 -1
View File
@@ -890,8 +890,21 @@ parse_argument_list (argument_list_type alt, idx_t obj)
STACK_PUSH (IDX, token_data ()); STACK_PUSH (IDX, token_data ());
break; break;
} }
case AL_FUNC_EXPR:
case AL_ARRAY_DECL: case AL_ARRAY_DECL:
{
if (token_is (TOK_COMMA))
{
STACK_PUSH (IDX, next_temp_name ());
DUMP_OPCODE_3 (assignment, ID(1), OPCODE_ARG_TYPE_SIMPLE, ECMA_SIMPLE_VALUE_UNDEFINED);
DUMP_OPCODE_3 (meta, OPCODE_META_TYPE_VARG, ID(1), INVALID_VALUE);
STACK_INCR_HEAD(U8, 1);
STACK_DROP (IDX, 1);
skip_newlines ();
continue;
}
/* FALLTHRU */
}
case AL_FUNC_EXPR:
case AL_CONSTRUCT_EXPR: case AL_CONSTRUCT_EXPR:
{ {
parse_assignment_expression (); parse_assignment_expression ();
+3
View File
@@ -156,6 +156,9 @@ dump_variable (idx_t id)
case ECMA_SIMPLE_VALUE_TRUE: \ case ECMA_SIMPLE_VALUE_TRUE: \
__printf ("true"); \ __printf ("true"); \
break; \ break; \
case ECMA_SIMPLE_VALUE_UNDEFINED: \
__printf ("undefined"); \
break; \
default: \ default: \
JERRY_UNREACHABLE (); \ JERRY_UNREACHABLE (); \
} \ } \
+6
View File
@@ -71,3 +71,9 @@ assert(Array.prototype.length === 0);
Array.prototype[0] = 'string value'; Array.prototype[0] = 'string value';
assert(Array.prototype.length === 1); assert(Array.prototype.length === 1);
assert(Array.prototype[0] === 'string value'); assert(Array.prototype[0] === 'string value');
var c = [0,,,'3'];
assert (c[0] === 0);
assert (c[1] === undefined);
assert (c[2] === undefined);
assert (c[3] === '3');