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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (download) (annotate)
Tue Oct 27 15:16:36 2015 UTC (4 years, 9 months ago) by jhr
File size: 1771 byte(s)
making copyrights consistent for all code in the repository
(* translate-env-fn.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.
 *)

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