From: Tim Vaughan Date: Wed, 1 Aug 2018 09:08:18 +0000 (+0200) Subject: Return stack restoration working? X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=commitdiff_plain;h=7e659fc69e0155eb7fe4353debafb830da35097b Return stack restoration working? --- diff --git a/src/scheme.4th b/src/scheme.4th index 135bdab..4f04d8c 100644 --- a/src/scheme.4th +++ b/src/scheme.4th @@ -588,15 +588,37 @@ global-env obj! 2drop ; +: list->pad ( list -- n ) + + 2dup car drop -rot \ keep length of list on stack + 2dup cdr 2swap car drop \ get length from list + + pad + 1- \ final dest addr + pad \ initial dest addr + swap + do + 2dup cdr 2swap car + drop i ! + -1 +loop + + 2drop +; + : restore-return-stack ( continuation -- ) - R> -rot \ store top of return stack on PS + trace + continuation->rstack-list - 2dup print 2dup + list->pad + dup + RSP0 + RSP! \ expand return stack to accommodate entries - \ TODO: Implement body of return stack restoration + 0 \ initial offset + do + pad i + @ RSP0 i 1+ + ! + loop - >R \ restore original top of return stack + trace ; : restore-continuation ( continuation -- )