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/Semant/basics/access.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/Semant/basics/access.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)
Original Path: sml/branches/SMLNJ/src/compiler/Semant/basics/access.sml

1 : monnier 16 (* Copyright 1996 by AT&T Bell Laboratories *)
2 :     (* access.sml *)
3 :    
4 :     structure Access : ACCESS =
5 :     struct
6 :    
7 :     local structure LV = LambdaVar
8 :     structure EM = ErrorMsg
9 :     structure PS = PersStamps
10 :     structure S = Symbol
11 :     in
12 :    
13 :     fun bug msg = EM.impossible("Bugs in Access: "^msg)
14 :    
15 :     type lvar = LV.lvar
16 :     type persstamp = PS.persstamp
17 :    
18 :     (*
19 :     * access: how to find the dynamic value corresponding to a variable.
20 :     * An LVAR is just a lambda-bound variable --- a temporary used to denote
21 :     * a binding in the current compilation unit. EXTERN refers to a binding
22 :     * defined externally (in other modules). PATH is an absolute address from
23 :     * a lambda-bound variable (i.e. we find the value of the lambda-bound
24 :     * variable, and then do selects from that). PATH's are kept in reverse
25 :     * order. NO_ACCESS is used to denote built-in structures that do not
26 :     * have corresponding dynamic objects (e.g., the built-in InLine is a
27 :     * structure that declares all the built-in primitives --- it is likely
28 :     * that NO_ACCESS will go away in the future once we have cleaned up the
29 :     * bootstrap procedure.
30 :     *)
31 :     datatype access
32 :     = LVAR of lvar
33 :     | EXTERN of persstamp
34 :     | PATH of access * int
35 :     | NO_ACCESS
36 :    
37 :     (*
38 :     * conrep: how to decide the data representations for data constructors.
39 :     * All true datatypes are divided into four categories, depending on the
40 :     * pair of parameters (m,n) where m is the number of constant constructors
41 :     * and n is the number of value carrying constructors. REF, EXN, SUSP
42 :     * are special constructors for reference cells, exceptions, and suspensions;
43 :     * treating them as data constructors simplifies the match compilation.
44 :     * LISTCONS and LISTNIL are special conreps for unrolled lists. The process
45 :     * of assigning conreps probably should be performed on the intermediate
46 :     * language instead.
47 :     *)
48 :     datatype conrep
49 :     = UNTAGGED (* 30 bit + 00; a pointer *)
50 :     | TAGGED of int (* a pointer; 1st field is the tag *)
51 :     | TRANSPARENT (* 32 bit value *)
52 :     | CONSTANT of int (* should be int31 *)
53 :     | REF
54 :     | EXN of access
55 :     | SUSP of (access * access) option
56 :     | LISTCONS
57 :     | LISTNIL
58 :    
59 :    
60 :     datatype consig
61 :     = CSIG of int * int
62 :     | CNIL
63 :    
64 :     (****************************************************************************
65 :     * UTILITY FUNCTIONS ON ACCESS *
66 :     ****************************************************************************)
67 :    
68 :     (** printing the access *)
69 :     fun prAcc (LVAR i) = "LVAR(" ^ LV.prLvar i ^ ")"
70 :     | prAcc (PATH(a,i)) = "PATH(" ^ Int.toString i ^ ","^ prAcc a ^ ")"
71 :     | prAcc (EXTERN pid) = "EXTERN(" ^ PS.toHex pid ^ ")"
72 :     | prAcc (NO_ACCESS) = "NO_ACCESS"
73 :    
74 :     (** printing the conrep *)
75 :     fun prRep (UNTAGGED) = "UT"
76 :     | prRep (TAGGED i) = "TG(" ^ Int.toString i ^ ")"
77 :     | prRep (TRANSPARENT) = "TN"
78 :     | prRep (CONSTANT i) = "CN(" ^ Int.toString i ^ ")"
79 :     | prRep (REF) = "RF"
80 :     | prRep (EXN acc) = "EXN" ^ prAcc acc
81 :     | prRep (LISTCONS) = "LC"
82 :     | prRep (LISTNIL) = "LN"
83 :     | prRep (SUSP _) = "SS"
84 :    
85 :     (** printing the data sign *)
86 :     fun prCsig (CSIG(i,j)) = "B" ^ Int.toString i ^ "U" ^ Int.toString j
87 :     | prCsig (CNIL) = "CNIL"
88 :    
89 :     (** testing if a conrep is an exception or not *)
90 :     fun isExn (EXN _) = true
91 :     | isExn _ = false
92 :    
93 :     (** fetching a component out of a structure access *)
94 :     fun selAcc (NO_ACCESS, _) = NO_ACCESS (* bug "Selecting from a NO_ACCESS !" *)
95 :     | selAcc (p, i) = PATH(p, i)
96 :    
97 :     (** duplicating an access variable *)
98 :     fun dupAcc (v, mkv) = LVAR(mkv(LV.lvarSym(v)))
99 :    
100 :     fun namedAcc (s, mkv) = LVAR(mkv(SOME s))
101 :     fun newAcc (mkv) = LVAR (mkv(NONE))
102 :     fun extAcc pid = EXTERN pid
103 :     val nullAcc = NO_ACCESS
104 :    
105 :     fun accLvar (LVAR v) = SOME v
106 :     | accLvar _ = NONE
107 :    
108 :     end (* local *)
109 :     end (* structure Access *)
110 :    
111 :     (*
112 :     * $Log: access.sml,v $
113 :     * Revision 1.1.1.1 1997/01/14 01:38:09 george
114 :     * Version 109.24
115 :     *
116 :     *)

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