# SCM Repository

# View of /branches/vis15/src/compiler/simple/simple-types.sml

Parent Directory | Revision Log

Revision

File size: 3200 byte(s)

**3846**- (**download**) (**annotate**)*Wed May 11 13:35:09 2016 UTC*(3 years, 1 month ago) by*jhr*File size: 3200 byte(s)

working on merge: added support for accessing other strand's state

(* simple-types.sml * * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) * * COPYRIGHT (c) 2015 The University of Chicago * All rights reserved. * * Internal representation of Diderot types after simplification. This is essentially * the Types representations with the meta variables stripped out. *) structure SimpleTypes = struct datatype ty = T_Bool | T_Int | T_String | T_Sequence of ty * int option (* sequence of values; second argument is length *) | T_Strand of Atom.atom (* strand type *) (* convolution kernel; argument is number of levels of differentiation *) | T_Kernel of diff (* scalars, vectors, matrices, etc.; argument is tensor shape *) | T_Tensor of shape (* data sets from NRRD *) | T_Image of { dim : dim, (* 1D, 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 : diff, (* number of levels of differentiation supported *) dim : dim, (* 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 withtype diff = int and shape = int list and dim = int (* instantiated meta variable values *) datatype meta_arg = TY of ty | DIFF of diff | SHAPE of shape | DIM of dim local fun listToString fmt sep items = String.concatWithMap sep fmt items val shapeToString = listToString Int.toString "," in fun toString ty = (case ty of T_Bool => "bool" | T_Int => "int" | T_String => "string" | T_Sequence(ty, NONE) => toString ty ^ "[]" | T_Sequence(ty, SOME dim) => concat[toString ty, "[", Int.toString dim, "]"] | T_Strand id => Atom.toString id | T_Kernel n => "kernel#" ^ Int.toString n | T_Tensor[] => "real" | T_Tensor[2] => "vec2" | T_Tensor[3] => "vec3" | T_Tensor[4] => "vec4" | T_Tensor shape => concat["tensor[", shapeToString shape, "]"] | T_Image{dim, shape} => concat[ "image(", Int.toString dim, ")[", shapeToString shape, "]" ] | T_Field{diff, dim, shape} => concat[ "field#", Int.toString diff, "(", Int.toString dim, ")[", shapeToString shape, "]" ] | T_Fun(tys1, ty2) => let fun tysToString [] = "()" | tysToString [ty] = toString ty | tysToString tys = String.concat[ "(", listToString toString " * " tys, ")" ] in String.concat[tysToString tys1, " -> ", toString ty2] end (* end case *)) end (* local *) (* return the range (return type) of a function type *) fun rngOf (T_Fun(_, ty)) = ty | rngOf ty = raise Fail(concat["SimpleTypes.rngOf(", toString ty, ")"]) end

root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |

Powered by ViewVC 1.0.0 |