Process type abbreviations in *shape-shifting* function headers.
This commit is contained in:
Kartik K. Agaram 2016-09-13 00:07:38 -07:00
parent 2440e5bd77
commit 431bbb1aa7
3 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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
]

View File

@ -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