/**************************************************************************************
 * Chaga compiler                                                                     *
 * Copyright (C) 2026 Robert James Bruce                                              *
 *                                                                                    *
 * This file is part of the Chaga compiler.                                           *
 *                                                                                    *
 * The Chaga compiler is free software: you can redistribute it and/or modify it      *
 * under the terms of the GNU General Public License as published by the              *
 * Free Software Foundation, either version 3 of the License, or (at your option) any *
 * later version.                                                                     *
 *                                                                                    *
 * The Chaga compiler is distributed in the hope that it will be useful, but WITHOUT  *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or              *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License               *
 * for more details.                                                                  *
 *                                                                                    *
 * You should have received a copy of the GNU General Public License                  *
 * along with the Chaga compiler. If not, see <https://www.gnu.org/licenses/>.        *
 **************************************************************************************/
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#ifndef CHAGA_COMPILER_CONSTANTS
#include "chaga_compiler-constants.h"
#endif

#ifndef CHAGA_DATA_STRUCTURES
#include "chaga_compiler-data_structures.h"
#endif

#include "chaga_compiler-data_structure_management.h"
#include "chaga_compiler-diagnostic_tools.h"

stackframe_node * create_stackframe_cross_reference_table_for_main_only (symtab_node *);
asmblr_node * create_assembler_program (ast_node *, symtab_node *, stackframe_node *);
asmblr_node * create_assembler_output_for_main_function_definition (asmblr_node *, symtab_node *, stackframe_node *, unsigned long long int);
asmblr_node * create_assembler_output_print_statement (asmblr_node *, ast_node *, stackframe_node *);
asmblr_node * create_assembler_output_set_statement_numerical_expression_integer (asmblr_node *, ast_node *, symtab_node *, stackframe_node *);
asmblr_node * create_assembler_output_set_statement_numerical_expression_float (asmblr_node *, ast_node *, symtab_node *, stackframe_node *);
asmblr_node * create_assembler_output_set_statement_boolean_expression (asmblr_node *, ast_node *, symtab_node *, stackframe_node *);
asmblr_node * create_assembler_output_exit_main_function (asmblr_node *);
asmblr_node * create_assembler_output_for_internal_chaga_input_output_library (asmblr_node *);
void write_assembler_output_to_file (FILE *, asmblr_node *);
void create_executable_output_file_from_x86_assembler_file (char *, char *, char *);
size_t symbol_table_count_number_of_datatype_declarations_for_given_scope_level_excluding_argv_argc_in_main (symtab_node *, unsigned long long int);
unsigned long long int retrieve_highest_label_number_from_assembly_output (asmblr_node *);
size_t determine_stackframe_storage_size_for_all_locally_defined_variables_in_main (stackframe_node *, symtab_node *);
char * escape_double_quotes_inside_text (char *);

