Fix syntax checking of large object literals.

Related issue: #354

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-06-29 20:45:17 +03:00
committed by Evgeny Gavrin
parent 73d082aa55
commit 5e329c815c
2 changed files with 54 additions and 18 deletions
+18 -18
View File
@@ -44,9 +44,9 @@ STATIC_STACK (props, prop_literal)
enum
{
U8_global_size
size_t_stack_global_size
};
STATIC_STACK (U8, uint8_t)
STATIC_STACK (size_t_stack, size_t)
/**
* Get buffer for SyntaxError longjmp label
@@ -82,7 +82,7 @@ create_prop_literal (literal_t lit, prop_type type)
void
syntax_start_checking_of_prop_names (void)
{
STACK_PUSH (U8, (uint8_t) STACK_SIZE (props));
STACK_PUSH (size_t_stack, STACK_SIZE (props));
}
void
@@ -95,13 +95,13 @@ syntax_add_prop_name (operand op, prop_type pt)
void
syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unused___)
{
if (STACK_SIZE (props) - STACK_TOP (U8) < 2)
if (STACK_SIZE (props) - STACK_TOP (size_t_stack) < 2)
{
STACK_DROP (U8, 1);
STACK_DROP (size_t_stack, 1);
return;
}
for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1);
for (size_t i = (STACK_TOP (size_t_stack) + 1);
i < STACK_SIZE (props);
i++)
{
@@ -113,7 +113,7 @@ syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unu
JERRY_ASSERT (previous.type == PROP_DATA
|| previous.type == PROP_GET
|| previous.type == PROP_SET);
for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1))
for (size_t j = STACK_TOP (size_t_stack); j < i; j = j + 1)
{
/*4*/
const prop_literal current = STACK_ELEMENT (props, j);
@@ -157,14 +157,14 @@ syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unu
}
}
STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8)));
STACK_DROP (U8, 1);
STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack)));
STACK_DROP (size_t_stack, 1);
}
void
syntax_start_checking_of_vargs (void)
{
STACK_PUSH (U8, (uint8_t) STACK_SIZE (props));
STACK_PUSH (size_t_stack, STACK_SIZE (props));
}
void syntax_add_varg (operand op)
@@ -203,19 +203,19 @@ syntax_check_for_eval_and_arguments_in_strict_mode (operand op, bool is_strict,
void
syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___)
{
if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict)
if (STACK_SIZE (props) - STACK_TOP (size_t_stack) < 2 || !is_strict)
{
STACK_DROP (U8, 1);
STACK_DROP (size_t_stack, 1);
return;
}
for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1); i < STACK_SIZE (props); i = (uint8_t) (i + 1))
for (size_t i = (STACK_TOP (size_t_stack) + 1u); i < STACK_SIZE (props); i++)
{
JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG);
literal_t previous = STACK_ELEMENT (props, i).lit;
JERRY_ASSERT (previous->get_type () == LIT_STR_T
|| previous->get_type () == LIT_MAGIC_STR_T
|| previous->get_type () == LIT_MAGIC_STR_EX_T);
for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1))
for (size_t j = STACK_TOP (size_t_stack); j < i; j++)
{
JERRY_ASSERT (STACK_ELEMENT (props, j).type == VARG);
literal_t current = STACK_ELEMENT (props, j).lit;
@@ -230,8 +230,8 @@ syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc _
}
}
STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8)));
STACK_DROP (U8, 1);
STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack)));
STACK_DROP (size_t_stack, 1);
}
void
@@ -247,13 +247,13 @@ void
syntax_init (void)
{
STACK_INIT (props);
STACK_INIT (U8);
STACK_INIT (size_t_stack);
}
void
syntax_free (void)
{
STACK_FREE (U8);
STACK_FREE (size_t_stack);
STACK_FREE (props);
}
+36
View File
@@ -90,3 +90,39 @@ a.q;
a.q = 1;
assert (flow == 'get: undefined, set: undefined');
// FIXME: change to 'eval' after large object literals byte-code representation would be fixed (issue #276)
f = new Function("obj = { \
'1': '', '2': '', '3': '', '4': '', '5': '', '6': '', '7': '', '8': '', \
'9': '', '10': '', '11': '', '12': '', '13': '', '14': '', '15': '', '16': '', \
'17': '', '18': '', '19': '', '20': '', '21': '', '22': '', '23': '', '24': '', \
'25': '', '26': '', '27': '', '28': '', '29': '', '30': '', '31': '', '32': '', \
'33': '', '34': '', '35': '', '36': '', '37': '', '38': '', '39': '', '40': '', \
'41': '', '42': '', '43': '', '44': '', '45': '', '46': '', '47': '', '48': '', \
'49': '', '50': '', '51': '', '52': '', '53': '', '54': '', '55': '', '56': '', \
'57': '', '58': '', '59': '', '60': '', '61': '', '62': '', '63': '', '64': '', \
'65': '', '66': '', '67': '', '68': '', '69': '', '70': '', '71': '', '72': '', \
'73': '', '74': '', '75': '', '76': '', '77': '', '78': '', '79': '', '80': '', \
'81': '', '82': '', '83': '', '84': '', '85': '', '86': '', '87': '', '88': '', \
'89': '', '90': '', '91': '', '92': '', '93': '', '94': '', '95': '', '96': '', \
'97': '', '98': '', '99': '', '100': '', '101': '', '102': '', '103': '', '104': '', \
'105': '', '106': '', '107': '', '108': '', '109': '', '110': '', '111': '', '112': '', \
'113': '', '114': '', '115': '', '116': '', '117': '', '118': '', '119': '', '120': '', \
'121': '', '122': '', '123': '', '124': '', '125': '', '126': '', '127': '', '128': '', \
'129': '', '130': '', '131': '', '132': '', '133': '', '134': '', '135': '', '136': '', \
'137': '', '138': '', '139': '', '140': '', '141': '', '142': '', '143': '', '144': '', \
'145': '', '146': '', '147': '', '148': '', '149': '', '150': '', '151': '', '152': '', \
'153': '', '154': '', '155': '', '156': '', '157': '', '158': '', '159': '', '160': '', \
'161': '', '162': '', '163': '', '164': '', '165': '', '166': '', '167': '', '168': '', \
'169': '', '170': '', '171': '', '172': '', '173': '', '174': '', '175': '', '176': '', \
'177': '', '178': '', '179': '', '180': '', '181': '', '182': '', '183': '', '184': '', \
'185': '', '186': '', '187': '', '188': '', '189': '', '190': '', '191': '', '192': '', \
'193': '', '194': '', '195': '', '196': '', '197': '', '198': '', '199': '', '200': '', \
'201': '', '202': '', '203': '', '204': '', '205': '', '206': '', '207': '', '208': '', \
'209': '', '210': '', '211': '', '212': '', '213': '', '214': '', '215': '', '216': '', \
'217': '', '218': '', '219': '', '220': '', '221': '', '222': '', '223': '', '224': '', \
'225': '', '226': '', '227': '', '228': '', '229': '', '230': '', '231': '', '232': '', \
'233': '', '234': '', '235': '', '236': '', '237': '', '238': '', '239': '', '240': '', \
'241': '', '242': '', '243': '', '244': '', '245': '', '246': '', '247': '', '248': '', \
'249': '', '250': '', '251': '', '252': '', '253': '', '254': '', '255': '', \
'256': '', 257: '' };");