From de3628c5b54cebc6e0d66a531bbe88e338f2bea5 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 30 Oct 2024 14:27:02 -0400 Subject: [PATCH] Fix for methods not appearing in headers --- compile.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/compile.c b/compile.c index a3ec1f7..f83306d 100644 --- a/compile.c +++ b/compile.c @@ -3756,23 +3756,6 @@ CORD compile_statement_type_header(env_t *env, ast_t *ast) "extern const TypeInfo_t ", full_name, ";\n" ); } - case FunctionDef: { - auto fndef = Match(ast, FunctionDef); - const char *decl_name = Match(fndef->name, Var)->name; - bool is_private = decl_name[0] == '_'; - if (is_private) return CORD_EMPTY; - CORD arg_signature = "("; - for (arg_ast_t *arg = fndef->args; arg; arg = arg->next) { - type_t *arg_type = get_arg_ast_type(env, arg); - arg_signature = CORD_cat(arg_signature, compile_declaration(arg_type, CORD_cat("$", arg->name))); - if (arg->next) arg_signature = CORD_cat(arg_signature, ", "); - } - arg_signature = CORD_cat(arg_signature, ")"); - - type_t *ret_t = fndef->ret_type ? parse_type_ast(env, fndef->ret_type) : Type(VoidType); - CORD ret_type_code = compile_type(ret_t); - return CORD_all(ret_type_code, " ", namespace_prefix(env, env->namespace), decl_name, arg_signature, ";\n"); - } case Extern: { auto ext = Match(ast, Extern); type_t *t = parse_type_ast(env, ext->type); @@ -3819,6 +3802,23 @@ CORD compile_statement_namespace_header(env_t *env, ast_t *ast) block = def->namespace; break; } + case FunctionDef: { + auto fndef = Match(ast, FunctionDef); + const char *decl_name = Match(fndef->name, Var)->name; + bool is_private = decl_name[0] == '_'; + if (is_private) return CORD_EMPTY; + CORD arg_signature = "("; + for (arg_ast_t *arg = fndef->args; arg; arg = arg->next) { + type_t *arg_type = get_arg_ast_type(env, arg); + arg_signature = CORD_cat(arg_signature, compile_declaration(arg_type, CORD_cat("$", arg->name))); + if (arg->next) arg_signature = CORD_cat(arg_signature, ", "); + } + arg_signature = CORD_cat(arg_signature, ")"); + + type_t *ret_t = fndef->ret_type ? parse_type_ast(env, fndef->ret_type) : Type(VoidType); + CORD ret_type_code = compile_type(ret_t); + return CORD_all(ret_type_code, " ", namespace_prefix(env, env->namespace), decl_name, arg_signature, ";\n"); + } default: return CORD_EMPTY; } env_t *ns_env = namespace_env(env, ns_name);