2603 - bugfix: defining main with commandline args

Pretty hacky fix: we simply suppress static dispatch for main.
This commit is contained in:
Kartik K. Agaram 2016-01-25 19:32:03 -08:00
parent 50c4ac802e
commit 8f0a914953
3 changed files with 12 additions and 13 deletions

View File

@ -59,7 +59,7 @@ long long int slurp_recipe(istream& in) {
}
slurp_body(in, result);
// End recipe Body(result)
get_or_insert(Recipe, get(Recipe_ordinal, result.name)) = result;
put(Recipe, get(Recipe_ordinal, result.name), result);
// track added recipes because we may need to undo them in tests; see below
Recently_added_recipes.push_back(get(Recipe_ordinal, result.name));
return get(Recipe_ordinal, result.name);

View File

@ -30,7 +30,7 @@ for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin();
}
:(before "End Load Recipe Header(result)")
if (contains_key(Recipe_ordinal, result.name)) {
if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
const recipe_ordinal r = get(Recipe_ordinal, result.name);
//? cerr << result.name << ": " << contains_key(Recipe, r) << (contains_key(Recipe, r) ? get(Recipe, r).has_header : 0) << matching_variant_name(result) << '\n';
if (!contains_key(Recipe, r) || get(Recipe, r).has_header) {

View File

@ -112,18 +112,17 @@ Current_routine = NULL;
:(replace{} "void run_main(int argc, char* argv[])")
void run_main(int argc, char* argv[]) {
recipe_ordinal r = get(Recipe_ordinal, "main");
if (r) {
routine* main_routine = new routine(r);
// pass in commandline args as ingredients to main
// todo: test this
Current_routine = main_routine;
for (long long int i = 1; i < argc; ++i) {
vector<double> arg;
arg.push_back(new_mu_string(argv[i]));
current_call().ingredient_atoms.push_back(arg);
}
run(main_routine);
assert(r);
routine* main_routine = new routine(r);
// pass in commandline args as ingredients to main
// todo: test this
Current_routine = main_routine;
for (long long int i = 1; i < argc; ++i) {
vector<double> arg;
arg.push_back(new_mu_string(argv[i]));
current_call().ingredient_atoms.push_back(arg);
}
run(main_routine);
}
//:: To schedule new routines to run, call 'start-running'.