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

SCM Repository

[diderot] Diff of /trunk/src/compiler/ast/type-util.sml
ViewVC logotype

Diff of /trunk/src/compiler/ast/type-util.sml

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

revision 382, Tue Oct 5 21:46:21 2010 UTC revision 383, Tue Oct 5 21:53:49 2010 UTC
# Line 14  Line 14 
14    (* returns true if the type is a value type (bool, int, string, or tensor) *)    (* returns true if the type is a value type (bool, int, string, or tensor) *)
15      val isValueType : Types.ty -> bool      val isValueType : Types.ty -> bool
16    
17    (* prune out instantiated meta variables *)    (* prune out instantiated meta variables from a type.  We also normalize
18       * tensor shapes (i.e., remove 1s).
19       *)
20      val prune : Types.ty -> Types.ty      val prune : Types.ty -> Types.ty
21      val pruneDiff : Types.diff -> Types.diff      val pruneDiff : Types.diff -> Types.diff
22      val pruneShape : Types.shape -> Types.shape      val pruneShape : Types.shape -> Types.shape
# Line 47  Line 49 
49            Ty.T_Tensor(            Ty.T_Tensor(
50              Ty.Shape(List.tabulate(order, fn _ => Ty.DimVar(MetaVar.newDimVar()))))              Ty.Shape(List.tabulate(order, fn _ => Ty.DimVar(MetaVar.newDimVar()))))
51    
52    (* prune out instantiated meta variables from a type *)    (* prune out instantiated meta variables from a type.  We also normalize
53       * tensor dimensions (i.e., remove 1s).
54       *)
55      fun prune ty = (case ty      fun prune ty = (case ty
56             of (ty as Ty.T_Var(Ty.TV{bind, ...})) => (case !bind             of (ty as Ty.T_Var(Ty.TV{bind, ...})) => (case !bind
57                   of NONE => ty                   of NONE => ty
# Line 80  Line 84 
84              | dim => dim              | dim => dim
85            (* end case *))            (* end case *))
86    
87        and filterDim dim = (case pruneDim dim
88               of Ty.DimConst 1 => NONE
89                | dim => SOME dim
90              (* end case *))
91    
92      and pruneShape shape = (case shape      and pruneShape shape = (case shape
93             of Ty.Shape dd => Ty.Shape(List.map pruneDim dd)             of Ty.Shape dd => Ty.Shape(List.mapPartial filterDim dd)
94              | Ty.ShapeVar(Ty.SV{bind=ref(SOME shape), ...}) => pruneShape shape              | Ty.ShapeVar(Ty.SV{bind=ref(SOME shape), ...}) => pruneShape shape
95              | Ty.ShapeExt(shape, dim) => Ty.shapeExt(pruneShape shape, pruneDim dim)              | Ty.ShapeExt(shape, dim) => (case filterDim dim
96                     of SOME dim => Ty.shapeExt(pruneShape shape, dim)
97                      | NONE => pruneShape shape
98                    (* end case *))
99              | _ => shape              | _ => shape
100            (* end case *))            (* end case *))
101    

Legend:
Removed from v.382  
changed lines
  Added in v.383

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