@@ -602,9 +602,9 @@ ecma_op_function_is_generator (ecma_object_t *obj_p) /**< object */
602602 && !ecma_get_object_is_builtin (obj_p ))
603603 {
604604 ecma_extended_object_t * ext_func_obj_p = (ecma_extended_object_t * ) obj_p ;
605- const ecma_compiled_code_t * bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_obj_p );
605+ const ecma_compiled_code_t * byte_code_p = ecma_op_function_get_compiled_code (ext_func_obj_p );
606606
607- return ( bytecode_data_p -> status_flags & CBC_CODE_FLAGS_GENERATOR ) != 0 ;
607+ return CBC_FUNCTION_GET_TYPE ( byte_code_p -> status_flags ) == CBC_FUNCTION_GENERATOR ;
608608 }
609609
610610 return false;
@@ -843,26 +843,20 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */
843843 uint16_t status_flags = bytecode_data_p -> status_flags ;
844844
845845#if ENABLED (JERRY_ES2015 )
846- bool is_construct_call = JERRY_CONTEXT (current_new_target ) != NULL ;
847- if (JERRY_UNLIKELY (status_flags & (CBC_CODE_FLAGS_CLASS_CONSTRUCTOR | CBC_CODE_FLAGS_GENERATOR )))
848- {
849- if (!is_construct_call && (status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR ))
850- {
851- return ecma_raise_type_error (ECMA_ERR_MSG ("Class constructor cannot be invoked without 'new'." ));
852- }
846+ uint16_t function_type = CBC_FUNCTION_GET_TYPE (status_flags );
853847
854- if (( status_flags & CBC_CODE_FLAGS_GENERATOR ) && is_construct_call )
855- {
856- return ecma_raise_type_error ( ECMA_ERR_MSG ( "Generator functions cannot be invoked with 'new'." ));
857- }
848+ if (JERRY_UNLIKELY ( function_type == CBC_FUNCTION_CONSTRUCTOR )
849+ && JERRY_CONTEXT ( current_new_target ) == NULL )
850+ {
851+ return ecma_raise_type_error ( ECMA_ERR_MSG ( "Class constructor cannot be invoked without 'new'." ));
858852 }
859853#endif /* ENABLED (JERRY_ES2015) */
860854
861855 /* 1. */
862856#if ENABLED (JERRY_ES2015 )
863857 ecma_object_t * old_function_object_p = JERRY_CONTEXT (current_function_obj_p );
864858
865- if (JERRY_UNLIKELY (status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION ))
859+ if (JERRY_UNLIKELY (function_type == CBC_FUNCTION_ARROW ))
866860 {
867861 ecma_arrow_function_t * arrow_func_p = (ecma_arrow_function_t * ) func_obj_p ;
868862
@@ -920,7 +914,7 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */
920914 }
921915#if ENABLED (JERRY_ES2015 )
922916 // ECMAScript v6, 9.2.2.8
923- if (JERRY_UNLIKELY (status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR ))
917+ if (JERRY_UNLIKELY (function_type == CBC_FUNCTION_CONSTRUCTOR ))
924918 {
925919 ecma_value_t lexical_this ;
926920 lexical_this = (ECMA_GET_THIRD_BIT_FROM_POINTER_TAG (ext_func_p -> u .function .scope_cp ) ? ECMA_VALUE_UNINITIALIZED
@@ -1278,20 +1272,31 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
12781272
12791273 ecma_object_t * new_this_obj_p = NULL ;
12801274 ecma_value_t this_arg ;
1275+
1276+ #if ENABLED (JERRY_ES2015 )
12811277 ecma_extended_object_t * ext_func_obj_p = (ecma_extended_object_t * ) func_obj_p ;
12821278 const ecma_compiled_code_t * byte_code_p = ecma_op_function_get_compiled_code (ext_func_obj_p );
12831279
1284- if (byte_code_p -> status_flags & ( CBC_CODE_FLAGS_ARROW_FUNCTION | CBC_CODE_FLAGS_ACCESSOR ))
1280+ if (! CBC_FUNCTION_IS_CONSTRUCTABLE ( byte_code_p -> status_flags ))
12851281 {
1286- if ( byte_code_p -> status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION )
1282+ switch ( CBC_FUNCTION_GET_TYPE ( byte_code_p -> status_flags ) )
12871283 {
1288- return ecma_raise_type_error (ECMA_ERR_MSG ("Arrow functions have no constructor." ));
1284+ case CBC_FUNCTION_GENERATOR :
1285+ {
1286+ return ecma_raise_type_error (ECMA_ERR_MSG ("Generator functions cannot be invoked with 'new'." ));
1287+ }
1288+ case CBC_FUNCTION_ARROW :
1289+ {
1290+ return ecma_raise_type_error (ECMA_ERR_MSG ("Arrow functions cannot be invoked with 'new'." ));
1291+ }
1292+ default :
1293+ {
1294+ JERRY_ASSERT (CBC_FUNCTION_GET_TYPE (byte_code_p -> status_flags ) == CBC_FUNCTION_ACCESSOR );
1295+ return ecma_raise_type_error (ECMA_ERR_MSG ("Accessor functions cannot be invoked with 'new'." ));
1296+ }
12891297 }
1290-
1291- return ecma_raise_type_error (ECMA_ERR_MSG ("Expected a constructor." ));
12921298 }
12931299
1294- #if ENABLED (JERRY_ES2015 )
12951300 /* 6. */
12961301 ecma_object_t * old_new_target_p = JERRY_CONTEXT (current_new_target );
12971302 JERRY_CONTEXT (current_new_target ) = new_target_p ;
@@ -1366,17 +1371,18 @@ ecma_op_lazy_instantiate_prototype_object (ecma_object_t *object_p) /**< the fun
13661371 {
13671372 const ecma_compiled_code_t * byte_code_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t * ) object_p );
13681373
1369- if (byte_code_p -> status_flags & CBC_CODE_FLAGS_GENERATOR )
1374+ if (!CBC_FUNCTION_HAS_PROTOTYPE (byte_code_p -> status_flags ))
1375+ {
1376+ return NULL ;
1377+ }
1378+
1379+ if (CBC_FUNCTION_GET_TYPE (byte_code_p -> status_flags ) == CBC_FUNCTION_GENERATOR )
13701380 {
13711381 proto_object_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE ),
13721382 0 ,
13731383 ECMA_OBJECT_TYPE_GENERAL );
13741384 init_constructor = false;
13751385 }
1376- else if (byte_code_p -> status_flags & (CBC_CODE_FLAGS_ARROW_FUNCTION | CBC_CODE_FLAGS_ACCESSOR ))
1377- {
1378- return NULL ;
1379- }
13801386 }
13811387#endif /* ENABLED (JERRY_ES2015) */
13821388
@@ -1474,7 +1480,7 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**<
14741480 ECMA_SET_SECOND_BIT_TO_POINTER_TAG (ext_func_p -> u .function .scope_cp );
14751481 const ecma_compiled_code_t * bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p );
14761482
1477- if (! (bytecode_data_p -> status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR ) )
1483+ if (CBC_FUNCTION_GET_TYPE (bytecode_data_p -> status_flags ) != CBC_FUNCTION_CONSTRUCTOR )
14781484 {
14791485 ecma_value_t value = * ecma_compiled_code_resolve_function_name (bytecode_data_p );
14801486 if (value != ECMA_VALUE_EMPTY )
@@ -1694,7 +1700,7 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
16941700 bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t * ) object_p );
16951701
16961702#if ENABLED (JERRY_ES2015 )
1697- if (bytecode_data_p -> status_flags & ( CBC_CODE_FLAGS_ARROW_FUNCTION | CBC_CODE_FLAGS_ACCESSOR ))
1703+ if (! CBC_FUNCTION_HAS_PROTOTYPE ( bytecode_data_p -> status_flags ))
16981704 {
16991705 return ;
17001706 }
0 commit comments