CORE_Static
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
global S32 global_indent;
|
||||
global S32 is_inside_struct;
|
||||
|
||||
function void gen_ast(Ast *ast);
|
||||
function bool gen_expr(Ast_Expr *ast);
|
||||
CORE_Static void gen_ast(Ast *ast);
|
||||
CORE_Static bool gen_expr(Ast_Expr *ast);
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_indent(){
|
||||
for(S32 i = 0; i < global_indent; i++) gen(" ");
|
||||
}
|
||||
|
||||
global Intern_String last_filename;
|
||||
global int last_line;
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_line(Ast *node){
|
||||
if(emit_line_directives){
|
||||
last_line = node->pos->line+1;
|
||||
@@ -26,14 +26,14 @@ gen_line(Ast *node){
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_last_line(){
|
||||
if(emit_line_directives){
|
||||
genln("#line %d", last_line);
|
||||
}
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string_scope_name(Arena *a, Ast_Scope *scope){
|
||||
String string = {};
|
||||
if(scope->parent_scope) string = string_scope_name(a, scope->parent_scope);
|
||||
@@ -42,14 +42,14 @@ string_scope_name(Arena *a, Ast_Scope *scope){
|
||||
return string;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_scope_name(Ast_Scope *scope){
|
||||
Scratch scratch;
|
||||
String string = string_scope_name(scratch, scope);
|
||||
gen("%.*s", (int)string.len, string.str);
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
unique_name(Arena *allocator, Ast *ast){
|
||||
Scratch scratch(allocator);
|
||||
String result = string_scope_name(scratch, ast->parent_scope);
|
||||
@@ -59,7 +59,7 @@ unique_name(Arena *allocator, Ast *ast){
|
||||
}
|
||||
|
||||
global String prefixed_string_type;
|
||||
function const char *
|
||||
CORE_Static const char *
|
||||
get_ctype_name_for_type(Ast_Type *type){
|
||||
switch(type->kind){
|
||||
case TYPE_VOID: return "void";
|
||||
@@ -84,7 +84,7 @@ get_ctype_name_for_type(Ast_Type *type){
|
||||
return "<unknown_type>";
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string_simple_decl_prefix(Arena *a, Ast_Type *ast){
|
||||
switch(ast->kind){
|
||||
case TYPE_POINTER:{
|
||||
@@ -121,7 +121,7 @@ string_simple_decl_prefix(Arena *a, Ast_Type *ast){
|
||||
return {};
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string_simple_decl_postfix(Arena *a, Ast_Type *ast){
|
||||
switch(ast->kind){
|
||||
case TYPE_POINTER:
|
||||
@@ -140,7 +140,7 @@ string_simple_decl_postfix(Arena *a, Ast_Type *ast){
|
||||
return {};
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
string_simple_decl(Arena *a, Ast_Type *ast, Intern_String name = {}){
|
||||
if(ast->kind == TYPE_LAMBDA) {
|
||||
String prefix = string_simple_decl_prefix(a, ast->func.ret);
|
||||
@@ -165,14 +165,14 @@ string_simple_decl(Arena *a, Ast_Type *ast, Intern_String name = {}){
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_simple_decl(Ast_Type *ast, Intern_String name = {}){
|
||||
Scratch scratch;
|
||||
String string = string_simple_decl(scratch, ast, name);
|
||||
gen("%.*s", (int)string.len, string.str);
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
gen_string_simple_decl(Arena *a, Ast_Type *ast, String name){
|
||||
Scratch scratch;
|
||||
String string = string_simple_decl(scratch, ast, pctx->intern(name));
|
||||
@@ -180,7 +180,7 @@ gen_string_simple_decl(Arena *a, Ast_Type *ast, String name){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
get_type_postfix(Ast_Type *type){
|
||||
switch(type->kind) {
|
||||
case TYPE_F32: return "f"_s; break;
|
||||
@@ -197,7 +197,7 @@ get_type_postfix(Ast_Type *type){
|
||||
return ""_s;
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
gen_value(Token *pos, Value a){
|
||||
if(is_untyped(a.type)) compiler_error(pos, "Internal compiler error: Untyped got propagated to the codegen stage");
|
||||
|
||||
@@ -250,7 +250,7 @@ gen_value(Token *pos, Value a){
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_stmt_scope(Ast_Scope *scope, B32 switch_case_gen_break = 0){
|
||||
gen("{");
|
||||
global_indent++;
|
||||
@@ -270,7 +270,7 @@ enum {
|
||||
DONT_EMIT_VALUE = 1,
|
||||
};
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_pointer(Ast_Expr *expr){
|
||||
gen("&");
|
||||
if(is_flag_set(expr->flags, AST_IS_LVALUE)){
|
||||
@@ -286,7 +286,7 @@ gen_pointer(Ast_Expr *expr){
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_try_any_or_slice(Ast_Expr *expr, Ast_Type *decl_type){
|
||||
|
||||
// We want normal values to get boxed as Any pointers
|
||||
@@ -305,7 +305,7 @@ gen_try_any_or_slice(Ast_Expr *expr, Ast_Type *decl_type){
|
||||
else gen_expr(expr);
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_var(Ast_Decl *decl, B32 emit_value, B32 scope_names){
|
||||
if(is_flag_set(decl->flags, AST_FOREIGN)) gen("extern ");
|
||||
gen_simple_decl(decl->type, decl->name);
|
||||
@@ -327,7 +327,7 @@ gen_var(Ast_Decl *decl, B32 emit_value, B32 scope_names){
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_lambda(Intern_String name, Ast_Lambda *lambda, B32 generate_block = true){
|
||||
gen_simple_decl(lambda->resolved_type->func.ret, name);
|
||||
gen("(");
|
||||
@@ -344,7 +344,7 @@ gen_lambda(Intern_String name, Ast_Lambda *lambda, B32 generate_block = true){
|
||||
else gen(";");
|
||||
}
|
||||
|
||||
function bool
|
||||
CORE_Static bool
|
||||
gen_expr(Ast_Expr *ast){
|
||||
switch(ast->kind){
|
||||
CASE(IDENT, Atom){
|
||||
@@ -515,7 +515,7 @@ gen_expr(Ast_Expr *ast){
|
||||
return true;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
gen_ast(Ast *ast){
|
||||
switch(ast->kind){
|
||||
|
||||
@@ -767,7 +767,7 @@ gen_ast(Ast *ast){
|
||||
}
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
compile_to_c_code(){
|
||||
generating_time_begin = os_time();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user