extern const char* entity_type_strings[Entity_Type_Count];
typedef struct Entity {
+ u32 id;
+
EntityType type;
EntityState state;
typedef struct EntityHeap {
bh_arena entity_arena;
bh_arr(Entity *) entities;
+ i32 next_id;
i32 state_count[Entity_State_Count];
i32 type_count[Entity_Type_Count];
{
"target": "exec",
- "shell_cmd": "/usr/bin/onyx -V -o \"${folder}/${file_base_name}.wasm\" \"$file\"",
+ "shell_cmd": "/usr/bin/onyx -V --no-colors -o \"${folder}/${file_base_name}.wasm\" \"$file\"",
"working_dir": "${folder}",
"selector": "source.onyx",
"file_regex": "^\\(([^:]+):([0-9]+),([0-9]+)\\) (.*)",
bh_table_init(global_heap_allocator, context.packages, 16);
// NOTE: This will be initialized upon the first call to entity_heap_insert.
+ context.entities.next_id = 0;
context.entities.entities = NULL;
onyx_errors_init(&context.loaded_files);
return (i32) e1->state - (i32) e2->state;
else if (e1->type != e2->type)
return (i32) e1->type - (i32) e2->type;
- else
+ else if (e1->micro_attempts != e2->micro_attempts)
return (i32) (e1->micro_attempts - e2->micro_attempts);
-
+ else
+ return (i32) (e1->id - e2->id);
}
#define eh_parent(index) (((index) - 1) / 2)
Entity* entity;
Entity ent;
+ ent.id = entities->next_id++;
ent.state = Entity_State_Resolve_Symbols;
ent.package = package;
ent.scope = scope;
ENTITY_INSERT(ent);
((AstFunction *) node)->entity_header = entity;
+ ent.id = entities->next_id++;
ent.type = Entity_Type_Function;
ent.function = (AstFunction *) node;
ENTITY_INSERT(ent);
ent.global = (AstGlobal *) node;
ENTITY_INSERT(ent);
+ ent.id = entities->next_id++;
ent.type = Entity_Type_Global;
ent.global = (AstGlobal *) node;
ENTITY_INSERT(ent);
ent.type_alias = (AstType *) node;
ENTITY_INSERT(ent);
((AstStructType *) node)->entity_defaults = entity;
+
+ ent.id = entities->next_id++;
// fallthrough
}
ent.mem_res = (AstMemRes *) node;
ENTITY_INSERT(ent);
+ ent.id = entities->next_id++;
ent.type = Entity_Type_Memory_Reservation;
ent.mem_res = (AstMemRes *) node;
ENTITY_INSERT(ent);