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

SCM Repository

[diderot] View of /trunk/src/ast/meta-var.sml
ViewVC logotype

View of /trunk/src/ast/meta-var.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 75 - (download) (annotate)
Mon May 24 20:41:18 2010 UTC (10 years, 4 months ago) by jhr
File size: 1531 byte(s)
  Propoagating changes to meta variables
(* meta-var.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * The Diderot typechecker uses four kinds of meta variables:
 *
 *	type variables
 *	differentiation variables
 *	shape variables
 *	dimension variables
 *)

structure MetaVar =
  struct

    datatype ty_var = datatype Types.ty_var
    datatype diff_var = datatype Types.diff_var
    datatype shape_var = datatype Types.shape_var
    datatype dim_var = datatype Types.dim_var
    datatype kind = datatype Types.kind


  (***** Type variables ****)

    fun newTyVar () = TV{
	    id = Stamp.new(),
	    bind = ref NONE
	  }

    fun tyVarToString (TV{id, ...}) = "'ty" ^ Stamp.toString id


  (***** Differentiation variables ****)

    fun newDiffVar () = DfV{
	    id = Stamp.new(),
	    bound = ref 0,
	    bind = ref NONE
	  }

    fun diffVarToString (DfV{id, ...}) = "'diff" ^ Stamp.toString id


  (***** Shape variables ****)

    fun newShapeVar () = SV{
	    id = Stamp.new(),
	    bind = ref NONE
	  }

    fun shapeVarToString (SV{id, ...}) = "'shp" ^ Stamp.toString id


  (***** Dimension variables ****)

    fun newDimVar () = DV{
	    id = Stamp.new(),
	    bind = ref NONE
	  }

    fun dimVarToString (DV{id, ...}) = "'dim" ^ Stamp.toString id


  (***** Meta variables ****)

    fun metaToString (TYPE tv) = tyVarToString tv
      | metaToString (DIFF dv) = diffVarToString dv
      | metaToString (SHAPE sv) = shapeVarToString sv
      | metaToString (DIM dv) = dimVarToString dv

  end

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