Debian Codegraph @

gcc/testsuite/gm2/cse/pass/testcse16.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 MODULE testcse16 ;
18
19 CONST
20 MaxScopes = 20 ; (* Maximum number of scopes at any one time. *)
21 NulSym = 0 ;
22
23 TYPE
24 CallFrame = RECORD
25 Main : CARDINAL ; (* Main scope for insertions *)
26 Search: CARDINAL ; (* Search scope for symbol searches *)
27 Start : CARDINAL ; (* ScopePtr value before StartScope *)
28 (* was called. *)
29 END ;
30
31 VAR
32 ScopeCallFrame: ARRAY [1..MaxScopes] OF CallFrame ;
33 ScopePtr : CARDINAL ;
34
35
36 PROCEDURE foo (Sym: CARDINAL) ;
37 BEGIN
38 INC(ScopePtr) ;
39 WITH ScopeCallFrame[ScopePtr] DO
40 Main := ScopeCallFrame[ScopePtr-1].Main ;
41 (*
42 Start := ScopeCallFrame[ScopePtr-1].Start ;
43 Search := Sym
44 *)
45 END
46 END foo ;
47
48
49 PROCEDURE IsAlreadyDeclaredSym (Name: CARDINAL) : BOOLEAN ;
50 BEGIN
51 WITH ScopeCallFrame[ScopePtr] DO
52 RETURN( GetLocalSym(ScopeCallFrame[ScopePtr].Main, Name)#NulSym )
53 END
54 END IsAlreadyDeclaredSym ;
55
56
57 PROCEDURE GetLocalSym (Sym: CARDINAL; Name: CARDINAL) : CARDINAL ;
58 BEGIN
59 RETURN( 0 )
60 END GetLocalSym ;
61
62
63 BEGIN
64 ScopePtr := 1 ;
65 WITH ScopeCallFrame[ScopePtr] DO
66 Main := 1 ;
67 Start := 1 ;
68 Search := 1
69 END ;
70 foo(1000) ;
71 IF ScopeCallFrame[ScopePtr].Main#ScopeCallFrame[ScopePtr-1].Main
72 THEN
73 HALT
74 END ;
75 (*
76 IF IsAlreadyDeclaredSym(1234)
77 THEN
78 END
79 *)
80 END testcse16.