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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/global-env/strand-env.sml
ViewVC logotype

View of /branches/vis15/src/compiler/global-env/strand-env.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3408 - (download) (annotate)
Wed Nov 11 20:26:18 2015 UTC (4 years ago) by jhr
File size: 1653 byte(s)
working on merge
(* strand-env.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.
 *)

structure StrandEnv : sig

  (* the environment that describes the external view of a strand *)
    type t

  (* create a new strand environment from its name and list of parameters *)
    val new : Atom.atom * AST.var list -> t

  (* return the name of the strand *)
    val strandName : t -> Atom.atom

  (* return the parameter types *)
    val paramTys : t -> Types.ty list

  (* lookup a strand state variable *)
    val findStateVar : t * Atom.atom -> AST.var option

  (* insert a strand state variable into the given strand environment *)
    val insertStateVar : t * Atom.atom * AST.var -> unit

  end = struct

    structure ATbl = AtomTable

    datatype t = SE of {
	name : Atom.atom,			(* the strand's name *)
	paramTys : Types.ty list,		(* the types of the strand's parameters *)
	env : AST.var ATbl.hash_table		(* the strand's state variables *)
      }

  (* create a new strand environment *)
    fun new (name, params) = SE{
	  name = name,
	  paramTys = List.map Var.monoTypeOf params,
	  env = ATbl.mkTable(32, Fail "strand-env")
	}

  (* return the name of the strand *)
    fun strandName (SE{name, ...}) = name

  (* return the parameter types *)
    fun paramTys (SE{paramTys=tys, ...}) = tys

  (* lookup a strand state variable *)
    fun findStateVar (SE{env, ...}, x) = ATbl.find env x

  (* insert a strand state variable into the given strand environment *)
    fun insertStateVar (SE{env, ...}, x, x') = ATbl.insert env (x, x')

  end

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