From 2cc42dcec9809efd12de279a7cc4641db691e0a8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 15 Apr 2016 09:12:48 -0700 Subject: 2834 - make 'wait-for-location' more intuitive Previously to watch an address we had to perform a lookup of it, which the instruction then proceeded to undo. This way wait-for-instruction no longer supports literal ingredients, but the real-world usage becomes cleaner. --- 063wait.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to '063wait.cc') diff --git a/063wait.cc b/063wait.cc index 46bd406f..19bfb2d8 100644 --- a/063wait.cc +++ b/063wait.cc @@ -7,15 +7,16 @@ def f1 [ 1:number <- copy 0 start-running f2 - wait-for-location 1:number + 2:address:number <- copy 1/unsafe + wait-for-location 2:address:number # now wait for f2 to run and modify location 1 before using its value - 2:number <- copy 1:number + 3:number <- copy 1:number ] def f2 [ 1:number <- copy 34 ] -# if we got the synchronization wrong we'd be storing 0 in location 2 -+mem: storing 34 in location 2 +# if we got the synchronization wrong we'd be storing 0 in location 3 ++mem: storing 34 in location 3 //: define the new state that all routines can be in @@ -36,16 +37,22 @@ WAIT_FOR_LOCATION, put(Recipe_ordinal, "wait-for-location", WAIT_FOR_LOCATION); :(before "End Primitive Recipe Checks") case WAIT_FOR_LOCATION: { + if (SIZE(inst.ingredients) != 1) { + raise << maybe(get(Recipe, r).name) << "'wait-for-location' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end(); + break; + } + if (!is_mu_address(inst.ingredients.at(0))) { + raise << maybe(get(Recipe, r).name) << "'wait-for-location' requires an address ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end(); + } break; } :(before "End Primitive Recipe Implementations") case WAIT_FOR_LOCATION: { - reagent loc = current_instruction().ingredients.at(0); - canonize(loc); + int loc = ingredients.at(0).at(0); Current_routine->state = WAITING; - Current_routine->waiting_on_location = loc.value; - Current_routine->old_value_of_waiting_location = get_or_insert(Memory, loc.value); - trace(9998, "run") << "waiting for location " << loc.value << " to change from " << no_scientific(get_or_insert(Memory, loc.value)) << end(); + Current_routine->waiting_on_location = loc; + Current_routine->old_value_of_waiting_location = get_or_insert(Memory, loc); + trace(9998, "run") << "waiting for location " << loc << " to change from " << no_scientific(get_or_insert(Memory, loc)) << end(); break; } -- cgit 1.4.1-2-gfad0 ;id=9aea89ba73280bcaeee67f6bd01f725a9698b344'>root/prototypes/browse/18/main.mu
blob: f98e9a2b74ac80ce87b021c11de706e9c9d1305e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33