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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/translate/translate.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/translate/translate.sml

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

revision 3720, Mon Apr 4 18:20:42 2016 UTC revision 3721, Mon Apr 4 19:38:34 2016 UTC
# Line 197  Line 197 
197                  end                  end
198              | S.E_Cons args => [IL.ASSGN(lhs, IL.CONS(IL.Var.ty lhs, List.map (lookup env) args))]              | S.E_Cons args => [IL.ASSGN(lhs, IL.CONS(IL.Var.ty lhs, List.map (lookup env) args))]
199              | S.E_Seq args => [IL.ASSGN(lhs, IL.CONS(IL.Var.ty lhs, List.map (lookup env) args))]              | S.E_Seq args => [IL.ASSGN(lhs, IL.CONS(IL.Var.ty lhs, List.map (lookup env) args))]
200    (*
201              | S.E_Slice(x, indices, ty) => let              | S.E_Slice(x, indices, ty) => let
202                  val x = lookup env x                  val x = lookup env x
203                  val mask = List.map isSome indices                  val mask = List.map isSome indices
# Line 207  Line 208 
208                    if List.all (fn b => b) mask                    if List.all (fn b => b) mask
209                      then [IL.ASSGN(lhs, IL.OP(Op.TensorSub(IL.Var.ty x), x::indices))]                      then [IL.ASSGN(lhs, IL.OP(Op.TensorSub(IL.Var.ty x), x::indices))]
210                      else [IL.ASSGN(lhs, IL.OP(Op.Slice(IL.Var.ty x, mask), x::indices))]                      else [IL.ASSGN(lhs, IL.OP(Op.Slice(IL.Var.ty x, mask), x::indices))]
211                    end*)
212    | S.E_Slice(x, indices, ty) => let
213    val x = lookup env x
214    val mask = List.map isSome indices
215    fun cvt NONE = NONE
216    | cvt (SOME x) = SOME(lookup env x)
217    val indices = List.mapPartial cvt indices
218    
219    val sliceop=Op.Slice(IL.Var.ty x, mask)
220    val sliceargs= x::indices
221    
222    fun iterArgs []=[]
223    | iterArgs(e1::es)=let
224    val  IL.VB_RHS( IL.LIT(Literal.Int i))=IL.Var.binding e1
225    in [IntInf.toInt i]@iterArgs es end
226    val const = iterArgs (List.drop(sliceargs,1))
227    val rator=(case (IL.Var.ty lhs,IL.Var.ty x,ty)
228    of (DstTy.TensorTy rstTy, DstTy.TensorTy argTy, _) => MkOperators.sliceT (mask, const, rstTy, argTy)
229    | (_,_,Ty.T_Field{diff, dim, shape})              => MkOperators.sliceF(mask, const, shape, dim)
230    (*end case*))
231    
232    (*val assn=[IL.ASSGN(lhs, IL.OP(sliceop, sliceargs))]*)
233    val assn=[IL.ASSGN(lhs,IL.EINAPP(rator,[x]))]
234    in
235    if List.all (fn b => b) mask
236    then [IL.ASSGN(lhs, IL.OP(Op.TensorSub(IL.Var.ty x), x::indices))]
237    else assn
238                  end                  end
239    
240    
241              | S.E_Coerce{srcTy, dstTy, x} => (case (srcTy, dstTy)              | S.E_Coerce{srcTy, dstTy, x} => (case (srcTy, dstTy)
242                   of (Ty.T_Int, Ty.T_Tensor _) =>                   of (Ty.T_Int, Ty.T_Tensor _) =>
243                        [IL.ASSGN(lhs, IL.OP(Op.IntToReal, [lookup env x]))]                        [IL.ASSGN(lhs, IL.OP(Op.IntToReal, [lookup env x]))]

Legend:
Removed from v.3720  
changed lines
  Added in v.3721

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