return comp_type;
}
+Type* type_build_implicit_type_of_struct_literal(bh_allocator alloc, AstStructLiteral* lit) {
+ Type* type = type_create(Type_Kind_Struct, alloc, 0);
+ type->ast_type = NULL;
+ type->Struct.name = NULL;
+ type->Struct.mem_count = bh_arr_length(lit->args.named_values);
+ type->Struct.meta_tags = NULL;
+ type->Struct.constructed_from = NULL;
+ type->Struct.status = SPS_Start;
+ type->Struct.poly_sln = NULL;
+ type_register(type);
+
+ type->Struct.memarr = NULL;
+ sh_new_arena(type->Struct.members);
+ bh_arr_new(global_heap_allocator, type->Struct.memarr, type->Struct.mem_count);
+
+ u32 size = 0;
+ u32 offset = 0;
+ u32 alignment = 1;
+ u32 idx = 0;
+ bh_arr_each(AstNamedValue *, pnv, lit->args.named_values) {
+ AstNamedValue *nv = *pnv;
+
+ Type* member_type = resolve_expression_type(nv->value);
+ if (member_type == NULL) {
+ return NULL;
+ }
+
+ u32 mem_alignment = type_alignment_of(member_type);
+ if (mem_alignment <= 0) {
+ return NULL;
+ }
+
+ alignment = bh_max(alignment, mem_alignment);
+
+ // Should these structs be packed or not?
+ bh_align(offset, mem_alignment);
+
+ token_toggle_end(nv->token);
+ if (shgeti(type->Struct.members, nv->token->text) != -1) {
+ token_toggle_end(nv->token);
+ return NULL;
+ }
+
+ StructMember *smem = bh_alloc_item(alloc, StructMember);
+ smem->offset = offset;
+ smem->type = member_type;
+ smem->idx = idx;
+ smem->name = bh_strdup(alloc, nv->token->text);
+ smem->token = nv->token;
+ smem->initial_value = &nv->value;
+ smem->meta_tags = NULL;
+ smem->included_through_use = 0;
+ smem->used = 0;
+ smem->use_through_pointer_index = -1;
+ shput(type->Struct.members, nv->token->text, smem);
+ bh_arr_push(type->Struct.memarr, smem);
+ token_toggle_end(nv->token);
+
+ u32 type_size = type_size_of(member_type);
+ offset += type_size;
+ size = offset;
+ idx++;
+ }
+
+ type->Struct.alignment = alignment;
+ type->Struct.size = size;
+ type->Struct.linear_members = NULL;
+ bh_arr_new(global_heap_allocator, type->Struct.linear_members, type->Struct.mem_count);
+ build_linear_types_with_offset(type, &type->Struct.linear_members, 0);
+
+ type->Struct.status = SPS_Uses_Done;
+ return type;
+}
+
Type* type_make_pointer(bh_allocator alloc, Type* to) {
if (to == NULL) return NULL;
if (to == (Type *) &node_that_signals_failure) return to;
--- /dev/null
+{ x = 0.0990, y = 0.0950, vx = 9.8000, vy = 9.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.1959, y = 0.1799, vx = 9.6000, vy = 8.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.2910, y = 0.2549, vx = 9.4000, vy = 7.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.3840, y = 0.3200, vx = 9.2000, vy = 6.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.4750, y = 0.3750, vx = 9.0000, vy = 5.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.5640, y = 0.4200, vx = 8.8000, vy = 4.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.6510, y = 0.4549, vx = 8.6000, vy = 3.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.7360, y = 0.4799, vx = 8.4000, vy = 2.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.8190, y = 0.4950, vx = 8.2000, vy = 1.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.9000, y = 0.5000, vx = 8.0000, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 0.9790, y = 0.4950, vx = 7.8000, vy = -1.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.0560, y = 0.4799, vx = 7.6000, vy = -2.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.1310, y = 0.4549, vx = 7.4000, vy = -3.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.2040, y = 0.4200, vx = 7.2000, vy = -4.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.2750, y = 0.3750, vx = 7.0000, vy = -5.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.3440, y = 0.3200, vx = 6.8000, vy = -6.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.4110, y = 0.2549, vx = 6.6000, vy = -7.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.4760, y = 0.1799, vx = 6.4000, vy = -8.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5390, y = 0.0949, vx = 6.2000, vy = -9.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.6000, y = 0.0000, vx = 0.3000, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.6020, y = 0.0000, vx = 0.0050, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.6010, y = 0.0000, vx = -0.0097, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5999, y = 0.0000, vx = -0.0104, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5988, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5977, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5966, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5955, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5944, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5933, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5922, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5911, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5900, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5889, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5877, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5866, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5855, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5844, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5833, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5822, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }
+{ x = 1.5811, y = 0.0000, vx = -0.0105, vy = 0.0000, ax = -20.0000, ay = -100.0000 }