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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/basis/basis-vars.sml
ViewVC logotype

Diff of /branches/lamont/src/compiler/basis/basis-vars.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2297, Fri Mar 15 22:05:31 2013 UTC revision 2298, Fri Mar 15 22:18:22 2013 UTC
# Line 92  Line 92 
92              in              in
93                [t, t] --> t                [t, t] --> t
94              end))              end))
95        val add_fr = polyVar(N.op_add, all([DK,NK], (* field + scalar *)
96              fn [Ty.DIFF k, Ty.DIM d] => let
97                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
98                in
99                  [t, Ty.realTy] --> t
100                end))
101        val add_rf = polyVar(N.op_add, all([DK,NK], (* scalar + field *)
102              fn [Ty.DIFF k, Ty.DIM d] => let
103                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
104                in
105                  [Ty.realTy, t] --> t
106                end))
107    
108      val sub_ii = monoVar(N.op_sub, [Ty.T_Int, Ty.T_Int] --> Ty.T_Int)      val sub_ii = monoVar(N.op_sub, [Ty.T_Int, Ty.T_Int] --> Ty.T_Int)
109      val sub_tt = polyVar(N.op_sub, all([SK], fn [Ty.SHAPE dd] => let      val sub_tt = polyVar(N.op_sub, all([SK], fn [Ty.SHAPE dd] => let
# Line 105  Line 117 
117              in              in
118                [t, t] --> t                [t, t] --> t
119              end))              end))
120        val sub_fr = polyVar(N.op_sub, all([DK,NK], (* field - scalar *)
121              fn [Ty.DIFF k, Ty.DIM d] => let
122                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
123                in
124                  [t, Ty.realTy] --> t
125                end))
126        val sub_rf = polyVar(N.op_sub, all([DK,NK], (* scalar - field *)
127              fn [Ty.DIFF k, Ty.DIM d] => let
128                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
129                in
130                  [Ty.realTy, t] --> t
131                end))
132    
133    (* note that we assume that operators are tested in the order defined here, so that mul_rr    (* note that we assume that operators are tested in the order defined here, so that mul_rr
134     * takes precedence over mul_rt and mul_tr!     * takes precedence over mul_rt and mul_tr!
# Line 165  Line 189 
189      val dist_t3  = monoVar (N.fn_dist, vec3Ty)      val dist_t3  = monoVar (N.fn_dist, vec3Ty)
190      end      end
191    
   
   
192    (* exponentiation; we distinguish between integer and real exponents to allow x^2 to be compiled    (* exponentiation; we distinguish between integer and real exponents to allow x^2 to be compiled
193     * as x*x.     * as x*x.
194     *)     *)
# Line 192  Line 214 
214                      --> field(k, d, dd)                      --> field(k, d, dd)
215                  end))                  end))
216    
217      (* curl on 2d and 3d vector fields *)
218        local
219          val diff0 = Ty.DiffConst 0
220          fun field' (k, d, dd) = field(k, Ty.DimConst d, Ty.Shape(List.map Ty.DimConst dd))
221        in
222    (* FIXME: we want to be able to require that k > 0, but we don't have a way to do that! *)
223        val curl2D = polyVar (N.op_curl, all([DK],
224              fn [Ty.DIFF k] =>
225                [field' (Ty.DiffVar(k, 0), 2, [2])] --> field' (diff0, 2, [])))
226        val curl3D = polyVar (N.op_curl, all([DK],
227              fn [Ty.DIFF k] =>
228                [field' (Ty.DiffVar(k, 0), 3, [3])] --> field' (diff0, 2, [3])))
229        end (* local *)
230    
231      val lt_ii = monoVar(N.op_lt, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)      val lt_ii = monoVar(N.op_lt, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)
232      val lt_rr = monoVar(N.op_lt, [Ty.realTy, Ty.realTy] --> Ty.T_Bool)      val lt_rr = monoVar(N.op_lt, [Ty.realTy, Ty.realTy] --> Ty.T_Bool)
233      val lte_ii = monoVar(N.op_lte, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)      val lte_ii = monoVar(N.op_lte, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)

Legend:
Removed from v.2297  
changed lines
  Added in v.2298

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