1 /* $Id: cdekl.h,v 1.9 1997/01/08 09:49:15 cim Exp $ */ 2 3 /* Copyright (C) 1994, 1998 Sverre Hvammen Johansen, 4 * Department of Informatics, University of Oslo. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; version 2. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 18 19 #if STDC_HEADERS 20 #include <float.h> 21 #endif 22 23 #if HAVE_VALUES_H 24 #include <values.h> 25 #else 26 #include <math.h> 27 #endif 28 29 #if HAVE_LIMITS_H 30 #include <limits.h> 31 #endif 32 33 union val 34 { 35 long ival; 36 double rval; 37 struct 38 { 39 char *txt; 40 int id; 41 } 42 tval; 43 int entry; 44 long n_of_stack_elements; 45 struct 46 { 47 short val_entry, ref_entry, txt_entry; 48 } 49 stack; 50 struct 51 { 52 long n_of_stack_elements; 53 short entry; 54 } 55 combined_stack; 56 char *ident; 57 struct 58 { 59 short label, inthunk; 60 } thunk; 61 }; 62 63 /* Definition of type */ 64 65 #define TALLTY 'A' 66 #define TNOTY 'N' 67 #define TINTG 'I' 68 #define TSHORT 'I' /* S */ 69 #define TREAL 'R' 70 #define TLONG 'R' /* D */ 71 #define TBOOL 'B' 72 #define TCHAR 'C' 73 #define TLABEL 'L' 74 #define TTEXT 'T' 75 #define TREF 'P' 76 #define TVOIDP 'O' 77 #define TERROR 'E' 78 #define TVARARGS 'V' 79 80 /* Definition of kind */ 81 82 #define KNOKD 'N' 83 #define KSIMPLE 'S' 84 #define KARRAY 'A' 85 #define KPROC 'P' 86 #define KCLASS 'C' 87 #define KBLOKK 'B' 88 #define KPRBLK 'R' 89 #define KFOR 'F' 90 #define KINSP 'I' 91 #define KCON 'O' 92 #define KERROR 'E' 93 94 /* Definition of categ */ 95 96 #define CCONSTU 'U' 97 #define CCONST 'C' 98 #define CLOCAL 'L' 99 #define CDEFLT 'D' 100 #define CVALUE 'V' 101 #define CNAME 'N' 102 #define CVAR 'B' 103 #define CVIRT 'I' 104 #define CEXTR 'X' 105 #define CEXTRMAIN 'M' 106 #define CERROR 'E' 107 #define CSPEC 'S' 108 #define CHIDEN 'H' 109 #define CPROT 'P' 110 #define CHIPRO 'A' 111 #define CNEW 'W' 112 #define CCPROC 'R' 113 #define CEXTROUT 'F' 114 115 struct DECL 116 { 117 char *ident; /* Navnet til deklarasjonen */ 118 long plev; /* Prefix niv�, kan fjernes */ 119 char *identqual; /* Navnet til kvalifikasjonen */ 120 struct BLOCK *encl; /* Omslutningen til deklarasjonen */ 121 struct BLOCK *descr; /* Representasjonen av deklarasjonen */ 122 struct DECL *match; /* Matsjende deklarasjoner (virtual) */ 123 struct DECL *next; /* Neste deklarasjon i lista */ 124 struct DECL *prefqual; /* Prefiks-kjede eller kval. til peker */ 125 union val value; /* Verdi for konstantdeklarasjon */ 126 long line; /* Linjenommer */ 127 short dim; /* Dimensjonen */ 128 short virtno; /* Virtuelt nommer */ 129 char type, 130 kind, 131 categ; /* Hvilken type deklarasjon */ 132 char protected; /* Angir om attributtet er protected */ 133 }; 134 135 struct BLOCK 136 { 137 struct DECL quant; /* Deklarasjonen til denne blokken */ 138 char inner; 139 char localclasses, 140 thisused; 141 char stat; 142 char structure_written; 143 144 char codeclass; 145 short navirt; /* Antall virtuelle bindinger proc - lab/swi */ 146 short ptypno; 147 short blno, 148 blev; /* Blokknommer og blokknivaa */ 149 short napar; /* Antall parametere */ 150 short fornest, 151 connest; /* Dybde p� nesting av for-l�kke og inspect */ 152 short ent; /* entringspunkt */ 153 short navirtlab; 154 155 char *rtname; 156 157 char *timestamp; 158 char *filename; 159 struct DECL *when; 160 struct DECL *parloc; /* Parametere og lokale deklarasjoner */ 161 struct DECL *lastparloc; 162 struct DECL *virt; /* Blokkens virtuelle bindinger */ 163 struct DECL *lastvirt; 164 struct DECL *hiprot; /* Blokkens protections */ 165 struct BLOCK *next_block; /* Neste blokk i sekvensen */ 166 }; 167 168 /* Kodeklasser */ 169 #define CCNO 0 170 #define CCSIMPLE 11 /* Ingen ekstra parametere mod, rem, abs 171 * o.s.v. */ 172 #define CCSIMPLEDANGER 10 173 #define CCBLANKSCOPY 1 /* Kall p} Blanks eller Copy. Kan starte GBC. 174 * Tillordner antvalue, antref og anttext */ 175 #define CCTEXT 2 /* Peker til tekst-variabel som f|rste 176 * parameter */ 177 #define CCTEXTDANGER 12 178 #define CCFILEBLANKSCOPY 13 /* Kall p} filename */ 179 #define CCFILE 9 /* Peker til file-klasse som f|rste parameter 180 */ 181 #define CCFILEDANGER 3 182 #define CCDETACH 4 /* Peker til klasse som skal detach'es som 183 * parameter */ 184 #define CCCALLRESUME 5 /* Siste parameter er returadressen */ 185 #define CCEXIT 6 /* Main modul: goto ll<exitlabel>; Ekstern 186 * modul: lgoto=<exitlabel>;mgoto=0;return; */ 187 #define CCRANDOMRUTDANGER 7 /* Ranom rutinene har siste parameter 188 * overfort by name */ 189 #define CCCPROC 8 /* Ekstern C-prosedyre */ 190 191 192 extern void beginBlock (); 193 extern void endBlock (); 194 extern void regDecl (); 195 extern regInner (); 196 extern struct DECL *newDecl (); 197 extern struct BLOCK *firstclass (); 198 extern inBlock (); 199 extern outBlock (); 200 extern struct DECL *regThis (); 201 202 extern removeBlock (); 203 204 extern char *prefquantident; 205 extern int localused; 206 207 extern struct BLOCK *cblock; 208 extern struct BLOCK *ssblock; 209 extern struct BLOCK *sblock; 210 extern struct BLOCK *eblock; 211 extern int cblev; 212 extern char subclass (); 213 extern char insert_with_codeclass; 214 extern struct DECL *cprevdecl; 215 216 extern struct DECL *commonprefiks; 217 extern struct DECL *commonqual (); 218 extern struct DECL *findGlobal (); 219 extern struct DECL *findLocal (); 220 extern struct DECL *findDecl (); 221 222 extern struct DECL *firstParam (); 223 extern struct DECL *nextParam (); 224 extern moreParam (); 225 226 extern int arrdim; 227 extern struct DECL *lastArray; 228 extern setArrayDim (); 229 extern char dangerProc (); 230 231 extern struct BLOCK *seenthrough; 232 extern body (); 233 extern struct DECL *classtext; 234 extern char subordinate (); 235 extern sameParam (); 236 extern reinit (); 237 extern initDecl (); 238 239 extern char yaccerror; 240