diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-22 11:51:36 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-22 11:51:36 -0800 |
commit | 7136ddd5ac12d3aa4d516f719dea37a027a25b5a (patch) | |
tree | c11e4ba47269076b39a96905b9d03b0765f639c4 | |
parent | aff93bb2c1ea1a96fc110fad8b2dd84e0673f87f (diff) | |
download | mu-7136ddd5ac12d3aa4d516f719dea37a027a25b5a.tar.gz |
2473 - bad idea to use /raw with multiple intentions
/raw is to express absolute addresses /unsafe is to sidestep type-checking in test setup
-rw-r--r-- | 021check_instruction.cc | 10 | ||||
-rw-r--r-- | 030container.cc | 2 | ||||
-rw-r--r-- | 031address.cc | 8 | ||||
-rw-r--r-- | 032array.cc | 12 | ||||
-rw-r--r-- | 042name.cc | 4 | ||||
-rw-r--r-- | 044space.cc | 16 | ||||
-rw-r--r-- | 045space_surround.cc | 4 | ||||
-rw-r--r-- | 047global.cc | 4 | ||||
-rw-r--r-- | 056recipe_header.cc | 2 | ||||
-rw-r--r-- | 091run_interactive.cc | 2 |
10 files changed, 34 insertions, 30 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc index 57757446..3d418dce 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -78,9 +78,9 @@ recipe main [ bool types_match(reagent lhs, reagent rhs) { // '_' never raises type error if (is_dummy(lhs)) return true; - // to sidestep type-checking, use /raw in the source. - // this is unsafe, and will be highlighted in red inside vim. just for some tests. - if (is_raw(rhs)) return true; + // to sidestep type-checking, use /unsafe in the source. + // this will be highlighted in red inside vim. just for setting up some tests. + if (is_unsafe(rhs)) return true; if (is_literal(rhs)) return valid_type_for_literal(lhs, rhs) && size_of(rhs) == size_of(lhs); if (!lhs.type) return !rhs.type; return types_match(lhs.type, rhs.type); @@ -125,6 +125,10 @@ bool is_raw(const reagent& r) { return has_property(r, "raw"); } +bool is_unsafe(const reagent& r) { + return has_property(r, "unsafe"); +} + bool is_mu_array(reagent r) { if (!r.type) return false; if (is_literal(r)) return false; diff --git a/030container.cc b/030container.cc index 49655db5..346f0eed 100644 --- a/030container.cc +++ b/030container.cc @@ -516,7 +516,7 @@ recipe main [ :(scenario run_allows_type_definition_after_use) % Hide_errors = true; recipe main [ - 1:bar <- copy 0/raw + 1:bar <- copy 0/unsafe ] container bar [ diff --git a/031address.cc b/031address.cc index ebbc4e95..4d012ad5 100644 --- a/031address.cc +++ b/031address.cc @@ -3,7 +3,7 @@ :(scenario copy_indirect) recipe main [ - 1:address:number <- copy 2/raw + 1:address:number <- copy 2/unsafe 2:number <- copy 34 # This loads location 1 as an address and looks up *that* location. 3:number <- copy 1:address:number/lookup @@ -17,7 +17,7 @@ canonize(x); //: 'lookup' property :(scenario store_indirect) recipe main [ - 1:address:number <- copy 2/raw + 1:address:number <- copy 2/unsafe 1:address:number/lookup <- copy 34 ] +mem: storing 34 in location 2 @@ -126,7 +126,7 @@ recipe main [ 1:number <- copy 2 2:number <- copy 34 3:number <- copy 35 - 4:address:number <- copy 5/raw + 4:address:number <- copy 5/unsafe *4:address:number <- get 1:address:point/lookup, 0:offset ] +mem: storing 34 in location 5 @@ -168,7 +168,7 @@ canonize(base); :(scenario lookup_abbreviation) recipe main [ - 1:address:number <- copy 2/raw + 1:address:number <- copy 2/unsafe 2:number <- copy 34 3:number <- copy *1:address:number ] diff --git a/032array.cc b/032array.cc index ac883490..81bfbe18 100644 --- a/032array.cc +++ b/032array.cc @@ -85,7 +85,7 @@ recipe main [ 2:number <- copy 14 3:number <- copy 15 4:number <- copy 16 - 5:address:array:number <- copy 1/raw + 5:address:array:number <- copy 1/unsafe 6:array:number <- copy *5:address:array:number ] +mem: storing 3 in location 6 @@ -204,7 +204,7 @@ recipe main [ 2:number <- copy 14 3:number <- copy 15 4:number <- copy 16 - 5:address:array:number <- copy 1/raw + 5:address:array:number <- copy 1/unsafe 6:number <- index *5:address:array:number, 1 ] +mem: storing 15 in location 6 @@ -234,7 +234,7 @@ recipe main [ 5:number <- copy 14 6:number <- copy 15 7:number <- copy 16 - 8:address:array:point <- copy 1/raw + 8:address:array:point <- copy 1/unsafe index *8:address:array:point, -1 ] +error: main: invalid index -1 @@ -249,7 +249,7 @@ recipe main [ 5:number <- copy 14 6:number <- copy 15 7:number <- copy 16 - 8:address:array:point <- copy 1/raw + 8:address:array:point <- copy 1/unsafe 9:number <- index *8:address:array:point, 0 ] +error: main: 'index' on *8:address:array:point can't be saved in 9:number; type should be point @@ -354,7 +354,7 @@ recipe main [ 5:number <- copy 14 6:number <- copy 15 7:number <- copy 16 - 8:address:array:point <- copy 1/raw + 8:address:array:point <- copy 1/unsafe index-address *8:address:array:point, -1 ] +error: main: invalid index -1 @@ -369,7 +369,7 @@ recipe main [ 5:number <- copy 14 6:number <- copy 15 7:number <- copy 16 - 8:address:array:point <- copy 1/raw + 8:address:array:point <- copy 1/unsafe 9:address:number <- index-address *8:address:array:point, 0 ] +error: main: 'index' on *8:address:array:point can't be saved in 9:address:number; type should be <address : <point : <>>> diff --git a/042name.cc b/042name.cc index e9812624..8ef2f467 100644 --- a/042name.cc +++ b/042name.cc @@ -215,8 +215,8 @@ if (inst.name == "get" || inst.name == "get-address") { :(scenarios transform) :(scenario transform_names_handles_containers) recipe main [ - a:point <- copy 0/raw - b:number <- copy 0/raw + a:point <- copy 0/unsafe + b:number <- copy 0/unsafe ] +name: assign a 1 +name: assign b 3 diff --git a/044space.cc b/044space.cc index 0031536d..4f57ebd5 100644 --- a/044space.cc +++ b/044space.cc @@ -7,7 +7,7 @@ # then location 0 is really location 11, location 1 is really location 12, and so on. recipe main [ 10:number <- copy 5 # pretend array; in practice we'll use new - default-space:address:array:location <- copy 10/raw + default-space:address:array:location <- copy 10/unsafe 1:number <- copy 23 ] +mem: storing 23 in location 12 @@ -19,8 +19,8 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/raw - 1:address:number <- copy 3/raw + default-space:address:array:location <- copy 1000/unsafe + 1:address:number <- copy 3/unsafe 8:number/raw <- copy *1:address:number ] +mem: storing 34 in location 8 @@ -70,8 +70,8 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/raw - 1:address:point <- copy 12/raw + default-space:address:array:location <- copy 1000/unsafe + 1:address:point <- copy 12/unsafe 9:number/raw <- get *1:address:point, 1:offset ] +mem: storing 35 in location 9 @@ -90,8 +90,8 @@ recipe main [ # pretend array 1000:number <- copy 5 # actual start of this recipe - default-space:address:array:location <- copy 1000/raw - 1:address:array:number <- copy 12/raw + default-space:address:array:location <- copy 1000/unsafe + 1:address:array:number <- copy 12/unsafe 9:number/raw <- index *1:address:array:number, 1 ] +mem: storing 35 in location 9 @@ -224,7 +224,7 @@ long long int address(long long int offset, long long int base) { :(scenario get_default_space) recipe main [ - default-space:address:array:location <- copy 10/raw + default-space:address:array:location <- copy 10/unsafe 1:address:array:location/raw <- copy default-space:address:array:location ] +mem: storing 10 in location 1 diff --git a/045space_surround.cc b/045space_surround.cc index b55cbf5c..821066cc 100644 --- a/045space_surround.cc +++ b/045space_surround.cc @@ -9,8 +9,8 @@ recipe main [ 10:number <- copy 5 # pretend array 20:number <- copy 5 # pretend array - default-space:address:array:location <- copy 10/raw - 0:address:array:location/names:dummy <- copy 20/raw # later layers will explain the /names: property + default-space:address:array:location <- copy 10/unsafe + 0:address:array:location/names:dummy <- copy 20/unsafe # later layers will explain the /names: property 1:number <- copy 32 1:number/space:1 <- copy 33 ] diff --git a/047global.cc b/047global.cc index c0e09ce4..bd433af7 100644 --- a/047global.cc +++ b/047global.cc @@ -9,8 +9,8 @@ recipe main [ 10:number <- copy 5 20:number <- copy 5 # actual start of this recipe - global-space:address:array:location <- copy 20/raw - default-space:address:array:location <- copy 10/raw + global-space:address:array:location <- copy 20/unsafe + default-space:address:array:location <- copy 10/unsafe 1:number <- copy 23 1:number/space:global <- copy 24 ] diff --git a/056recipe_header.cc b/056recipe_header.cc index e918074d..78850c43 100644 --- a/056recipe_header.cc +++ b/056recipe_header.cc @@ -128,7 +128,7 @@ if (curr.name == "load-ingredients") { recipe add2 x:number, y:number -> z:number [ local-scope load-ingredients - z:address:number <- copy 0/raw + z:address:number <- copy 0/unsafe reply z ] +error: add2: replied with the wrong type at 'reply z' diff --git a/091run_interactive.cc b/091run_interactive.cc index ec9e13d7..55fb92fe 100644 --- a/091run_interactive.cc +++ b/091run_interactive.cc @@ -12,7 +12,7 @@ recipe main [ :(scenario run_interactive_empty) recipe main [ - 1:address:array:character <- copy 0/raw + 1:address:array:character <- copy 0/unsafe 2:address:array:character <- run-interactive 1:address:array:character ] # result is null |