Browse Source

Fix Tuple type info bug
Caused by not having type safe tagged unions :P (Silly C)

Ginger Bill 8 years ago
parent
commit
67ed8a9a4a
2 changed files with 18 additions and 6 deletions
  1. 12 0
      code/demo.odin
  2. 6 6
      src/ir.c

+ 12 - 0
code/demo.odin

@@ -6,7 +6,15 @@
 #import "opengl.odin";
 #import "opengl.odin";
 #import "os.odin";
 #import "os.odin";
 
 
+foo :: proc(x: int) -> f32 {
+	return 123;
+}
+
 main :: proc() {
 main :: proc() {
+
+	fmt.printf("%T\n", foo);
+
+when false {
 /*
 /*
 	Version 0.1.1
 	Version 0.1.1
 
 
@@ -57,6 +65,9 @@ main :: proc() {
 	To come very Soon™:
 	To come very Soon™:
 	 * Linux and OS X builds (unofficial ones do exist already)
 	 * Linux and OS X builds (unofficial ones do exist already)
 */
 */
+	{
+
+	}
 
 
 	{
 	{
 		Fruit :: enum {
 		Fruit :: enum {
@@ -145,4 +156,5 @@ main :: proc() {
 		// align_of([vector 7]i32) != align_of([7]i32) // this may be the case
 		// align_of([vector 7]i32) != align_of([7]i32) // this may be the case
 	}
 	}
 }
 }
+}
 
 

+ 6 - 6
src/ir.c

@@ -6504,10 +6504,10 @@ void ir_gen_tree(irGen *s) {
 					irValue *variadic   = ir_emit_struct_ep(proc, tag, 2);
 					irValue *variadic   = ir_emit_struct_ep(proc, tag, 2);
 					irValue *convention = ir_emit_struct_ep(proc, tag, 3);
 					irValue *convention = ir_emit_struct_ep(proc, tag, 3);
 
 
-					if (t->Proc.params) {
+					if (t->Proc.params != NULL) {
 						ir_emit_store(proc, params, ir_get_type_info_ptr(proc, t->Proc.params));
 						ir_emit_store(proc, params, ir_get_type_info_ptr(proc, t->Proc.params));
 					}
 					}
-					if (t->Proc.results) {
+					if (t->Proc.results != NULL) {
 						ir_emit_store(proc, results, ir_get_type_info_ptr(proc, t->Proc.results));
 						ir_emit_store(proc, results, ir_get_type_info_ptr(proc, t->Proc.results));
 					}
 					}
 					ir_emit_store(proc, variadic, ir_make_const_bool(a, t->Proc.variadic));
 					ir_emit_store(proc, variadic, ir_make_const_bool(a, t->Proc.variadic));
@@ -6525,8 +6525,8 @@ void ir_gen_tree(irGen *s) {
 						ir_emit_store(proc, ir_emit_struct_ep(proc, record, 4), align);
 						ir_emit_store(proc, ir_emit_struct_ep(proc, record, 4), align);
 					}
 					}
 
 
-					irValue *memory_types   = ir_type_info_member_types_offset(proc, t->Record.field_count);
-					irValue *memory_names   = ir_type_info_member_names_offset(proc, t->Record.field_count);
+					irValue *memory_types = ir_type_info_member_types_offset(proc, t->Tuple.variable_count);
+					irValue *memory_names = ir_type_info_member_names_offset(proc, t->Tuple.variable_count);
 
 
 					for (isize i = 0; i < t->Tuple.variable_count; i++) {
 					for (isize i = 0; i < t->Tuple.variable_count; i++) {
 						// NOTE(bill): offset is not used for tuples
 						// NOTE(bill): offset is not used for tuples
@@ -6542,8 +6542,8 @@ void ir_gen_tree(irGen *s) {
 						}
 						}
 					}
 					}
 
 
-					ir_fill_slice(proc, ir_emit_struct_ep(proc, record, 0), memory_types,   ir_make_const_int(a, t->Record.field_count));
-					ir_fill_slice(proc, ir_emit_struct_ep(proc, record, 1), memory_names,   ir_make_const_int(a, t->Record.field_count));
+					ir_fill_slice(proc, ir_emit_struct_ep(proc, record, 0), memory_types,   ir_make_const_int(a, t->Tuple.variable_count));
+					ir_fill_slice(proc, ir_emit_struct_ep(proc, record, 1), memory_names,   ir_make_const_int(a, t->Tuple.variable_count));
 				} break;
 				} break;
 				case Type_Record: {
 				case Type_Record: {
 					switch (t->Record.kind) {
 					switch (t->Record.kind) {