summaryrefslogtreecommitdiff
path: root/src/codegen/codegen.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/codegen.h')
-rw-r--r--src/codegen/codegen.h46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/codegen/codegen.h b/src/codegen/codegen.h
index 942de41..ec77817 100644
--- a/src/codegen/codegen.h
+++ b/src/codegen/codegen.h
@@ -8,10 +8,34 @@
#include <stdio.h>
// Main codegen entry points.
+
+/**
+ * @brief Generates code for a given AST node.
+ *
+ * @param ctx Parser context.
+ * @param node The AST node to generate code for.
+ * @param out Output file stream.
+ */
void codegen_node(ParserContext *ctx, ASTNode *node, FILE *out);
+
+/**
+ * @brief Generates code for a single AST node (non-recursive for siblings).
+ */
void codegen_node_single(ParserContext *ctx, ASTNode *node, FILE *out);
+
+/**
+ * @brief Walker for list of nodes (calls codegen_node recursively).
+ */
void codegen_walker(ParserContext *ctx, ASTNode *node, FILE *out);
+
+/**
+ * @brief Generates code for an expression node.
+ */
void codegen_expression(ParserContext *ctx, ASTNode *node, FILE *out);
+
+/**
+ * @brief Internal handler for match statements.
+ */
void codegen_match_internal(ParserContext *ctx, ASTNode *node, FILE *out, int use_result);
// Utility functions (codegen_utils.c).
@@ -26,7 +50,7 @@ void emit_auto_type(ParserContext *ctx, ASTNode *init_expr, Token t, FILE *out);
char *codegen_type_to_string(Type *t);
void emit_func_signature(FILE *out, ASTNode *func, const char *name_override);
char *strip_template_suffix(const char *name);
-char *strip_template_suffix(const char *name);
+// duplicate decl removed: char *strip_template_suffix(const char *name);
int emit_move_invalidation(ParserContext *ctx, ASTNode *node, FILE *out);
void codegen_expression_with_move(ParserContext *ctx, ASTNode *node, FILE *out);
@@ -46,19 +70,19 @@ int emit_tests_and_runner(ParserContext *ctx, ASTNode *node, FILE *out);
void print_type_defs(ParserContext *ctx, FILE *out, ASTNode *nodes);
// Global state (shared across modules).
-extern ASTNode *global_user_structs;
-extern char *g_current_impl_type;
-extern int tmp_counter;
-extern int defer_count;
-extern ASTNode *defer_stack[];
-extern ASTNode *g_current_lambda;
-extern char *g_current_func_ret_type;
+extern ASTNode *global_user_structs; ///< List of user defined structs.
+extern char *g_current_impl_type; ///< Type currently being implemented (in impl block).
+extern int tmp_counter; ///< Counter for temporary variables.
+extern int defer_count; ///< Counter for defer statements in current scope.
+extern ASTNode *defer_stack[]; ///< Stack of deferred nodes.
+extern ASTNode *g_current_lambda; ///< Current lambda being generated.
+extern char *g_current_func_ret_type; ///< Return type of current function.
// Defer boundary tracking for proper defer execution on break/continue/return
#define MAX_DEFER 1024
#define MAX_LOOP_DEPTH 64
-extern int loop_defer_boundary[]; // defer_count at each loop entry
-extern int loop_depth; // current loop nesting depth
-extern int func_defer_boundary; // defer_count at function entry
+extern int loop_defer_boundary[]; ///< Defer stack index at start of each loop.
+extern int loop_depth; ///< Current loop nesting depth.
+extern int func_defer_boundary; ///< Defer stack index at function entry.
#endif