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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/common/strand-util.sml
ViewVC logotype

View of /branches/vis12/src/compiler/common/strand-util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2807 - (download) (annotate)
Sat Nov 8 17:55:14 2014 UTC (4 years, 11 months ago) by jhr
File size: 2111 byte(s)
  Fix bug in shutdown fragment; proper tracking of HasGlobals property
(* strand-util.sml
 *
 * COPYRIGHT (c) 2014 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Utility definitions for strands.
 *
 * NOTE: this module deserves a different name, since it covers much more than just strands!
 *)

structure StrandUtil =
  struct

  (* method names *)
    datatype method_name
      = Update
      | Stabilize

    fun nameToString Update = "Update"
      | nameToString Stabilize = "Stabilize"

  (* program properties *)
    datatype program_prop
      = HasGlobals			(* present if the program has global variables *)
      | HasInputs			(* present if the program has input variables *)
      | StrandArray			(* present if the strands are organized in initial array *)
      | DynamicSeq			(* present if strands compute dynamic sequences *)
      | StrandsMayDie                   (* present if strands may die *)
      | HasStabilizeMethod		(* present if there is a user-defined stabilize method *)
      | NewStrands                      (* present if new strands may be created dynamically *)
      | StrandCommunication             (* present if strands read the state of other strands *)
      | GlobalReduce                    (* present if there is a global reduce phase *)

    fun propToString HasGlobals = "HasGlobals"
      | propToString HasInputs = "HasInputs"
      | propToString StrandArray = "StrandArray"
      | propToString DynamicSeq = "DynamicSeq"
      | propToString StrandsMayDie = "StrandsMayDie"
      | propToString HasStabilizeMethod = "HasStabilizeMethod"
      | propToString NewStrands = "NewStrands"
      | propToString StrandCommunication = "StrandCommunication"
      | propToString GlobalReduce = "GlobalReduce"

    fun propsToString [] = "none"
      | propsToString [p] = propToString p 
      | propsToString (p::props) = String.concat(
          propToString p
            :: List.foldr (fn (p, l) => "," :: propToString p :: l) [] props)

    fun hasProp (prop : program_prop) = List.exists (fn p => prop = p)

    fun clearProp (prop : program_prop) = List.filter (fn p => (p <> prop))

  end

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