bool genexe(compile_t* c, ast_t* program) { errors_t* errors = c->opt->check.errors; // The first package is the main package. It has to have a Main actor. const char* main_actor = c->str_Main; const char* env_class = c->str_Env; ast_t* package = ast_child(program); ast_t* main_def = ast_get(package, main_actor, NULL); if(main_def == NULL) { errorf(errors, NULL, "no Main actor found in package '%s'", c->filename); return false; } // Generate the Main actor and the Env class. ast_t* main_ast = type_builtin(c->opt, main_def, main_actor); ast_t* env_ast = type_builtin(c->opt, main_def, env_class); if(lookup(c->opt, main_ast, main_ast, c->str_create) == NULL) return false; if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Reachability\n"); reach(c->reach, main_ast, c->str_create, NULL, c->opt); reach(c->reach, env_ast, c->str__create, NULL, c->opt); if(c->opt->limit == PASS_REACH) return true; if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Selector painting\n"); paint(&c->reach->types); if(c->opt->limit == PASS_PAINT) return true; if(!gentypes(c)) return false; if(c->opt->verbosity >= VERBOSITY_ALL) reach_dump(c->reach); reach_type_t* t_main = reach_type(c->reach, main_ast); reach_type_t* t_env = reach_type(c->reach, env_ast); if((t_main == NULL) || (t_env == NULL)) return false; gen_main(c, t_main, t_env); if(!genopt(c, true)) return false; if(c->opt->runtimebc) { if(!codegen_merge_runtime_bitcode(c)) return false; // Rerun the optimiser without the Pony-specific optimisation passes. // Inlining runtime functions can screw up these passes so we can't // run the optimiser only once after merging. if(!genopt(c, false)) return false; } const char* file_o = genobj(c); if(file_o == NULL) return false; if(c->opt->limit < PASS_ALL) return true; if(!link_exe(c, program, file_o)) return false; #ifdef PLATFORM_IS_WINDOWS _unlink(file_o); #else unlink(file_o); #endif return true; }
bool genexe(compile_t* c, ast_t* program) { errors_t* errors = c->opt->check.errors; // The first package is the main package. It has to have a Main actor. const char* main_actor = c->str_Main; const char* env_class = c->str_Env; ast_t* package = ast_child(program); ast_t* main_def = ast_get(package, main_actor, NULL); if(main_def == NULL) { errorf(errors, NULL, "no Main actor found in package '%s'", c->filename); return false; } // Generate the Main actor and the Env class. ast_t* main_ast = type_builtin(c->opt, main_def, main_actor); ast_t* env_ast = type_builtin(c->opt, main_def, env_class); if(lookup(NULL, main_ast, main_ast, c->str_create) == NULL) return false; if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Reachability\n"); reach(c->reach, main_ast, c->str_create, NULL, c->opt); reach(c->reach, env_ast, c->str__create, NULL, c->opt); if(c->opt->limit == PASS_REACH) return true; if(c->opt->verbosity >= VERBOSITY_INFO) fprintf(stderr, " Selector painting\n"); paint(&c->reach->types); if(c->opt->limit == PASS_PAINT) return true; if(!gentypes(c)) return false; if(c->opt->verbosity >= VERBOSITY_ALL) reach_dump(c->reach); reach_type_t* t_main = reach_type(c->reach, main_ast); reach_type_t* t_env = reach_type(c->reach, env_ast); if((t_main == NULL) || (t_env == NULL)) return false; gen_main(c, t_main, t_env); if(!genopt(c)) return false; const char* file_o = genobj(c); if(file_o == NULL) return false; if(c->opt->limit < PASS_ALL) return true; if(!link_exe(c, program, file_o)) return false; #ifdef PLATFORM_IS_WINDOWS _unlink(file_o); #else unlink(file_o); #endif return true; }