]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gm2/pim/pass/getconst.mod
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / testsuite / gm2 / pim / pass / getconst.mod
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 getconst ;
19
20 CONST
21 LongReal = 1 ;
22 Integer = 2 ;
23 Char = 3 ;
24
25
26 PROCEDURE GetSymName (s: CARDINAL) : CARDINAL ;
27 BEGIN
28 RETURN s
29 END GetSymName ;
30
31 PROCEDURE LengthKey (s: CARDINAL) : CARDINAL ;
32 BEGIN
33 RETURN s
34 END LengthKey ;
35
36 PROCEDURE GetKey (s: CARDINAL; a: ARRAY OF CHAR) ;
37 BEGIN
38 END GetKey ;
39
40
41 (*
42 GetConstLitType - returns the type of the constant, Sym.
43 All constants have type NulSym except CHAR constants
44 ie 00C 012C etc and floating point constants which have type LONGREAL.
45 *)
46
47 PROCEDURE GetConstLitType (Sym: CARDINAL) : CARDINAL ;
48 CONST
49 Max = 4096 ;
50 VAR
51 a : ARRAY [0..Max] OF CHAR ;
52 i,
53 High: CARDINAL ;
54 BEGIN
55 GetKey(GetSymName(Sym), a) ;
56 High := LengthKey(GetSymName(Sym)) ;
57 IF a[High-1]='C'
58 THEN
59 RETURN( Char )
60 ELSE
61 i := 0 ;
62 WHILE i<High DO
63 IF (a[i]='.') OR (a[i]='+')
64 THEN
65 RETURN( LongReal )
66 ELSE
67 INC(i)
68 END
69 END ;
70 RETURN( Integer )
71 END
72 END GetConstLitType ;
73
74
75 BEGIN
76 IF GetConstLitType(2)=2
77 THEN
78 END
79 END getconst.