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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/IL/translate-env-fn.sml
ViewVC logotype

View of /branches/vis12/src/compiler/IL/translate-env-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1685 - (download) (annotate)
Sun Jan 22 15:23:36 2012 UTC (7 years, 7 months ago) by jhr
File size: 1718 byte(s)
  Create a branch to implement things that we need for the Vis 2012 paper
(* translate-env-fn.sml
 *
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

signature TRANSLATE_ENV_PARAMS =
  sig

    structure SrcIL : SSA
    structure DstIL : SSA

    type var_env = DstIL.var SrcIL.Var.Tbl.hash_table
    type state_var_env = DstIL.state_var SrcIL.StateVar.Tbl.hash_table

    val rename : (var_env * SrcIL.var) -> DstIL.var
    val renameSV : (state_var_env * SrcIL.state_var) -> DstIL.state_var

  end

functor TranslateEnvFn (Params : TRANSLATE_ENV_PARAMS) : sig

    structure SrcIL : SSA
    structure DstIL : SSA

    type env

    val mkEnv : unit -> env

    val rename : (env * SrcIL.var) -> DstIL.var
    val renameList : (env * SrcIL.var list) -> DstIL.var list
    val renameSV : (env * SrcIL.state_var) -> DstIL.state_var

    val insertNd : (env * Stamp.stamp * DstIL.node) -> unit
    val findNd : env -> Stamp.stamp -> DstIL.node option

  end = struct

    structure SrcIL = Params.SrcIL
    structure DstIL = Params.DstIL

    datatype env = E of {
	ndMap : DstIL.node Stamp.Tbl.hash_table,
	vMap : Params.var_env,
        svMap : Params.state_var_env
      }

    fun mkEnv () = E{
            ndMap = Stamp.Tbl.mkTable (256, Fail "ndMap"),
            vMap = SrcIL.Var.Tbl.mkTable (256, Fail "vMap"),
            svMap = SrcIL.StateVar.Tbl.mkTable (64, Fail "svMap")
          }

    fun rename (E{vMap, ...}, x) = Params.rename(vMap, x)

    fun renameList (env, xs) = List.map (fn x => rename (env, x)) xs

    fun renameSV (E{svMap, ...}, x) = Params.renameSV (svMap, x)

    fun insertNd (E{ndMap, ...}, id, nd) = Stamp.Tbl.insert ndMap (id, nd)

    fun findNd (E{ndMap, ...}) = Stamp.Tbl.find ndMap

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0