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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (download) (annotate)
Sun May 23 22:54:59 2010 UTC (9 years, 3 months ago) by jhr
Original Path: trunk/src/ast/types.sml
File size: 2072 byte(s)
  Comment out raw types, which are not used yet.
(* types.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * Internal representation of Diderot types.  These are the types produced
 * by the type checker.
 *)

structure Types =
  struct

  (* kinds for type variables *)
    datatype kind
      = TK_NAT		(* ranges over natural numbers (0, 1, 2, ...) *)
      | TK_SHAPE	(* ranges over tensor shapes *)
      | TK_TYPE		(* ranges over types *)

(*
  (* 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
*)

    datatype ty
      = T_Var of var
      | T_Bool
      | T_Int
      | T_String
    (* convolution kernel; argument is number of levels of differentiation *)
      | T_Kernel of nat
    (* scalars, vectors, matrices, etc.; argument is tensor shape *)
      | T_Tensor of shape
    (* data sets from NRRD *)
      | T_Image of {
	  dim : nat,		(* 2D or 3D data set *)
	  shape : shape		(* 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,		(* dimension of domain (2D or 3D field) *)
	  shape : shape		(* shape of tensors in range; order is length of list *)
	}
      | T_Fun of ty list * ty list

    and shape
      = Shape of nat list
      | ShapeVar of var
      | ShapeExt of shape * nat		(* extension of shape (i.e., for D operator) *)

    and nat
      = NatConst of int			(* i *)
      | NatExp of (nat * int)		(* d + i; for diff fields only *)
      | NatVar of var

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

    type scheme = var list * ty

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

  end

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