Debian Codegraph @

gcc/testsuite/gm2/cse/pass/testcse43.mod

raw
1 (* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
17
18 MODULE testcse43 ;
19
20
21 CONST
22 MaxSyms = 100 ;
23 MaxAlias = 100 ;
24
25 TYPE
26 AliasList = POINTER TO AList ;
27
28 (*
29 AList has two main components: List and Syms.
30
31 List is contains the alias through its pairing of indices in
32 the To and From fields.
33
34 Syms contains the actual symbols that the List indices reference
35 together with their mode.
36 *)
37
38 SymIndex = [0..MaxSyms] ;
39
40 Alias = RECORD
41 From, To: SymIndex ; (* index into syms, showing the alias *)
42 END ;
43
44 Symbol = RECORD
45 addr : CARDINAL ;
46 Id : CARDINAL ; (* symbol value from SymbolTable.mod *)
47 Dirty : BOOLEAN ; (* have we written to this symbol yet? *)
48 Count : CARDINAL ; (* number of times used (read and write) *)
49 END ;
50
51 AList = RECORD
52 List : ARRAY [1..MaxAlias] OF Alias ;
53 AliasPtr: CARDINAL ; (* points to the top of the List array *)
54 Syms : ARRAY [1..MaxSyms] OF Symbol ;
55 SymPtr : SymIndex ; (* points to the top of the Syms array *)
56 Next : AliasList ; (* used to store old lists on the free queue *)
57 END ;
58
59
60 PROCEDURE New () : AliasList ;
61 BEGIN
62 RETURN( NIL )
63 END New ;
64
65
66 PROCEDURE DuplicateAlias (a: AliasList) : AliasList ;
67 VAR
68 b: AliasList ;
69 i: CARDINAL ;
70 j: CARDINAL ;
71 BEGIN
72 b := New() ;
73 (* it may well be faster simply to perform b^ := a^ ?? *)
74 i := a^.AliasPtr ;
75 b^.AliasPtr := i ;
76 WHILE i>0 DO
77 b^.List[i] := a^.List[i] ;
78 DEC(i)
79 END ;
80 j := a^.SymPtr ;
81 b^.SymPtr := j ;
82 WHILE j>0 DO
83 b^.Syms[j] := a^.Syms[j] ;
84 DEC(j)
85 END ;
86 RETURN( b )
87 END DuplicateAlias ;
88
89
90 VAR
91 a, b: AliasList ;
92 j, i: CARDINAL ;
93 BEGIN
94 b := DuplicateAlias(a)
95 END testcse43.