C_FILES="onyx onyxbuiltins onyxchecker onyxclone onyxdoc onyxentities onyxerrors onyxlex onyxparser onyxsempass onyxsymres onyxtypes onyxutils onyxwasm"
TARGET='./bin/onyx'
CC='gcc'
-FLAGS='-O3 -I./include'
-BUILD_DIR='./build'
+if [ "$1" = "debug" ]; then
+ FLAGS='-g3 -I./include'
+else
+ FLAGS='-O3 -I./include'
+fi
+
+BUILD_DIR='./build'
mkdir -p "$BUILD_DIR"
for file in $C_FILES ; do
Entity_Type_Foreign_Global_Header,
Entity_Type_Function_Header,
Entity_Type_Global_Header,
+ Entity_Type_Struct_Member_Default,
Entity_Type_Memory_Reservation,
Entity_Type_Expression,
Entity_Type_Global,
break;
}
- case Ast_Kind_Type_Alias:
case Ast_Kind_Struct_Type:
case Ast_Kind_Poly_Struct_Type: {
+ ent.type = Entity_Type_Struct_Member_Default;
+ ent.type_alias = (AstType *) node;
+ entity_heap_insert(&compiler_state->prog_info.entities, ent);
+ // fallthrough
+ }
+ case Ast_Kind_Type_Alias: {
ent.type = Entity_Type_Type_Alias;
ent.type_alias = (AstType *) node;
entity_heap_insert(&compiler_state->prog_info.entities, ent);
static void symres_enum(AstEnumType* enum_node);
static void symres_memres_type(AstMemRes** memres);
static void symres_memres(AstMemRes** memres);
+static void symres_struct_defaults(AstType* st);
static AstFieldAccess* make_field_access(AstTyped* node, char* field) {
AstFieldAccess* fa = onyx_ast_node_new(semstate.node_allocator, sizeof(AstFieldAccess), Ast_Kind_Field_Access);
return type;
}
}
-
- if (member->initial_value != NULL) {
- symres_expression(&member->initial_value);
- }
}
return type;
}
}
+static void symres_struct_defaults(AstType* t) {
+ switch (t->kind) {
+ case Ast_Kind_Struct_Type: {
+ AstStructType* st = (AstStructType *) t;
+ bh_arr_each(AstStructMember *, smem, st->members) {
+ if ((*smem)->initial_value != NULL) {
+ symres_expression(&(*smem)->initial_value);
+ }
+ }
+ break;
+ }
+
+ case Ast_Kind_Poly_Struct_Type: {
+ AstPolyStructType* st = (AstPolyStructType *) t;
+ bh_arr_each(AstStructMember *, smem, st->base_struct->members) {
+ if ((*smem)->initial_value != NULL) {
+ symres_expression(&(*smem)->initial_value);
+ }
+ }
+ break;
+ }
+
+ default: break;
+ }
+}
+
static void symres_polyproc(AstPolyProc* pp) {
pp->poly_scope = semstate.curr_scope;
}
case Entity_Type_Memory_Reservation: symres_memres(&ent->mem_res); break;
case Entity_Type_Polymorphic_Proc: symres_polyproc(ent->poly_proc); break;
case Entity_Type_String_Literal: symres_expression(&ent->expr); break;
+ case Entity_Type_Struct_Member_Default: symres_struct_defaults((AstType *) ent->type_alias); break;
default: break;
}