Browse Source

Fix bugs: Array Literals with constant elements; IR printing of raw procedure types

gingerBill 6 years ago
parent
commit
a0c81c79ad
3 changed files with 7 additions and 4 deletions
  1. 1 1
      src/ir.cpp
  2. 5 2
      src/ir_print.cpp
  3. 1 1
      src/tokenizer.cpp

+ 1 - 1
src/ir.cpp

@@ -7360,7 +7360,7 @@ irAddr ir_build_addr(irProcedure *proc, Ast *expr) {
 
 
 		case Type_Array: {
 		case Type_Array: {
 			if (cl->elems.count > 0) {
 			if (cl->elems.count > 0) {
-				// ir_emit_store(proc, v, ir_add_module_constant(proc->module, type, exact_value_compound(expr)));
+				ir_emit_store(proc, v, ir_add_module_constant(proc->module, type, exact_value_compound(expr)));
 
 
 				auto temp_data = array_make<irCompoundLitElemTempData>(heap_allocator(), 0, cl->elems.count);
 				auto temp_data = array_make<irCompoundLitElemTempData>(heap_allocator(), 0, cl->elems.count);
 				defer (array_free(&temp_data));
 				defer (array_free(&temp_data));

+ 5 - 2
src/ir_print.cpp

@@ -316,8 +316,11 @@ void ir_print_proc_type_without_pointer(irFileBuffer *f, irModule *m, Type *t) {
 	if (t->Proc.return_by_pointer) {
 	if (t->Proc.return_by_pointer) {
 		ir_print_type(f, m, reduce_tuple_to_single_type(t->Proc.results));
 		ir_print_type(f, m, reduce_tuple_to_single_type(t->Proc.results));
 		// ir_fprintf(f, "* sret noalias ");
 		// ir_fprintf(f, "* sret noalias ");
-		ir_write_string(f, str_lit("* noalias "));
-		if (param_count > 0) ir_write_string(f, str_lit(", "));
+		// ir_write_string(f, str_lit("* noalias "));
+		ir_write_string(f, str_lit("*"));
+		if (param_count > 0 || t->Proc.calling_convention == ProcCC_Odin)  {
+			ir_write_string(f, str_lit(", "));
+		}
 	}
 	}
 	isize param_index = 0;
 	isize param_index = 0;
 	for (isize i = 0; i < param_count; i++) {
 	for (isize i = 0; i < param_count; i++) {

+ 1 - 1
src/tokenizer.cpp

@@ -100,7 +100,6 @@ TOKEN_KIND(Token__KeywordBegin, ""), \
 	TOKEN_KIND(Token_defer,       "defer"),       \
 	TOKEN_KIND(Token_defer,       "defer"),       \
 	TOKEN_KIND(Token_return,      "return"),      \
 	TOKEN_KIND(Token_return,      "return"),      \
 	TOKEN_KIND(Token_proc,        "proc"),        \
 	TOKEN_KIND(Token_proc,        "proc"),        \
-	TOKEN_KIND(Token_macro,       "macro"),       \
 	TOKEN_KIND(Token_struct,      "struct"),      \
 	TOKEN_KIND(Token_struct,      "struct"),      \
 	TOKEN_KIND(Token_union,       "union"),       \
 	TOKEN_KIND(Token_union,       "union"),       \
 	TOKEN_KIND(Token_enum,        "enum"),        \
 	TOKEN_KIND(Token_enum,        "enum"),        \
@@ -121,6 +120,7 @@ TOKEN_KIND(Token__KeywordBegin, ""), \
 	TOKEN_KIND(Token_align_of,    "align_of"),    \
 	TOKEN_KIND(Token_align_of,    "align_of"),    \
 	TOKEN_KIND(Token_offset_of,   "offset_of"),   \
 	TOKEN_KIND(Token_offset_of,   "offset_of"),   \
 	TOKEN_KIND(Token_type_of,     "type_of"),     \
 	TOKEN_KIND(Token_type_of,     "type_of"),     \
+	TOKEN_KIND(Token_macro,       "macro"),       \
 	TOKEN_KIND(Token_const,       "const"),       \
 	TOKEN_KIND(Token_const,       "const"),       \
 	TOKEN_KIND(Token_asm,         "asm"),         \
 	TOKEN_KIND(Token_asm,         "asm"),         \
 	TOKEN_KIND(Token_yield,       "yield"),       \
 	TOKEN_KIND(Token_yield,       "yield"),       \