Reorganize layers in preparation for a better, more type-safe
implementation of first-class and higher-order recipes.
This commit is contained in:
Kartik K. Agaram 2016-01-17 21:20:05 -08:00
parent 3063b2393a
commit 94fed20200
6 changed files with 33 additions and 32 deletions

View File

@ -182,25 +182,6 @@ recipe main [
+mem: array size is 0
+mem: storing 1 in location 3
//: Make sure that each routine gets a different alloc to start.
:(scenario new_concurrent)
recipe f1 [
start-running f2:recipe
1:address:number/raw <- new number:type
# wait for f2 to complete
{
loop-unless 4:number/raw
}
]
recipe f2 [
2:address:number/raw <- new number:type
# hack: assumes scheduler implementation
3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw
# signal f2 complete
4:number/raw <- copy 1
]
+mem: storing 0 in location 3
//: If a routine runs out of its initial allocation, it should allocate more.
:(scenario new_overflow)
% Initial_memory_per_routine = 2;
@ -367,17 +348,6 @@ long long int new_mu_string(const string& contents) {
return result;
}
//: pass in commandline args as ingredients to main
//: todo: test this
:(after "Update main_routine")
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);
}
//: stash recognizes strings
:(scenario stash_string)

View File

@ -137,7 +137,6 @@ void run_mu_scenario(const scenario& s) {
Trace_stream = new trace_stream;
setup();
}
assert(Routines.empty());
vector<recipe_ordinal> tmp = load("recipe scenario-"+s.name+" [ "+s.to_run+" ]");
bind_special_scenario_names(tmp.at(0));
transform_all();

View File

@ -457,3 +457,8 @@ recipe foo a:boolean -> b:number [
]
+error: main: missing type for x in 'y:number <- foo x'
+error: main: failed to find a matching call for 'y:number <- foo x'
:(before "End Includes")
using std::min;
using std::max;
using std::abs;

View File

@ -114,7 +114,14 @@ void run_main(int argc, char* argv[]) {
recipe_ordinal r = get(Recipe_ordinal, "main");
if (r) {
routine* main_routine = new routine(r);
// Update main_routine
// 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);
}
}
@ -504,3 +511,23 @@ case LIMIT_TIME: {
}
break;
}
//:: make sure that each routine gets a different alloc to start
:(scenario new_concurrent)
recipe f1 [
start-running f2:recipe
1:address:number/raw <- new number:type
# wait for f2 to complete
{
loop-unless 4:number/raw
}
]
recipe f2 [
2:address:number/raw <- new number:type
# hack: assumes scheduler implementation
3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw
# signal f2 complete
4:number/raw <- copy 1
]
+mem: storing 0 in location 3