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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/ast/var.sml
ViewVC logotype

Diff of /branches/lamont/src/compiler/ast/var.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 11  Line 11 
11    
12      datatype var_kind = datatype AST.var_kind      datatype var_kind = datatype AST.var_kind
13    
14      fun nameOf (V{name, ...}) = name      fun nameOf (V{name, ...}) = Atom.toString name
15      fun typeOf (V{ty, ...}) = ty      fun typeOf (V{ty, ...}) = ty
16      fun monoTypeOf (V{ty=([], ty), ...}) = ty      fun monoTypeOf (V{ty=([], ty), ...}) = ty
17        | monoTypeOf (V{name, ...}) = raise Fail(name ^ " is not monomrphic")        | monoTypeOf (V{name, ...}) = raise Fail(Atom.toString name ^ " is not monomrphic")
18      fun kindOf (V{kind, ...}) = kind      fun kindOf (V{kind, ...}) = kind
19      fun uniqueNameOf (V{name, id, ...}) = name ^ Stamp.toString id      fun uniqueNameOf (V{name, id, ...}) = Atom.toString name ^ Stamp.toString id
20    
21      fun new (name, kind, ty) = let      fun new (name, kind, ty) = let
22            val id = Stamp.new()            val id = Stamp.new()
23            in            in
24              V{name=Atom.toString name, id=id, kind=kind, ty=([], ty)}              V{name=name, id=id, kind=kind, ty=([], ty)}
25            end            end
26    
27      fun newPoly (name, kind, scheme) = let      fun newPoly (name, kind, scheme) = let
28            val id = Stamp.new()            val id = Stamp.new()
29            in            in
30              V{name=Atom.toString name, id=id, kind=kind, ty=scheme}              V{name=name, id=id, kind=kind, ty=scheme}
31            end            end
32    
33        fun copy (V{name, kind, ty, ...}) = V{name=name, id=Stamp.new(), kind=kind, ty=ty}
34    
35      (* return true if variable has global scope *)
36        fun isGlobal (V{kind, ...}) = (case kind
37               of BasisVar => true
38                | InputVar => true
39                | GlobalVar => true
40                | FunVar => true
41                | _ => false
42              (* end case *))
43    
44      fun compare (V{id=a, ...}, V{id=b, ...}) = Stamp.compare(a, b)      fun compare (V{id=a, ...}, V{id=b, ...}) = Stamp.compare(a, b)
45      fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)      fun same (V{id=a, ...}, V{id=b, ...}) = Stamp.same(a, b)
46      fun hash (V{id, ...}) = Stamp.hash id      fun hash (V{id, ...}) = Stamp.hash id

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