Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/src/compiler/cfg-ir/inputs.sml
ViewVC logotype

View of /branches/vis15/src/compiler/cfg-ir/inputs.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3447 - (download) (annotate)
Fri Nov 20 17:21:39 2015 UTC (4 years, 4 months ago) by jhr
File size: 2451 byte(s)
working on merge
(* inputs.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *
 * Common representation for tracking inputs through the passes of the compiler.
 *)

structure Inputs : sig

    datatype init_from_nrrd
      = DynSeq of string
      | 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 : init_from_nrrd option
      }

    val same : 'a input * 'a input -> bool

    val hash : 'a input -> word

    val initToString : init_from_nrrd -> 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

    datatype init_from_nrrd
      = DynSeq of string
      | 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 : init_from_nrrd option
      }

    fun same (INP{name=n1, ...}, INP{name=n2, ...}) = (n1 = n2)

    fun hash (INP{name, ...}) = HashString.hashString name

    fun initToString (DynSeq name) = String.concat["load(\"", name, "\")"]
      | 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