aboutsummaryrefslogtreecommitdiff
path: root/src/checker/entity.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-10 11:24:50 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-10 11:24:50 +0100
commit7509cdceb83dbbeb69b1b85b956cf45a62959b26 (patch)
treeebed5cfd541b87f06db0f46fb1cc68c8e93ea4dd /src/checker/entity.cpp
parent6979678ff947cecc8e6e0d0e8ceea7e0304d3f4e (diff)
Default struct member reordering for minimal size
Rule: largest members to smallest; if same size, order in source order
Diffstat (limited to 'src/checker/entity.cpp')
-rw-r--r--src/checker/entity.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/checker/entity.cpp b/src/checker/entity.cpp
index a1a368b6a..85e668c0d 100644
--- a/src/checker/entity.cpp
+++ b/src/checker/entity.cpp
@@ -41,11 +41,13 @@ struct Entity {
union {
struct { ExactValue value; } Constant;
struct {
- b8 visited; // Cycle detection
- b8 used; // Variable is used
- b8 is_field; // Is struct field
- b8 anonymous; // Variable is an anonymous
- b8 is_using; // `using` variable
+ b8 visited; // Cycle detection
+ b8 used; // Variable is used
+ b8 anonymous; // Variable is an anonymous
+ b8 is_using; // `using` variable
+
+ i32 field_index; // Order in source
+ b8 is_field; // Is struct field
} Variable;
struct {} TypeName;
struct {
@@ -103,8 +105,9 @@ Entity *make_entity_param(gbAllocator a, Scope *scope, Token token, Type *type,
return entity;
}
-Entity *make_entity_field(gbAllocator a, Scope *scope, Token token, Type *type, b32 is_anonymous) {
+Entity *make_entity_field(gbAllocator a, Scope *scope, Token token, Type *type, b32 is_anonymous, i32 field_index) {
Entity *entity = make_entity_variable(a, scope, token, type);
+ entity->Variable.field_index = field_index;
entity->Variable.is_field = true;
entity->Variable.anonymous = cast(b8)is_anonymous;
return entity;