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

SCM Repository

[diderot] Diff of /trunk/src/compiler/ast/meta-var.sml
ViewVC logotype

Diff of /trunk/src/compiler/ast/meta-var.sml

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

trunk/src/ast/type-var.sml revision 65, Thu May 13 21:04:35 2010 UTC trunk/src/ast/meta-var.sml revision 75, Mon May 24 20:41:18 2010 UTC
# Line 1  Line 1 
1  (* type-var.sml  (* meta-var.sml
2   *   *
3   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5     *
6     * The Diderot typechecker uses four kinds of meta variables:
7     *
8     *      type variables
9     *      differentiation variables
10     *      shape variables
11     *      dimension variables
12   *)   *)
13    
14  structure TypeVar =  structure MetaVar =
15    struct    struct
16    
17      datatype var = datatype Types.var      datatype ty_var = datatype Types.ty_var
18        datatype diff_var = datatype Types.diff_var
19        datatype shape_var = datatype Types.shape_var
20        datatype dim_var = datatype Types.dim_var
21        datatype kind = datatype Types.kind
22    
23    
24      (***** Type variables ****)
25    
26        fun newTyVar () = TV{
27                id = Stamp.new(),
28                bind = ref NONE
29              }
30    
31        fun tyVarToString (TV{id, ...}) = "'ty" ^ Stamp.toString id
32    
33    
34      (***** Differentiation variables ****)
35    
36      fun new kind = TV{      fun newDiffVar () = DfV{
37              kind = kind,              id = Stamp.new(),
38              stamp = Stamp.new()              bound = ref 0,
39                bind = ref NONE
40            }            }
41    
42        fun diffVarToString (DfV{id, ...}) = "'diff" ^ Stamp.toString id
43    
44    
45      (***** Shape variables ****)
46    
47        fun newShapeVar () = SV{
48                id = Stamp.new(),
49                bind = ref NONE
50              }
51    
52        fun shapeVarToString (SV{id, ...}) = "'shp" ^ Stamp.toString id
53    
54    
55      (***** Dimension variables ****)
56    
57        fun newDimVar () = DV{
58                id = Stamp.new(),
59                bind = ref NONE
60              }
61    
62        fun dimVarToString (DV{id, ...}) = "'dim" ^ Stamp.toString id
63    
64    
65      (***** Meta variables ****)
66    
67        fun metaToString (TYPE tv) = tyVarToString tv
68          | metaToString (DIFF dv) = diffVarToString dv
69          | metaToString (SHAPE sv) = shapeVarToString sv
70          | metaToString (DIM dv) = dimVarToString dv
71    
72    end    end

Legend:
Removed from v.65  
changed lines
  Added in v.75

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