New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added -e eval option for runtop and natruntop #10438
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,20 +48,21 @@ let prepare ppf = | |
Format.fprintf ppf "Uncaught exception: %s\n" (Printexc.to_string x); | ||
false | ||
|
||
let file_argument name = | ||
let input_argument name = | ||
let filename = Toploop.filename_of_input name in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same here) |
||
let ppf = Format.err_formatter in | ||
if Filename.check_suffix name ".cmxs" | ||
|| Filename.check_suffix name ".cmx" | ||
|| Filename.check_suffix name ".cmxa" | ||
then preload_objects := name :: !preload_objects | ||
if Filename.check_suffix filename ".cmxs" | ||
|| Filename.check_suffix filename ".cmx" | ||
|| Filename.check_suffix filename ".cmxa" | ||
then preload_objects := filename :: !preload_objects | ||
else if is_expanded !current then begin | ||
(* Script files are not allowed in expand options because otherwise the | ||
check in override arguments may fail since the new argv can be larger | ||
than the original argv. | ||
*) | ||
Printf.eprintf "For implementation reasons, the toplevel does not support\ | ||
\ having script files (here %S) inside expanded arguments passed through\ | ||
\ the -args{,0} command-line option.\n" name; | ||
\ the -args{,0} command-line option.\n" filename; | ||
raise (Compenv.Exit_with_status 2) | ||
end else begin | ||
let newargs = Array.sub !argv !Arg.current | ||
|
@@ -73,6 +74,8 @@ let file_argument name = | |
else raise (Compenv.Exit_with_status 2) | ||
end | ||
|
||
let file_argument x = input_argument (Toploop.File x) | ||
|
||
let wrap_expand f s = | ||
let start = !current in | ||
let arr = f s in | ||
|
@@ -81,10 +84,12 @@ let wrap_expand f s = | |
|
||
module Options = Main_args.Make_opttop_options (struct | ||
include Main_args.Default.Opttopmain | ||
let _stdin () = file_argument "" | ||
let _stdin () = input_argument Toploop.Stdin | ||
let _args = wrap_expand Arg.read_arg | ||
let _args0 = wrap_expand Arg.read_arg0 | ||
let anonymous s = file_argument s | ||
let _eval s = input_argument (Toploop.String s) | ||
|
||
end);; | ||
|
||
let () = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a minor comment (I don't think it's worth changing anything now), but the patch would have been less invasive with
let input_argument input = let name = ... in ...
.