From 12c3ee1e4576f13808e962b2f818fb5d61466e9d Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 2 Jun 2015 00:48:32 -0700 Subject: 1520 - repl kinda working But we really should test the top-level integration with 'run-interactive'. --- 060string.mu | 10 +++++----- 078run_interactive.cc | 14 +++++++++++++- repl.mu | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/060string.mu b/060string.mu index 47a05c5a..0e7d0da5 100644 --- a/060string.mu +++ b/060string.mu @@ -291,15 +291,15 @@ recipe integer-to-decimal-string [ recipe buffer-to-array [ default-space:address:array:character <- new location:type, 30:literal in:address:buffer <- next-ingredient - len:number <- get in:address:buffer/deref, length:offset -#? $print [size ], len:number, [ -#? ] #? 1 - s:address:array:character <- get in:address:buffer/deref, data:offset { # propagate null buffer - break-if s:address:array:character + break-if in:address:buffer reply 0:literal } + len:number <- get in:address:buffer/deref, length:offset +#? $print [size ], len:number, [ +#? ] #? 1 + s:address:array:character <- get in:address:buffer/deref, data:offset # we can't just return s because it is usually the wrong length result:address:array:character <- new character:type, len:number i:number <- copy 0:literal diff --git a/078run_interactive.cc b/078run_interactive.cc index 1075c922..910147f1 100644 --- a/078run_interactive.cc +++ b/078run_interactive.cc @@ -19,7 +19,7 @@ case RUN_INTERACTIVE: { // just an integer prints value of that location in memory // instruction executes // backspace at start begins new attempt -// ctrl-d working [not after first instruction is run] +// ctrl-d working void run_interactive(long long int address) { //? tb_shutdown(); //? 1 long long int size = Memory[address]; @@ -61,3 +61,15 @@ void run_interactive(long long int address) { //? cerr << "interactive transformed_until: " << Recipe[Recipe_number["interactive"]].transformed_until << '\n'; //? 1 Current_routine->calls.push_front(call(Recipe_number["interactive"])); } + +//:: debugging tool + +:(before "End Primitive Recipe Declarations") +_RUN_DEPTH, +:(before "End Primitive Recipe Numbers") +Recipe_number["$run-depth"] = _RUN_DEPTH; +:(before "End Primitive Recipe Implementations") +case _RUN_DEPTH: { + cerr << Current_routine->calls.size(); + break; +} diff --git a/repl.mu b/repl.mu index daa59189..5bbba673 100644 --- a/repl.mu +++ b/repl.mu @@ -8,6 +8,8 @@ recipe main [ 0:literal/real-screen <- print-string 0:literal/real-screen, msg:address:array:character { inst:address:array:character, 0:literal/real-keyboard, 0:literal/real-screen <- read-instruction 0:literal/real-keyboard, 0:literal/real-screen +#? $print [ccc: ], inst:address:array:character #? 1 +#? move-cursor-down-on-display #? 1 break-unless inst:address:array:character #? 0:literal/real-screen <- print-string 0:literal/real-screen, inst:address:array:character run-interactive inst:address:array:character @@ -25,7 +27,9 @@ recipe main [ clear-line-on-display # just to refresh the screen loop } +#? wait-for-key-from-keyboard #? 1 return-to-console +#? $print [aaaa] #? 1 ] # basic keyboard input; just text and enter @@ -71,9 +75,13 @@ recipe read-instruction [ jump-if completed?:boolean, +completed:label # Otherwise we're just getting started. result:address:buffer, k:address:keyboard, x:address:screen <- slurp-regular-characters result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation +#? $print [aaa: ], result:address:buffer #? 1 +#? move-cursor-down-on-display #? 1 trace [error], [slurp-regular-characters should never return normally] +completed result2:address:array:character <- buffer-to-array result:address:buffer +#? $print [bbb: ], result2:address:array:character #? 1 +#? move-cursor-down-on-display #? 1 trace [app], [exiting read-instruction] reply result2:address:array:character, k:address:keyboard/same-as-ingredient:0, x:address:screen/same-as-ingredient:1 ] @@ -88,6 +96,7 @@ recipe slurp-regular-characters [ complete:continuation <- next-ingredient trace [app], [slurp-regular-characters] characters-slurped:number <- copy 0:literal +#? $run-depth #? 1 { +next-character #? $print [a0 #? 1 @@ -95,10 +104,16 @@ recipe slurp-regular-characters [ #? move-cursor-down-on-display #? 1 # read character c:character, k:address:keyboard <- wait-for-key k:address:keyboard +#? print-character x:address:screen, c:character #? 1 +#? move-cursor-down-on-display #? 1 # quit? { +#? $print [aaa] #? 1 +#? move-cursor-down-on-display #? 1 ctrl-d?:boolean <- equal c:character, 4:literal/ctrl-d/eof break-unless ctrl-d?:boolean +#? $print [ctrl-d] #? 1 +#? move-cursor-down-on-display #? 1 trace [app], [slurp-regular-characters: ctrl-d] reply 0:literal, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 } -- cgit 1.4.1-2-gfad0