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

SCM Repository

[diderot] View of /trunk/src/ast/types.sml
ViewVC logotype

View of /trunk/src/ast/types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (download) (annotate)
Tue May 11 16:02:48 2010 UTC (10 years, 5 months ago) by jhr
File size: 1845 byte(s)
  Fix representation of types
(* types.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * Internal representation of Diderot types
 *)

structure Types =
  struct

  (* kinds for type variables *)
    datatype kind
      = TK_NAT		(* ranges over natural numbers (0, 1, 2, ...) *)
      | TK_INT		(* ranges over integer types *)
      | TK_FLT		(* ranges over floating-point types *)
      | TK_RAW		(* ranges over raw (scalar) types *)
      | TK_TYPE		(* ranges over types *)
(* Question: do we want kinds for tensors of different orders (e.g., TK_TENSOR of word?);
 * Then TK_RAW would be TK_TENSOR of 0w0.
 *)

  (* raw numeric types as supported by NRRD *)
    datatype raw_ty
      = RT_Int8 | RT_UInt8
      | RT_Int16 | RT_UInt16
      | RT_Int32 | RT_UInt32
      | RT_Int64 | RT_UInt64
      | RT_Float | RT_Double
      | RT_Var of var

    and ty
      = T_Var of var
      | T_Bool
      | T_Int
    (* scalars, vectors, matrices, etc. *)
      | T_Tensor of nat list	(* tensor shape *)
    (* data sets from NRRD *)
      | T_Image of {
	  dim : nat,		(* 2D or 3D data set *)
	  shape : nat list	(* tensor shape; order is length of list *)
	}
    (* continuous field reconstructed from a data set *)
      | T_Field of {
	  diff : nat,		(* number of levels of differentiation supported *)
	  dim : nat,		(* 2D or 3D field *)
	  shape : nat list	(* tensor shape; order is length of list *)
	}

    and nat
      = NatConst of int			(* i *)
      | NatExp of (nat * int)		(* d + i *)
      | NatVar of var

  (* type variables; the kind field restricts their range *)
    and var = TV of {
	  kind : kind,
	  stamp : Stamp.stamp
	}

  (* useful types *)
    val realTy = T_Tensor[]
    fun vec2Ty = T_Tensor[NatConst 2]
    fun vec3Ty = T_Tensor[NatConst 3]
    fun vec4Ty = T_Tensor[NatConst 4]

  end

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