Styles fixes in libecmaobjects, libecmaoperations: indentation and braces rules.

This commit is contained in:
Ruben Ayrapetyan
2014-08-11 22:04:53 +04:00
parent 38c6c2357d
commit 48cff24f08
15 changed files with 1676 additions and 1632 deletions
+46 -24
View File
@@ -51,7 +51,8 @@
/** /**
* Type of ecma-value * Type of ecma-value
*/ */
typedef enum { typedef enum
{
ECMA_TYPE_SIMPLE, /**< simple value */ ECMA_TYPE_SIMPLE, /**< simple value */
ECMA_TYPE_NUMBER, /**< 64-bit integer */ ECMA_TYPE_NUMBER, /**< 64-bit integer */
ECMA_TYPE_STRING, /**< pointer to description of a string */ ECMA_TYPE_STRING, /**< pointer to description of a string */
@@ -62,7 +63,8 @@ typedef enum {
/** /**
* Simple ecma-values * Simple ecma-values
*/ */
typedef enum { typedef enum
{
/** /**
* Empty value is implementation defined value, used for: * Empty value is implementation defined value, used for:
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type); * - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
@@ -83,7 +85,8 @@ typedef enum {
/** /**
* Type of ecma-property * Type of ecma-property
*/ */
typedef enum { typedef enum
{
ECMA_PROPERTY_NAMEDDATA, /**< named data property */ ECMA_PROPERTY_NAMEDDATA, /**< named data property */
ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */ ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */
ECMA_PROPERTY_INTERNAL /**< internal property */ ECMA_PROPERTY_INTERNAL /**< internal property */
@@ -94,7 +97,8 @@ typedef enum {
* *
* See also: ECMA-262 v5, 8.9. * See also: ECMA-262 v5, 8.9.
*/ */
typedef enum { typedef enum
{
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */ ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */ ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */ ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
@@ -107,7 +111,8 @@ typedef enum {
/** /**
* Description of an ecma-value * Description of an ecma-value
*/ */
typedef struct { typedef struct
{
/** Value type (ecma_type_t) */ /** Value type (ecma_type_t) */
unsigned int value_type : 2; unsigned int value_type : 2;
@@ -122,7 +127,8 @@ typedef struct {
* *
* See also: ECMA-262 v5, 8.9. * See also: ECMA-262 v5, 8.9.
*/ */
typedef struct { typedef struct
{
/** Type (ecma_completion_type_t) */ /** Type (ecma_completion_type_t) */
unsigned int type : 3; unsigned int type : 3;
@@ -142,7 +148,8 @@ typedef struct {
/** /**
* Internal properties' identifiers. * Internal properties' identifiers.
*/ */
typedef enum { typedef enum
{
ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */ ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */
ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */ ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */
ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */ ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */
@@ -193,7 +200,8 @@ typedef enum
/** /**
* Description of ecma-property * Description of ecma-property
*/ */
typedef struct ecma_property_t { typedef struct ecma_property_t
{
/** Property's type (ecma_property_type_t) */ /** Property's type (ecma_property_type_t) */
unsigned int type : 2; unsigned int type : 2;
@@ -201,10 +209,11 @@ typedef struct ecma_property_t {
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH; unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
/** Property's details (depending on Type) */ /** Property's details (depending on Type) */
union { union
{
/** Description of named data property */ /** Description of named data property */
struct __packed ecma_named_data_property_t { struct __packed ecma_named_data_property_t
{
/** Compressed pointer to property's name (pointer to String) */ /** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH; unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
@@ -222,7 +231,8 @@ typedef struct ecma_property_t {
} named_data_property; } named_data_property;
/** Description of named accessor property */ /** Description of named accessor property */
struct __packed ecma_named_accessor_property_t { struct __packed ecma_named_accessor_property_t
{
/** Compressed pointer to property's name (pointer to String) */ /** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH; unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
@@ -240,7 +250,8 @@ typedef struct ecma_property_t {
} named_accessor_property; } named_accessor_property;
/** Description of internal property */ /** Description of internal property */
struct __packed ecma_internal_property_t { struct __packed ecma_internal_property_t
{
/** Internal property's type */ /** Internal property's type */
unsigned int type : 4; unsigned int type : 4;
@@ -253,7 +264,8 @@ typedef struct ecma_property_t {
/** /**
* Description of GC's information layout * Description of GC's information layout
*/ */
typedef struct { typedef struct
{
/** /**
* Reference counter of the object. * Reference counter of the object.
* *
@@ -285,7 +297,8 @@ typedef struct {
/** /**
* Types of lexical environments * Types of lexical environments
*/ */
typedef enum { typedef enum
{
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */ ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */ ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */
} ecma_lexical_environment_type_t; } ecma_lexical_environment_type_t;
@@ -293,7 +306,8 @@ typedef enum {
/** /**
* Internal object types * Internal object types
*/ */
typedef enum { typedef enum
{
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3), ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3),
Arguments (10.6), Array (15.4) specification-defined objects Arguments (10.6), Array (15.4) specification-defined objects
and not host objects */ and not host objects */
@@ -308,7 +322,8 @@ typedef enum {
/** /**
* ECMA-defined object classes * ECMA-defined object classes
*/ */
typedef enum { typedef enum
{
ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */ ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */
ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */ ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */
ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */ ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */
@@ -327,7 +342,8 @@ typedef enum {
* Description of ECMA-object or lexical environment * Description of ECMA-object or lexical environment
* (depending on is_lexical_environment). * (depending on is_lexical_environment).
*/ */
typedef struct ecma_object_t { typedef struct ecma_object_t
{
/** Compressed pointer to property list */ /** Compressed pointer to property list */
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH; unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
@@ -339,11 +355,13 @@ typedef struct ecma_object_t {
* Attributes of either general object or lexical environment * Attributes of either general object or lexical environment
* (depending on is_lexical_environment) * (depending on is_lexical_environment)
*/ */
union { union
{
/** /**
* A general object's attributes (if !is_lexical_environment) * A general object's attributes (if !is_lexical_environment)
*/ */
struct { struct
{
/** Attribute 'Extensible' */ /** Attribute 'Extensible' */
unsigned int extensible : 1; unsigned int extensible : 1;
@@ -357,7 +375,8 @@ typedef struct ecma_object_t {
/** /**
* A lexical environment's attribute (if is_lexical_environment) * A lexical environment's attribute (if is_lexical_environment)
*/ */
struct { struct
{
/** /**
* Type of lexical environment (ecma_lexical_environment_type_t). * Type of lexical environment (ecma_lexical_environment_type_t).
*/ */
@@ -451,7 +470,8 @@ typedef uint16_t ecma_length_t;
/** /**
* Description of an Array's header * Description of an Array's header
*/ */
typedef struct { typedef struct
{
/** Compressed pointer to next chunk */ /** Compressed pointer to next chunk */
uint16_t next_chunk_p; uint16_t next_chunk_p;
@@ -462,7 +482,8 @@ typedef struct {
/** /**
* Description of first chunk in a chain of chunks that contains an Array. * Description of first chunk in a chain of chunks that contains an Array.
*/ */
typedef struct { typedef struct
{
/** Array's header */ /** Array's header */
ecma_array_header_t header; ecma_array_header_t header;
@@ -473,7 +494,8 @@ typedef struct {
/** /**
* Description of non-first chunk in a chain of chunks that contains an Array * Description of non-first chunk in a chain of chunks that contains an Array
*/ */
typedef struct { typedef struct
{
/** Compressed pointer to next chunk */ /** Compressed pointer to next chunk */
uint16_t next_chunk_p; uint16_t next_chunk_p;
+19 -4
View File
@@ -98,7 +98,11 @@ ecma_is_value_true (ecma_value_t value) /**< ecma-value */
ecma_value_t ecma_value_t
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */ ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
{ {
return (ecma_value_t) { .value_type = ECMA_TYPE_SIMPLE, .value = value }; return (ecma_value_t)
{
.value_type = ECMA_TYPE_SIMPLE,
.value = value
};
} /* ecma_make_simple_value */ } /* ecma_make_simple_value */
/** /**
@@ -193,7 +197,10 @@ ecma_copy_value (const ecma_value_t value, /**< ecma-value */
ecma_number_t *number_copy_p = ecma_alloc_number (); ecma_number_t *number_copy_p = ecma_alloc_number ();
*number_copy_p = *num_p; *number_copy_p = *num_p;
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_NUMBER }; value_copy = (ecma_value_t)
{
.value_type = ECMA_TYPE_NUMBER
};
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p); ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
break; break;
@@ -205,7 +212,10 @@ ecma_copy_value (const ecma_value_t value, /**< ecma-value */
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p); ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p);
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_STRING }; value_copy = (ecma_value_t)
{
.value_type = ECMA_TYPE_STRING
};
ECMA_SET_POINTER(value_copy.value, string_copy_p); ECMA_SET_POINTER(value_copy.value, string_copy_p);
break; break;
@@ -289,7 +299,12 @@ ecma_make_completion_value (ecma_completion_type_t type, /**< type */
ecma_value_t value, /**< value */ ecma_value_t value, /**< value */
uint8_t target) /**< target */ uint8_t target) /**< target */
{ {
return (ecma_completion_value_t) { .type = type, .value = value, .target = target }; return (ecma_completion_value_t)
{
.type = type,
.value = value,
.target = target
};
} /* ecma_make_completion_value */ } /* ecma_make_completion_value */
/** /**
+5 -4
View File
@@ -646,9 +646,9 @@ ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-te
const ecma_char_t *str_iter_p = string_p; const ecma_char_t *str_iter_p = string_p;
ecma_length_t ecma_str_len = ecma_string_p->header.unit_number; ecma_length_t ecma_str_len = ecma_string_p->header.unit_number;
const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data, const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data;
*current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data const ecma_char_t *current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data +
+ sizeof (ecma_string_p->data)); sizeof (ecma_string_p->data));
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE); JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p; const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p;
@@ -724,7 +724,8 @@ ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of th
ecma_property_descriptor_t ecma_property_descriptor_t
ecma_make_empty_property_descriptor (void) ecma_make_empty_property_descriptor (void)
{ {
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t) { ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t)
{
.is_value_defined = false, .is_value_defined = false,
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED), .value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
+6 -5
View File
@@ -37,14 +37,15 @@
* to specified non_compressed_pointer. * to specified non_compressed_pointer.
*/ */
#define ECMA_SET_POINTER(field, non_compressed_pointer) \ #define ECMA_SET_POINTER(field, non_compressed_pointer) \
do { \ do \
{ \
void *__temp_pointer = non_compressed_pointer; \ void *__temp_pointer = non_compressed_pointer; \
non_compressed_pointer = __temp_pointer; \ non_compressed_pointer = __temp_pointer; \
} \ } while (0); \
while (0); \ \
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \ (field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
: mem_compress_pointer (non_compressed_pointer) \ : (mem_compress_pointer (non_compressed_pointer) \
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
/** /**
* Set value of non-null compressed pointer field so that it will correspond * Set value of non-null compressed pointer field so that it will correspond
+4
View File
@@ -59,12 +59,14 @@ ecma_op_check_object_coercible (ecma_value_t value) /**< ecma-value */
break; break;
} }
case ECMA_TYPE_NUMBER: case ECMA_TYPE_NUMBER:
case ECMA_TYPE_STRING: case ECMA_TYPE_STRING:
case ECMA_TYPE_OBJECT: case ECMA_TYPE_OBJECT:
{ {
break; break;
} }
case ECMA_TYPE__COUNT: case ECMA_TYPE__COUNT:
{ {
JERRY_UNREACHABLE(); JERRY_UNREACHABLE();
@@ -170,10 +172,12 @@ ecma_op_to_primitive (ecma_value_t value, /**< ecma-value */
ecma_copy_value (value, true), ecma_copy_value (value, true),
ECMA_TARGET_ID_RESERVED); ECMA_TARGET_ID_RESERVED);
} }
case ECMA_TYPE_OBJECT: case ECMA_TYPE_OBJECT:
{ {
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type); JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type);
} }
case ECMA_TYPE__COUNT: case ECMA_TYPE__COUNT:
{ {
JERRY_UNREACHABLE(); JERRY_UNREACHABLE();
+10 -6
View File
@@ -73,8 +73,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
{ {
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p); ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
: ECMA_SIMPLE_VALUE_FALSE;
break; break;
} }
@@ -82,8 +81,14 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
{ {
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
has_binding = ecma_op_object_has_property (binding_obj_p, name_p) ? ECMA_SIMPLE_VALUE_TRUE if (ecma_op_object_has_property (binding_obj_p, name_p))
: ECMA_SIMPLE_VALUE_FALSE; {
has_binding = ECMA_SIMPLE_VALUE_TRUE;
}
else
{
has_binding = ECMA_SIMPLE_VALUE_FALSE;
}
break; break;
} }
@@ -144,8 +149,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE; prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
prop_desc.is_configurable_defined = true; prop_desc.is_configurable_defined = true;
prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE : ECMA_PROPERTY_NOT_CONFIGURABLE;
: ECMA_PROPERTY_NOT_CONFIGURABLE;
} }
ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p, ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p,
+6 -12
View File
@@ -34,18 +34,12 @@ ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
switch (id) switch (id)
{ {
case ECMA_MAGIC_STRING_ARGUMENTS: case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
return (ecma_char_t*) "arguments"; case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
case ECMA_MAGIC_STRING_EVAL: case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
return (ecma_char_t*) "eval"; case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
case ECMA_MAGIC_STRING_PROTOTYPE: case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
return (ecma_char_t*) "prototype"; case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
case ECMA_MAGIC_STRING_CONSTRUCTOR:
return (ecma_char_t*) "constructor";
case ECMA_MAGIC_STRING_CALLER:
return (ecma_char_t*) "caller";
case ECMA_MAGIC_STRING_UNDEFINED:
return (ecma_char_t*) "undefined";
} }
JERRY_UNREACHABLE(); JERRY_UNREACHABLE();
+5 -2
View File
@@ -86,9 +86,12 @@ ecma_make_reference (ecma_value_t base, /**< base value */
const ecma_char_t *name_p, /**< referenced name */ const ecma_char_t *name_p, /**< referenced name */
bool is_strict) /**< strict reference flag */ bool is_strict) /**< strict reference flag */
{ {
ecma_reference_t ref = (ecma_reference_t) { .base = ecma_copy_value (base, true), ecma_reference_t ref = (ecma_reference_t)
{
.base = ecma_copy_value (base, true),
.referenced_name_p = name_p, .referenced_name_p = name_p,
.is_strict = is_strict }; .is_strict = is_strict
};
return ref; return ref;
} /* ecma_make_reference */ } /* ecma_make_reference */