Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
melsman committed Oct 30, 2023
1 parent 6881c73 commit 58a107c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 4 additions & 2 deletions basis/repl.sml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ fun pretty_exported (i:int) : int =
z_strong)
| C ([], "intinf") => (IntInf.toString (prim("unsafe_cast", v)), z_strong)
| C ([], "int") => (Int.toString (prim("unsafe_cast", v)), z_strong)
| C ([], "word") => ("0wx" ^ Word.toString (prim("unsafe_cast", v)), z_strong)
| C ([], "real") => (Real.toString (prim("unsafe_cast", v)), z_strong)
| C ([], "bool") => (Bool.toString (prim("unsafe_cast", v)), z_strong)
| C ([], "string") => ("\"" ^ String.toString (prim("unsafe_cast", v)) ^ "\"",
Expand Down Expand Up @@ -443,7 +444,9 @@ fun pretty_exported (i:int) : int =
let val tag = con_tag v
in (lookNullaryTag cs tag, z_strong)
end
end handle Fail s => ("con: " ^ s, z_con1)
end handle Fail s =>
if List.null ts then ("<" ^ tn ^ ">", z_strong)
else ("<" ^ tn ^ "," ^ Int.toString (length ts) ^ ">", z_strong)
)
| A _ => ("fn", z_strong)
| V s => ("tv: " ^ s, z_con1)
Expand All @@ -454,6 +457,5 @@ fun pretty_exported (i:int) : int =
; size s'
end
in
val () = print ("[Installing pretty-printer!]\n");
val () = _export("pretty_exported", pretty_exported)
end
18 changes: 14 additions & 4 deletions src/Manager/Repl.sml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ fun mapi (f:int*'a->'b) (xs:'a list) : 'b list =
* Debugging and reporting
* ------------------------------------------- *)

val basislib_p = Flags.is_on0 "basislib"

val debug_p = Flags.is_on0 "debug_compiler"

fun debug s =
if debug_p() then print("[REPL DEBUG: " ^ s ^ "]\n")
else ()

val print_post_elab_ast = Flags.is_on0 "print_post_elab_ast"

val print_export_bases = Flags.is_on0 "print_export_bases"

fun maybe_print_topdec s topdec =
Expand Down Expand Up @@ -859,11 +860,11 @@ fun run () : OS.Process.status =
let val () = Flags.turn_on "report_file_sig"
val () = List.app Flags.block_entry flags_to_block
val () = if Flags.is_on "garbage_collection" then
( print("Disabling garbage collection - it is not supported with the REPL\n")
( print("|Garbage collection disabled - it is not supported in the REPL!\n")
; Flags.turn_off "garbage_collection"
)
else ()
val () = print "Type :help; for help...\n";
val () = print "|Type :help; for help...\n";
val () = Flags.turn_off "messages"
in case MO.mk_repl_runtime of
SOME f =>
Expand Down Expand Up @@ -898,7 +899,16 @@ fun run () : OS.Process.status =
handle _ => die "run: failed to open reply_pipe"
val () = debug "opened reply_pipe"
val rp = {command_pipe=command_pipe,reply_pipe=reply_pipe,pid=childpid}
in repl (0, PE.begin_stdin(), rp, ["runtime"], nil)
val init = (0, PE.begin_stdin(), rp, ["runtime"], nil)
val init = if basislib_p() then
let val (stepno,state,rp,libs_acc,deps) = init
val cmd = ":load " ^ (!Flags.install_dir ## "basis/repl.mlb")
val (stepno,libs_acc,deps) = process_cmd stepno rp cmd libs_acc deps
in (stepno,state,rp,libs_acc,deps)
end
else ( print ("!Basis Library and Pretty Printing are not loaded!\n")
; init )
in repl init
end
| NONE => die "run - not possible to build runtime"
end
Expand Down

0 comments on commit 58a107c

Please sign in to comment.