|
Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
|
Type checking and symbol table management for AST nodes with memory tracking. More...
#include "../ast/ast.h"#include "../c_libs/memory/memory.h"#include "../helper/help.h"#include "../lexer/lexer.h"

Go to the source code of this file.
Classes | |
| struct | StaticAllocation |
| struct | StaticMemoryAnalyzer |
| struct | Symbol |
| Represents a symbol with associated type and metadata. More... | |
| struct | Scope |
| Represents a lexical scope with hierarchical relationships. More... | |
| struct | ModuleImport |
| Represents an imported module with optional aliasing. More... | |
| struct | ModuleDependency |
| struct | TypeError |
| Represents an error encountered during type checking. More... | |
Typedefs | |
| typedef struct Scope | Scope |
| Represents a lexical scope with hierarchical relationships. | |
Enumerations | |
| enum | TypeMatchResult { TYPE_MATCH_EXACT , TYPE_MATCH_COMPATIBLE , TYPE_MATCH_NONE } |
| Result of type compatibility checking. More... | |
Functions | |
| void | static_memory_analyzer_init (StaticMemoryAnalyzer *analyzer, ArenaAllocator *arena) |
| void | static_memory_track_alloc (StaticMemoryAnalyzer *analyzer, size_t line, size_t column, const char *var_name, const char *function_name, Token *tokens, size_t token_count, const char *file_path) |
| void | static_memory_track_free (StaticMemoryAnalyzer *analyzer, const char *var_name, const char *function_name, bool is_conditional) |
| int | static_memory_check_and_report (StaticMemoryAnalyzer *analyzer, ArenaAllocator *arena) |
| bool | static_memory_check_use_after_free (StaticMemoryAnalyzer *analyzer, const char *var_name, size_t line, size_t column, ArenaAllocator *arena, Token *tokens, int token_count, const char *file_path, const char *function_name) |
| StaticMemoryAnalyzer * | get_static_analyzer (Scope *scope) |
| void | static_memory_track_alias (StaticMemoryAnalyzer *analyzer, const char *new_var, const char *source_var, const char *function_name) |
| void | static_memory_mark_addr_taken (StaticMemoryAnalyzer *analyzer, const char *var_name, const char *function_name) |
| void | static_memory_check_free_nonalloc (StaticMemoryAnalyzer *analyzer, const char *var_name, size_t line, size_t column, Token *tokens, int token_count, const char *file_path, const char *function_name, ArenaAllocator *arena) |
| bool | is_pointer_assignment (AstNode *assignment) |
| void | init_scope (Scope *scope, Scope *parent, const char *name, ArenaAllocator *arena) |
| Initialize a scope structure with enhanced metadata. | |
| bool | scope_add_symbol (Scope *scope, const char *name, AstNode *type, bool is_public, bool is_mutable, ArenaAllocator *arena) |
| bool | scope_add_symbol_with_ownership (Scope *scope, const char *name, AstNode *type, bool is_public, bool is_mutable, bool returns_ownership, bool takes_ownership, ArenaAllocator *arena) |
| Symbol * | scope_lookup (Scope *scope, const char *name) |
| Original scope_lookup - now wraps the visibility version. | |
| Symbol * | scope_lookup_current_only (Scope *scope, const char *name) |
| Original scope_lookup_current_only - now wraps the visibility version. | |
| Symbol * | scope_lookup_with_visibility (Scope *scope, const char *name, Scope *requesting_module_scope) |
| Symbol * | scope_lookup_current_only_with_visibility (Scope *scope, const char *name, Scope *requesting_module_scope) |
| Look up a symbol only in the current scope with visibility rules. | |
| Scope * | find_containing_module (Scope *scope) |
| Find the containing module scope for a given scope. | |
| Scope * | create_child_scope (Scope *parent, const char *name, ArenaAllocator *arena) |
| Create a new child scope under the specified parent. | |
| void | debug_print_scope (Scope *scope, int indent_level) |
| void | debug_print_struct_type (AstNode *struct_type, int indent) |
| void | build_dependency_graph (AstNode **modules, size_t module_count, GrowableArray *dep_graph, ArenaAllocator *arena) |
| bool | process_module_in_order (const char *module_name, GrowableArray *dep_graph, AstNode **modules, size_t module_count, Scope *global_scope, ArenaAllocator *arena) |
| Process modules in dependency order (topological sort) | |
| bool | typecheck_program_multipass (AstNode *program, Scope *global_scope, ArenaAllocator *arena) |
| Three-pass typechecking for modules to handle forward references. | |
| const char * | get_current_function_name (Scope *scope) |
| bool | register_module (Scope *global_scope, const char *module_name, Scope *module_scope, ArenaAllocator *arena) |
| Register a module scope in the global scope. | |
| Scope * | find_module_scope (Scope *global_scope, const char *module_name) |
| Find a module scope by name. | |
| bool | add_module_import (Scope *importing_scope, const char *module_name, const char *alias, Scope *module_scope, ArenaAllocator *arena) |
| Add a module import to a scope. | |
| Symbol * | lookup_qualified_symbol (Scope *scope, const char *module_alias, const char *symbol_name) |
| Look up a qualified symbol (module_alias.symbol_name) with visibility rules. | |
| Scope * | create_module_scope (Scope *global_scope, const char *module_name, ArenaAllocator *arena) |
| Create a new module scope. | |
| bool | typecheck_module_stmt (AstNode *node, Scope *global_scope, ArenaAllocator *arena) |
| bool | typecheck_use_stmt (AstNode *node, Scope *current_scope, Scope *global_scope, ArenaAllocator *arena) |
| void | tc_error_init (Token *tokens, int token_count, const char *file_path, ArenaAllocator *arena) |
| Set global context for error reporting Call this once at the start of typechecking. | |
| void | tc_error (AstNode *node, const char *error_type, const char *format,...) |
| Simple error reporting - replaces fprintf(stderr, ...) Usage: tc_error(node, "Type Error", "Variable '%s' not found", var_name);. | |
| void | tc_error_help (AstNode *node, const char *error_type, const char *help, const char *format,...) |
| Error with help message. | |
| void | tc_error_id (AstNode *node, const char *identifier, const char *error_type, const char *format,...) |
| Error with identifier highlighting. | |
| TypeMatchResult | types_match (AstNode *type1, AstNode *type2) |
| bool | is_numeric_type (AstNode *type) |
| bool | is_integer_type (AstNode *type) |
| bool | is_pointer_type (AstNode *type) |
| bool | is_pointer_to_function_type (AstNode *type) |
| bool | is_array_type (AstNode *type) |
| bool | is_void_type (AstNode *type) |
| bool | is_bool_type (AstNode *type) |
| bool | is_struct_type_node (AstNode *type) |
| bool | is_function_type (AstNode *type) |
| bool | is_cast_valid (AstNode *from_type, AstNode *to_type) |
| AstNode * | get_element_type (AstNode *array_or_pointer_type, ArenaAllocator *arena) |
| const char * | type_to_string (AstNode *type, ArenaAllocator *arena) |
| bool | contains_alloc_expression (AstNode *expr) |
| bool | typecheck (AstNode *node, Scope *scope, ArenaAllocator *arena, BuildConfig *config) |
| AstNode * | typecheck_expression (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_statement (AstNode *stmt, Scope *scope, ArenaAllocator *arena) |
| const char * | extract_variable_name (AstNode *expr) |
| bool | typecheck_var_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_func_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| AstNode * | create_struct_type (ArenaAllocator *arena, const char *name, AstNode **member_types, const char **member_names, size_t member_count, size_t line, size_t column) |
| AstNode * | get_struct_member_type (AstNode *struct_type, const char *member_name) |
| bool | struct_has_member (AstNode *struct_type, const char *member_name) |
| bool | typecheck_struct_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_spread_decl (AstNode *spread, Scope *scope, ArenaAllocator *arena, const char *child_name, GrowableArray *seen_names, AstNode ***member_types, const char ***member_names, size_t *member_count) |
| bool | typecheck_enum_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_return_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_if_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_defer_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_switch_stmt (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_case_stmt (AstNode *node, Scope *scope, ArenaAllocator *arena, AstNode *expected_type) |
| bool | typecheck_default_stmt (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_infinite_loop_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_while_loop_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_for_loop_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_loop_decl (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_os_stmt (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| bool | typecheck_link_stmt (AstNode *node, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_binary_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_unary_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_call_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_member_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_index_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_deref_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_addr_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_alloc_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_free_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_memcpy_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_cast_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_input_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_system_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_sizeof_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_assignment_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_array_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | typecheck_syscall_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| Type check a syscall expression. | |
| AstNode * | typecheck_struct_expr_internal (AstNode *expr, Scope *scope, ArenaAllocator *arena, AstNode *expected_type) |
| AstNode * | typecheck_struct_expr (AstNode *expr, Scope *scope, ArenaAllocator *arena) |
| AstNode * | get_enclosing_function_return_type (Scope *scope) |
| bool | validate_array_type (AstNode *array_type, Scope *scope, ArenaAllocator *arena) |
| bool | check_array_bounds (AstNode *array_type, AstNode *index_expr, ArenaAllocator *arena) |
| AstNode * | typecheck_multidim_array_access (AstNode *base_type, AstNode **indices, size_t index_count, ArenaAllocator *arena) |
| TypeMatchResult | check_array_compatibility (AstNode *type1, AstNode *type2) |
| bool | validate_array_initializer (AstNode *declared_type, AstNode *initializer, Scope *scope, ArenaAllocator *arena) |
| void | print_type_error (TypeError *error) |
Variables | |
| Token * | g_tokens |
| int | g_token_count |
| const char * | g_file_path |
| ArenaAllocator * | g_arena |
Type checking and symbol table management for AST nodes with memory tracking.
Provides type checking for the Abstract Syntax Tree (AST), including:
| enum TypeMatchResult |
| bool add_module_import | ( | Scope * | importing_scope, |
| const char * | module_name, | ||
| const char * | alias, | ||
| Scope * | module_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
Add a module import to a scope.
| void build_dependency_graph | ( | AstNode ** | modules, |
| size_t | module_count, | ||
| GrowableArray * | dep_graph, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool check_array_bounds | ( | AstNode * | array_type, |
| AstNode * | index_expr, | ||
| ArenaAllocator * | arena | ||
| ) |
| TypeMatchResult check_array_compatibility | ( | AstNode * | type1, |
| AstNode * | type2 | ||
| ) |
| bool contains_alloc_expression | ( | AstNode * | expr | ) |
| Scope * create_child_scope | ( | Scope * | parent, |
| const char * | name, | ||
| ArenaAllocator * | arena | ||
| ) |
Create a new child scope under the specified parent.
Allocates and initializes a new scope as a child of the given parent, automatically establishing the parent-child relationship and adding the new scope to the parent's children list.
| parent | Parent scope for the new child (NULL for root scope) |
| name | Descriptive name for the new scope |
| arena | Arena allocator for memory management |
Creation process:
| Scope * create_module_scope | ( | Scope * | global_scope, |
| const char * | module_name, | ||
| ArenaAllocator * | arena | ||
| ) |
Create a new module scope.
| AstNode * create_struct_type | ( | ArenaAllocator * | arena, |
| const char * | name, | ||
| AstNode ** | member_types, | ||
| const char ** | member_names, | ||
| size_t | member_count, | ||
| size_t | line, | ||
| size_t | column | ||
| ) |
| void debug_print_scope | ( | Scope * | scope, |
| int | indent_level | ||
| ) |
| void debug_print_struct_type | ( | AstNode * | struct_type, |
| int | indent | ||
| ) |
| const char * extract_variable_name | ( | AstNode * | expr | ) |
Find a module scope by name.
| const char * get_current_function_name | ( | Scope * | scope | ) |
| AstNode * get_element_type | ( | AstNode * | array_or_pointer_type, |
| ArenaAllocator * | arena | ||
| ) |
| StaticMemoryAnalyzer * get_static_analyzer | ( | Scope * | scope | ) |
| void init_scope | ( | Scope * | scope, |
| Scope * | parent, | ||
| const char * | name, | ||
| ArenaAllocator * | arena | ||
| ) |
Initialize a scope structure with enhanced metadata.
Sets up a new scope with proper initialization of all fields, including parent-child relationships, depth calculation, and growable arrays for symbols and children. The scope is fully prepared for symbol addition and child scope creation.
| scope | Pointer to the scope structure to initialize (must be pre-allocated) |
| parent | Parent scope for hierarchical lookup (NULL for global scope) |
| name | Descriptive name for debugging and identification (NULL becomes "unnamed") |
| arena | Arena allocator for all memory allocations within this scope |
Initialization includes:
| bool is_array_type | ( | AstNode * | type | ) |
| bool is_bool_type | ( | AstNode * | type | ) |
| bool is_function_type | ( | AstNode * | type | ) |
| bool is_integer_type | ( | AstNode * | type | ) |
| bool is_numeric_type | ( | AstNode * | type | ) |
| bool is_pointer_assignment | ( | AstNode * | assignment | ) |
| bool is_pointer_to_function_type | ( | AstNode * | type | ) |
| bool is_pointer_type | ( | AstNode * | type | ) |
| bool is_struct_type_node | ( | AstNode * | type | ) |
| bool is_void_type | ( | AstNode * | type | ) |
| Symbol * lookup_qualified_symbol | ( | Scope * | scope, |
| const char * | module_alias, | ||
| const char * | symbol_name | ||
| ) |
Look up a qualified symbol (module_alias.symbol_name) with visibility rules.
| void print_type_error | ( | TypeError * | error | ) |
| bool process_module_in_order | ( | const char * | module_name, |
| GrowableArray * | dep_graph, | ||
| AstNode ** | modules, | ||
| size_t | module_count, | ||
| Scope * | global_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
Process modules in dependency order (topological sort)
| bool register_module | ( | Scope * | global_scope, |
| const char * | module_name, | ||
| Scope * | module_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
Register a module scope in the global scope.
| bool scope_add_symbol | ( | Scope * | scope, |
| const char * | name, | ||
| AstNode * | type, | ||
| bool | is_public, | ||
| bool | is_mutable, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool scope_add_symbol_with_ownership | ( | Scope * | scope, |
| const char * | name, | ||
| AstNode * | type, | ||
| bool | is_public, | ||
| bool | is_mutable, | ||
| bool | returns_ownership, | ||
| bool | takes_ownership, | ||
| ArenaAllocator * | arena | ||
| ) |
Original scope_lookup - now wraps the visibility version.
Original scope_lookup_current_only - now wraps the visibility version.
| Symbol * scope_lookup_current_only_with_visibility | ( | Scope * | scope, |
| const char * | name, | ||
| Scope * | requesting_module_scope | ||
| ) |
Look up a symbol only in the current scope with visibility rules.
| Symbol * scope_lookup_with_visibility | ( | Scope * | scope, |
| const char * | name, | ||
| Scope * | requesting_module_scope | ||
| ) |
| void static_memory_analyzer_init | ( | StaticMemoryAnalyzer * | analyzer, |
| ArenaAllocator * | arena | ||
| ) |
| int static_memory_check_and_report | ( | StaticMemoryAnalyzer * | analyzer, |
| ArenaAllocator * | arena | ||
| ) |
| void static_memory_check_free_nonalloc | ( | StaticMemoryAnalyzer * | analyzer, |
| const char * | var_name, | ||
| size_t | line, | ||
| size_t | column, | ||
| Token * | tokens, | ||
| int | token_count, | ||
| const char * | file_path, | ||
| const char * | function_name, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool static_memory_check_use_after_free | ( | StaticMemoryAnalyzer * | analyzer, |
| const char * | var_name, | ||
| size_t | line, | ||
| size_t | column, | ||
| ArenaAllocator * | arena, | ||
| Token * | tokens, | ||
| int | token_count, | ||
| const char * | file_path, | ||
| const char * | function_name | ||
| ) |
| void static_memory_mark_addr_taken | ( | StaticMemoryAnalyzer * | analyzer, |
| const char * | var_name, | ||
| const char * | function_name | ||
| ) |
| void static_memory_track_alias | ( | StaticMemoryAnalyzer * | analyzer, |
| const char * | new_var, | ||
| const char * | source_var, | ||
| const char * | function_name | ||
| ) |
| void static_memory_track_alloc | ( | StaticMemoryAnalyzer * | analyzer, |
| size_t | line, | ||
| size_t | column, | ||
| const char * | var_name, | ||
| const char * | function_name, | ||
| Token * | tokens, | ||
| size_t | token_count, | ||
| const char * | file_path | ||
| ) |
| void static_memory_track_free | ( | StaticMemoryAnalyzer * | analyzer, |
| const char * | var_name, | ||
| const char * | function_name, | ||
| bool | is_conditional | ||
| ) |
| bool struct_has_member | ( | AstNode * | struct_type, |
| const char * | member_name | ||
| ) |
| void tc_error | ( | AstNode * | node, |
| const char * | error_type, | ||
| const char * | format, | ||
| ... | |||
| ) |
Simple error reporting - replaces fprintf(stderr, ...) Usage: tc_error(node, "Type Error", "Variable '%s' not found", var_name);.
| void tc_error_help | ( | AstNode * | node, |
| const char * | error_type, | ||
| const char * | help, | ||
| const char * | format, | ||
| ... | |||
| ) |
Error with help message.
| void tc_error_id | ( | AstNode * | node, |
| const char * | identifier, | ||
| const char * | error_type, | ||
| const char * | format, | ||
| ... | |||
| ) |
Error with identifier highlighting.
| void tc_error_init | ( | Token * | tokens, |
| int | token_count, | ||
| const char * | file_path, | ||
| ArenaAllocator * | arena | ||
| ) |
Set global context for error reporting Call this once at the start of typechecking.
| const char * type_to_string | ( | AstNode * | type, |
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena, | ||
| BuildConfig * | config | ||
| ) |
| AstNode * typecheck_addr_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_alloc_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_array_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_assignment_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_binary_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_call_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_case_stmt | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena, | ||
| AstNode * | expected_type | ||
| ) |
| AstNode * typecheck_cast_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_default_stmt | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_defer_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_deref_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_enum_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_expression | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_for_loop_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_free_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_func_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_if_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_index_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_infinite_loop_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_input_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_link_stmt | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_loop_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_member_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_memcpy_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_module_stmt | ( | AstNode * | node, |
| Scope * | global_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_multidim_array_access | ( | AstNode * | base_type, |
| AstNode ** | indices, | ||
| size_t | index_count, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_os_stmt | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_program_multipass | ( | AstNode * | program, |
| Scope * | global_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
Three-pass typechecking for modules to handle forward references.
This allows modules to be declared and used in any order by:
| program | AST_PROGRAM node containing all modules |
| global_scope | Global scope to register modules in |
| arena | Arena allocator for memory management |
| bool typecheck_return_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_sizeof_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_spread_decl | ( | AstNode * | spread, |
| Scope * | scope, | ||
| ArenaAllocator * | arena, | ||
| const char * | child_name, | ||
| GrowableArray * | seen_names, | ||
| AstNode *** | member_types, | ||
| const char *** | member_names, | ||
| size_t * | member_count | ||
| ) |
| bool typecheck_statement | ( | AstNode * | stmt, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_struct_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_struct_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_struct_expr_internal | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena, | ||
| AstNode * | expected_type | ||
| ) |
| bool typecheck_switch_stmt | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_syscall_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
Type check a syscall expression.
Syscall requires:
Returns: int (the return value from the syscall)
| AstNode * typecheck_system_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| AstNode * typecheck_unary_expr | ( | AstNode * | expr, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_use_stmt | ( | AstNode * | node, |
| Scope * | current_scope, | ||
| Scope * | global_scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_var_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool typecheck_while_loop_decl | ( | AstNode * | node, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| TypeMatchResult types_match | ( | AstNode * | type1, |
| AstNode * | type2 | ||
| ) |
| bool validate_array_initializer | ( | AstNode * | declared_type, |
| AstNode * | initializer, | ||
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
| bool validate_array_type | ( | AstNode * | array_type, |
| Scope * | scope, | ||
| ArenaAllocator * | arena | ||
| ) |
|
extern |
|
extern |
|
extern |
|
extern |