static void print_graphs(MSTicker *s, MSList *execution_list, bool_t force_schedule){ MSList *it; MSList *unschedulable=NULL; for(it=execution_list;it!=NULL;it=it->next){ print_graph((MSFilter*)it->data,s,&unschedulable,force_schedule); } /* filters that are part of a loop haven't been called in process() because one of their input refers to a filter that could not be scheduled (because they could not be scheduled themselves)... Do you understand ?*/ /* we resolve this by simply assuming that they must be called anyway for the loop to run correctly*/ /* we just recall run_graphs on them, as if they were source filters */ if (unschedulable!=NULL) { print_graphs(s,unschedulable,TRUE); ms_list_free(unschedulable); } }
void ms_ticker_print_graphs(MSTicker *ticker){ print_graphs(ticker,ticker->execution_list,FALSE); }
static int compile(struct OPTIONS *options) { MODULE *module; PARSER parser; char buffer[MAX_LINE] = ""; if (options->filename) { parser.filename = options->filename; parser.file = fopen(options->filename, "rt"); } else { parser.filename = "<stdin>"; parser.file = stdin; } /* * 1. Read and parse source code from standard input. */ module = CAST_TO_MODULE(tree_create_node(DEF_MODULE)); module->filename = parser.filename; module->table = create_hash(10, key_type_copyable); module->strings = create_hash(10, key_type_copyable); module->max_registers = 6; parser.buffer = parser.p = buffer; parser.input = get_line; parser.module = module; parser.scope = module->table; parser.args = NULL; if (yyparse(&parser) == 1) return 0; /* * 2. Optimise! */ //TODO: Think of some possible optimisations! // - Constant folding. // - Common subexpression elimination. // - Dead code removal. // - Function inlining. process_functions(module, analyse_tail_recursion); process_functions(module, analyse_symbols); process_functions(module, process_closures); process_functions(module, flatten); process_functions(module, optimise_constant_folding); process_functions(module, reduce); process_functions(module, definite_assignment_analysis); process_functions(module, analyse_inlining); process_functions(module, optimise_constant_tests); process_functions(module, remove_dead_code); /* * 3. Output assembly code. */ process_functions(module, i386ify); process_functions(module, register_allocation); process_functions(module, analyse_function_size); if (options->graphs) print_graphs(module); else generate_as(module); /* * 4. Clean up. */ //TODO: May not be necessary as things are generally freed on termination. tree_destroy_node(CAST_TO_NODE(module)); if (parser.file != stdin) fclose(parser.file); return 1; }