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

SCM Repository

[diderot] Annotation of /branches/vis12/src/compiler/ast/var.sml
ViewVC logotype

Annotation of /branches/vis12/src/compiler/ast/var.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 171 - (view) (download)
Original Path: trunk/src/compiler/ast/var.sml

1 : jhr 71 (* var.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure Var =
8 :     struct
9 :    
10 :     datatype var = datatype AST.var
11 :    
12 : jhr 72 datatype var_kind = datatype AST.var_kind
13 :    
14 : jhr 79 fun nameOf (V{name, ...}) = name
15 : jhr 71 fun typeOf (V{ty, ...}) = ty
16 : jhr 171 fun monoTypeOf (V{ty=([], ty), ...}) = ty
17 :     | monoTypeOf (V{name, ...}) = raise Fail(name ^ " is not monomrphic")
18 : jhr 72 fun kindOf (V{kind, ...}) = kind
19 : jhr 71
20 :     fun new (name, kind, ty) = let
21 :     val id = Stamp.new()
22 :     in
23 :     V{name=Atom.toString name, id=id, kind=kind, ty=([], ty)}
24 :     end
25 :    
26 : jhr 78 fun newPoly (name, kind, scheme) = let
27 :     val id = Stamp.new()
28 :     in
29 :     V{name=Atom.toString name, id=id, kind=kind, ty=scheme}
30 :     end
31 :    
32 : jhr 136 fun compare (V{id=a, ...}, V{id=b, ...}) = Stamp.compare(a, b)
33 :     fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)
34 :     fun hash (V{id, ...}) = Stamp.hash id
35 :    
36 :     local
37 :     structure V =
38 :     struct
39 :     type ord_key = var
40 :     val compare = compare
41 :     end
42 :     in
43 :     structure Map = RedBlackMapFn (V)
44 :     structure Set = RedBlackSetFn (V)
45 :     end
46 :    
47 : jhr 71 end

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