Commit 6df26008 authored by Julian Kranz's avatar Julian Kranz

Merge

parents ae08be79 ca7005bf
structure C1Templates = struct
val header = ExpandFile.mkTemplateFromFile "detail/codegen/c1/runtime.h"
val runtime = ExpandFile.mkTemplateFromFile "detail/codegen/c1/runtime.c"
fun stdHooks basename =
let
......@@ -21,15 +19,15 @@ structure C1Templates = struct
]
end
fun expandHeader basename hooks =
fun expandHeader path basename hooks =
ExpandFile.expandTemplate
{src=header,
{src=ExpandFile.mkTemplateFromFile (path ^ "/runtime.h"),
dst=basename ^ ".h",
hooks=stdHooks basename @ hooks}
fun expandRuntime basename hooks =
fun expandRuntime path basename hooks =
ExpandFile.expandTemplate
{src=runtime,
{src=ExpandFile.mkTemplateFromFile (path ^ "/runtime.c"),
dst=basename ^ ".c",
hooks=stdHooks basename @ hooks}
......@@ -1061,9 +1059,9 @@ structure C1 = struct
(ListMergeSort.sort (fn ((_,i1),(_,i2)) => i1>i2)
(AtomMap.listItemsi (!(#allocFuncs s))))
val state = emitType s (SOME "state", !(#stateType s))
val path = Controls.get BasicControl.runtimePath
val _ =
C1Templates.expandHeader outputName [
C1Templates.expandHeader path outputName [
C1Templates.mkHook ("init", str (prefix ^ "init")),
C1Templates.mkHook ("set_code", str (prefix ^ "set_code")),
C1Templates.mkHook ("get_ip_offset", str (prefix ^ "get_ip_offset")),
......@@ -1081,7 +1079,7 @@ structure C1 = struct
C1Templates.mkHook ("tagnames", align constructors)
]
val _ =
C1Templates.expandRuntime outputName [
C1Templates.expandRuntime path outputName [
C1Templates.mkHook ("init", str (prefix ^ "init")),
C1Templates.mkHook ("set_code", str (prefix ^ "set_code")),
C1Templates.mkHook ("get_ip_offset", str (prefix ^ "get_ip_offset")),
......
......@@ -29,6 +29,9 @@ structure BasicControl : sig
(* the name for the generated file *)
val outputName : string option Controls.control
(* the name for the generated file *)
val runtimePath : string Controls.control
(* the prefix for exported functions *)
val exportPrefix : string Controls.control
......@@ -145,6 +148,15 @@ structure BasicControl : sig
default = NONE
}
(* the path to the files *)
val runtimePath : string Controls.control = Controls.genControl {
name = "runtime",
pri = [0],
obscurity = 0,
help = "path to the runtime files",
default = "./detail/codegen/c1/"
}
(* the prefix for exported functions*)
val exportPrefix : string Controls.control = Controls.genControl {
name = "prefix",
......
......@@ -65,6 +65,8 @@ structure Main = struct
\ -h show help message\n\
\ -p pfx\n\
\ --prefix=pfx prefix functions with pfx\n\
\ -r path\n\
\ --runtime=path path to the runtime files, defaults to detail/codegen/c1/\n\
\ -o name\n\
\ --outname=name base name of output file, defaults to gdsl-pfx\n\
\ -t do not run the type checker\n\
......@@ -101,6 +103,13 @@ structure Main = struct
and processLibname arg = Controls.set (BasicControl.outputName, SOME arg)
and processRuntime arg =
if String.size arg=0 then () else
if String.sub (arg,String.size arg-1) = #"/" then
Controls.set (BasicControl.runtimePath, String.substring (arg,0,String.size arg-1))
else
Controls.set (BasicControl.runtimePath, arg)
and processMaxIter arg = case Int.fromString arg of
SOME num => Controls.set (BasicControl.maxIter, num)
| NONE => bad ("!* expected number for --maxIter\n")
......@@ -129,7 +138,10 @@ structure Main = struct
if String.isPrefix "--prefix=" arg
then (processPrefix (String.extract (arg,9,NONE)); processArgs args)
else
if String.isPrefix "--libname=" arg
if String.isPrefix "--runtime=" arg
then (processRuntime (String.extract (arg,10,NONE)); processArgs args)
else
if String.isPrefix "--outname=" arg
then (processLibname (String.extract (arg,10,NONE)); processArgs args)
else
if String.isPrefix "--maxIter=" arg
......@@ -150,6 +162,10 @@ structure Main = struct
(arg :: args) => (processLibname arg; processArgs args)
| [] => badopt ()
)
| "-r" => (case args of
(arg :: args) => (processRuntime arg; processArgs args)
| [] => badopt ()
)
| _ => badopt ()
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment