Zen-C
Loading...
Searching...
No Matches
codegen_utils.c File Reference
#include "../ast/ast.h"
#include "../parser/parser.h"
#include "../zprep.h"
#include "codegen.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for codegen_utils.c:

Functions

char * strip_template_suffix (const char *name)
 
void emit_c_decl (ParserContext *ctx, FILE *out, const char *type_str, const char *name)
 
void emit_var_decl_type (ParserContext *ctx, FILE *out, const char *type_str, const char *var_name)
 
ASTNodefind_struct_def_codegen (ParserContext *ctx, const char *name)
 
char * get_field_type_str (ParserContext *ctx, const char *struct_name, const char *field_name)
 
char * infer_type (ParserContext *ctx, ASTNode *node)
 
char * extract_call_args (const char *args)
 
const char * parse_original_method_name (const char *mangled)
 
char * replace_string_type (const char *args)
 
void emit_auto_type (ParserContext *ctx, ASTNode *init_expr, Token t, FILE *out)
 
char * codegen_type_to_string (Type *t)
 
void emit_func_signature (ParserContext *ctx, FILE *out, ASTNode *func, const char *name_override)
 
int emit_move_invalidation (ParserContext *ctx, ASTNode *node, FILE *out)
 
void codegen_expression_with_move (ParserContext *ctx, ASTNode *node, FILE *out)
 

Variables

ASTNodeglobal_user_structs = NULL
 List of user defined structs.
 
char * g_current_impl_type = NULL
 Type currently being implemented (in impl block).
 
int tmp_counter = 0
 Counter for temporary variables.
 
ASTNodedefer_stack [MAX_DEFER]
 Stack of deferred nodes.
 
int defer_count = 0
 Counter for defer statements in current scope.
 
ASTNodeg_current_lambda = NULL
 Current lambda being generated.
 
int loop_defer_boundary [MAX_LOOP_DEPTH]
 Defer stack index at start of each loop.
 
int loop_depth = 0
 Current loop nesting depth.
 
int func_defer_boundary = 0
 Defer stack index at function entry.
 

Function Documentation

◆ codegen_expression_with_move()

void codegen_expression_with_move ( ParserContext ctx,
ASTNode node,
FILE *  out 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ codegen_type_to_string()

char * codegen_type_to_string ( Type t)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit_auto_type()

void emit_auto_type ( ParserContext ctx,
ASTNode init_expr,
Token  t,
FILE *  out 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit_c_decl()

void emit_c_decl ( ParserContext ctx,
FILE *  out,
const char *  type_str,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit_func_signature()

void emit_func_signature ( ParserContext ctx,
FILE *  out,
ASTNode func,
const char *  name_override 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit_move_invalidation()

int emit_move_invalidation ( ParserContext ctx,
ASTNode node,
FILE *  out 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit_var_decl_type()

void emit_var_decl_type ( ParserContext ctx,
FILE *  out,
const char *  type_str,
const char *  var_name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_call_args()

char * extract_call_args ( const char *  args)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_struct_def_codegen()

ASTNode * find_struct_def_codegen ( ParserContext ctx,
const char *  name 
)
Here is the caller graph for this function:

◆ get_field_type_str()

char * get_field_type_str ( ParserContext ctx,
const char *  struct_name,
const char *  field_name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ infer_type()

char * infer_type ( ParserContext ctx,
ASTNode node 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_original_method_name()

const char * parse_original_method_name ( const char *  mangled)
Here is the caller graph for this function:

◆ replace_string_type()

char * replace_string_type ( const char *  args)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ strip_template_suffix()

char * strip_template_suffix ( const char *  name)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ defer_count

int defer_count = 0

Counter for defer statements in current scope.

◆ defer_stack

ASTNode* defer_stack[MAX_DEFER]

Stack of deferred nodes.

◆ func_defer_boundary

int func_defer_boundary = 0

Defer stack index at function entry.

◆ g_current_impl_type

char* g_current_impl_type = NULL

Type currently being implemented (in impl block).

◆ g_current_lambda

ASTNode* g_current_lambda = NULL

Current lambda being generated.

◆ global_user_structs

ASTNode* global_user_structs = NULL

List of user defined structs.

◆ loop_defer_boundary

int loop_defer_boundary[MAX_LOOP_DEPTH]

Defer stack index at start of each loop.

◆ loop_depth

int loop_depth = 0

Current loop nesting depth.

◆ tmp_counter

int tmp_counter = 0

Counter for temporary variables.