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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/simplify/simple-var.sml
ViewVC logotype

View of /branches/vis12/src/compiler/simplify/simple-var.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2481 - (download) (annotate)
Mon Oct 14 15:00:53 2013 UTC (6 years, 1 month ago) by jhr
File size: 1341 byte(s)
  merging in new SimpleAST representation from stage
(* simple-var.sml
 *
 * COPYRIGHT (c) 2013 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure SimpleVar =
  struct

    datatype var = datatype Simple.var

    datatype var_kind = datatype Simple.var_kind

    fun nameOf (V{name, ...}) = name
    fun typeOf (V{ty, ...}) = ty
    fun kindOf (V{kind, ...}) = kind
    fun uniqueNameOf (V{name, id, ...}) = name ^ Stamp.toString id

    fun new (name, kind, ty) = let
	  val id = Stamp.new()
	  in
	    V{name=name, id=id, kind=kind, ty=ty}
	  end

    fun copy (V{name, kind, ty, ...}) = V{name=name, id=Stamp.new(), kind=kind, ty=ty}

  (* return true if variable has global scope *)
    fun isGlobal (V{kind, ...}) = (case kind
	   of BasisVar => true
	    | InputVar => true
	    | GlobalVar => true
	    | FunVar => true
	    | _ => false
	  (* end case *))

    fun compare (V{id=a, ...}, V{id=b, ...}) = Stamp.compare(a, b)
    fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)
    fun hash (V{id, ...}) = Stamp.hash id

    local
      structure V =
	struct
	  type ord_key = var
	  val compare = compare
	end
    in
    structure Map = RedBlackMapFn (V)
    structure Set = RedBlackSetFn (V)
    end

    structure Tbl = HashTableFn (
      struct
	type hash_key = var
	val hashVal = hash
	val sameKey = same
      end)

  end

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