Browse Source

Minor code reorganization

gingerBill 7 years ago
parent
commit
60a7c68aa6
3 changed files with 7 additions and 9 deletions
  1. 1 0
      src/ir.cpp
  2. 3 0
      src/main.cpp
  3. 3 9
      src/parser.cpp

+ 1 - 0
src/ir.cpp

@@ -7795,6 +7795,7 @@ bool ir_gen_init(irGen *s, Checker *c) {
 
 	gbFileError err = gb_file_create(&s->output_file, output_file_path);
 	if (err != gbFileError_None) {
+		gb_printf_err("Failed to create file %s\n", output_file_path);
 		return false;
 	}
 

+ 3 - 0
src/main.cpp

@@ -713,6 +713,7 @@ int main(int arg_count, char **arg_ptr) {
 		return 0;
 	}
 
+
 	timings_start_section(&timings, str_lit("type check"));
 
 	Checker checker = {0};
@@ -728,6 +729,8 @@ int main(int arg_count, char **arg_ptr) {
 	}
 	// defer (ir_gen_destroy(&ir_gen));
 
+
+
 	timings_start_section(&timings, str_lit("llvm ir gen"));
 	ir_gen_tree(&ir_gen);
 

+ 3 - 9
src/parser.cpp

@@ -4213,6 +4213,7 @@ skip:
 	file->id = imported_file.index;
 	array_add(&p->files, file);
 	p->total_line_count += file->tokenizer.line_count;
+	p->total_token_count += file->tokens.count;
 	gb_mutex_unlock(&p->file_add_mutex);
 
 	return ParseFile_None;
@@ -4258,7 +4259,6 @@ ParseFileError parse_files(Parser *p, String init_filename) {
 	array_add(&p->imports, init_imported_file);
 	p->init_fullpath = init_fullpath;
 
-
 	// IMPORTANT TODO(bill): Figure out why this doesn't work on *nix sometimes
 #if USE_THREADED_PARSER && defined(GB_SYSTEM_WINDOWS)
 	isize thread_count = gb_max(build_context.thread_count, 1);
@@ -4297,7 +4297,8 @@ ParseFileError parse_files(Parser *p, String init_filename) {
 					if (err != ParseFile_None) {
 						return err;
 					}
-					t->user_index = curr_import_index++;
+					t->user_index = curr_import_index;
+					curr_import_index++;
 					gb_thread_start(t, parse_worker_file_proc, p);
 					are_any_alive = true;
 				}
@@ -4306,7 +4307,6 @@ ParseFileError parse_files(Parser *p, String init_filename) {
 				break;
 			}
 		}
-
 	} else {
 		for_array(i, p->imports) {
 			ParseFileError err = parse_import(p, p->imports[i]);
@@ -4316,7 +4316,6 @@ ParseFileError parse_files(Parser *p, String init_filename) {
 		}
 	}
 #else
-
 	for_array(i, p->imports) {
 		ParseFileError err = parse_import(p, p->imports[i]);
 		if (err != ParseFile_None) {
@@ -4325,11 +4324,6 @@ ParseFileError parse_files(Parser *p, String init_filename) {
 	}
 #endif
 
-	for_array(i, p->files) {
-		p->total_token_count += p->files[i]->tokens.count;
-	}
-
-
 	return ParseFile_None;
 }