static int module_add_default_prototype(struct module *m) { struct symbol *param, *fun; param = symbol_new("size", type_long); param->variable.is_parameter = true; fun = function_declare(symbol_new(UUC_WHAT_MALLOC, type_generic), list_new(LI_ELEM, param, NULL), m); module_add_prototype(m, fun); param = symbol_new("map_controller", type_generic); param->variable.is_parameter = true; fun = function_declare(symbol_new("map", type_void), list_new(LI_ELEM, param, NULL), m); // arguments module_add_prototype(m, fun); param = symbol_new("reduce_controller", type_generic); param->variable.is_parameter = true; fun = function_declare(symbol_new("reduce", type_void), list_new(LI_ELEM, param, NULL), m); // arguments module_add_prototype(m, fun); return 0; }
void write_asm(Syntax* complete_syntax,Stack* string_stack){ tablevar = list_new(); openf("output.s"); //open file. emit_format(); emit_str(string_stack); emit_header(); //print .text function_declare("main"); //declare .globl main emit_init(); //alloc for main. if(complete_syntax->type == BLOCK){ emitblock(complete_syntax); }else printf("invalid syntax"); emit_footer(); //ralloc for main closef(fp); //close file. free(tablevar); }