Fix reg_var_decl generation.

This commit is contained in:
Ilmir Usmanov
2014-09-23 20:05:10 +04:00
parent 6c422fec2e
commit d26b7f9f4e
2 changed files with 10 additions and 29 deletions
+7 -17
View File
@@ -290,7 +290,12 @@ lp_string_hash (lp_string str)
static idx_t static idx_t
next_temp_name (void) next_temp_name (void)
{ {
return TEMP_NAME()++; TEMP_NAME ()++;
if (MAX_TEMP_NAME () < TEMP_NAME ())
{
MAX_TEMP_NAME () = TEMP_NAME ();
}
return TEMP_NAME ();
} }
static void static void
@@ -310,10 +315,6 @@ finish_scope (void)
static void static void
reset_temp_name (void) reset_temp_name (void)
{ {
if (MAX_TEMP_NAME() < TEMP_NAME())
{
MAX_TEMP_NAME() = TEMP_NAME();
}
TEMP_NAME() = MIN_TEMP_NAME(); TEMP_NAME() = MIN_TEMP_NAME();
} }
@@ -2795,18 +2796,7 @@ parse_source_element_list (void)
skip_newlines (); skip_newlines ();
} }
lexer_save_token (TOK ()); lexer_save_token (TOK ());
if (MAX_TEMP_NAME () > MIN_TEMP_NAME ()) REWRITE_OPCODE_2 (STACK_HEAD (U16, 1), reg_var_decl, MIN_TEMP_NAME (), MAX_TEMP_NAME ());
{
REWRITE_OPCODE_2 (STACK_HEAD (U16, 1), reg_var_decl, MIN_TEMP_NAME (), MAX_TEMP_NAME () - 1);
}
else if (MAX_TEMP_NAME () == MIN_TEMP_NAME ())
{
REWRITE_OPCODE_2 (STACK_HEAD (U16, 1), reg_var_decl, MIN_TEMP_NAME (), MAX_TEMP_NAME ());
}
else
{
JERRY_UNREACHABLE ();
}
finish_scope (); finish_scope ();
STACK_DROP (U16, 1); STACK_DROP (U16, 1);
+3 -12
View File
@@ -19,29 +19,20 @@
const ecma_char_t * const ecma_char_t *
deserialize_string_by_id (uint8_t id) deserialize_string_by_id (uint8_t id)
{ {
JERRY_ASSERT (id < bytecode_data.strs_count);
JERRY_ASSERT (bytecode_data.strings[id].str[bytecode_data.strings[id].length] == '\0'); JERRY_ASSERT (bytecode_data.strings[id].str[bytecode_data.strings[id].length] == '\0');
if (id >= bytecode_data.strs_count)
{
return NULL;
}
return ((const ecma_char_t *) bytecode_data.strings[id].str); return ((const ecma_char_t *) bytecode_data.strings[id].str);
} }
ecma_number_t ecma_number_t
deserialize_num_by_id (uint8_t id) deserialize_num_by_id (uint8_t id)
{ {
if (id < bytecode_data.strs_count) JERRY_ASSERT (id >= bytecode_data.strs_count);
{
return 0;
}
id = (uint8_t) (id - bytecode_data.strs_count); id = (uint8_t) (id - bytecode_data.strs_count);
if (id >= bytecode_data.nums_count) JERRY_ASSERT (id < bytecode_data.nums_count);
{
return 0;
}
return bytecode_data.nums[id]; return bytecode_data.nums[id];
} }