Added static to non extern non main functions in c_generator giving a 12 second compilation speedup - added a nodes touched pass, commented out in main, and fixed the test_extern test to use the right printf arguments.

This commit is contained in:
Nathan Braswell
2016-07-06 22:46:57 -07:00
parent a5deef8c30
commit dc5fe39083
3 changed files with 17 additions and 3 deletions

View File

@@ -203,8 +203,11 @@ obj c_generator (Object) {
parameter_types += ", ..."
parameters += ", ..."
}
return make_pair(type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameter_types + ");\n",
type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameters + ")")
var possibly_static = string()
if (!backing.is_extern && decorated_name != "main")
possibly_static = "static "
return make_pair(possibly_static + type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameter_types + ");\n",
possibly_static + type_to_c(backing.type->return_type) + " " + decorated_name + "(" + parameters + ")")
}
fun generate_c(name_ast_map: map<string, pair<*tree<symbol>,*ast_node>>, ast_to_syntax_in: map<*ast_node, *tree<symbol>> ): pair<string,string> {
ast_to_syntax = ast_to_syntax_in