SCM Repository
View of /trunk/src/compiler/inputs/inputs.sml
Parent Directory
|
Revision Log
Revision 2472 -
(download)
(annotate)
Sat Oct 12 14:23:12 2013 UTC (8 years, 8 months ago) by jhr
File size: 2910 byte(s)
Sat Oct 12 14:23:12 2013 UTC (8 years, 8 months ago) by jhr
File size: 2910 byte(s)
Adding inputs directory for a future merging of code from stage
(* inputs.sml * * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. * * Common representation for tracking inputs through the passes of the compiler. *) structure Inputs : sig datatype initialization = String of string | Bool of bool | Int of IntInf.int | Real of FloatLit.float | Tensor of int list * FloatLit.float vector | Seq of initialization list | Proxy of string * ImageInfo.info (* input image specified by proxy *) | Image of ImageInfo.info (* input image w/o proxy *) datatype 'ty input = INP of { ty : 'ty, name : string, desc : string option, init : initialization option } val same : 'a input * 'a input -> bool val hash : 'a input -> word val initToString : initialization -> string val toString : 'ty input -> string val imageInfo : 'ty input -> ImageInfo.info option (* type conversion *) val map : ('a -> 'b) -> 'a input -> 'b input end = struct (* initialization of input variables *) datatype initialization = String of string | Bool of bool | Int of IntInf.int | Real of FloatLit.float | Tensor of int list * FloatLit.float vector | Seq of initialization list | Proxy of string * ImageInfo.info | Image of ImageInfo.info datatype 'ty input = INP of { ty : 'ty, name : string, desc : string option, init : initialization option } fun same (INP{name=n1, ...}, INP{name=n2, ...}) = (n1 = n2) fun hash (INP{name, ...}) = HashString.hashString name fun initToString (String s) = String.concat["\"", String.toString s, "\""] | initToString (Bool b) = Bool.toString b | initToString (Int n) = if (n < 0) then "-" ^ IntInf.toString(~n) else IntInf.toString n | initToString (Real f) = FloatLit.toString f | initToString (Tensor(dims, vals)) = "[...]" | initToString (Seq vs) = String.concat["{", String.concatWith "," (List.map initToString vs), "}"] | initToString (Proxy(name, _)) = String.concat["image(\"", name, "\")"] | initToString (Image info) = ImageInfo.toString info fun toString (INP{name, desc=NONE, init=NONE, ...}) = name | toString (INP{name, desc=SOME desc, init=NONE, ...}) = String.concat[name, "(\"", String.toString desc, "\""] | toString (INP{name, desc=NONE, init=SOME v, ...}) = String.concat[name, " = ", initToString v] | toString (INP{name, desc=SOME desc, init=SOME v, ...}) = String.concat[name, "(\"", String.toString desc, "\") = ", initToString v] fun imageInfo (INP{init=SOME(Proxy(_, info)), ...}) = SOME info | imageInfo (INP{init=SOME(Image info), ...}) = SOME info | imageInfo _ = NONE (* type conversion *) fun map f (INP{ty, name, desc, init}) = INP{ty = f ty, name = name, desc = desc, init = init} end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |