F diff --git a/src/backend/asm/intel/intel_asm.c b/src/backend/asm/intel/intel_asm.c
--- a/src/backend/asm/intel/intel_asm.c
+++ b/src/backend/asm/intel/intel_asm.c
whole_size+=get_type_size(((struct Denoted_Object*)it->data)->object->type);
release_stack_space(compile_data,whole_size);
}
+ void release_stack_frame_for_function(struct Compile_Data_Intel_Asm *compile_data)
+ {
+
+ }
void intel_asm_memory_location_to_rax(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location)
{
switch(location->type)
F diff --git a/src/backend/asm/intel/intel_asm.h b/src/backend/asm/intel/intel_asm.h
--- a/src/backend/asm/intel/intel_asm.h
+++ b/src/backend/asm/intel/intel_asm.h
int number_of_anon_labels;
_Bool in_main;
+ struct AST_Function_Definition *current_function;
int offset_from_stack_frame;
int stack_space_taken_for_current_block;
};
struct Intel_Asm_Memory_Location* reserve_static_space_for_string(struct Compile_Data_Intel_Asm *compile_data,struct Constant *string);
void release_stack_space_for_whole_block_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct Normal_Scope *scope);
+ void release_stack_frame_for_function(struct Compile_Data_Intel_Asm *compile_data);
void intel_asm_memory_location_to_rax(struct Compile_Data_Intel_Asm *compile_data,struct Intel_Asm_Memory_Location *location);
F diff --git a/src/backend/asm/intel/intel_compile.c b/src/backend/asm/intel/intel_compile.c
--- a/src/backend/asm/intel/intel_compile.c
+++ b/src/backend/asm/intel/intel_compile.c
{
compile_ast_to_intel_asm(compile_data,ret->return_expression);
push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
- if(!compile_data->in_main)
- push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RBP));
+
+ push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RBP));
push_intel_asm_instruction(compile_data,get_intel_asm_simple_instruction(INTEL_ASM_OP_RET));
}
void compile_object_declaration_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Object_Declaration *objd)
{
- /*
- push_intel_asm_instruction(compile_data,
- get_intel_asm_binary_instruction(get_intel_asm_register(INTEL_ASM_REGISTER_SP),
- get_intel_asm_in_instruction_number(4),
- INTEL_ASM_OP_SUB));
- */
reserve_stack_space_for_object(compile_data,objd->object->object);
}
void compile_function_definition_to_intel_asm(struct Compile_Data_Intel_Asm *compile_data,struct AST_Function_Definition *def)
{
compile_data->offset_from_stack_frame=0;
compile_data->stack_space_taken_for_current_block=0;
+ compile_data->current_function=def;
export_function_definition(compile_data,def);
F diff --git a/src/backend/asm/intel/intel_instruction.c b/src/backend/asm/intel/intel_instruction.c
--- a/src/backend/asm/intel/intel_instruction.c
+++ b/src/backend/asm/intel/intel_instruction.c
{
struct Intel_Asm_Label *ret;
char *label;
- label=calloc(1,1024);
+ label=wonky_calloc(1,1024);
if(snprintf(label,1024,"_label_%d",compile_data->number_of_anon_labels)!=1024)
label[1023]='\0';/*TODO throw an error*/
F diff --git a/src/backend/text/print/print.c b/src/backend/text/print/print.c
--- a/src/backend/text/print/print.c
+++ b/src/backend/text/print/print.c
case TS_ARRAY:
{
char *number_of_elements;
- number_of_elements=calloc(1,1024);
+ number_of_elements=wonky_calloc(1,1024);
if(snprintf(number_of_elements,1024," array [%zu] of ",((struct Type_Array*)type)->number_of_elements)==1024)
number_of_elements[1023]='\0';
{
char *str;
- str=calloc(1,1024);
+ str=wonky_calloc(1,1024);
if(snprintf(str,1024," bitfield object with %zu bits ",object->number_of_bits)==1024)
str[1023]='\0';
F diff --git a/src/environment/error/gcc_error.c b/src/environment/error/gcc_error.c
--- a/src/environment/error/gcc_error.c
+++ b/src/environment/error/gcc_error.c
else
filename_length=sizeof("NULL")+100;
- ret=calloc(filename_length+64,1);
+ ret=wonky_calloc(filename_length+64,1);
sprintf(ret,"%s %zu:%zu ",filename,line,column);
return ret;