Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/compiler/Elaborator/basics/debindex.sml
ViewVC logotype

Annotation of /sml/trunk/compiler/Elaborator/basics/debindex.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2492 - (view) (download)

1 : blume 902 (* COPYRIGHT (c) 1997 YALE FLINT PROJECT *)
2 :     (* debindex.sml *)
3 :    
4 :     (*
5 :     * This implements the abstraction of de Bruijn indices used
6 :     * by the FLINT type and term language. The notion of depth
7 :     * refers to the type-binding depth relative to the top level
8 :     * of the current compilation unit. I can't make type depth
9 : dbm 2492 * and index abstract because certain clients want to use
10 : blume 902 * the values of these types as table indices.
11 :     *)
12 :    
13 :     (* I moved this into the elaborator library. It may be moved
14 :     * back to FLINT if the elaborator gets "cleaned up", i.e., if
15 :     * it is made to be unaware of such middle-end specifics.
16 :     * (08/2001 Blume) *)
17 :    
18 :     structure DebIndex : DEB_INDEX =
19 :     struct
20 :    
21 :     local structure EM = ErrorMsg
22 :     in
23 :    
24 :     fun bug s = EM.impossible ("DebIndex: " ^ s)
25 :    
26 :     type depth = int
27 :     type index = int
28 :    
29 :     val top = 0
30 :    
31 :     fun next i = i + 1
32 :    
33 :     fun prev i = if (i > 0) then i-1 else bug "negative depth in prev"
34 :    
35 :     fun eq (i:int, j) = (i=j)
36 :    
37 :     fun dp_key (i : depth) = i
38 :    
39 :     fun dp_print i = Int.toString i
40 :    
41 :     fun dp_toint (i : depth) = i
42 :     fun dp_fromint (i : int) = i
43 :    
44 :     fun calc (cur:int, def) =
45 :     if def > cur then bug "the definition is deeper than the use"
46 :     else (cur - def)
47 :    
48 :     val cmp = Int.compare
49 :    
50 :     fun di_key i = i
51 :    
52 :     fun di_print i = Int.toString i
53 :    
54 :     fun di_toint (i : index) = i
55 :     fun di_fromint (i : int) = i
56 :    
57 :     val innermost = 1
58 :     val innersnd = 2
59 :     fun di_inner i = i+1
60 :    
61 :     end (* local *)
62 :     end (* structure DebIndex *)
63 :    
64 :    

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