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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/c-util/tree-ty-to-c.sml
ViewVC logotype

View of /branches/vis12/src/compiler/c-util/tree-ty-to-c.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1806 - (download) (annotate)
Sat Apr 7 00:02:25 2012 UTC (9 years, 2 months ago) by jhr
File size: 1279 byte(s)
  Working on input support
(* tree-ty-to-c.sml
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure TreeTyToC : sig

  (* translate a TreeIL type to an external CLang type *)
    val trType : TreeIL.Ty.ty -> CLang.ty

  end = struct

    structure Ty = TreeIL.Ty
    structure CL = CLang
    structure N = CNames

    fun trType ty = (case ty
           of Ty.BoolTy => CL.T_Named "bool"
            | Ty.StringTy => CL.charPtr
            | Ty.IntTy => !N.gIntTy
            | Ty.TensorTy[] => !N.gRealTy
            | Ty.TensorTy[n] => CL.T_Array(!N.gRealTy, SOME n)
            | Ty.TensorTy[n, m] => CL.T_Array(CL.T_Array(!N.gRealTy, SOME n), SOME m)
            | Ty.TensorTy[n, m, l] => CL.T_Array(CL.T_Array(CL.T_Array(!N.gRealTy, SOME n), SOME m), SOME l)
            | Ty.SeqTy(Ty.IntTy, n) => CL.T_Array(!N.gIntTy, SOME n)
            | Ty.SeqTy(ty, n) => CL.T_Array(trType ty, SOME n)
            | Ty.DynSeqTy _ => CL.T_Ptr(CL.T_Named N.dynSeqTy)
            | Ty.AddrTy info => CL.T_Ptr(CL.T_Num(ImageInfo.sampleTy info))
            | Ty.ImageTy info => CL.T_Ptr(CL.T_Named(N.imageTy(ImageInfo.dim info)))
            | _ => raise Fail(concat["TreeTyToC.trType(", Ty.toString ty, ")"])
          (* end case *))

  end

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