14
14
*/
15
15
16
16
#include "ecma-conversion.h"
17
+ #include "ecma-errors.h"
17
18
#include "ecma-exceptions.h"
18
19
#include "ecma-function-object.h"
19
20
#include "ecma-helpers.h"
@@ -155,8 +156,8 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
155
156
156
157
if (globals_p -> snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET )
157
158
{
158
- const char * const error_message_p = "Maximum snapshot size reached" ;
159
- globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
159
+ globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE ,
160
+ (const jerry_char_t * ) ecma_error_maximum_snapshot_size );
160
161
return 0 ;
161
162
}
162
163
@@ -170,8 +171,8 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
170
171
#if JERRY_ESNEXT
171
172
if (compiled_code_p -> status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS )
172
173
{
173
- const char * const error_message_p = "Unsupported feature: tagged template literals" ;
174
- globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
174
+ globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE ,
175
+ (const jerry_char_t * ) ecma_error_tagged_template_literals );
175
176
return 0 ;
176
177
}
177
178
@@ -187,7 +188,8 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
187
188
/* Regular expression. */
188
189
if (globals_p -> snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t ) > snapshot_buffer_size )
189
190
{
190
- globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE , error_buffer_too_small_p );
191
+ globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE ,
192
+ (const jerry_char_t * ) error_buffer_too_small_p );
191
193
return 0 ;
192
194
}
193
195
@@ -208,7 +210,8 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
208
210
buffer_p ,
209
211
buffer_size ))
210
212
{
211
- globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE , error_buffer_too_small_p );
213
+ globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE ,
214
+ (const jerry_char_t * ) error_buffer_too_small_p );
212
215
/* cannot return inside ECMA_FINALIZE_UTF8_STRING */
213
216
}
214
217
@@ -243,7 +246,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
243
246
compiled_code_p ,
244
247
((size_t ) compiled_code_p -> size ) << JMEM_ALIGNMENT_LOG ))
245
248
{
246
- globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE , error_buffer_too_small_p );
249
+ globals_p -> snapshot_error = jerry_create_error (JERRY_ERROR_RANGE , ( const jerry_char_t * ) error_buffer_too_small_p );
247
250
return 0 ;
248
251
}
249
252
@@ -340,8 +343,8 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
340
343
341
344
if (globals_p -> snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET )
342
345
{
343
- const char * const error_message_p = "Maximum snapshot size reached" ;
344
- globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
346
+ globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE ,
347
+ (const jerry_char_t * ) ecma_error_maximum_snapshot_size );
345
348
return 0 ;
346
349
}
347
350
@@ -355,8 +358,8 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
355
358
if (!CBC_IS_FUNCTION (compiled_code_p -> status_flags ))
356
359
{
357
360
/* Regular expression literals are not supported. */
358
- const char * const error_message_p = "Regular expression literals are not supported" ;
359
- globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
361
+ globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE ,
362
+ (const jerry_char_t * ) ecma_error_regular_expression_not_supported );
360
363
return 0 ;
361
364
}
362
365
@@ -366,8 +369,8 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
366
369
compiled_code_p ,
367
370
((size_t ) compiled_code_p -> size ) << JMEM_ALIGNMENT_LOG ))
368
371
{
369
- const char * const error_message_p = "Snapshot buffer too small" ;
370
- globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
372
+ globals_p -> snapshot_error = jerry_create_error ( JERRY_ERROR_RANGE ,
373
+ (const jerry_char_t * ) ecma_error_snapshot_buffer_small );
371
374
return 0 ;
372
375
}
373
376
@@ -775,8 +778,7 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
775
778
if ((generate_snapshot_opts & ~allowed_options ) != 0
776
779
|| (options_p != NULL && (options_p -> options & ~allowed_parse_options ) != 0 ))
777
780
{
778
- const char * const error_message_p = "Unsupported generate snapshot flags specified" ;
779
- return jerry_create_error (JERRY_ERROR_RANGE , (const jerry_char_t * ) error_message_p );
781
+ return jerry_create_error (JERRY_ERROR_RANGE , (const jerry_char_t * ) ecma_error_snapshot_flag_not_supported );
780
782
}
781
783
782
784
snapshot_globals_t globals ;
@@ -847,9 +849,8 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
847
849
& literals_num ))
848
850
{
849
851
JERRY_ASSERT (lit_map_p == NULL );
850
- const char * const error_message_p = "Cannot allocate memory for literals" ;
851
852
ecma_bytecode_deref (bytecode_data_p );
852
- return jerry_create_error (JERRY_ERROR_COMMON , (const jerry_char_t * ) error_message_p );
853
+ return jerry_create_error (JERRY_ERROR_COMMON , (const jerry_char_t * ) ecma_error_cannot_allocate_memory_literals );
853
854
}
854
855
855
856
jerry_snapshot_set_offsets (buffer_p + (aligned_header_size / sizeof (uint32_t )),
0 commit comments