mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
-o option
This commit is contained in:
parent
fe5a93218b
commit
3e2c87d42f
5 changed files with 18 additions and 2 deletions
BIN
lama-spec.pdf
BIN
lama-spec.pdf
Binary file not shown.
|
|
@ -34,6 +34,7 @@ procedure for each unit will be called only once (regardless of the imports' sha
|
|||
Additionally, the following options can be given to the driver:
|
||||
|
||||
\begin{itemize}
|
||||
\item "\texttt{-o $filename$}"~--- specifies an alternative file name for the executable.
|
||||
\item "\texttt{-I $path$}"~--- specifies a path to look for external units. Multiples instances of this option can be given in driver's
|
||||
invocation, and the paths are looked up in that order.
|
||||
\item "\texttt{-dp}"~--- forces the driver to dump the AST of compiled unit in \textsc{html} representation. The dump is written in the file with the same
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class options args =
|
|||
"When no options specified, builds the source file into executable.\n" ^
|
||||
"Options:\n" ^
|
||||
" -c --- compile into object file\n" ^
|
||||
" -o <file> --- write executable into file <file>\n" ^
|
||||
" -I <path> --- add <path> into unit search path list\n" ^
|
||||
" -i --- interpret on a source-level interpreter\n" ^
|
||||
" -s --- compile into stack machine code and interpret on the stack machine initerpreter\n" ^
|
||||
|
|
@ -61,6 +62,7 @@ class options args =
|
|||
val help = ref false
|
||||
val i = ref 1
|
||||
val infile = ref (None : string option)
|
||||
val outfile = ref (None : string option)
|
||||
val paths = ref [X86.get_std_path ()]
|
||||
val mode = ref (`Default : [`Default | `Eval | `SM | `Compile ])
|
||||
(* Workaround until Ostap starts to memoize properly *)
|
||||
|
|
@ -76,6 +78,7 @@ class options args =
|
|||
| "-w" -> self#set_workaround
|
||||
(* end of the workaround *)
|
||||
| "-c" -> self#set_mode `Compile
|
||||
| "-o" -> (match self#peek with None -> raise (Commandline_error "File name expected after '-o' specifier") | Some fname -> self#set_outfile fname)
|
||||
| "-I" -> (match self#peek with None -> raise (Commandline_error "Path expected after '-I' specifier") | Some path -> self#add_include_path path)
|
||||
| "-s" -> self#set_mode `SM
|
||||
| "-i" -> self#set_mode `Eval
|
||||
|
|
@ -104,6 +107,10 @@ class options args =
|
|||
match !infile with
|
||||
| None -> infile := Some name
|
||||
| Some name' -> raise (Commandline_error (Printf.sprintf "Input file ('%s') already specified" name'))
|
||||
method private set_outfile name =
|
||||
match !outfile with
|
||||
| None -> outfile := Some name
|
||||
| Some name' -> raise (Commandline_error (Printf.sprintf "Output file ('%s') already specified" name'))
|
||||
method private add_include_path path =
|
||||
paths := path :: !paths
|
||||
method private set_mode s =
|
||||
|
|
@ -116,6 +123,10 @@ class options args =
|
|||
then (incr i; Some (args.(j)))
|
||||
else None
|
||||
method get_mode = !mode
|
||||
method get_output_option =
|
||||
match !outfile with
|
||||
| None -> Printf.sprintf "-o %s" self#basename
|
||||
| Some name -> Printf.sprintf "-o %s" name
|
||||
method get_infile =
|
||||
match !infile with
|
||||
| None -> raise (Commandline_error "Input file not specified")
|
||||
|
|
@ -150,6 +161,10 @@ class options args =
|
|||
then self#dump_file "sm" (SM.show_prg sm)
|
||||
else ()
|
||||
method greet =
|
||||
(match !outfile with
|
||||
| None -> ()
|
||||
| Some _ -> (match !mode with `Default -> () | _ -> Printf.printf "Output file option ignored in this mode.\n")
|
||||
);
|
||||
if !version then Printf.printf "%s\n" Version.version;
|
||||
if !help then Printf.printf "%s" help_string
|
||||
end
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ let build cmd prog =
|
|||
let objs = find_objects (fst @@ fst prog) cmd#get_include_paths in
|
||||
let buf = Buffer.create 255 in
|
||||
List.iter (fun o -> Buffer.add_string buf o; Buffer.add_string buf " ") objs;
|
||||
let gcc_cmdline = Printf.sprintf "gcc -g -m32 -o %s %s.s %s %s/runtime.a" cmd#basename cmd#basename (Buffer.contents buf) inc in
|
||||
let gcc_cmdline = Printf.sprintf "gcc -g -m32 %s %s.s %s %s/runtime.a" cmd#get_output_option cmd#basename (Buffer.contents buf) inc in
|
||||
Sys.command gcc_cmdline
|
||||
| `Compile ->
|
||||
Sys.command (Printf.sprintf "gcc -g -m32 -c %s.s" cmd#basename)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
let version = "Version 1.00, e0ad5aa8, Thu Feb 20 20:29:57 2020 +0300"
|
||||
let version = "Version 1.00, fe5a9321, Sun Feb 23 01:48:49 2020 +0300"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue