mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Add package name and source code location to Type_Info_Named
This commit is contained in:
@@ -55,7 +55,12 @@ Type_Info_Struct_Soa_Kind :: enum u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variant Types
|
// Variant Types
|
||||||
Type_Info_Named :: struct {name: string, base: ^Type_Info};
|
Type_Info_Named :: struct {
|
||||||
|
name: string,
|
||||||
|
base: ^Type_Info,
|
||||||
|
pkg: string,
|
||||||
|
loc: Source_Code_Location,
|
||||||
|
};
|
||||||
Type_Info_Integer :: struct {signed: bool, endianness: Platform_Endianness};
|
Type_Info_Integer :: struct {signed: bool, endianness: Platform_Endianness};
|
||||||
Type_Info_Rune :: struct {};
|
Type_Info_Rune :: struct {};
|
||||||
Type_Info_Float :: struct {endianness: Platform_Endianness};
|
Type_Info_Float :: struct {endianness: Platform_Endianness};
|
||||||
|
|||||||
+15
@@ -12172,6 +12172,21 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
|
|||||||
|
|
||||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), name);
|
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), name);
|
||||||
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 1), gtip);
|
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 1), gtip);
|
||||||
|
|
||||||
|
if (t->Named.type_name->pkg) {
|
||||||
|
irValue *name = ir_const_string(proc->module, t->Named.type_name->pkg->name);
|
||||||
|
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
String proc_name = {};
|
||||||
|
if (t->Named.type_name->parent_proc_decl) {
|
||||||
|
DeclInfo *decl = t->Named.type_name->parent_proc_decl;
|
||||||
|
if (decl->entity && decl->entity->kind == Entity_Procedure) {
|
||||||
|
proc_name = decl->entity->token.string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
irValue *loc = ir_emit_source_code_location(proc, proc_name, t->Named.type_name->token.pos);
|
||||||
|
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), loc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -11973,9 +11973,30 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da
|
|||||||
switch (t->kind) {
|
switch (t->kind) {
|
||||||
case Type_Named: {
|
case Type_Named: {
|
||||||
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_named_ptr);
|
tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_named_ptr);
|
||||||
LLVMValueRef vals[2] = {
|
|
||||||
|
LLVMValueRef pkg_name = nullptr;
|
||||||
|
if (t->Named.type_name->pkg) {
|
||||||
|
pkg_name = lb_const_string(m, t->Named.type_name->pkg->name).value;
|
||||||
|
} else {
|
||||||
|
pkg_name = LLVMConstNull(lb_type(m, t_string));
|
||||||
|
}
|
||||||
|
|
||||||
|
String proc_name = {};
|
||||||
|
if (t->Named.type_name->parent_proc_decl) {
|
||||||
|
DeclInfo *decl = t->Named.type_name->parent_proc_decl;
|
||||||
|
if (decl->entity && decl->entity->kind == Entity_Procedure) {
|
||||||
|
proc_name = decl->entity->token.string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TokenPos pos = t->Named.type_name->token.pos;
|
||||||
|
|
||||||
|
lbValue loc = lb_emit_source_code_location(p, proc_name, pos);
|
||||||
|
|
||||||
|
LLVMValueRef vals[4] = {
|
||||||
lb_const_string(p->module, t->Named.type_name->token.string).value,
|
lb_const_string(p->module, t->Named.type_name->token.string).value,
|
||||||
lb_get_type_info_ptr(m, t->Named.base).value,
|
lb_get_type_info_ptr(m, t->Named.base).value,
|
||||||
|
pkg_name,
|
||||||
|
loc.value
|
||||||
};
|
};
|
||||||
|
|
||||||
lbValue res = {};
|
lbValue res = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user