diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-13 00:07:38 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-13 00:07:38 -0700 |
commit | 431bbb1aa7944c5b67fa25d833d7ca992f72511d (patch) | |
tree | 52f8522713824fc7c8e7423f2efc7827983b6311 | |
parent | 2440e5bd77c573d32c38774713e0b6432744b8dc (diff) | |
download | mu-431bbb1aa7944c5b67fa25d833d7ca992f72511d.tar.gz |
3346
Process type abbreviations in *shape-shifting* function headers.
-rw-r--r-- | 056shape_shifting_recipe.cc | 7 | ||||
-rw-r--r-- | 059to_text.mu | 8 | ||||
-rw-r--r-- | chessboard.mu | 8 |
3 files changed, 14 insertions, 9 deletions
diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc index 761656fd..1903921e 100644 --- a/056shape_shifting_recipe.cc +++ b/056shape_shifting_recipe.cc @@ -25,8 +25,13 @@ def foo a:_t -> result:_t [ //: be rewriting such instructions to *specializations* with the type //: ingredients filled in. +//: One exception (and this makes things very ugly): we need to expand type +//: abbreviations in shape-shifting recipes because we need them types for +//: deciding which variant to specialize. + :(before "End Transform Checks") -if (any_type_ingredient_in_header(/*recipe_ordinal*/p->first)) continue; +r.transformed_until = t; +if (Transform.at(t) != static_cast<transform_fn>(expand_type_abbreviations) && any_type_ingredient_in_header(/*recipe_ordinal*/p->first)) continue; :(after "Running One Instruction") if (Current_routine->calls.front().running_step_index == 0 diff --git a/059to_text.mu b/059to_text.mu index 25d5f55a..207ade78 100644 --- a/059to_text.mu +++ b/059to_text.mu @@ -6,26 +6,26 @@ # 'shorter' variant of to-text, when you want to enable some sort of trimming # define it to be identical to 'to-text' by default -def to-text-line x:_elem -> y:address:array:character [ +def to-text-line x:_elem -> y:text [ local-scope load-ingredients y <- to-text x ] # variant for arrays (since we can't pass them around otherwise) -def array-to-text-line x:address:array:_elem -> y:address:array:character [ +def array-to-text-line x:address:array:_elem -> y:text [ local-scope load-ingredients y <- to-text *x ] scenario to-text-line-early-warning-for-static-dispatch [ - x:address:array:character <- to-text-line 34 + x:text <- to-text-line 34 # just ensure there were no errors ] scenario array-to-text-line-early-warning-for-static-dispatch [ n:address:array:number <- new number:type, 3 - x:address:array:character <- array-to-text-line n + x:text <- array-to-text-line n # just ensure there were no errors ] diff --git a/chessboard.mu b/chessboard.mu index b58f2d6b..8245d3be 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -102,7 +102,7 @@ def chessboard screen:address:screen, console:address:console -> screen:address: ## a board is an array of files, a file is an array of characters (squares) -def new-board initial-position:address:array:character -> board:address:array:address:array:character [ +def new-board initial-position:address:array:character -> board:board [ local-scope load-ingredients # assert(length(initial-position) == 64) @@ -139,7 +139,7 @@ def new-file position:address:array:character, index:number -> result:address:ar } ] -def print-board screen:address:screen, board:address:array:address:array:character -> screen:address:screen [ +def print-board screen:address:screen, board:board -> screen:address:screen [ local-scope load-ingredients row:number <- copy 7 # start printing from the top of the board @@ -175,7 +175,7 @@ def print-board screen:address:screen, board:address:array:address:array:charact cursor-to-next-line screen ] -def initial-position -> board:address:array:address:array:character [ +def initial-position -> board:board [ local-scope # layout in memory (in raster order): # R P _ _ _ _ p r @@ -532,7 +532,7 @@ F read-move-file: routine failed to pause after coming up (before any keys were ] ] -def make-move board:address:array:address:array:character, m:address:move -> board:address:array:address:array:character [ +def make-move board:board, m:address:move -> board:board [ local-scope load-ingredients from-file:number <- get *m, from-file:offset |