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/src/compiler/FLINT/kernel/debindex.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/FLINT/kernel/debindex.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 419 - (view) (download)

1 : monnier 245 (* 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 :     * and index abstract because certain clients wants to use
10 :     * the values of these types as table indices.
11 :     *)
12 :     structure DebIndex : DEB_INDEX =
13 :     struct
14 :    
15 :     local structure EM = ErrorMsg
16 :     in
17 :    
18 :     fun bug s = EM.impossible ("DebIndex: " ^ s)
19 :    
20 :     type depth = int
21 :     type index = int
22 :    
23 :     val top = 0
24 :    
25 :     fun next i = i + 1
26 :    
27 :     fun prev i = if (i > 0) then i-1 else bug "negative depth in prev"
28 :    
29 :     fun eq (i:int, j) = (i=j)
30 :    
31 :     fun dp_key (i : depth) = i
32 :    
33 :     fun dp_print i = Int.toString i
34 :    
35 :     fun dp_toint (i : depth) = i
36 :     fun dp_fromint (i : int) = i
37 :    
38 :     fun calc (cur:int, def) =
39 :     if def > cur then bug "the definition is deeper than the use"
40 :     else (cur - def)
41 :    
42 :     val cmp = Int.compare
43 :    
44 :     fun di_key i = i
45 :    
46 :     fun di_print i = Int.toString i
47 :    
48 :     fun di_toint (i : index) = i
49 :     fun di_fromint (i : int) = i
50 :    
51 :     val innermost = 1
52 :     val innersnd = 2
53 :     fun di_inner i = i+1
54 :    
55 :     end (* local *)
56 :     end (* structure DebIndex *)
57 :    
58 :    

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