~ubuntu-branches/ubuntu/karmic/fweb/karmic

« back to all changes in this revision

Viewing changes to Web/xrefs.hweb

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2002-01-04 23:20:22 UTC
  • Revision ID: james.westby@ubuntu.com-20020104232022-330ad4iyzpvb5bm4
Tags: upstream-1.62
ImportĀ upstreamĀ versionĀ 1.62

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@z --- xrefs.hweb ---
 
2
 
 
3
FWEB version 1.62 (September 25, 1998)
 
4
 
 
5
Based on version 0.5 of S. Levy's CWEB [copyright (C) 1987 Princeton University]
 
6
 
 
7
@x-----------------------------------------------------------------------------
 
8
 
 
9
@* DATA STRUCTURES EXCLUSIVE to WEAVE.
 
10
As explained in \.{common.web}, the field of a |name_info| structure that
 
11
contains the |rlink| of a module name is used for a completely different
 
12
purpose in the case of identifiers.  It is then called the |ilk| of the
 
13
identifier, and it is used to distinguish between various types of
 
14
identifiers, as follows:
 
15
 
 
16
{\narrower\narrower\everypar={\noindent\hang}
 
17
|normal| identifiers are part of the \cee\ program; they 
 
18
will appear in \It{italic type}.
 
19
 
 
20
|roman| identifiers are index entries that appear after
 
21
\.{@@\^} in the \.{WEB} file.
 
22
 
 
23
|wildcard| identifiers are index entries that appear after
 
24
\.{@@9} in the \.{WEB} file; they will appear in a format controlled by the
 
25
user-defined macro~\.{\\9}.
 
26
 
 
27
|typewriter| identifiers are index entries that appear after
 
28
\.{@@.} in the \.{WEB} file; they will appear in \.{typewriter type}.
 
29
 
 
30
|do_like| \dots\ identifiers are reserved words whose |ilk| explains how
 
31
they are to be treated when code is being formatted.
 
32
 
 
33
}
 
34
 
 
35
@d normal 0 /* ordinary identifiers have |normal| ilk */
 
36
@d roman 1 /* normal index entries have |roman| ilk */
 
37
@d wildcard 2 /* user-formatted index entries have |wildcard| ilk */
 
38
@d typewriter 3 /* `typewriter type' entries have |typewriter| ilk */
 
39
 
 
40
@d is_reserved(a) (a->ilk>typewriter) /* tells if a name is a reserved word */
 
41
 
 
42
@ We keep track of the current module number in |module_count|, which is
 
43
the total number of modules that have started.  Modules which have been
 
44
altered by a change file entry have their |chngd_module| flag turned on
 
45
during the first phase.
 
46
 
 
47
@<Global...@>=
 
48
 
 
49
EXTERN boolean change_exists; /* has any module changed? */
 
50
 
 
51
@ The other large memory area in \WEAVE\ keeps the cross-reference data.
 
52
All uses of the name~|p| are recorded in a linked list beginning at
 
53
|p->xref|, which points into the |xmem| array. The elements of |xmem| are
 
54
structures consisting of an integer~|num| and a pointer~|xlink| to
 
55
another element of |xmem|.  If |x=p->xref| is a pointer into |xmem|, the
 
56
value of |x->num| is either a module number where |p|~is used, or it is
 
57
|def_flag| plus a module number where |p|~is defined; and |x->xlink| points
 
58
to the next such cross-reference for~|p|, if any. This list of
 
59
cross-references is in decreasing order by module number. The next unused
 
60
slot in |xmem| is |xref_ptr|.
 
61
 
 
62
The global variable |xref_switch| is set either to |def_flag| or to zero,
 
63
depending on whether the next cross-reference to an identifier is to be
 
64
underlined or not in the index. This switch is set to |def_flag| when
 
65
\.{@@\_}, \.{@@[}, \.{@@]},\.{@@d}, \.{@@m}, or \.{@@f} is scanned, and it
 
66
is cleared to zero when the next identifier or index entry cross-reference
 
67
has been made.  Similarly, the global variable |mod_xref_switch| is either
 
68
|def_flag| or zero, depending on whether a module name is being defined or
 
69
used.
 
70
 
 
71
@d append_xref(c) if (xref_ptr==xmem_end) 
 
72
                        OVERFLW("cross-references",ABBREV(max_refs));
 
73
  else 
 
74
        {
 
75
        (++xref_ptr)->num=c;
 
76
        xref_ptr->Language = (boolean) language;
 
77
        }
 
78
 
 
79
@<Type...@>=
 
80
 
 
81
typedef struct xref_info0 
 
82
        {
 
83
          sixteen_bits num; /* module number plus zero or |def_flag| */
 
84
          struct xref_info0 HUGE *xlink; /* pointer to the previous
 
85
                                cross-reference */ 
 
86
          boolean Language;     /* Language in force for this module. */
 
87
        } xref_info;
 
88
 
 
89
typedef xref_info HUGE *xref_pointer;
 
90
typedef ASCII HUGE *XREF_POINTER; /* For assignments like |name_dir->xref =
 
91
                                (XREF_POINTER)xref_ptr|. See the comment
 
92
                                immediately below about~|xref|. */ 
 
93
 
 
94
@  The integer |def_flag| is added to a module number when that module is
 
95
defined. 
 
96
 
 
97
For variable names, a different approach is taken.  If a name (especially a
 
98
function name) is preceded by~\.{@@[}, the switch |defd_switch| is set to
 
99
|YES|.  Then when |new_xref| is called, the module number of that name is
 
100
entered into the |defined_in| field.
 
101
 
 
102
@d def_flag ID_FLAG /* must be strictly larger than |max_modules| */
 
103
 
 
104
@d xref equiv_or_xref /* The trouble with this is that |xref| is a
 
105
        |xref_pointer| whereas |equiv_or_xref| is |ASCII|. This means that
 
106
        lots of casting needs to be done to keep the compiler happy. Hence
 
107
        the previous |typedef|. */
 
108
 
 
109
@f XREF_POINTER int
 
110
 
 
111
@<Global...@>=
 
112
 
 
113
#ifndef COMMON_FCNS_
 
114
  IN_COMMON BUF_SIZE max_modules; /* Size allocated in \.{common.web}. */
 
115
#endif
 
116
 
 
117
EXTERN BUF_SIZE max_refs;
 
118
EXTERN xref_info HUGE *xmem; /* contains cross-reference information */
 
119
EXTERN xref_pointer xmem_end;
 
120
 
 
121
EXTERN xref_pointer xref_ptr; /* the largest occupied position in |xmem| */
 
122
 
 
123
EXTERN sixteen_bits xref_switch,mod_xref_switch; // either zero or |def_flag|.
 
124
EXTERN boolean defd_switch; // Set by `\.{@@[}'.
 
125
EXTERN NAME_TYPE defd_type SET(NEVER_DEFINED);
 
126
EXTERN boolean typd_switch; // Set by `\.{@@]}'.
 
127
EXTERN boolean index_short; // Set by `\.{@@+}'.