13
13
* limitations under the License.
14
14
*/
15
15
16
- #include " mem-allocator .h"
16
+ #include " ecma-helpers .h"
17
17
#include " jrt-libc-includes.h"
18
+ #include " jsp-mm.h"
18
19
#include " lexer.h"
19
20
#include " syntax-errors.h"
20
- #include " ecma-helpers.h"
21
21
22
22
static token saved_token, prev_token, sent_token, empty_token;
23
23
@@ -474,9 +474,7 @@ convert_string_to_token_transform_escape_seq (token_type tok_type, /**< type of
474
474
JERRY_ASSERT (source_str_p != NULL );
475
475
}
476
476
477
- MEM_DEFINE_LOCAL_ARRAY (str_buf_p,
478
- source_str_size,
479
- ecma_char_t );
477
+ ecma_char_t *str_buf_p = (ecma_char_t *) jsp_mm_alloc (source_str_size * sizeof (ecma_char_t ));
480
478
481
479
const char *source_str_iter_p = source_str_p;
482
480
ecma_char_t *str_buf_iter_p = str_buf_p;
@@ -632,7 +630,7 @@ convert_string_to_token_transform_escape_seq (token_type tok_type, /**< type of
632
630
PARSE_ERROR (" Malformed escape sequence" , source_str_p - buffer_start);
633
631
}
634
632
635
- MEM_FINALIZE_LOCAL_ARRAY (str_buf_p);
633
+ jsp_mm_free (str_buf_p);
636
634
637
635
return ret;
638
636
} /* convert_string_to_token_transform_escape_seq */
@@ -860,13 +858,12 @@ parse_number (void)
860
858
tok_length = (size_t ) (buffer - token_start);;
861
859
if (is_fp || is_exp)
862
860
{
863
- ecma_char_t *temp = (ecma_char_t *) mem_heap_alloc_block ((size_t ) (tok_length + 1 ),
864
- MEM_HEAP_ALLOC_SHORT_TERM);
861
+ ecma_char_t *temp = (ecma_char_t *) jsp_mm_alloc ((size_t ) (tok_length + 1 ) * sizeof (ecma_char_t ));
865
862
strncpy ((char *) temp, token_start, (size_t ) (tok_length));
866
863
temp[tok_length] = ' \0 ' ;
867
864
ecma_number_t res = ecma_zt_string_to_number (temp);
868
865
JERRY_ASSERT (!ecma_number_is_nan (res));
869
- mem_heap_free_block (temp);
866
+ jsp_mm_free (temp);
870
867
known_token = convert_seen_num_to_token (res);
871
868
token_start = NULL ;
872
869
return known_token;
@@ -1467,28 +1464,22 @@ lexer_are_tokens_with_same_identifier (token id1, /**< identifier token (TOK_NAM
1467
1464
} /* lexer_are_tokens_with_same_identifier */
1468
1465
1469
1466
/* *
1470
- * Initialize lexer to start parsing of a new source
1467
+ * Intitialize lexer
1471
1468
*/
1472
1469
void
1473
- lexer_init_source (const char *source, /* *< script source */
1474
- size_t source_size) /* *< script source size in bytes */
1470
+ lexer_init (const char *source, /* *< script source */
1471
+ size_t source_size /* *< script source size in bytes */ ,
1472
+ bool show_opcodes) /* *< flag indicating if to dump opcodes */
1475
1473
{
1474
+ empty_token.type = TOK_EMPTY;
1475
+ empty_token.uid = 0 ;
1476
+ empty_token.loc = 0 ;
1477
+
1476
1478
saved_token = prev_token = sent_token = empty_token;
1477
1479
1478
1480
buffer_size = source_size;
1479
1481
lexer_set_source (source);
1480
1482
lexer_set_strict_mode (false );
1481
- } /* lexer_init_source */
1482
-
1483
- /* *
1484
- * Intitialize lexer
1485
- */
1486
- void
1487
- lexer_init (bool show_opcodes) /* *< flag indicating if to dump opcodes */
1488
- {
1489
- empty_token.type = TOK_EMPTY;
1490
- empty_token.uid = 0 ;
1491
- empty_token.loc = 0 ;
1492
1483
1493
1484
#ifndef JERRY_NDEBUG
1494
1485
allow_dump_lines = show_opcodes;
@@ -1497,8 +1488,3 @@ lexer_init (bool show_opcodes) /**< flag indicating if to dump opcodes */
1497
1488
allow_dump_lines = false ;
1498
1489
#endif /* JERRY_NDEBUG */
1499
1490
} /* lexer_init */
1500
-
1501
- void
1502
- lexer_free (void )
1503
- {
1504
- }
0 commit comments