| 1 |
// { dg-do assemble } |
| 2 |
// { dg-require-effective-target ilp32 } */ |
| 3 |
// { dg-options "-w -fpermissive" } |
| 4 |
// prms-id: 784 |
| 5 |
|
| 6 |
//# 1 "GctSymbol.GctSymbol.CHMap.cc" |
| 7 |
// This may look like C code, but it is really -*- C++ -*- |
| 8 |
/* |
| 9 |
Copyright (C) 1988, 2000, 2002 Free Software Foundation |
| 10 |
written by Doug Lea ([email protected]) |
| 11 |
|
| 12 |
This file is part of the GNU C++ Library. This library is free |
| 13 |
software; you can redistribute it and/or modify it under the terms of |
| 14 |
the GNU Library General Public License as published by the Free |
| 15 |
Software Foundation; either version 2 of the License, or (at your |
| 16 |
option) any later version. This library is distributed in the hope |
| 17 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 18 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 |
PURPOSE. See the GNU Library General Public License for more details. |
| 20 |
You should have received a copy of the GNU Library General Public |
| 21 |
License along with this library; if not, write to the Free Software |
| 22 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 |
*/ |
| 24 |
|
| 25 |
|
| 26 |
//#pragma implementation |
| 27 |
|
| 28 |
//# 1 "GctSymbol.GctSymbol.CHMap.h" 1 |
| 29 |
// This may look like C code, but it is really -*- C++ -*- |
| 30 |
/* |
| 31 |
Copyright (C) 1988 Free Software Foundation |
| 32 |
written by Doug Lea ([email protected]) |
| 33 |
|
| 34 |
This file is part of the GNU C++ Library. This library is free |
| 35 |
software; you can redistribute it and/or modify it under the terms of |
| 36 |
the GNU Library General Public License as published by the Free |
| 37 |
Software Foundation; either version 2 of the License, or (at your |
| 38 |
option) any later version. This library is distributed in the hope |
| 39 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 40 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 41 |
PURPOSE. See the GNU Library General Public License for more details. |
| 42 |
You should have received a copy of the GNU Library General Public |
| 43 |
License along with this library; if not, write to the Free Software |
| 44 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 45 |
*/ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
//#pragma interface |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
//# 1 "GctSymbol.GctSymbol.Map.h" 1 |
| 55 |
// This may look like C code, but it is really -*- C++ -*- |
| 56 |
/* |
| 57 |
Copyright (C) 1988 Free Software Foundation |
| 58 |
written by Doug Lea ([email protected]) |
| 59 |
|
| 60 |
This file is part of the GNU C++ Library. This library is free |
| 61 |
software; you can redistribute it and/or modify it under the terms of |
| 62 |
the GNU Library General Public License as published by the Free |
| 63 |
Software Foundation; either version 2 of the License, or (at your |
| 64 |
option) any later version. This library is distributed in the hope |
| 65 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 66 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 67 |
PURPOSE. See the GNU Library General Public License for more details. |
| 68 |
You should have received a copy of the GNU Library General Public |
| 69 |
License along with this library; if not, write to the Free Software |
| 70 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 71 |
*/ |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
//#pragma interface |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Pix.h" 1 |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
typedef void* Pix; |
| 85 |
|
| 86 |
//# 26 "GctSymbol.GctSymbol.Map.h" 2 |
| 87 |
|
| 88 |
//# 1 "GctSymbol.defs.h" 1 |
| 89 |
// This may look like C code, but it is really -*- C++ -*- |
| 90 |
/* |
| 91 |
Copyright (C) 1988 Free Software Foundation |
| 92 |
written by Doug Lea ([email protected]) |
| 93 |
|
| 94 |
This file is part of the GNU C++ Library. This library is free |
| 95 |
software; you can redistribute it and/or modify it under the terms of |
| 96 |
the GNU Library General Public License as published by the Free |
| 97 |
Software Foundation; either version 2 of the License, or (at your |
| 98 |
option) any later version. This library is distributed in the hope |
| 99 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 100 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 101 |
PURPOSE. See the GNU Library General Public License for more details. |
| 102 |
You should have received a copy of the GNU Library General Public |
| 103 |
License along with this library; if not, write to the Free Software |
| 104 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 105 |
*/ |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
//# 1 "../../GctSymbol.h" 1 |
| 114 |
// -*- C++ -*- |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
// |
| 119 |
// GctSymbol class |
| 120 |
// |
| 121 |
// Expects to be included by Gct.h |
| 122 |
// |
| 123 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 124 |
// |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
//#pragma interface |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
//# 25 "../../GctSymbol.h" 2 |
| 137 |
|
| 138 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1 |
| 139 |
// This may look like C code, but it is really -*- C++ -*- |
| 140 |
/* |
| 141 |
Copyright (C) 1988 Free Software Foundation |
| 142 |
written by Doug Lea ([email protected]) |
| 143 |
|
| 144 |
This file is part of the GNU C++ Library. This library is free |
| 145 |
software; you can redistribute it and/or modify it under the terms of |
| 146 |
the GNU Library General Public License as published by the Free |
| 147 |
Software Foundation; either version 2 of the License, or (at your |
| 148 |
option) any later version. This library is distributed in the hope |
| 149 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 150 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 151 |
PURPOSE. See the GNU Library General Public License for more details. |
| 152 |
You should have received a copy of the GNU Library General Public |
| 153 |
License along with this library; if not, write to the Free Software |
| 154 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 155 |
*/ |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
//#pragma interface |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 1 |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
// Compatibility with old library. |
| 169 |
|
| 170 |
|
| 171 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 172 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 173 |
// Copyright (C) 1991 Per Bothner. |
| 174 |
// |
| 175 |
// This library is free software; you can redistribute it and/or |
| 176 |
// modify it under the terms of the GNU Library General Public |
| 177 |
// License as published by the Free Software Foundation; either |
| 178 |
// version 2 of the License, or (at your option) any later version. |
| 179 |
// |
| 180 |
// This library is distributed in the hope that it will be useful, |
| 181 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 182 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 183 |
// Library General Public License for more details. |
| 184 |
// |
| 185 |
// You should have received a copy of the GNU Library General Public |
| 186 |
// License along with this library; if not, write to the Free |
| 187 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
//#pragma interface |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 1 |
| 197 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 198 |
// Copyright (C) 1991 Per Bothner. |
| 199 |
// |
| 200 |
// This library is free software; you can redistribute it and/or |
| 201 |
// modify it under the terms of the GNU Library General Public |
| 202 |
// License as published by the Free Software Foundation; either |
| 203 |
// version 2 of the License, or (at your option) any later version. |
| 204 |
// |
| 205 |
// This library is distributed in the hope that it will be useful, |
| 206 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 207 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 208 |
// Library General Public License for more details. |
| 209 |
// |
| 210 |
// You should have received a copy of the GNU Library General Public |
| 211 |
// License along with this library; if not, write to the Free |
| 212 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
//#pragma interface |
| 218 |
|
| 219 |
|
| 220 |
/* KLUDGES!! */ |
| 221 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1 |
| 222 |
|
| 223 |
|
| 224 |
extern "C" { |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/mips/lib/gcc/decstatn/cygnus-1.96/include/stddef.h" 1 |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
/* This avoids lossage on Sunos but only if stdtypes.h comes first. |
| 236 |
There's no way to win with the other order! Sun lossage. */ |
| 237 |
|
| 238 |
/* In case nobody has defined these types, but we aren't running under |
| 239 |
GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and |
| 240 |
__WCHAR_TYPE__ have reasonable values. This can happen if the |
| 241 |
parts of GCC is compiled by an older compiler, that actually |
| 242 |
include gstddef.h, such as collect2. */ |
| 243 |
|
| 244 |
/* Signed type of difference of two pointers. */ |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
typedef long int ptrdiff_t; |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
/* Unsigned type of `sizeof' something. */ |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
typedef unsigned int size_t; |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
/* Data type for wide chars. */ |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
/* A null pointer constant. */ |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
/* Offset of member MEMBER in a struct of type TYPE. */ |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
//# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 2 |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
} |
| 328 |
|
| 329 |
//# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 2 |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
class ostream; class streambuf; |
| 347 |
|
| 348 |
typedef long streamoff, streampos; |
| 349 |
|
| 350 |
struct _ios_fields { // The data members of an ios. |
| 351 |
streambuf *_strbuf; |
| 352 |
ostream* _tie; |
| 353 |
long _width; |
| 354 |
unsigned long _flags; |
| 355 |
char _fill; |
| 356 |
unsigned char _state; |
| 357 |
unsigned short _precision; |
| 358 |
}; |
| 359 |
|
| 360 |
|
| 361 |
enum state_value { _good = 0, _eof = 1, _fail = 2, _bad = 4 }; |
| 362 |
|
| 363 |
|
| 364 |
class ios : public _ios_fields { |
| 365 |
public: |
| 366 |
enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 }; |
| 367 |
enum open_mode { |
| 368 |
in=1, |
| 369 |
out=2, |
| 370 |
ate=4, |
| 371 |
app=8, |
| 372 |
trunc=16, |
| 373 |
nocreate=32, |
| 374 |
noreplace=64 }; |
| 375 |
enum seek_dir { beg, cur, end}; |
| 376 |
enum { skipws=01, left=02, right=04, internal=010, |
| 377 |
dec=020, oct=040, hex=0100, |
| 378 |
showbase=0200, showpoint=0400, uppercase=01000, showpos=02000, |
| 379 |
scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000, |
| 380 |
dont_close=0x80000000 //Don't close streambuf when destroying stream |
| 381 |
}; |
| 382 |
|
| 383 |
ostream* tie() { return _tie; } |
| 384 |
ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } |
| 385 |
|
| 386 |
// Methods to change the format state. |
| 387 |
char fill() { return _fill; } |
| 388 |
char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; } |
| 389 |
unsigned long flags() { return _flags; } |
| 390 |
unsigned long flags(unsigned long new_val) { |
| 391 |
unsigned long old_val = _flags; _flags = new_val; return old_val; } |
| 392 |
unsigned short precision() { return _precision; } |
| 393 |
unsigned short precision(int newp) { |
| 394 |
unsigned short oldp = _precision; _precision = (unsigned short)newp; |
| 395 |
return oldp; } |
| 396 |
unsigned long setf(unsigned long val) { |
| 397 |
unsigned long oldbits = _flags; |
| 398 |
_flags |= val; return oldbits; } |
| 399 |
unsigned long setf(unsigned long val, unsigned long mask) { |
| 400 |
unsigned long oldbits = _flags; |
| 401 |
_flags = (_flags & ~mask) | (val & mask); return oldbits; } |
| 402 |
unsigned long unsetf(unsigned long mask) { |
| 403 |
unsigned long oldbits = _flags & mask; |
| 404 |
_flags &= ~mask; return oldbits; } |
| 405 |
long width() { return _width; } |
| 406 |
long width(long val) { long save = _width; _width = val; return save; } |
| 407 |
|
| 408 |
static const unsigned long basefield; |
| 409 |
static const unsigned long adjustfield; |
| 410 |
static const unsigned long floatfield; |
| 411 |
|
| 412 |
streambuf* rdbuf() { return _strbuf; } |
| 413 |
void clear(int state = 0) { _state = state; } |
| 414 |
int good() { return _state == 0; } |
| 415 |
int eof() { return _state & ios::eofbit; } |
| 416 |
int fail() { return _state & (ios::badbit|ios::failbit); } |
| 417 |
int bad() { return _state & ios::badbit; } |
| 418 |
int rdstate() { return _state; } |
| 419 |
void set(int flag) { _state |= flag; } |
| 420 |
operator void*() { return fail() ? (void*)0 : (void*)this; } |
| 421 |
int operator!() { return fail(); } |
| 422 |
|
| 423 |
|
| 424 |
void unset(state_value flag) { _state &= ~flag; } |
| 425 |
void close(); |
| 426 |
int is_open(); |
| 427 |
int readable(); |
| 428 |
int writable(); |
| 429 |
|
| 430 |
|
| 431 |
protected: |
| 432 |
ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' '; |
| 433 |
_flags=ios::skipws; _precision=6; } |
| 434 |
}; |
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
typedef ios::seek_dir _seek_dir; |
| 440 |
|
| 441 |
|
| 442 |
// Magic numbers and bits for the _flags field. |
| 443 |
// The magic numbers use the high-order bits of _flags; |
| 444 |
// the remaining bits are abailable for variable flags. |
| 445 |
// Note: The magic numbers must all be negative if stdio |
| 446 |
// emulation is desired. |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
struct __streambuf { |
| 463 |
// NOTE: If this is changed, also change __FILE in stdio/stdio.h! |
| 464 |
int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ |
| 465 |
char* _gptr; /* Current get pointer */ |
| 466 |
char* _egptr; /* End of get area. */ |
| 467 |
char* _eback; /* Start of putback+get area. */ |
| 468 |
char* _pbase; /* Start of put area. */ |
| 469 |
char* _pptr; /* Current put pointer. */ |
| 470 |
char* _epptr; /* End of put area. */ |
| 471 |
char* _base; /* Start of reserve area. */ |
| 472 |
char* _ebuf; /* End of reserve area. */ |
| 473 |
struct streambuf *_chain; |
| 474 |
}; |
| 475 |
|
| 476 |
struct streambuf : private __streambuf { |
| 477 |
friend class ios; |
| 478 |
friend class istream; |
| 479 |
friend class ostream; |
| 480 |
protected: |
| 481 |
static streambuf* _list_all; /* List of open streambufs. */ |
| 482 |
streambuf*& xchain() { return _chain; } |
| 483 |
void _un_link(); |
| 484 |
void _link_in(); |
| 485 |
char* gptr() const { return _gptr; } |
| 486 |
char* pptr() const { return _pptr; } |
| 487 |
char* egptr() const { return _egptr; } |
| 488 |
char* epptr() const { return _epptr; } |
| 489 |
char* pbase() const { return _pbase; } |
| 490 |
char* eback() const { return _eback; } |
| 491 |
char* ebuf() const { return _ebuf; } |
| 492 |
char* base() const { return _base; } |
| 493 |
void xput_char(char c) { *_pptr++ = c; } |
| 494 |
int xflags() { return _flags; } |
| 495 |
int xflags(int f) { int fl = _flags; _flags = f; return fl; } |
| 496 |
void xsetflags(int f) { _flags |= f; } |
| 497 |
void gbump(int n) { _gptr += n; } |
| 498 |
void pbump(int n) { _pptr += n; } |
| 499 |
void setb(char* b, char* eb, int a=0); |
| 500 |
void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; } |
| 501 |
void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; } |
| 502 |
public: |
| 503 |
static int flush_all(); |
| 504 |
static void flush_all_linebuffered(); // Flush all line buffered files. |
| 505 |
virtual int underflow(); // Leave public for now |
| 506 |
virtual int overflow(int c = (-1) ); // Leave public for now |
| 507 |
virtual int doallocate(); |
| 508 |
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); |
| 509 |
virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); |
| 510 |
int sputbackc(char c); |
| 511 |
int sungetc(); |
| 512 |
streambuf(); |
| 513 |
virtual ~streambuf(); |
| 514 |
int unbuffered() { return _flags & 2 ? 1 : 0; } |
| 515 |
int linebuffered() { return _flags & 0x4000 ? 1 : 0; } |
| 516 |
void unbuffered(int i) |
| 517 |
{ if (i) _flags |= 2 ; else _flags &= ~2 ; } |
| 518 |
void linebuffered(int i) |
| 519 |
{ if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; } |
| 520 |
int allocate() { |
| 521 |
if (base() || unbuffered()) return 0; |
| 522 |
else return doallocate(); } |
| 523 |
virtual int sync(); |
| 524 |
virtual int pbackfail(int c); |
| 525 |
virtual int ungetfail(); |
| 526 |
virtual streambuf* setbuf(char* p, int len); |
| 527 |
int in_avail() { return _egptr - _gptr; } |
| 528 |
int out_waiting() { return _pptr - _pbase; } |
| 529 |
virtual int sputn(const char* s, int n); |
| 530 |
virtual int sgetn(char* s, int n); |
| 531 |
long sgetline(char* buf, size_t n, char delim, int putback_delim); |
| 532 |
int sbumpc() { |
| 533 |
if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; |
| 534 |
else return *(unsigned char*)_gptr++; } |
| 535 |
int sgetc() { |
| 536 |
if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; |
| 537 |
else return *(unsigned char*)_gptr; } |
| 538 |
int snextc() { |
| 539 |
if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ; |
| 540 |
else return *(unsigned char*)_gptr; } |
| 541 |
int sputc(int c) { |
| 542 |
if (_pptr >= _epptr) return overflow(c); |
| 543 |
return *_pptr++ = c, (unsigned char)c; } |
| 544 |
int vscan(char const *fmt0, char* ap); |
| 545 |
int vform(char const *fmt0, char* ap); |
| 546 |
}; |
| 547 |
|
| 548 |
struct __file_fields { |
| 549 |
char _fake; |
| 550 |
char _shortbuf[1]; |
| 551 |
short _fileno; |
| 552 |
int _blksize; |
| 553 |
char* _save_gptr; |
| 554 |
char* _save_egptr; |
| 555 |
long _offset; |
| 556 |
}; |
| 557 |
|
| 558 |
class filebuf : public streambuf { |
| 559 |
struct __file_fields _fb; |
| 560 |
void init(); |
| 561 |
public: |
| 562 |
filebuf(); |
| 563 |
filebuf(int fd); |
| 564 |
filebuf(int fd, char* p, int len); |
| 565 |
~filebuf(); |
| 566 |
filebuf* attach(int fd); |
| 567 |
filebuf* open(const char *filename, const char *mode); |
| 568 |
filebuf* open(const char *filename, int mode, int prot = 0664); |
| 569 |
virtual int underflow(); |
| 570 |
virtual int overflow(int c = (-1) ); |
| 571 |
int is_open() { return _fb._fileno >= 0; } |
| 572 |
int fd() { return is_open() ? _fb._fileno : (-1) ; } |
| 573 |
filebuf* close(); |
| 574 |
virtual int doallocate(); |
| 575 |
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); |
| 576 |
int sputn(const char* s, int n); |
| 577 |
int sgetn(char* s, int n); |
| 578 |
protected: // See documentation in filebuf.C. |
| 579 |
virtual int pbackfail(int c); |
| 580 |
virtual int sync(); |
| 581 |
int is_reading() { return eback() != egptr(); } |
| 582 |
char* cur_ptr() { return is_reading() ? gptr() : pptr(); } |
| 583 |
/* System's idea of pointer */ |
| 584 |
char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); } |
| 585 |
int do_flush(); |
| 586 |
// Low-level operations (Usually invoke system calls.) |
| 587 |
virtual int sys_read(char* buf, size_t size); |
| 588 |
virtual long sys_seek(long , _seek_dir); |
| 589 |
virtual long sys_write(const void*, long); |
| 590 |
virtual int sys_stat(void*); // Actually, a (struct stat*) |
| 591 |
virtual int sys_close(); |
| 592 |
}; |
| 593 |
|
| 594 |
|
| 595 |
inline int ios::readable() { return rdbuf()->_flags & 4 ; } |
| 596 |
inline int ios::writable() { return rdbuf()->_flags & 8 ; } |
| 597 |
inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;} |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
//# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 2 |
| 603 |
|
| 604 |
|
| 605 |
class istream; class ostream; |
| 606 |
typedef istream& (*__imanip)(istream&); |
| 607 |
typedef ostream& (*__omanip)(ostream&); |
| 608 |
|
| 609 |
extern istream& ws(istream& ins); |
| 610 |
extern ostream& flush(ostream& outs); |
| 611 |
extern ostream& endl(ostream& outs); |
| 612 |
extern ostream& ends(ostream& outs); |
| 613 |
|
| 614 |
class ostream : public ios |
| 615 |
{ |
| 616 |
void do_osfx(); |
| 617 |
public: |
| 618 |
ostream(); |
| 619 |
ostream(streambuf* sb, ostream* tied=(__null) ); |
| 620 |
~ostream(); |
| 621 |
|
| 622 |
int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; } |
| 623 |
void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) |
| 624 |
do_osfx(); } |
| 625 |
streambuf* ostreambuf() const { return _strbuf; } |
| 626 |
ostream& flush(); |
| 627 |
ostream& put(char c); |
| 628 |
ostream& write(const char *s, int n); |
| 629 |
ostream& write(const unsigned char *s, int n) { return write((char*)s, n);} |
| 630 |
ostream& write(const void *s, int n) { return write((char*)s, n);} |
| 631 |
ostream& seekp(streampos); |
| 632 |
ostream& seekp(streamoff, _seek_dir); |
| 633 |
streampos tellp(); |
| 634 |
ostream& form(const char *format ...); |
| 635 |
ostream& vform(const char *format, char* args); |
| 636 |
}; |
| 637 |
|
| 638 |
ostream& operator<<(ostream&, char c); |
| 639 |
ostream& operator<<(ostream& os, unsigned char c) { return os << (char)c; } |
| 640 |
//ostream& operator<<(ostream &os, signed char c) { return os << (char)c; } |
| 641 |
extern ostream& operator<<(ostream&, const char *s); |
| 642 |
inline ostream& operator<<(ostream& os, const unsigned char *s) |
| 643 |
{ return os << (const char*)s; } |
| 644 |
//inline ostream& operator<<(ostream& os, const signed char *s) |
| 645 |
//{ return os << (const char*)s; } |
| 646 |
ostream& operator<<(ostream&, void *p); |
| 647 |
ostream& operator<<(ostream&, int n); |
| 648 |
ostream& operator<<(ostream&, long n); |
| 649 |
ostream& operator<<(ostream&, unsigned int n); |
| 650 |
ostream& operator<<(ostream&, unsigned long n); |
| 651 |
ostream& operator<<(ostream& os, short n) {return os << (int)n;} |
| 652 |
ostream& operator<<(ostream& os, unsigned short n) |
| 653 |
{return os << (unsigned int)n;} |
| 654 |
ostream& operator<<(ostream&, float n); |
| 655 |
ostream& operator<<(ostream&, double n); |
| 656 |
ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); } |
| 657 |
ostream& operator<<(ostream&, streambuf*); |
| 658 |
|
| 659 |
class istream : public ios |
| 660 |
{ |
| 661 |
size_t _gcount; |
| 662 |
public: |
| 663 |
istream(); |
| 664 |
istream(streambuf* sb, ostream*tied=(__null) ); |
| 665 |
~istream(); |
| 666 |
streambuf* istreambuf() const { return _strbuf; } |
| 667 |
istream& get(char& c); |
| 668 |
istream& get(unsigned char& c); |
| 669 |
istream& read(char *ptr, int n); |
| 670 |
istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); } |
| 671 |
istream& read(void *ptr, int n) { return read((char*)ptr, n); } |
| 672 |
int get() { return _strbuf->sbumpc(); } |
| 673 |
istream& getline(char* ptr, int len, char delim = '\n'); |
| 674 |
istream& get(char* ptr, int len, char delim = '\n'); |
| 675 |
istream& gets(char **s, char delim = '\n'); |
| 676 |
int ipfx(int need) { |
| 677 |
if (!good()) { set(ios::failbit); return 0; } |
| 678 |
if (_tie && (need == 0 || rdbuf()->in_avail())) ; //??? THIS LINE IS QUESTIONABLE */ |
| 679 |
if (!need && (flags() & ios::skipws) && !ws(*this)) return 0; |
| 680 |
return 1; |
| 681 |
} |
| 682 |
int ipfx0() { // Optimized version of ipfx(0). |
| 683 |
if (!good()) { set(ios::failbit); return 0; } |
| 684 |
if (_tie) _tie->flush(); |
| 685 |
if ((flags() & ios::skipws) && !ws(*this)) return 0; |
| 686 |
return 1; |
| 687 |
} |
| 688 |
int ipfx1() { // Optimized version of ipfx(1). |
| 689 |
if (!good()) { set(ios::failbit); return 0; } |
| 690 |
if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); |
| 691 |
return 1; |
| 692 |
} |
| 693 |
size_t gcount() { return _gcount; } |
| 694 |
istream& seekg(streampos); |
| 695 |
istream& seekg(streamoff, _seek_dir); |
| 696 |
streampos tellg(); |
| 697 |
istream& putback(char ch) { |
| 698 |
if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit); |
| 699 |
return *this;} |
| 700 |
istream& unget() { |
| 701 |
if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit); |
| 702 |
return *this;} |
| 703 |
|
| 704 |
istream& unget(char ch) { return putback(ch); } |
| 705 |
int skip(int i); |
| 706 |
|
| 707 |
}; |
| 708 |
|
| 709 |
istream& operator>>(istream&, char*); |
| 710 |
istream& operator>>(istream& is, unsigned char* p) { return is >> (char*)p; } |
| 711 |
//istream& operator>>(istream& is, signed char* p) { return is >> (char*)p; } |
| 712 |
istream& operator>>(istream&, char& c); |
| 713 |
istream& operator>>(istream&, unsigned char& c); |
| 714 |
//istream& operator>>(istream&, signed char& c); |
| 715 |
istream& operator>>(istream&, int&); |
| 716 |
istream& operator>>(istream&, long&); |
| 717 |
istream& operator>>(istream&, short&); |
| 718 |
istream& operator>>(istream&, unsigned int&); |
| 719 |
istream& operator>>(istream&, unsigned long&); |
| 720 |
istream& operator>>(istream&, unsigned short&); |
| 721 |
istream& operator>>(istream&, float&); |
| 722 |
istream& operator>>(istream&, double&); |
| 723 |
istream& operator>>(istream& is, __imanip func) { return (*func)(is); } |
| 724 |
|
| 725 |
class iostream : public ios { |
| 726 |
size_t _gcount; |
| 727 |
public: |
| 728 |
iostream(); |
| 729 |
operator istream&() { return *(istream*)this; } |
| 730 |
operator ostream&() { return *(ostream*)this; } |
| 731 |
~iostream(); |
| 732 |
// NOTE: These duplicate istream methods. |
| 733 |
istream& get(char& c) { return ((istream*)this)->get(c); } |
| 734 |
istream& get(unsigned char& c) { return ((istream*)this)->get(c); } |
| 735 |
istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); } |
| 736 |
istream& read(unsigned char *ptr, int n) |
| 737 |
{ return ((istream*)this)->read((char*)ptr, n); } |
| 738 |
istream& read(void *ptr, int n) |
| 739 |
{ return ((istream*)this)->read((char*)ptr, n); } |
| 740 |
int get() { return _strbuf->sbumpc(); } |
| 741 |
istream& getline(char* ptr, int len, char delim = '\n') |
| 742 |
{ return ((istream*)this)->getline(ptr, len, delim); } |
| 743 |
istream& get(char* ptr, int len, char delim = '\n') |
| 744 |
{ return ((istream*)this)->get(ptr, len, delim); } |
| 745 |
istream& gets(char **s, char delim = '\n') |
| 746 |
{ return ((istream*)this)->gets(s, delim); } |
| 747 |
int ipfx(int need) { return ((istream*)this)->ipfx(need); } |
| 748 |
int ipfx0() { return ((istream*)this)->ipfx0(); } |
| 749 |
int ipfx1() { return ((istream*)this)->ipfx1(); } |
| 750 |
size_t gcount() { return _gcount; } |
| 751 |
istream& putback(char ch) { return ((istream*)this)->putback(ch); } |
| 752 |
istream& unget() { return ((istream*)this)->unget(); } |
| 753 |
istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); } |
| 754 |
istream& seekg(streamoff off, _seek_dir dir) |
| 755 |
{ return ((istream*)this)->seekg(off, dir); } |
| 756 |
streampos tellg() { return ((istream*)this)->tellg(); } |
| 757 |
|
| 758 |
istream& unget(char ch) { return putback(ch); } |
| 759 |
|
| 760 |
|
| 761 |
// NOTE: These duplicate ostream methods. |
| 762 |
int opfx() { return ((ostream*)this)->opfx(); } |
| 763 |
void osfx() { ((ostream*)this)->osfx(); } |
| 764 |
ostream& flush() { return ((ostream*)this)->flush(); } |
| 765 |
ostream& put(char c) { return ((ostream*)this)->put(c); } |
| 766 |
ostream& write(const char *s, int n) |
| 767 |
{ return ((ostream*)this)->write(s, n); } |
| 768 |
ostream& write(const unsigned char *s, int n) |
| 769 |
{ return ((ostream*)this)->write((char*)s, n); } |
| 770 |
ostream& write(const void *s, int n) |
| 771 |
{ return ((ostream*)this)->write((char*)s, n); } |
| 772 |
ostream& form(const char *format ...); |
| 773 |
ostream& vform(const char *format, char* args) |
| 774 |
{ return ((ostream*)this)->vform(format, args); } |
| 775 |
ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); } |
| 776 |
ostream& seekp(streamoff off, _seek_dir dir) |
| 777 |
{ return ((ostream*)this)->seekp(off, dir); } |
| 778 |
streampos tellp() { return ((ostream*)this)->tellp(); } |
| 779 |
}; |
| 780 |
|
| 781 |
extern istream cin; |
| 782 |
extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf() |
| 783 |
|
| 784 |
inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; } |
| 785 |
|
| 786 |
struct Iostream_init { } ; // Compatibility hack for AT&T libraray. |
| 787 |
|
| 788 |
|
| 789 |
//# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 2 |
| 790 |
|
| 791 |
|
| 792 |
extern char* form(char*, ...); |
| 793 |
|
| 794 |
extern char* dec(long, int=0); |
| 795 |
extern char* dec(int, int=0); |
| 796 |
extern char* dec(unsigned long, int=0); |
| 797 |
extern char* dec(unsigned int, int=0); |
| 798 |
|
| 799 |
extern char* hex(long, int=0); |
| 800 |
extern char* hex(int, int=0); |
| 801 |
extern char* hex(unsigned long, int=0); |
| 802 |
extern char* hex(unsigned int, int=0); |
| 803 |
|
| 804 |
extern char* oct(long, int=0); |
| 805 |
extern char* oct(int, int=0); |
| 806 |
extern char* oct(unsigned long, int=0); |
| 807 |
extern char* oct(unsigned int, int=0); |
| 808 |
|
| 809 |
inline istream& WS(istream& str) { return ws(str); } |
| 810 |
|
| 811 |
|
| 812 |
//# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2 |
| 813 |
|
| 814 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Regex.h" 1 |
| 815 |
// This may look like C code, but it is really -*- C++ -*- |
| 816 |
/* |
| 817 |
Copyright (C) 1988 Free Software Foundation |
| 818 |
written by Doug Lea ([email protected]) |
| 819 |
|
| 820 |
This file is part of the GNU C++ Library. This library is free |
| 821 |
software; you can redistribute it and/or modify it under the terms of |
| 822 |
the GNU Library General Public License as published by the Free |
| 823 |
Software Foundation; either version 2 of the License, or (at your |
| 824 |
option) any later version. This library is distributed in the hope |
| 825 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 826 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 827 |
PURPOSE. See the GNU Library General Public License for more details. |
| 828 |
You should have received a copy of the GNU Library General Public |
| 829 |
License along with this library; if not, write to the Free Software |
| 830 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 831 |
*/ |
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
//#pragma interface |
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
struct re_pattern_buffer; // defined elsewhere |
| 847 |
struct re_registers; |
| 848 |
|
| 849 |
class Regex |
| 850 |
{ |
| 851 |
private: |
| 852 |
|
| 853 |
Regex(const Regex&) {} // no X(X&) |
| 854 |
void operator = (const Regex&) {} // no assignment |
| 855 |
|
| 856 |
protected: |
| 857 |
re_pattern_buffer* buf; |
| 858 |
re_registers* reg; |
| 859 |
|
| 860 |
public: |
| 861 |
Regex(const char* t, |
| 862 |
int fast = 0, |
| 863 |
int bufsize = 40, |
| 864 |
const char* transtable = 0); |
| 865 |
|
| 866 |
~Regex(); |
| 867 |
|
| 868 |
int match(const char* s, int len, int pos = 0) const; |
| 869 |
int search(const char* s, int len, |
| 870 |
int& matchlen, int startpos = 0) const; |
| 871 |
int match_info(int& start, int& length, int nth = 0) const; |
| 872 |
|
| 873 |
int OK() const; // representation invariant |
| 874 |
}; |
| 875 |
|
| 876 |
// some built in regular expressions |
| 877 |
|
| 878 |
extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" |
| 879 |
extern const Regex RXint; // = "-?[0-9]+" |
| 880 |
extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| |
| 881 |
// \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) |
| 882 |
// \\([eE][---+]?[0-9]+\\)?" |
| 883 |
extern const Regex RXalpha; // = "[A-Za-z]+" |
| 884 |
extern const Regex RXlowercase; // = "[a-z]+" |
| 885 |
extern const Regex RXuppercase; // = "[A-Z]+" |
| 886 |
extern const Regex RXalphanum; // = "[0-9A-Za-z]+" |
| 887 |
extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" |
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
//# 27 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2 |
| 892 |
|
| 893 |
|
| 894 |
struct StrRep // internal String representations |
| 895 |
{ |
| 896 |
unsigned short len; // string length |
| 897 |
unsigned short sz; // allocated space |
| 898 |
char s[1]; // the string starts here |
| 899 |
// (at least 1 char for trailing null) |
| 900 |
// allocated & expanded via non-public fcts |
| 901 |
}; |
| 902 |
|
| 903 |
// primitive ops on StrReps -- nearly all String fns go through these. |
| 904 |
|
| 905 |
StrRep* Salloc(StrRep*, const char*, int, int); |
| 906 |
StrRep* Scopy(StrRep*, StrRep*); |
| 907 |
StrRep* Sresize(StrRep*, int); |
| 908 |
StrRep* Scat(StrRep*, const char*, int, const char*, int); |
| 909 |
StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); |
| 910 |
StrRep* Sprepend(StrRep*, const char*, int); |
| 911 |
StrRep* Sreverse(StrRep*, StrRep*); |
| 912 |
StrRep* Supcase(StrRep*, StrRep*); |
| 913 |
StrRep* Sdowncase(StrRep*, StrRep*); |
| 914 |
StrRep* Scapitalize(StrRep*, StrRep*); |
| 915 |
|
| 916 |
// These classes need to be defined in the order given |
| 917 |
|
| 918 |
class String; |
| 919 |
class SubString; |
| 920 |
|
| 921 |
class SubString |
| 922 |
{ |
| 923 |
friend class String; |
| 924 |
protected: |
| 925 |
|
| 926 |
String& S; // The String I'm a substring of |
| 927 |
unsigned short pos; // starting position in S's rep |
| 928 |
unsigned short len; // length of substring |
| 929 |
|
| 930 |
void assign(StrRep*, const char*, int = -1); |
| 931 |
SubString(String& x, int p, int l); |
| 932 |
SubString(const SubString& x); |
| 933 |
|
| 934 |
public: |
| 935 |
|
| 936 |
// Note there are no public constructors. SubStrings are always |
| 937 |
// created via String operations |
| 938 |
|
| 939 |
~SubString(); |
| 940 |
|
| 941 |
void operator = (const String& y); |
| 942 |
void operator = (const SubString& y); |
| 943 |
void operator = (const char* t); |
| 944 |
void operator = (char c); |
| 945 |
|
| 946 |
// return 1 if target appears anywhere in SubString; else 0 |
| 947 |
|
| 948 |
int contains(char c) const; |
| 949 |
int contains(const String& y) const; |
| 950 |
int contains(const SubString& y) const; |
| 951 |
int contains(const char* t) const; |
| 952 |
int contains(const Regex& r) const; |
| 953 |
|
| 954 |
// return 1 if target matches entire SubString |
| 955 |
|
| 956 |
int matches(const Regex& r) const; |
| 957 |
|
| 958 |
// IO |
| 959 |
|
| 960 |
friend ostream& operator<<(ostream& s, const SubString& x); |
| 961 |
|
| 962 |
// status |
| 963 |
|
| 964 |
unsigned int length() const; |
| 965 |
int empty() const; |
| 966 |
const char* chars() const; |
| 967 |
|
| 968 |
int OK() const; |
| 969 |
|
| 970 |
}; |
| 971 |
|
| 972 |
|
| 973 |
class String |
| 974 |
{ |
| 975 |
friend class SubString; |
| 976 |
|
| 977 |
protected: |
| 978 |
StrRep* rep; // Strings are pointers to their representations |
| 979 |
|
| 980 |
// some helper functions |
| 981 |
|
| 982 |
int search(int, int, const char*, int = -1) const; |
| 983 |
int search(int, int, char) const; |
| 984 |
int match(int, int, int, const char*, int = -1) const; |
| 985 |
int _gsub(const char*, int, const char* ,int); |
| 986 |
int _gsub(const Regex&, const char*, int); |
| 987 |
SubString _substr(int, int); |
| 988 |
|
| 989 |
public: |
| 990 |
|
| 991 |
// constructors & assignment |
| 992 |
|
| 993 |
String(); |
| 994 |
String(const String& x); |
| 995 |
String(const SubString& x); |
| 996 |
String(const char* t); |
| 997 |
String(const char* t, int len); |
| 998 |
String(char c); |
| 999 |
|
| 1000 |
~String(); |
| 1001 |
|
| 1002 |
void operator = (const String& y); |
| 1003 |
void operator = (const char* y); |
| 1004 |
void operator = (char c); |
| 1005 |
void operator = (const SubString& y); |
| 1006 |
|
| 1007 |
// concatenation |
| 1008 |
|
| 1009 |
void operator += (const String& y); |
| 1010 |
void operator += (const SubString& y); |
| 1011 |
void operator += (const char* t); |
| 1012 |
void operator += (char c); |
| 1013 |
|
| 1014 |
void prepend(const String& y); |
| 1015 |
void prepend(const SubString& y); |
| 1016 |
void prepend(const char* t); |
| 1017 |
void prepend(char c); |
| 1018 |
|
| 1019 |
|
| 1020 |
// procedural versions: |
| 1021 |
// concatenate first 2 args, store result in last arg |
| 1022 |
|
| 1023 |
friend void cat(const String&, const String&, String&); |
| 1024 |
friend void cat(const String&, const SubString&, String&); |
| 1025 |
friend void cat(const String&, const char*, String&); |
| 1026 |
friend void cat(const String&, char, String&); |
| 1027 |
|
| 1028 |
friend void cat(const SubString&, const String&, String&); |
| 1029 |
friend void cat(const SubString&, const SubString&, String&); |
| 1030 |
friend void cat(const SubString&, const char*, String&); |
| 1031 |
friend void cat(const SubString&, char, String&); |
| 1032 |
|
| 1033 |
friend void cat(const char*, const String&, String&); |
| 1034 |
friend void cat(const char*, const SubString&, String&); |
| 1035 |
friend void cat(const char*, const char*, String&); |
| 1036 |
friend void cat(const char*, char, String&); |
| 1037 |
|
| 1038 |
// double concatenation, by request. (yes, there are too many versions, |
| 1039 |
// but if one is supported, then the others should be too...) |
| 1040 |
// Concatenate first 3 args, store in last arg |
| 1041 |
|
| 1042 |
friend void cat(const String&,const String&, const String&,String&); |
| 1043 |
friend void cat(const String&,const String&,const SubString&,String&); |
| 1044 |
friend void cat(const String&,const String&, const char*, String&); |
| 1045 |
friend void cat(const String&,const String&, char, String&); |
| 1046 |
friend void cat(const String&,const SubString&,const String&,String&); |
| 1047 |
friend void cat(const String&,const SubString&,const SubString&,String&); |
| 1048 |
friend void cat(const String&,const SubString&, const char*, String&); |
| 1049 |
friend void cat(const String&,const SubString&, char, String&); |
| 1050 |
friend void cat(const String&,const char*, const String&, String&); |
| 1051 |
friend void cat(const String&,const char*, const SubString&, String&); |
| 1052 |
friend void cat(const String&,const char*, const char*, String&); |
| 1053 |
friend void cat(const String&,const char*, char, String&); |
| 1054 |
|
| 1055 |
friend void cat(const char*, const String&, const String&,String&); |
| 1056 |
friend void cat(const char*,const String&,const SubString&,String&); |
| 1057 |
friend void cat(const char*,const String&, const char*, String&); |
| 1058 |
friend void cat(const char*,const String&, char, String&); |
| 1059 |
friend void cat(const char*,const SubString&,const String&,String&); |
| 1060 |
friend void cat(const char*,const SubString&,const SubString&,String&); |
| 1061 |
friend void cat(const char*,const SubString&, const char*, String&); |
| 1062 |
friend void cat(const char*,const SubString&, char, String&); |
| 1063 |
friend void cat(const char*,const char*, const String&, String&); |
| 1064 |
friend void cat(const char*,const char*, const SubString&, String&); |
| 1065 |
friend void cat(const char*,const char*, const char*, String&); |
| 1066 |
friend void cat(const char*,const char*, char, String&); |
| 1067 |
|
| 1068 |
|
| 1069 |
// searching & matching |
| 1070 |
|
| 1071 |
// return position of target in string or -1 for failure |
| 1072 |
|
| 1073 |
int index(char c, int startpos = 0) const; |
| 1074 |
int index(const String& y, int startpos = 0) const; |
| 1075 |
int index(const SubString& y, int startpos = 0) const; |
| 1076 |
int index(const char* t, int startpos = 0) const; |
| 1077 |
int index(const Regex& r, int startpos = 0) const; |
| 1078 |
|
| 1079 |
// return 1 if target appears anyhere in String; else 0 |
| 1080 |
|
| 1081 |
int contains(char c) const; |
| 1082 |
int contains(const String& y) const; |
| 1083 |
int contains(const SubString& y) const; |
| 1084 |
int contains(const char* t) const; |
| 1085 |
int contains(const Regex& r) const; |
| 1086 |
|
| 1087 |
// return 1 if target appears anywhere after position pos |
| 1088 |
// (or before, if pos is negative) in String; else 0 |
| 1089 |
|
| 1090 |
int contains(char c, int pos) const; |
| 1091 |
int contains(const String& y, int pos) const; |
| 1092 |
int contains(const SubString& y, int pos) const; |
| 1093 |
int contains(const char* t, int pos) const; |
| 1094 |
int contains(const Regex& r, int pos) const; |
| 1095 |
|
| 1096 |
// return 1 if target appears at position pos in String; else 0 |
| 1097 |
|
| 1098 |
int matches(char c, int pos = 0) const; |
| 1099 |
int matches(const String& y, int pos = 0) const; |
| 1100 |
int matches(const SubString& y, int pos = 0) const; |
| 1101 |
int matches(const char* t, int pos = 0) const; |
| 1102 |
int matches(const Regex& r, int pos = 0) const; |
| 1103 |
|
| 1104 |
// return number of occurences of target in String |
| 1105 |
|
| 1106 |
int freq(char c) const; |
| 1107 |
int freq(const String& y) const; |
| 1108 |
int freq(const SubString& y) const; |
| 1109 |
int freq(const char* t) const; |
| 1110 |
|
| 1111 |
// SubString extraction |
| 1112 |
|
| 1113 |
// Note that you can't take a substring of a const String, since |
| 1114 |
// this leaves open the possiblility of indirectly modifying the |
| 1115 |
// String through the SubString |
| 1116 |
|
| 1117 |
SubString at(int pos, int len); |
| 1118 |
SubString operator () (int pos, int len); // synonym for at |
| 1119 |
|
| 1120 |
SubString at(const String& x, int startpos = 0); |
| 1121 |
SubString at(const SubString& x, int startpos = 0); |
| 1122 |
SubString at(const char* t, int startpos = 0); |
| 1123 |
SubString at(char c, int startpos = 0); |
| 1124 |
SubString at(const Regex& r, int startpos = 0); |
| 1125 |
|
| 1126 |
SubString before(int pos); |
| 1127 |
SubString before(const String& x, int startpos = 0); |
| 1128 |
SubString before(const SubString& x, int startpos = 0); |
| 1129 |
SubString before(const char* t, int startpos = 0); |
| 1130 |
SubString before(char c, int startpos = 0); |
| 1131 |
SubString before(const Regex& r, int startpos = 0); |
| 1132 |
|
| 1133 |
SubString through(int pos); |
| 1134 |
SubString through(const String& x, int startpos = 0); |
| 1135 |
SubString through(const SubString& x, int startpos = 0); |
| 1136 |
SubString through(const char* t, int startpos = 0); |
| 1137 |
SubString through(char c, int startpos = 0); |
| 1138 |
SubString through(const Regex& r, int startpos = 0); |
| 1139 |
|
| 1140 |
SubString from(int pos); |
| 1141 |
SubString from(const String& x, int startpos = 0); |
| 1142 |
SubString from(const SubString& x, int startpos = 0); |
| 1143 |
SubString from(const char* t, int startpos = 0); |
| 1144 |
SubString from(char c, int startpos = 0); |
| 1145 |
SubString from(const Regex& r, int startpos = 0); |
| 1146 |
|
| 1147 |
SubString after(int pos); |
| 1148 |
SubString after(const String& x, int startpos = 0); |
| 1149 |
SubString after(const SubString& x, int startpos = 0); |
| 1150 |
SubString after(const char* t, int startpos = 0); |
| 1151 |
SubString after(char c, int startpos = 0); |
| 1152 |
SubString after(const Regex& r, int startpos = 0); |
| 1153 |
|
| 1154 |
|
| 1155 |
// deletion |
| 1156 |
|
| 1157 |
// delete len chars starting at pos |
| 1158 |
void del(int pos, int len); |
| 1159 |
|
| 1160 |
// delete the first occurrence of target after startpos |
| 1161 |
|
| 1162 |
void del(const String& y, int startpos = 0); |
| 1163 |
void del(const SubString& y, int startpos = 0); |
| 1164 |
void del(const char* t, int startpos = 0); |
| 1165 |
void del(char c, int startpos = 0); |
| 1166 |
void del(const Regex& r, int startpos = 0); |
| 1167 |
|
| 1168 |
// global substitution: substitute all occurrences of pat with repl |
| 1169 |
|
| 1170 |
int gsub(const String& pat, const String& repl); |
| 1171 |
int gsub(const SubString& pat, const String& repl); |
| 1172 |
int gsub(const char* pat, const String& repl); |
| 1173 |
int gsub(const char* pat, const char* repl); |
| 1174 |
int gsub(const Regex& pat, const String& repl); |
| 1175 |
|
| 1176 |
// friends & utilities |
| 1177 |
|
| 1178 |
// split string into array res at separators; return number of elements |
| 1179 |
|
| 1180 |
friend int split(const String& x, String res[], int maxn, |
| 1181 |
const String& sep); |
| 1182 |
friend int split(const String& x, String res[], int maxn, |
| 1183 |
const Regex& sep); |
| 1184 |
|
| 1185 |
friend String common_prefix(const String& x, const String& y, |
| 1186 |
int startpos = 0); |
| 1187 |
friend String common_suffix(const String& x, const String& y, |
| 1188 |
int startpos = -1); |
| 1189 |
friend String replicate(char c, int n); |
| 1190 |
friend String replicate(const String& y, int n); |
| 1191 |
friend String join(String src[], int n, const String& sep); |
| 1192 |
|
| 1193 |
// simple builtin transformations |
| 1194 |
|
| 1195 |
friend String reverse(const String& x); |
| 1196 |
friend String upcase(const String& x); |
| 1197 |
friend String downcase(const String& x); |
| 1198 |
friend String capitalize(const String& x); |
| 1199 |
|
| 1200 |
// in-place versions of above |
| 1201 |
|
| 1202 |
void reverse(); |
| 1203 |
void upcase(); |
| 1204 |
void downcase(); |
| 1205 |
void capitalize(); |
| 1206 |
|
| 1207 |
// element extraction |
| 1208 |
|
| 1209 |
char& operator [] (int i); |
| 1210 |
char elem(int i) const; |
| 1211 |
char firstchar() const; |
| 1212 |
char lastchar() const; |
| 1213 |
|
| 1214 |
// conversion |
| 1215 |
|
| 1216 |
operator const char*() const; |
| 1217 |
const char* chars() const; |
| 1218 |
|
| 1219 |
|
| 1220 |
// IO |
| 1221 |
|
| 1222 |
friend ostream& operator<<(ostream& s, const String& x); |
| 1223 |
friend ostream& operator<<(ostream& s, const SubString& x); |
| 1224 |
friend istream& operator>>(istream& s, String& x); |
| 1225 |
|
| 1226 |
friend int readline(istream& s, String& x, |
| 1227 |
char terminator = '\n', |
| 1228 |
int discard_terminator = 1); |
| 1229 |
|
| 1230 |
// status |
| 1231 |
|
| 1232 |
unsigned int length() const; |
| 1233 |
int empty() const; |
| 1234 |
|
| 1235 |
// preallocate some space for String |
| 1236 |
void alloc(int newsize); |
| 1237 |
|
| 1238 |
// report current allocation (not length!) |
| 1239 |
|
| 1240 |
int allocation() const; |
| 1241 |
|
| 1242 |
|
| 1243 |
volatile void error(const char* msg) const; |
| 1244 |
|
| 1245 |
int OK() const; |
| 1246 |
}; |
| 1247 |
|
| 1248 |
typedef String StrTmp; // for backward compatibility |
| 1249 |
|
| 1250 |
// other externs |
| 1251 |
|
| 1252 |
int compare(const String& x, const String& y); |
| 1253 |
int compare(const String& x, const SubString& y); |
| 1254 |
int compare(const String& x, const char* y); |
| 1255 |
int compare(const SubString& x, const String& y); |
| 1256 |
int compare(const SubString& x, const SubString& y); |
| 1257 |
int compare(const SubString& x, const char* y); |
| 1258 |
int fcompare(const String& x, const String& y); // ignore case |
| 1259 |
|
| 1260 |
extern StrRep _nilStrRep; |
| 1261 |
extern String _nilString; |
| 1262 |
|
| 1263 |
// other inlines |
| 1264 |
|
| 1265 |
String operator + (const String& x, const String& y); |
| 1266 |
String operator + (const String& x, const SubString& y); |
| 1267 |
String operator + (const String& x, const char* y); |
| 1268 |
String operator + (const String& x, char y); |
| 1269 |
String operator + (const SubString& x, const String& y); |
| 1270 |
String operator + (const SubString& x, const SubString& y); |
| 1271 |
String operator + (const SubString& x, const char* y); |
| 1272 |
String operator + (const SubString& x, char y); |
| 1273 |
String operator + (const char* x, const String& y); |
| 1274 |
String operator + (const char* x, const SubString& y); |
| 1275 |
|
| 1276 |
int operator==(const String& x, const String& y); |
| 1277 |
int operator!=(const String& x, const String& y); |
| 1278 |
int operator> (const String& x, const String& y); |
| 1279 |
int operator>=(const String& x, const String& y); |
| 1280 |
int operator< (const String& x, const String& y); |
| 1281 |
int operator<=(const String& x, const String& y); |
| 1282 |
int operator==(const String& x, const SubString& y); |
| 1283 |
int operator!=(const String& x, const SubString& y); |
| 1284 |
int operator> (const String& x, const SubString& y); |
| 1285 |
int operator>=(const String& x, const SubString& y); |
| 1286 |
int operator< (const String& x, const SubString& y); |
| 1287 |
int operator<=(const String& x, const SubString& y); |
| 1288 |
int operator==(const String& x, const char* t); |
| 1289 |
int operator!=(const String& x, const char* t); |
| 1290 |
int operator> (const String& x, const char* t); |
| 1291 |
int operator>=(const String& x, const char* t); |
| 1292 |
int operator< (const String& x, const char* t); |
| 1293 |
int operator<=(const String& x, const char* t); |
| 1294 |
int operator==(const SubString& x, const String& y); |
| 1295 |
int operator!=(const SubString& x, const String& y); |
| 1296 |
int operator> (const SubString& x, const String& y); |
| 1297 |
int operator>=(const SubString& x, const String& y); |
| 1298 |
int operator< (const SubString& x, const String& y); |
| 1299 |
int operator<=(const SubString& x, const String& y); |
| 1300 |
int operator==(const SubString& x, const SubString& y); |
| 1301 |
int operator!=(const SubString& x, const SubString& y); |
| 1302 |
int operator> (const SubString& x, const SubString& y); |
| 1303 |
int operator>=(const SubString& x, const SubString& y); |
| 1304 |
int operator< (const SubString& x, const SubString& y); |
| 1305 |
int operator<=(const SubString& x, const SubString& y); |
| 1306 |
int operator==(const SubString& x, const char* t); |
| 1307 |
int operator!=(const SubString& x, const char* t); |
| 1308 |
int operator> (const SubString& x, const char* t); |
| 1309 |
int operator>=(const SubString& x, const char* t); |
| 1310 |
int operator< (const SubString& x, const char* t); |
| 1311 |
int operator<=(const SubString& x, const char* t); |
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
// status reports, needed before defining other things |
| 1317 |
|
| 1318 |
inline unsigned int String::length() const { return rep->len; } |
| 1319 |
inline int String::empty() const { return rep->len == 0; } |
| 1320 |
inline const char* String::chars() const { return &(rep->s[0]); } |
| 1321 |
inline int String::allocation() const { return rep->sz; } |
| 1322 |
inline void String::alloc(int newsize) { rep = Sresize(rep, newsize); } |
| 1323 |
|
| 1324 |
inline unsigned int SubString::length() const { return len; } |
| 1325 |
inline int SubString::empty() const { return len == 0; } |
| 1326 |
inline const char* SubString::chars() const { return &(S.rep->s[pos]); } |
| 1327 |
|
| 1328 |
|
| 1329 |
// constructors |
| 1330 |
|
| 1331 |
inline String::String() |
| 1332 |
: rep(&_nilStrRep) {} |
| 1333 |
inline String::String(const String& x) |
| 1334 |
: rep(Scopy(0, x.rep)) {} |
| 1335 |
inline String::String(const char* t) |
| 1336 |
: rep(Salloc(0, t, -1, -1)) {} |
| 1337 |
inline String::String(const char* t, int tlen) |
| 1338 |
: rep(Salloc(0, t, tlen, tlen)) {} |
| 1339 |
inline String::String(const SubString& y) |
| 1340 |
: rep(Salloc(0, y.chars(), y.length(), y.length())) {} |
| 1341 |
inline String::String(char c) |
| 1342 |
: rep(Salloc(0, &c, 1, 1)) {} |
| 1343 |
|
| 1344 |
inline String::~String() { if (rep != &_nilStrRep) delete rep; } |
| 1345 |
|
| 1346 |
inline SubString::SubString(const SubString& x) |
| 1347 |
:S(x.S), pos(x.pos), len(x.len) {} |
| 1348 |
inline SubString::SubString(String& x, int first, int l) |
| 1349 |
:S(x), pos(first), len(l) {} |
| 1350 |
|
| 1351 |
inline SubString::~SubString() {} |
| 1352 |
|
| 1353 |
// assignment |
| 1354 |
|
| 1355 |
inline void String::operator = (const String& y) |
| 1356 |
{ |
| 1357 |
rep = Scopy(rep, y.rep); |
| 1358 |
} |
| 1359 |
|
| 1360 |
inline void String::operator=(const char* t) |
| 1361 |
{ |
| 1362 |
rep = Salloc(rep, t, -1, -1); |
| 1363 |
} |
| 1364 |
|
| 1365 |
inline void String::operator=(const SubString& y) |
| 1366 |
{ |
| 1367 |
rep = Salloc(rep, y.chars(), y.length(), y.length()); |
| 1368 |
} |
| 1369 |
|
| 1370 |
inline void String::operator=(char c) |
| 1371 |
{ |
| 1372 |
rep = Salloc(rep, &c, 1, 1); |
| 1373 |
} |
| 1374 |
|
| 1375 |
|
| 1376 |
inline void SubString::operator = (const char* ys) |
| 1377 |
{ |
| 1378 |
assign(0, ys); |
| 1379 |
} |
| 1380 |
|
| 1381 |
inline void SubString::operator = (char ch) |
| 1382 |
{ |
| 1383 |
assign(0, &ch, 1); |
| 1384 |
} |
| 1385 |
|
| 1386 |
inline void SubString::operator = (const String& y) |
| 1387 |
{ |
| 1388 |
assign(y.rep, y.chars(), y.length()); |
| 1389 |
} |
| 1390 |
|
| 1391 |
inline void SubString::operator = (const SubString& y) |
| 1392 |
{ |
| 1393 |
assign(y.S.rep, y.chars(), y.length()); |
| 1394 |
} |
| 1395 |
|
| 1396 |
// Zillions of cats... |
| 1397 |
|
| 1398 |
inline void cat(const String& x, const String& y, String& r) |
| 1399 |
{ |
| 1400 |
r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); |
| 1401 |
} |
| 1402 |
|
| 1403 |
inline void cat(const String& x, const SubString& y, String& r) |
| 1404 |
{ |
| 1405 |
r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); |
| 1406 |
} |
| 1407 |
|
| 1408 |
inline void cat(const String& x, const char* y, String& r) |
| 1409 |
{ |
| 1410 |
r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); |
| 1411 |
} |
| 1412 |
|
| 1413 |
inline void cat(const String& x, char y, String& r) |
| 1414 |
{ |
| 1415 |
r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); |
| 1416 |
} |
| 1417 |
|
| 1418 |
inline void cat(const SubString& x, const String& y, String& r) |
| 1419 |
{ |
| 1420 |
r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); |
| 1421 |
} |
| 1422 |
|
| 1423 |
inline void cat(const SubString& x, const SubString& y, String& r) |
| 1424 |
{ |
| 1425 |
r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); |
| 1426 |
} |
| 1427 |
|
| 1428 |
inline void cat(const SubString& x, const char* y, String& r) |
| 1429 |
{ |
| 1430 |
r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); |
| 1431 |
} |
| 1432 |
|
| 1433 |
inline void cat(const SubString& x, char y, String& r) |
| 1434 |
{ |
| 1435 |
r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); |
| 1436 |
} |
| 1437 |
|
| 1438 |
inline void cat(const char* x, const String& y, String& r) |
| 1439 |
{ |
| 1440 |
r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); |
| 1441 |
} |
| 1442 |
|
| 1443 |
inline void cat(const char* x, const SubString& y, String& r) |
| 1444 |
{ |
| 1445 |
r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); |
| 1446 |
} |
| 1447 |
|
| 1448 |
inline void cat(const char* x, const char* y, String& r) |
| 1449 |
{ |
| 1450 |
r.rep = Scat(r.rep, x, -1, y, -1); |
| 1451 |
} |
| 1452 |
|
| 1453 |
inline void cat(const char* x, char y, String& r) |
| 1454 |
{ |
| 1455 |
r.rep = Scat(r.rep, x, -1, &y, 1); |
| 1456 |
} |
| 1457 |
|
| 1458 |
inline void cat(const String& a, const String& x, const String& y, String& r) |
| 1459 |
{ |
| 1460 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); |
| 1461 |
} |
| 1462 |
|
| 1463 |
inline void cat(const String& a, const String& x, const SubString& y, String& r) |
| 1464 |
{ |
| 1465 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); |
| 1466 |
} |
| 1467 |
|
| 1468 |
inline void cat(const String& a, const String& x, const char* y, String& r) |
| 1469 |
{ |
| 1470 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); |
| 1471 |
} |
| 1472 |
|
| 1473 |
inline void cat(const String& a, const String& x, char y, String& r) |
| 1474 |
{ |
| 1475 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); |
| 1476 |
} |
| 1477 |
|
| 1478 |
inline void cat(const String& a, const SubString& x, const String& y, String& r) |
| 1479 |
{ |
| 1480 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); |
| 1481 |
} |
| 1482 |
|
| 1483 |
inline void cat(const String& a, const SubString& x, const SubString& y, String& r) |
| 1484 |
{ |
| 1485 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); |
| 1486 |
} |
| 1487 |
|
| 1488 |
inline void cat(const String& a, const SubString& x, const char* y, String& r) |
| 1489 |
{ |
| 1490 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); |
| 1491 |
} |
| 1492 |
|
| 1493 |
inline void cat(const String& a, const SubString& x, char y, String& r) |
| 1494 |
{ |
| 1495 |
r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); |
| 1496 |
} |
| 1497 |
|
| 1498 |
inline void cat(const String& a, const char* x, const String& y, String& r) |
| 1499 |
{ |
| 1500 |
r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); |
| 1501 |
} |
| 1502 |
|
| 1503 |
inline void cat(const String& a, const char* x, const SubString& y, String& r) |
| 1504 |
{ |
| 1505 |
r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); |
| 1506 |
} |
| 1507 |
|
| 1508 |
inline void cat(const String& a, const char* x, const char* y, String& r) |
| 1509 |
{ |
| 1510 |
r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); |
| 1511 |
} |
| 1512 |
|
| 1513 |
inline void cat(const String& a, const char* x, char y, String& r) |
| 1514 |
{ |
| 1515 |
r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); |
| 1516 |
} |
| 1517 |
|
| 1518 |
|
| 1519 |
inline void cat(const char* a, const String& x, const String& y, String& r) |
| 1520 |
{ |
| 1521 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); |
| 1522 |
} |
| 1523 |
|
| 1524 |
inline void cat(const char* a, const String& x, const SubString& y, String& r) |
| 1525 |
{ |
| 1526 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); |
| 1527 |
} |
| 1528 |
|
| 1529 |
inline void cat(const char* a, const String& x, const char* y, String& r) |
| 1530 |
{ |
| 1531 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); |
| 1532 |
} |
| 1533 |
|
| 1534 |
inline void cat(const char* a, const String& x, char y, String& r) |
| 1535 |
{ |
| 1536 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); |
| 1537 |
} |
| 1538 |
|
| 1539 |
inline void cat(const char* a, const SubString& x, const String& y, String& r) |
| 1540 |
{ |
| 1541 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); |
| 1542 |
} |
| 1543 |
|
| 1544 |
inline void cat(const char* a, const SubString& x, const SubString& y, String& r) |
| 1545 |
{ |
| 1546 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); |
| 1547 |
} |
| 1548 |
|
| 1549 |
inline void cat(const char* a, const SubString& x, const char* y, String& r) |
| 1550 |
{ |
| 1551 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); |
| 1552 |
} |
| 1553 |
|
| 1554 |
inline void cat(const char* a, const SubString& x, char y, String& r) |
| 1555 |
{ |
| 1556 |
r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); |
| 1557 |
} |
| 1558 |
|
| 1559 |
inline void cat(const char* a, const char* x, const String& y, String& r) |
| 1560 |
{ |
| 1561 |
r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); |
| 1562 |
} |
| 1563 |
|
| 1564 |
inline void cat(const char* a, const char* x, const SubString& y, String& r) |
| 1565 |
{ |
| 1566 |
r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); |
| 1567 |
} |
| 1568 |
|
| 1569 |
inline void cat(const char* a, const char* x, const char* y, String& r) |
| 1570 |
{ |
| 1571 |
r.rep = Scat(r.rep, a, -1, x, -1, y, -1); |
| 1572 |
} |
| 1573 |
|
| 1574 |
inline void cat(const char* a, const char* x, char y, String& r) |
| 1575 |
{ |
| 1576 |
r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); |
| 1577 |
} |
| 1578 |
|
| 1579 |
|
| 1580 |
// operator versions |
| 1581 |
|
| 1582 |
inline void String::operator +=(const String& y) |
| 1583 |
{ |
| 1584 |
cat(*this, y, *this); |
| 1585 |
} |
| 1586 |
|
| 1587 |
inline void String::operator +=(const SubString& y) |
| 1588 |
{ |
| 1589 |
cat(*this, y, *this); |
| 1590 |
} |
| 1591 |
|
| 1592 |
inline void String::operator += (const char* y) |
| 1593 |
{ |
| 1594 |
cat(*this, y, *this); |
| 1595 |
} |
| 1596 |
|
| 1597 |
inline void String:: operator +=(char y) |
| 1598 |
{ |
| 1599 |
cat(*this, y, *this); |
| 1600 |
} |
| 1601 |
|
| 1602 |
// constructive concatenation |
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
inline String operator + (const String& x, const String& y) return r; // { dg-error "" } |
| 1607 |
{ |
| 1608 |
cat(x, y, r); // { dg-error "" } |
| 1609 |
} |
| 1610 |
|
| 1611 |
inline String operator + (const String& x, const SubString& y) return r; // { dg-error "" } |
| 1612 |
{ |
| 1613 |
cat(x, y, r); // { dg-error "" } |
| 1614 |
} |
| 1615 |
|
| 1616 |
inline String operator + (const String& x, const char* y) return r; // { dg-error "" } |
| 1617 |
{ |
| 1618 |
cat(x, y, r); // { dg-error "" } |
| 1619 |
} |
| 1620 |
|
| 1621 |
inline String operator + (const String& x, char y) return r; // { dg-error "" } |
| 1622 |
{ |
| 1623 |
cat(x, y, r); // { dg-error "" } |
| 1624 |
} |
| 1625 |
|
| 1626 |
inline String operator + (const SubString& x, const String& y) return r; // { dg-error "" } |
| 1627 |
{ |
| 1628 |
cat(x, y, r); // { dg-error "" } |
| 1629 |
} |
| 1630 |
|
| 1631 |
inline String operator + (const SubString& x, const SubString& y) return r; // { dg-error "" } |
| 1632 |
{ |
| 1633 |
cat(x, y, r); // { dg-error "" } |
| 1634 |
} |
| 1635 |
|
| 1636 |
inline String operator + (const SubString& x, const char* y) return r; // { dg-error "" } |
| 1637 |
{ |
| 1638 |
cat(x, y, r); // { dg-error "" } |
| 1639 |
} |
| 1640 |
|
| 1641 |
inline String operator + (const SubString& x, char y) return r; // { dg-error "" } |
| 1642 |
{ |
| 1643 |
cat(x, y, r); // { dg-error "" } |
| 1644 |
} |
| 1645 |
|
| 1646 |
inline String operator + (const char* x, const String& y) return r; // { dg-error "" } |
| 1647 |
{ |
| 1648 |
cat(x, y, r); // { dg-error "" } |
| 1649 |
} |
| 1650 |
|
| 1651 |
inline String operator + (const char* x, const SubString& y) return r; // { dg-error "" } |
| 1652 |
{ |
| 1653 |
cat(x, y, r); // { dg-error "" } |
| 1654 |
} |
| 1655 |
|
| 1656 |
inline String reverse(const String& x) return r; // { dg-error "" } |
| 1657 |
{ |
| 1658 |
r.rep = Sreverse(x.rep, r.rep); // { dg-error "" } |
| 1659 |
} |
| 1660 |
|
| 1661 |
inline String upcase(const String& x) return r; // { dg-error "" } |
| 1662 |
{ |
| 1663 |
r.rep = Supcase(x.rep, r.rep); // { dg-error "" } |
| 1664 |
} |
| 1665 |
|
| 1666 |
inline String downcase(const String& x) return r; // { dg-error "" } |
| 1667 |
{ |
| 1668 |
r.rep = Sdowncase(x.rep, r.rep); // { dg-error "" } |
| 1669 |
} |
| 1670 |
|
| 1671 |
inline String capitalize(const String& x) return r; // { dg-error "" } |
| 1672 |
{ |
| 1673 |
r.rep = Scapitalize(x.rep, r.rep); // { dg-error "" } |
| 1674 |
} |
| 1675 |
|
| 1676 |
//# 883 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" |
| 1677 |
|
| 1678 |
|
| 1679 |
// prepend |
| 1680 |
|
| 1681 |
inline void String::prepend(const String& y) |
| 1682 |
{ |
| 1683 |
rep = Sprepend(rep, y.chars(), y.length()); |
| 1684 |
} |
| 1685 |
|
| 1686 |
inline void String::prepend(const char* y) |
| 1687 |
{ |
| 1688 |
rep = Sprepend(rep, y, -1); |
| 1689 |
} |
| 1690 |
|
| 1691 |
inline void String::prepend(char y) |
| 1692 |
{ |
| 1693 |
rep = Sprepend(rep, &y, 1); |
| 1694 |
} |
| 1695 |
|
| 1696 |
inline void String::prepend(const SubString& y) |
| 1697 |
{ |
| 1698 |
rep = Sprepend(rep, y.chars(), y.length()); |
| 1699 |
} |
| 1700 |
|
| 1701 |
// misc transformations |
| 1702 |
|
| 1703 |
|
| 1704 |
inline void String::reverse() |
| 1705 |
{ |
| 1706 |
rep = Sreverse(rep, rep); |
| 1707 |
} |
| 1708 |
|
| 1709 |
|
| 1710 |
inline void String::upcase() |
| 1711 |
{ |
| 1712 |
rep = Supcase(rep, rep); |
| 1713 |
} |
| 1714 |
|
| 1715 |
|
| 1716 |
inline void String::downcase() |
| 1717 |
{ |
| 1718 |
rep = Sdowncase(rep, rep); |
| 1719 |
} |
| 1720 |
|
| 1721 |
|
| 1722 |
inline void String::capitalize() |
| 1723 |
{ |
| 1724 |
rep = Scapitalize(rep, rep); |
| 1725 |
} |
| 1726 |
|
| 1727 |
// element extraction |
| 1728 |
|
| 1729 |
inline char& String::operator [] (int i) |
| 1730 |
{ |
| 1731 |
if (((unsigned)i) >= length()) error("invalid index"); |
| 1732 |
return rep->s[i]; |
| 1733 |
} |
| 1734 |
|
| 1735 |
inline char String::elem (int i) const |
| 1736 |
{ |
| 1737 |
if (((unsigned)i) >= length()) error("invalid index"); |
| 1738 |
return rep->s[i]; |
| 1739 |
} |
| 1740 |
|
| 1741 |
inline char String::firstchar() const |
| 1742 |
{ |
| 1743 |
return elem(0); |
| 1744 |
} |
| 1745 |
|
| 1746 |
inline char String::lastchar() const |
| 1747 |
{ |
| 1748 |
return elem(length() - 1); |
| 1749 |
} |
| 1750 |
|
| 1751 |
// searching |
| 1752 |
|
| 1753 |
inline int String::index(char c, int startpos) const |
| 1754 |
{ |
| 1755 |
return search(startpos, length(), c); |
| 1756 |
} |
| 1757 |
|
| 1758 |
inline int String::index(const char* t, int startpos) const |
| 1759 |
{ |
| 1760 |
return search(startpos, length(), t); |
| 1761 |
} |
| 1762 |
|
| 1763 |
inline int String::index(const String& y, int startpos) const |
| 1764 |
{ |
| 1765 |
return search(startpos, length(), y.chars(), y.length()); |
| 1766 |
} |
| 1767 |
|
| 1768 |
inline int String::index(const SubString& y, int startpos) const |
| 1769 |
{ |
| 1770 |
return search(startpos, length(), y.chars(), y.length()); |
| 1771 |
} |
| 1772 |
|
| 1773 |
inline int String::index(const Regex& r, int startpos) const |
| 1774 |
{ |
| 1775 |
int unused; return r.search(chars(), length(), unused, startpos); |
| 1776 |
} |
| 1777 |
|
| 1778 |
inline int String::contains(char c) const |
| 1779 |
{ |
| 1780 |
return search(0, length(), c) >= 0; |
| 1781 |
} |
| 1782 |
|
| 1783 |
inline int String::contains(const char* t) const |
| 1784 |
{ |
| 1785 |
return search(0, length(), t) >= 0; |
| 1786 |
} |
| 1787 |
|
| 1788 |
inline int String::contains(const String& y) const |
| 1789 |
{ |
| 1790 |
return search(0, length(), y.chars(), y.length()) >= 0; |
| 1791 |
} |
| 1792 |
|
| 1793 |
inline int String::contains(const SubString& y) const |
| 1794 |
{ |
| 1795 |
return search(0, length(), y.chars(), y.length()) >= 0; |
| 1796 |
} |
| 1797 |
|
| 1798 |
inline int String::contains(char c, int p) const |
| 1799 |
{ |
| 1800 |
return match(p, length(), 0, &c, 1) >= 0; |
| 1801 |
} |
| 1802 |
|
| 1803 |
inline int String::contains(const char* t, int p) const |
| 1804 |
{ |
| 1805 |
return match(p, length(), 0, t) >= 0; |
| 1806 |
} |
| 1807 |
|
| 1808 |
inline int String::contains(const String& y, int p) const |
| 1809 |
{ |
| 1810 |
return match(p, length(), 0, y.chars(), y.length()) >= 0; |
| 1811 |
} |
| 1812 |
|
| 1813 |
inline int String::contains(const SubString& y, int p) const |
| 1814 |
{ |
| 1815 |
return match(p, length(), 0, y.chars(), y.length()) >= 0; |
| 1816 |
} |
| 1817 |
|
| 1818 |
inline int String::contains(const Regex& r) const |
| 1819 |
{ |
| 1820 |
int unused; return r.search(chars(), length(), unused, 0) >= 0; |
| 1821 |
} |
| 1822 |
|
| 1823 |
inline int String::contains(const Regex& r, int p) const |
| 1824 |
{ |
| 1825 |
return r.match(chars(), length(), p) >= 0; |
| 1826 |
} |
| 1827 |
|
| 1828 |
|
| 1829 |
inline int String::matches(const SubString& y, int p) const |
| 1830 |
{ |
| 1831 |
return match(p, length(), 1, y.chars(), y.length()) >= 0; |
| 1832 |
} |
| 1833 |
|
| 1834 |
inline int String::matches(const String& y, int p) const |
| 1835 |
{ |
| 1836 |
return match(p, length(), 1, y.chars(), y.length()) >= 0; |
| 1837 |
} |
| 1838 |
|
| 1839 |
inline int String::matches(const char* t, int p) const |
| 1840 |
{ |
| 1841 |
return match(p, length(), 1, t) >= 0; |
| 1842 |
} |
| 1843 |
|
| 1844 |
inline int String::matches(char c, int p) const |
| 1845 |
{ |
| 1846 |
return match(p, length(), 1, &c, 1) >= 0; |
| 1847 |
} |
| 1848 |
|
| 1849 |
inline int String::matches(const Regex& r, int p) const |
| 1850 |
{ |
| 1851 |
int l = (p < 0)? -p : length() - p; |
| 1852 |
return r.match(chars(), length(), p) == l; |
| 1853 |
} |
| 1854 |
|
| 1855 |
|
| 1856 |
inline int SubString::contains(const char* t) const |
| 1857 |
{ |
| 1858 |
return S.search(pos, pos+len, t) >= 0; |
| 1859 |
} |
| 1860 |
|
| 1861 |
inline int SubString::contains(const String& y) const |
| 1862 |
{ |
| 1863 |
return S.search(pos, pos+len, y.chars(), y.length()) >= 0; |
| 1864 |
} |
| 1865 |
|
| 1866 |
inline int SubString::contains(const SubString& y) const |
| 1867 |
{ |
| 1868 |
return S.search(pos, pos+len, y.chars(), y.length()) >= 0; |
| 1869 |
} |
| 1870 |
|
| 1871 |
inline int SubString::contains(char c) const |
| 1872 |
{ |
| 1873 |
return S.search(pos, pos+len, 0, c) >= 0; |
| 1874 |
} |
| 1875 |
|
| 1876 |
inline int SubString::contains(const Regex& r) const |
| 1877 |
{ |
| 1878 |
int unused; return r.search(chars(), len, unused, 0) >= 0; |
| 1879 |
} |
| 1880 |
|
| 1881 |
inline int SubString::matches(const Regex& r) const |
| 1882 |
{ |
| 1883 |
return r.match(chars(), len, 0) == len; |
| 1884 |
} |
| 1885 |
|
| 1886 |
|
| 1887 |
inline int String::gsub(const String& pat, const String& r) |
| 1888 |
{ |
| 1889 |
return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); |
| 1890 |
} |
| 1891 |
|
| 1892 |
inline int String::gsub(const SubString& pat, const String& r) |
| 1893 |
{ |
| 1894 |
return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); |
| 1895 |
} |
| 1896 |
|
| 1897 |
inline int String::gsub(const Regex& pat, const String& r) |
| 1898 |
{ |
| 1899 |
return _gsub(pat, r.chars(), r.length()); |
| 1900 |
} |
| 1901 |
|
| 1902 |
inline int String::gsub(const char* pat, const String& r) |
| 1903 |
{ |
| 1904 |
return _gsub(pat, -1, r.chars(), r.length()); |
| 1905 |
} |
| 1906 |
|
| 1907 |
inline int String::gsub(const char* pat, const char* r) |
| 1908 |
{ |
| 1909 |
return _gsub(pat, -1, r, -1); |
| 1910 |
} |
| 1911 |
|
| 1912 |
|
| 1913 |
|
| 1914 |
inline ostream& operator<<(ostream& s, const String& x) |
| 1915 |
{ |
| 1916 |
s << x.chars(); return s; |
| 1917 |
} |
| 1918 |
|
| 1919 |
// a zillion comparison operators |
| 1920 |
|
| 1921 |
inline int operator==(const String& x, const String& y) |
| 1922 |
{ |
| 1923 |
return compare(x, y) == 0; |
| 1924 |
} |
| 1925 |
|
| 1926 |
inline int operator!=(const String& x, const String& y) |
| 1927 |
{ |
| 1928 |
return compare(x, y) != 0; |
| 1929 |
} |
| 1930 |
|
| 1931 |
inline int operator>(const String& x, const String& y) |
| 1932 |
{ |
| 1933 |
return compare(x, y) > 0; |
| 1934 |
} |
| 1935 |
|
| 1936 |
inline int operator>=(const String& x, const String& y) |
| 1937 |
{ |
| 1938 |
return compare(x, y) >= 0; |
| 1939 |
} |
| 1940 |
|
| 1941 |
inline int operator<(const String& x, const String& y) |
| 1942 |
{ |
| 1943 |
return compare(x, y) < 0; |
| 1944 |
} |
| 1945 |
|
| 1946 |
inline int operator<=(const String& x, const String& y) |
| 1947 |
{ |
| 1948 |
return compare(x, y) <= 0; |
| 1949 |
} |
| 1950 |
|
| 1951 |
inline int operator==(const String& x, const SubString& y) |
| 1952 |
{ |
| 1953 |
return compare(x, y) == 0; |
| 1954 |
} |
| 1955 |
|
| 1956 |
inline int operator!=(const String& x, const SubString& y) |
| 1957 |
{ |
| 1958 |
return compare(x, y) != 0; |
| 1959 |
} |
| 1960 |
|
| 1961 |
inline int operator>(const String& x, const SubString& y) |
| 1962 |
{ |
| 1963 |
return compare(x, y) > 0; |
| 1964 |
} |
| 1965 |
|
| 1966 |
inline int operator>=(const String& x, const SubString& y) |
| 1967 |
{ |
| 1968 |
return compare(x, y) >= 0; |
| 1969 |
} |
| 1970 |
|
| 1971 |
inline int operator<(const String& x, const SubString& y) |
| 1972 |
{ |
| 1973 |
return compare(x, y) < 0; |
| 1974 |
} |
| 1975 |
|
| 1976 |
inline int operator<=(const String& x, const SubString& y) |
| 1977 |
{ |
| 1978 |
return compare(x, y) <= 0; |
| 1979 |
} |
| 1980 |
|
| 1981 |
inline int operator==(const String& x, const char* t) |
| 1982 |
{ |
| 1983 |
return compare(x, t) == 0; |
| 1984 |
} |
| 1985 |
|
| 1986 |
inline int operator!=(const String& x, const char* t) |
| 1987 |
{ |
| 1988 |
return compare(x, t) != 0; |
| 1989 |
} |
| 1990 |
|
| 1991 |
inline int operator>(const String& x, const char* t) |
| 1992 |
{ |
| 1993 |
return compare(x, t) > 0; |
| 1994 |
} |
| 1995 |
|
| 1996 |
inline int operator>=(const String& x, const char* t) |
| 1997 |
{ |
| 1998 |
return compare(x, t) >= 0; |
| 1999 |
} |
| 2000 |
|
| 2001 |
inline int operator<(const String& x, const char* t) |
| 2002 |
{ |
| 2003 |
return compare(x, t) < 0; |
| 2004 |
} |
| 2005 |
|
| 2006 |
inline int operator<=(const String& x, const char* t) |
| 2007 |
{ |
| 2008 |
return compare(x, t) <= 0; |
| 2009 |
} |
| 2010 |
|
| 2011 |
inline int operator==(const SubString& x, const String& y) |
| 2012 |
{ |
| 2013 |
return compare(y, x) == 0; |
| 2014 |
} |
| 2015 |
|
| 2016 |
inline int operator!=(const SubString& x, const String& y) |
| 2017 |
{ |
| 2018 |
return compare(y, x) != 0; |
| 2019 |
} |
| 2020 |
|
| 2021 |
inline int operator>(const SubString& x, const String& y) |
| 2022 |
{ |
| 2023 |
return compare(y, x) < 0; |
| 2024 |
} |
| 2025 |
|
| 2026 |
inline int operator>=(const SubString& x, const String& y) |
| 2027 |
{ |
| 2028 |
return compare(y, x) <= 0; |
| 2029 |
} |
| 2030 |
|
| 2031 |
inline int operator<(const SubString& x, const String& y) |
| 2032 |
{ |
| 2033 |
return compare(y, x) > 0; |
| 2034 |
} |
| 2035 |
|
| 2036 |
inline int operator<=(const SubString& x, const String& y) |
| 2037 |
{ |
| 2038 |
return compare(y, x) >= 0; |
| 2039 |
} |
| 2040 |
|
| 2041 |
inline int operator==(const SubString& x, const SubString& y) |
| 2042 |
{ |
| 2043 |
return compare(x, y) == 0; |
| 2044 |
} |
| 2045 |
|
| 2046 |
inline int operator!=(const SubString& x, const SubString& y) |
| 2047 |
{ |
| 2048 |
return compare(x, y) != 0; |
| 2049 |
} |
| 2050 |
|
| 2051 |
inline int operator>(const SubString& x, const SubString& y) |
| 2052 |
{ |
| 2053 |
return compare(x, y) > 0; |
| 2054 |
} |
| 2055 |
|
| 2056 |
inline int operator>=(const SubString& x, const SubString& y) |
| 2057 |
{ |
| 2058 |
return compare(x, y) >= 0; |
| 2059 |
} |
| 2060 |
|
| 2061 |
inline int operator<(const SubString& x, const SubString& y) |
| 2062 |
{ |
| 2063 |
return compare(x, y) < 0; |
| 2064 |
} |
| 2065 |
|
| 2066 |
inline int operator<=(const SubString& x, const SubString& y) |
| 2067 |
{ |
| 2068 |
return compare(x, y) <= 0; |
| 2069 |
} |
| 2070 |
|
| 2071 |
inline int operator==(const SubString& x, const char* t) |
| 2072 |
{ |
| 2073 |
return compare(x, t) == 0; |
| 2074 |
} |
| 2075 |
|
| 2076 |
inline int operator!=(const SubString& x, const char* t) |
| 2077 |
{ |
| 2078 |
return compare(x, t) != 0; |
| 2079 |
} |
| 2080 |
|
| 2081 |
inline int operator>(const SubString& x, const char* t) |
| 2082 |
{ |
| 2083 |
return compare(x, t) > 0; |
| 2084 |
} |
| 2085 |
|
| 2086 |
inline int operator>=(const SubString& x, const char* t) |
| 2087 |
{ |
| 2088 |
return compare(x, t) >= 0; |
| 2089 |
} |
| 2090 |
|
| 2091 |
inline int operator<(const SubString& x, const char* t) |
| 2092 |
{ |
| 2093 |
return compare(x, t) < 0; |
| 2094 |
} |
| 2095 |
|
| 2096 |
inline int operator<=(const SubString& x, const char* t) |
| 2097 |
{ |
| 2098 |
return compare(x, t) <= 0; |
| 2099 |
} |
| 2100 |
|
| 2101 |
|
| 2102 |
// a helper needed by at, before, etc. |
| 2103 |
|
| 2104 |
inline SubString String::_substr(int first, int l) |
| 2105 |
{ |
| 2106 |
if (first >= length() ) // ??? THIS LINE IS QUESTIONABLE |
| 2107 |
return SubString(_nilString, 0, 0) ; |
| 2108 |
else |
| 2109 |
return SubString(*this, first, l); |
| 2110 |
} |
| 2111 |
|
| 2112 |
|
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
//# 26 "../../GctSymbol.h" 2 |
| 2117 |
|
| 2118 |
|
| 2119 |
//# 1 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 1 |
| 2120 |
// -*- C++ -*- |
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
// |
| 2125 |
// GctHashObject class (is abstract) |
| 2126 |
// |
| 2127 |
// Expects to be included by Object.h or where needed explicitly. |
| 2128 |
// |
| 2129 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 2130 |
// |
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
//#pragma interface |
| 2137 |
|
| 2138 |
|
| 2139 |
|
| 2140 |
//# 1 "../../../../../../mips/include/Gct/Object/GctObject.h" 1 |
| 2141 |
// -*- C++ -*- |
| 2142 |
|
| 2143 |
|
| 2144 |
|
| 2145 |
// |
| 2146 |
// GctObject class (is abstract) |
| 2147 |
// |
| 2148 |
// Expects to be included by Object.h or where needed explicitly. |
| 2149 |
// |
| 2150 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 2151 |
// |
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
//#pragma interface |
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 |
| 2162 |
// -*- C++ -*- |
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
// |
| 2167 |
// tostrstream class |
| 2168 |
// |
| 2169 |
// A terminated oststream - an ostsrstream that auto-terminates on str() |
| 2170 |
// |
| 2171 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 2172 |
// |
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
|
| 2178 |
//#pragma interface |
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 1 |
| 2183 |
// This is part of the iostream library, providing input/output for C++. |
| 2184 |
// Copyright (C) 1991 Per Bothner. |
| 2185 |
// |
| 2186 |
// This library is free software; you can redistribute it and/or |
| 2187 |
// modify it under the terms of the GNU Library General Public |
| 2188 |
// License as published by the Free Software Foundation; either |
| 2189 |
// version 2 of the License, or (at your option) any later version. |
| 2190 |
// |
| 2191 |
// This library is distributed in the hope that it will be useful, |
| 2192 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2193 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2194 |
// Library General Public License for more details. |
| 2195 |
// |
| 2196 |
// You should have received a copy of the GNU Library General Public |
| 2197 |
// License along with this library; if not, write to the Free |
| 2198 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
//#pragma interface |
| 2204 |
|
| 2205 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 2206 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 2207 |
// Copyright (C) 1991 Per Bothner. |
| 2208 |
// |
| 2209 |
// This library is free software; you can redistribute it and/or |
| 2210 |
// modify it under the terms of the GNU Library General Public |
| 2211 |
// License as published by the Free Software Foundation; either |
| 2212 |
// version 2 of the License, or (at your option) any later version. |
| 2213 |
// |
| 2214 |
// This library is distributed in the hope that it will be useful, |
| 2215 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2216 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2217 |
// Library General Public License for more details. |
| 2218 |
// |
| 2219 |
// You should have received a copy of the GNU Library General Public |
| 2220 |
// License along with this library; if not, write to the Free |
| 2221 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2222 |
|
| 2223 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 2224 |
|
| 2225 |
//# 23 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 2 |
| 2226 |
|
| 2227 |
|
| 2228 |
class strstreambuf : public streambuf { |
| 2229 |
size_t *lenp; /* current (logical) length (i.e. valid data bytes) */ |
| 2230 |
size_t *sizep; /* allocated (physical) buffer size */ |
| 2231 |
char **bufp; |
| 2232 |
size_t _len; |
| 2233 |
size_t _size; |
| 2234 |
char *buf; |
| 2235 |
int _frozen; |
| 2236 |
protected: |
| 2237 |
virtual int overflow(int = (-1) ); |
| 2238 |
public: |
| 2239 |
strstreambuf(); |
| 2240 |
strstreambuf(int initial); |
| 2241 |
strstreambuf(char *ptr, int size, char *pstart = (__null) ); |
| 2242 |
~strstreambuf(); |
| 2243 |
int frozen() { return _frozen; } |
| 2244 |
void freeze(int n=1) { _frozen = n != 0; } |
| 2245 |
size_t pcount(); |
| 2246 |
char *str(); |
| 2247 |
}; |
| 2248 |
|
| 2249 |
class istrstream : public istream { |
| 2250 |
public: |
| 2251 |
istrstream(char*); |
| 2252 |
istrstream(char*, int); |
| 2253 |
strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; } |
| 2254 |
}; |
| 2255 |
|
| 2256 |
class ostrstream : public ostream { |
| 2257 |
public: |
| 2258 |
ostrstream(); |
| 2259 |
ostrstream(char *cp, int n, int mode=ios::out); |
| 2260 |
size_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } |
| 2261 |
char *str() { return ((strstreambuf*)_strbuf)->str(); } |
| 2262 |
void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } |
| 2263 |
int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } |
| 2264 |
strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; } |
| 2265 |
}; |
| 2266 |
|
| 2267 |
|
| 2268 |
//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 2 |
| 2269 |
|
| 2270 |
|
| 2271 |
// |
| 2272 |
// tostrstream class |
| 2273 |
// |
| 2274 |
// An isteam class that doesn't have that nasty skipws parameter that |
| 2275 |
// you have to remember to set. This class simply provides the istream |
| 2276 |
// functionality with a set of constructors which defaults skipws to |
| 2277 |
// FALSE (instead of defaulting to TRUE as is the case with plain istream). |
| 2278 |
// |
| 2279 |
class tostrstream: public ostrstream { |
| 2280 |
public: |
| 2281 |
tostrstream(): ostrstream() |
| 2282 |
{ } |
| 2283 |
// This constructor defines cp as the buffer to use for the |
| 2284 |
// stream (instead of one of its own devising); it does NOT |
| 2285 |
// initialize the ostrstream to contain cp (of length n). |
| 2286 |
tostrstream(char *cp, int n, int mode=ios::out): ostrtream(cp, n, mode) // { dg-error "" } |
| 2287 |
{ } |
| 2288 |
char *str() |
| 2289 |
{ |
| 2290 |
char *s = ostrstream::str(); |
| 2291 |
s[ostrstream::pcount()] = '\0'; |
| 2292 |
return s; |
| 2293 |
} |
| 2294 |
}; |
| 2295 |
|
| 2296 |
|
| 2297 |
//# 25 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 |
| 2298 |
|
| 2299 |
|
| 2300 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1 |
| 2301 |
// -*- C++ -*- |
| 2302 |
|
| 2303 |
|
| 2304 |
|
| 2305 |
// |
| 2306 |
// GttObject class (is abstract) |
| 2307 |
// |
| 2308 |
// Expects to be included where needed explicitly. |
| 2309 |
// |
| 2310 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 2311 |
// |
| 2312 |
|
| 2313 |
|
| 2314 |
|
| 2315 |
|
| 2316 |
|
| 2317 |
//#pragma interface |
| 2318 |
|
| 2319 |
|
| 2320 |
|
| 2321 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 |
| 2322 |
// -*- C++ -*- |
| 2323 |
//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" |
| 2324 |
|
| 2325 |
//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 |
| 2326 |
|
| 2327 |
|
| 2328 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 1 |
| 2329 |
// -*- C++ -*- |
| 2330 |
|
| 2331 |
|
| 2332 |
|
| 2333 |
// |
| 2334 |
// GttErrorHandler class |
| 2335 |
// |
| 2336 |
// Expects to be included by Gtt.h |
| 2337 |
// |
| 2338 |
// Wendell Baker, Berkeley CAD Group, 1992 ([email protected]) |
| 2339 |
// |
| 2340 |
|
| 2341 |
|
| 2342 |
|
| 2343 |
|
| 2344 |
|
| 2345 |
//#pragma interface |
| 2346 |
|
| 2347 |
|
| 2348 |
|
| 2349 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 |
| 2350 |
|
| 2351 |
|
| 2352 |
|
| 2353 |
|
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 |
| 2358 |
|
| 2359 |
|
| 2360 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1 |
| 2361 |
// -*- C++ -*- |
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
// |
| 2366 |
// Fake up a libstuff++ |
| 2367 |
// |
| 2368 |
// This is done as a complete and utter hack; this library has no function |
| 2369 |
// at all being in the boot area; it is here solely in order to provide a |
| 2370 |
// libstuff++ against which the Makefiles can resolve link lines. |
| 2371 |
// |
| 2372 |
// The only reason that this is done is to allow the STANDARD_C++_LIBRARIES |
| 2373 |
// as provided by the Makefile templates in the boot area to be the same |
| 2374 |
// ones that are used by the tools outside this hierarchy. |
| 2375 |
// |
| 2376 |
// The tools outside this hierarchy use a different libstuff++; one that is |
| 2377 |
// written in C++. This one is not written in C++ in order to be simpler. |
| 2378 |
// |
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
//#pragma interface |
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
extern "C" { |
| 2389 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 1 |
| 2390 |
|
| 2391 |
|
| 2392 |
|
| 2393 |
/* |
| 2394 |
* Useful stuff |
| 2395 |
*/ |
| 2396 |
|
| 2397 |
/* |
| 2398 |
*/ |
| 2399 |
|
| 2400 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/ansi.h" 1 |
| 2401 |
|
| 2402 |
|
| 2403 |
|
| 2404 |
|
| 2405 |
/* |
| 2406 |
* ANSI Compiler Support |
| 2407 |
* |
| 2408 |
* David Harrison |
| 2409 |
* University of California, Berkeley |
| 2410 |
* 1988 |
| 2411 |
* |
| 2412 |
* ANSI compatible compilers are supposed to define the preprocessor |
| 2413 |
* directive __STDC__. Based on this directive, this file defines |
| 2414 |
* certain ANSI specific macros. |
| 2415 |
* |
| 2416 |
* ARGS: |
| 2417 |
* Used in function prototypes. Example: |
| 2418 |
* extern int foo |
| 2419 |
* ARGS((char *blah, double threshold)); |
| 2420 |
*/ |
| 2421 |
|
| 2422 |
/* |
| 2423 |
* |
| 2424 |
* Modifications |
| 2425 |
* Wendell C Baker |
| 2426 |
* University of California, Berkeley |
| 2427 |
*/ |
| 2428 |
|
| 2429 |
/* Function prototypes */ |
| 2430 |
|
| 2431 |
|
| 2432 |
|
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
//# 15 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2 |
| 2458 |
|
| 2459 |
|
| 2460 |
|
| 2461 |
/* |
| 2462 |
* If g++, then we stub out part of this thing and let the C++ types take |
| 2463 |
* over and do the same job; some compatibility must be given however |
| 2464 |
*/ |
| 2465 |
|
| 2466 |
/* |
| 2467 |
* Use the GNU libg++ definition |
| 2468 |
*/ |
| 2469 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 |
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
|
| 2476 |
|
| 2477 |
//# 26 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2 |
| 2478 |
|
| 2479 |
//# 35 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" |
| 2480 |
|
| 2481 |
|
| 2482 |
/* |
| 2483 |
* Make various pieces of C code that use the old ``Boolean'' |
| 2484 |
* be compatible by faking up the definition of Boolean using |
| 2485 |
* the new bool type. |
| 2486 |
*/ |
| 2487 |
|
| 2488 |
|
| 2489 |
//# 58 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" |
| 2490 |
|
| 2491 |
|
| 2492 |
typedef long FitAny; /* can fit any integral type */ |
| 2493 |
|
| 2494 |
/* |
| 2495 |
* typedef char *String; - DO NOT USE THIS - it conflicts with C++ |
| 2496 |
* typedef char **Stringv; - just use char* and char** instead. |
| 2497 |
* - void* can be used for arbitrary pointers |
| 2498 |
*/ |
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
|
| 2503 |
extern int nocase_strcmp (char *, char *) ; |
| 2504 |
extern int nocase_strncmp (char *, char *, int) ; |
| 2505 |
|
| 2506 |
extern bool nocase_strequal (char *, char *) ; |
| 2507 |
extern bool nocase_strnequal (char *, char *, int) ; |
| 2508 |
|
| 2509 |
extern bool lead_strequal (char *, char *) ; |
| 2510 |
extern bool nocase_lead_strequal (char *, char *) ; |
| 2511 |
|
| 2512 |
extern int strhash (char *, int) ; |
| 2513 |
extern int nocase_strhash (char *, int) ; |
| 2514 |
|
| 2515 |
extern int sign (int) ; |
| 2516 |
|
| 2517 |
/* |
| 2518 |
* Some useful macros. |
| 2519 |
*/ |
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
|
| 2525 |
|
| 2526 |
|
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
|
| 2541 |
|
| 2542 |
|
| 2543 |
|
| 2544 |
|
| 2545 |
|
| 2546 |
|
| 2547 |
|
| 2548 |
|
| 2549 |
//# 33 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 |
| 2550 |
|
| 2551 |
} |
| 2552 |
|
| 2553 |
// |
| 2554 |
// This is here because we wish to provide externs for the two |
| 2555 |
// functions btoa(bool, unsigned = 0) and operator<<(ostream&, bool) |
| 2556 |
// because they are not provided in bool.h. |
| 2557 |
// |
| 2558 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 |
| 2559 |
|
| 2560 |
|
| 2561 |
|
| 2562 |
|
| 2563 |
|
| 2564 |
|
| 2565 |
|
| 2566 |
//# 41 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 |
| 2567 |
|
| 2568 |
extern const char *stringify(bool b); |
| 2569 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 2570 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 2571 |
// Copyright (C) 1991 Per Bothner. |
| 2572 |
// |
| 2573 |
// This library is free software; you can redistribute it and/or |
| 2574 |
// modify it under the terms of the GNU Library General Public |
| 2575 |
// License as published by the Free Software Foundation; either |
| 2576 |
// version 2 of the License, or (at your option) any later version. |
| 2577 |
// |
| 2578 |
// This library is distributed in the hope that it will be useful, |
| 2579 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2580 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2581 |
// Library General Public License for more details. |
| 2582 |
// |
| 2583 |
// You should have received a copy of the GNU Library General Public |
| 2584 |
// License along with this library; if not, write to the Free |
| 2585 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2586 |
|
| 2587 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 2588 |
|
| 2589 |
//# 43 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 |
| 2590 |
|
| 2591 |
extern ostream& operator<<(ostream&, bool); |
| 2592 |
|
| 2593 |
// Should this be kept separate? bool isn't, but then is |
| 2594 |
// included here only to define ostream& operator<<(ostream&, bool) |
| 2595 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 1 |
| 2596 |
// -*- C++ -*- |
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
// |
| 2601 |
// unit enum |
| 2602 |
// |
| 2603 |
// Wendell Baker, Berkeley CAD Group, 1991 ([email protected]) |
| 2604 |
// |
| 2605 |
|
| 2606 |
|
| 2607 |
// |
| 2608 |
// unit enum |
| 2609 |
// |
| 2610 |
// This _looks_ silly, but it has an important theoretical basis in category |
| 2611 |
// theory. For the pragmatic reason for its existence, see the example below. |
| 2612 |
// |
| 2613 |
enum unit { |
| 2614 |
UNIT = 1, |
| 2615 |
}; |
| 2616 |
|
| 2617 |
extern const char *stringify(unit u); |
| 2618 |
|
| 2619 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 2620 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 2621 |
// Copyright (C) 1991 Per Bothner. |
| 2622 |
// |
| 2623 |
// This library is free software; you can redistribute it and/or |
| 2624 |
// modify it under the terms of the GNU Library General Public |
| 2625 |
// License as published by the Free Software Foundation; either |
| 2626 |
// version 2 of the License, or (at your option) any later version. |
| 2627 |
// |
| 2628 |
// This library is distributed in the hope that it will be useful, |
| 2629 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2630 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2631 |
// Library General Public License for more details. |
| 2632 |
// |
| 2633 |
// You should have received a copy of the GNU Library General Public |
| 2634 |
// License along with this library; if not, write to the Free |
| 2635 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2636 |
|
| 2637 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 2638 |
|
| 2639 |
//# 28 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 2 |
| 2640 |
|
| 2641 |
extern ostream& operator<<(ostream&, unit); |
| 2642 |
|
| 2643 |
// |
| 2644 |
// A unit is used in cases where the type signature of an overloaded |
| 2645 |
// function must be differentiated in some stronger way than can be |
| 2646 |
// denoted unambiguously in the C++ syntax. This enum is used to give |
| 2647 |
// one of the functions a different type signature, thereby allowing |
| 2648 |
// the overloading. |
| 2649 |
// |
| 2650 |
// The use of ``unit'' instead of int or bool is important because a unit |
| 2651 |
// has only one possible value; therefore it adds no more information to |
| 2652 |
// the code. For example, say a bool was used instead, then in the testing |
| 2653 |
// phase, would have to ask: what if TRUE was given, what if FALSE was given. |
| 2654 |
// The problem is compounded if char or int is used. |
| 2655 |
// |
| 2656 |
// Example: |
| 2657 |
// |
| 2658 |
// class ID { |
| 2659 |
// public: |
| 2660 |
// ID(); // construct a null ID |
| 2661 |
// ID(unit); // alloc a ID with a new id |
| 2662 |
// private: |
| 2663 |
// static unsigned high_water; |
| 2664 |
// unsigned id; |
| 2665 |
// }; |
| 2666 |
// |
| 2667 |
// Try working this example save that ID implements all of the generic |
| 2668 |
// features of the identifier object, but the high_water is stored |
| 2669 |
// in the heir. That is what originally motivated the creation of unit. |
| 2670 |
// |
| 2671 |
|
| 2672 |
|
| 2673 |
//# 48 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 |
| 2674 |
|
| 2675 |
|
| 2676 |
// |
| 2677 |
// In the spirit of the standard GNU error handler functions |
| 2678 |
// as described in |
| 2679 |
// typedef void (*one_arg_error_handler_t)(const char*); |
| 2680 |
// a one argument error handler function pointer |
| 2681 |
// typedef void (*two_arg_error_handler_t)(const char*, const char*); |
| 2682 |
// a two argument error handler function pointer |
| 2683 |
// |
| 2684 |
// And now the NEW |
| 2685 |
// |
| 2686 |
// typedef void (*zero_arg_error_handler_t)(); |
| 2687 |
// a zero argument error handler function pointer |
| 2688 |
// |
| 2689 |
typedef void (*zero_arg_error_handler_t)(); |
| 2690 |
|
| 2691 |
// |
| 2692 |
// In the spirit of the default GNU error handler functions |
| 2693 |
// as described in |
| 2694 |
// extern void default_one_arg_error_handler(const char *message); |
| 2695 |
// print out message on stderr, and do the default thing (abort) |
| 2696 |
// extern void default_two_arg_error_handler(const char *kind, const char *message); |
| 2697 |
// print out kind and message on stderr, and do the default thing (abort) |
| 2698 |
// |
| 2699 |
// And now the NEW |
| 2700 |
// |
| 2701 |
// extern void default_zero_arg_error_handler(const char *message); |
| 2702 |
// do the default thing (abort) |
| 2703 |
// |
| 2704 |
extern void default_zero_arg_error_handler(); |
| 2705 |
|
| 2706 |
// Guaranteed to exit (1) |
| 2707 |
extern void exit_zero_arg_error_handler(); |
| 2708 |
extern void exit_one_arg_error_handler(const char *message); |
| 2709 |
extern void exit_two_arg_error_handler(const char *kind, const char *message); |
| 2710 |
|
| 2711 |
// Guaranteed to abort() |
| 2712 |
extern void abort_zero_arg_error_handler(); |
| 2713 |
extern void abort_one_arg_error_handler(const char *message); |
| 2714 |
extern void abort_two_arg_error_handler(const char *kind, const char *message); |
| 2715 |
|
| 2716 |
// |
| 2717 |
// In the spirit of the standard GNU error handlers |
| 2718 |
// as described in |
| 2719 |
// extern void verbose_File_error_handler(const char*); |
| 2720 |
// perror and set errno = 0 |
| 2721 |
// extern void quiet_File_error_handler(const char*); |
| 2722 |
// set errno = 0 |
| 2723 |
// extern void fatal_File_error_handler(const char*); |
| 2724 |
// perror and exit 1 |
| 2725 |
// |
| 2726 |
// And now the NEW |
| 2727 |
// |
| 2728 |
// extern void preserve_File_error_handler(const char *message); |
| 2729 |
// no perror, no assignment to errno. |
| 2730 |
// |
| 2731 |
extern void preserve_File_error_handler(const char *message); |
| 2732 |
|
| 2733 |
|
| 2734 |
//# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 |
| 2735 |
|
| 2736 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 |
| 2737 |
// -*- C++ -*- |
| 2738 |
//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" |
| 2739 |
|
| 2740 |
//# 28 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 |
| 2741 |
|
| 2742 |
|
| 2743 |
// |
| 2744 |
// It is expected that this will be virtually multiply inherited |
| 2745 |
// into all of the classes that need error reporting services. |
| 2746 |
// |
| 2747 |
// The typical way to have that done is by inheriting the GttObject |
| 2748 |
// as a virtual base class. |
| 2749 |
// |
| 2750 |
|
| 2751 |
// |
| 2752 |
// GttErrorHandler class |
| 2753 |
// |
| 2754 |
class GttErrorHandler { |
| 2755 |
public: |
| 2756 |
GttErrorHandler(); |
| 2757 |
GttErrorHandler(const char *program); |
| 2758 |
virtual ~GttErrorHandler(); |
| 2759 |
|
| 2760 |
// |
| 2761 |
// Error messages |
| 2762 |
// - an unacceptable, but expected and recoverable condition |
| 2763 |
// was detected (but the test fails) |
| 2764 |
// - errors are for ``the expected environment was not found'' |
| 2765 |
// rather than for ``file couldn't be opened'' |
| 2766 |
// - these messages cannot be shut off |
| 2767 |
// - the error handler determines the recovery action |
| 2768 |
// TODO - one day exceptions will be used here |
| 2769 |
// |
| 2770 |
static void error(const char *message); |
| 2771 |
static void error(tostrstream& message); |
| 2772 |
|
| 2773 |
static void error(const char *function, const char *message); |
| 2774 |
static void error(const char *function, tostrstream& message); |
| 2775 |
|
| 2776 |
static void error(const char *class_name, const char *method, const char *message); |
| 2777 |
static void error(const char *class_name, const char *method, tostrstream& message); |
| 2778 |
|
| 2779 |
// |
| 2780 |
// Fatal messages |
| 2781 |
// - an unacceptable and unexpected error was detected |
| 2782 |
// the data invariants were violated, there is no recovery |
| 2783 |
// - these messages cannot be shut off |
| 2784 |
// - the error handler determines the recovery action |
| 2785 |
// TODO - one day exceptions will be used here |
| 2786 |
// |
| 2787 |
static void fatal(const char *message); |
| 2788 |
static void fatal(tostrstream& message); |
| 2789 |
|
| 2790 |
static void fatal(const char *function, const char *message); |
| 2791 |
static void fatal(const char *function, tostrstream& message); |
| 2792 |
|
| 2793 |
static void fatal(const char *class_name, const char *method, const char *message); |
| 2794 |
static void fatal(const char *class_name, const char *method, tostrstream& message); |
| 2795 |
private: |
| 2796 |
// |
| 2797 |
// Two underscores are used here in order to prevent confusion of these |
| 2798 |
// private variables with any of the heir's private variables. Note that |
| 2799 |
// access control is different than visibility in C++, so all the variable |
| 2800 |
// names in a class hierarchy must be unique. |
| 2801 |
// |
| 2802 |
|
| 2803 |
static bool __partial_init; |
| 2804 |
static void __partial_initialize(); |
| 2805 |
static bool __full_init; |
| 2806 |
static void __full_initialize(const char *program); |
| 2807 |
static char *__program; |
| 2808 |
|
| 2809 |
static void __handle_error(); |
| 2810 |
static void __handle_fatal(); |
| 2811 |
static void __add_newline(const char *message); |
| 2812 |
|
| 2813 |
static bool __output_valid(); |
| 2814 |
static ostream *__output; |
| 2815 |
}; |
| 2816 |
|
| 2817 |
|
| 2818 |
//# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 |
| 2819 |
|
| 2820 |
|
| 2821 |
// |
| 2822 |
// GttObject class (is abstract) |
| 2823 |
// |
| 2824 |
class GttObject: virtual public GttErrorHandler { |
| 2825 |
protected: |
| 2826 |
GttObject(); |
| 2827 |
GttObject(const GttObject&); |
| 2828 |
virtual ~GttObject(); // ensure descendants have virtual destructors |
| 2829 |
|
| 2830 |
public: |
| 2831 |
// |
| 2832 |
// I/O Support |
| 2833 |
// |
| 2834 |
// The value typically persists only long enough for an i/o operation |
| 2835 |
// to be performed (see the defintion of output via operator<<(... ) below) |
| 2836 |
virtual const char *stringify(); |
| 2837 |
protected: |
| 2838 |
// This is the buffer into which the printed representation of this |
| 2839 |
// object will be put when the time comes. It is associated with the |
| 2840 |
// object so it will never go away (so long as the object exists). |
| 2841 |
// Use a pointer so that you only pay for the space when I/O is used |
| 2842 |
tostrstream *stringbuf; |
| 2843 |
void clear_stringbuf(); |
| 2844 |
|
| 2845 |
public: |
| 2846 |
// |
| 2847 |
// Consistency |
| 2848 |
// |
| 2849 |
// The global data invariant for the whole object (heirs included). |
| 2850 |
// This OK function will call the local invariant function ok() if |
| 2851 |
// necessary and in addition the OK functions of the heirs |
| 2852 |
// This is expected to compute the data invariant of the object. |
| 2853 |
// It will execute GctErrorHandler::fatal if there is wrong. |
| 2854 |
virtual void OK() const; |
| 2855 |
|
| 2856 |
protected: |
| 2857 |
// |
| 2858 |
// consistency |
| 2859 |
// |
| 2860 |
// This function computes the invariant which is local to this object. |
| 2861 |
// It does not call any of the ancestor's OK() or ok() functions. |
| 2862 |
// It is not a virtual function so that it can be called from within a |
| 2863 |
// constructor with impunity. Thus this function MUST NOT call any |
| 2864 |
// virtual functions either; it should call them by their full name if |
| 2865 |
// that is necessary. The global OK() function will call this function |
| 2866 |
// as necessary. |
| 2867 |
// |
| 2868 |
// This function must NOT NEVER EVER be made virtual. |
| 2869 |
void ok() const; |
| 2870 |
|
| 2871 |
protected: |
| 2872 |
// |
| 2873 |
// Class Name |
| 2874 |
// |
| 2875 |
// This must return a static (constant) string which is the name |
| 2876 |
// of the class being declared. By convention, not all classes |
| 2877 |
// must have one of these, but the major root abstract class must |
| 2878 |
// have one in order to allow the stringify() to work approximately |
| 2879 |
// correctly. |
| 2880 |
virtual const char *class_name() const = 0; |
| 2881 |
}; |
| 2882 |
|
| 2883 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 2884 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 2885 |
// Copyright (C) 1991 Per Bothner. |
| 2886 |
// |
| 2887 |
// This library is free software; you can redistribute it and/or |
| 2888 |
// modify it under the terms of the GNU Library General Public |
| 2889 |
// License as published by the Free Software Foundation; either |
| 2890 |
// version 2 of the License, or (at your option) any later version. |
| 2891 |
// |
| 2892 |
// This library is distributed in the hope that it will be useful, |
| 2893 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2894 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2895 |
// Library General Public License for more details. |
| 2896 |
// |
| 2897 |
// You should have received a copy of the GNU Library General Public |
| 2898 |
// License along with this library; if not, write to the Free |
| 2899 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2900 |
|
| 2901 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 2902 |
|
| 2903 |
//# 91 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 |
| 2904 |
|
| 2905 |
extern ostream& operator<<(ostream&, GttObject&); |
| 2906 |
|
| 2907 |
// There may be other X& operator<<(X&, GttObject&) defined in the |
| 2908 |
// packages defining class X. For example see the definition of |
| 2909 |
// GttUnitObject& operator<<(GttUnitObject&, GttObject&) in Unit. |
| 2910 |
|
| 2911 |
|
| 2912 |
//# 27 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 |
| 2913 |
|
| 2914 |
|
| 2915 |
//# 1 "../../../../../../mips/include/Gct/GctErrorHandler.h" 1 |
| 2916 |
// -*- C++ -*- |
| 2917 |
|
| 2918 |
|
| 2919 |
|
| 2920 |
// |
| 2921 |
// GctErrorHandler class |
| 2922 |
// |
| 2923 |
// Expects to be included by Gct.h |
| 2924 |
// |
| 2925 |
// Wendell Baker, Berkeley CAD Group, 1991 ([email protected]) |
| 2926 |
// |
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
//#pragma interface |
| 2933 |
|
| 2934 |
|
| 2935 |
|
| 2936 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 |
| 2937 |
|
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
|
| 2942 |
|
| 2943 |
|
| 2944 |
//# 25 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 2945 |
|
| 2946 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1 |
| 2947 |
// This may look like C code, but it is really -*- C++ -*- |
| 2948 |
/* |
| 2949 |
Copyright (C) 1988 Free Software Foundation |
| 2950 |
written by Doug Lea ([email protected]) |
| 2951 |
|
| 2952 |
This file is part of the GNU C++ Library. This library is free |
| 2953 |
software; you can redistribute it and/or modify it under the terms of |
| 2954 |
the GNU Library General Public License as published by the Free |
| 2955 |
Software Foundation; either version 2 of the License, or (at your |
| 2956 |
option) any later version. This library is distributed in the hope |
| 2957 |
that it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 2958 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 2959 |
PURPOSE. See the GNU Library General Public License for more details. |
| 2960 |
You should have received a copy of the GNU Library General Public |
| 2961 |
License along with this library; if not, write to the Free Software |
| 2962 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2963 |
*/ |
| 2964 |
|
| 2965 |
|
| 2966 |
//# 1321 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" |
| 2967 |
|
| 2968 |
//# 26 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 2969 |
|
| 2970 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 2971 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 2972 |
// Copyright (C) 1991 Per Bothner. |
| 2973 |
// |
| 2974 |
// This library is free software; you can redistribute it and/or |
| 2975 |
// modify it under the terms of the GNU Library General Public |
| 2976 |
// License as published by the Free Software Foundation; either |
| 2977 |
// version 2 of the License, or (at your option) any later version. |
| 2978 |
// |
| 2979 |
// This library is distributed in the hope that it will be useful, |
| 2980 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2981 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 2982 |
// Library General Public License for more details. |
| 2983 |
// |
| 2984 |
// You should have received a copy of the GNU Library General Public |
| 2985 |
// License along with this library; if not, write to the Free |
| 2986 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2987 |
|
| 2988 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 2989 |
|
| 2990 |
//# 27 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 2991 |
|
| 2992 |
|
| 2993 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1 |
| 2994 |
// -*- C++ -*- |
| 2995 |
//# 107 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" |
| 2996 |
|
| 2997 |
//# 29 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 2998 |
|
| 2999 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 |
| 3000 |
// -*- C++ -*- |
| 3001 |
//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" |
| 3002 |
|
| 3003 |
//# 30 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 3004 |
|
| 3005 |
|
| 3006 |
//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1 |
| 3007 |
// -*- C++ -*- |
| 3008 |
//# 98 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" |
| 3009 |
|
| 3010 |
//# 32 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 |
| 3011 |
|
| 3012 |
|
| 3013 |
// |
| 3014 |
// It is expected that this will be virtually multiply inherited |
| 3015 |
// into all of the classes that need error reporting services. |
| 3016 |
// |
| 3017 |
// The typical way to have that done is by inheriting the GctObject |
| 3018 |
// as a virtual base class. |
| 3019 |
// |
| 3020 |
|
| 3021 |
// |
| 3022 |
// GctErrorHandler class |
| 3023 |
// |
| 3024 |
// GPP_1_96_BUG |
| 3025 |
// NOTE - virtual public GttObject should be MI into GctObject - but that |
| 3026 |
// causes g++ 1.96 to segfault; so we must inherit GttObject here and use SI |
| 3027 |
// GPP_1_96_BUG |
| 3028 |
class GctErrorHandler: virtual public GttObject { |
| 3029 |
public: |
| 3030 |
GctErrorHandler(); |
| 3031 |
GctErrorHandler(const String& program); |
| 3032 |
virtual ~GctErrorHandler(); |
| 3033 |
|
| 3034 |
// |
| 3035 |
// Debugging messages |
| 3036 |
// - these are turned off for production code. |
| 3037 |
// - these messages can be shut off |
| 3038 |
// |
| 3039 |
static void debug(const char *message); |
| 3040 |
static void debug(tostrstream& message); |
| 3041 |
|
| 3042 |
static void debug(const char *function, const char *message); |
| 3043 |
static void debug(const char *function, tostrstream& message); |
| 3044 |
|
| 3045 |
static void debug(const char *class_name, const char *method, const char *message); |
| 3046 |
static void debug(const char *class_name, const char *method, tostrstream& message); |
| 3047 |
|
| 3048 |
static bool debug(); // current debug switch |
| 3049 |
static void debug(bool value); // change the debug switch |
| 3050 |
|
| 3051 |
// |
| 3052 |
// Informational messages |
| 3053 |
// - these correspond to a ``verbose'' mode |
| 3054 |
// - these are not errors, just chatty progress reports |
| 3055 |
// - these messages can be shut off |
| 3056 |
// |
| 3057 |
static void note(const char *message); |
| 3058 |
static void note(tostrstream& message); |
| 3059 |
|
| 3060 |
static void note(const char *function, const char *message); |
| 3061 |
static void note(const char *function, tostrstream& message); |
| 3062 |
|
| 3063 |
static void note(const char *class_name, const char *method, const char *message); |
| 3064 |
static void note(const char *class_name, const char *method, tostrstream& message); |
| 3065 |
|
| 3066 |
static bool note(); // current note switch |
| 3067 |
static void note(bool value); // change the note switch |
| 3068 |
|
| 3069 |
// |
| 3070 |
// Warning messages |
| 3071 |
// - warnings are system-recoverable errors |
| 3072 |
// - the system has noticed something and taken some |
| 3073 |
// corrective action |
| 3074 |
// - these messages can be shut off |
| 3075 |
// |
| 3076 |
static void warning(const char *message); |
| 3077 |
static void warning(tostrstream& message); |
| 3078 |
|
| 3079 |
static void warning(const char *function, const char *message); |
| 3080 |
static void warning(const char *function, tostrstream& message); |
| 3081 |
|
| 3082 |
static void warning(const char *class_name, const char *method, const char *message); |
| 3083 |
static void warning(const char *class_name, const char *method, tostrstream& message); |
| 3084 |
|
| 3085 |
static bool warning(); // current warning switch |
| 3086 |
static void warning(bool value); // change the warning switch |
| 3087 |
|
| 3088 |
// |
| 3089 |
// Error messages |
| 3090 |
// - an unacceptable, but expected and recoverable |
| 3091 |
// condition was detected |
| 3092 |
// - errors are for ``the expected environment was not found'' |
| 3093 |
// rather than for ``file couldn't be opened'' |
| 3094 |
// - these messages cannot be shut off |
| 3095 |
// - the error handler determines the recovery action |
| 3096 |
// TODO - one day exceptions will be used here |
| 3097 |
// |
| 3098 |
static void error(const char *message); |
| 3099 |
static void error(tostrstream& message); |
| 3100 |
|
| 3101 |
static void error(const char *function, const char *message); |
| 3102 |
static void error(const char *function, tostrstream& message); |
| 3103 |
|
| 3104 |
static void error(const char *class_name, const char *method, const char *message); |
| 3105 |
static void error(const char *class_name, const char *method, tostrstream& message); |
| 3106 |
|
| 3107 |
// can't turn off errors - no ``static void error(bool value);'' |
| 3108 |
static zero_arg_error_handler_t error(); // current error handler |
| 3109 |
static void error(zero_arg_error_handler_t handler);// change the error handler |
| 3110 |
|
| 3111 |
static void error_is_lib_error_handler(); // change the error handler |
| 3112 |
static void error_is_exit(); // change the error handler |
| 3113 |
|
| 3114 |
// Describes the fatal handler - WATCHOUT - implicitly uses AllocRing |
| 3115 |
static const char *error_handler_description(); |
| 3116 |
|
| 3117 |
// |
| 3118 |
// Fatal messages |
| 3119 |
// - an unacceptable and unexpected error was detected |
| 3120 |
// the data invariants were violated, there is no recovery |
| 3121 |
// - these messages cannot be shut off |
| 3122 |
// - the error handler determines the recovery action |
| 3123 |
// TODO - one day exceptions will be used here |
| 3124 |
// |
| 3125 |
static void fatal(const char *message); |
| 3126 |
static void fatal(tostrstream& message); |
| 3127 |
|
| 3128 |
static void fatal(const char *function, const char *message); |
| 3129 |
static void fatal(const char *function, tostrstream& message); |
| 3130 |
|
| 3131 |
static void fatal(const char *class_name, const char *method, const char *message); |
| 3132 |
static void fatal(const char *class_name, const char *method, tostrstream& message); |
| 3133 |
|
| 3134 |
// can't turn off fatals - no ``static void fatal(bool value);'' |
| 3135 |
static zero_arg_error_handler_t fatal(); // return the fatal handler |
| 3136 |
static void fatal(zero_arg_error_handler_t handler); // change the fatal handler |
| 3137 |
|
| 3138 |
static void fatal_is_exit(); // change the fatal handler |
| 3139 |
static void fatal_is_abort(); // change the fatal handler |
| 3140 |
|
| 3141 |
// Describes the fatal handler - WATCHOUT - implicitly uses AllocRing |
| 3142 |
static const char *fatal_handler_description(); |
| 3143 |
private: |
| 3144 |
// |
| 3145 |
// Two underscores are used here in order to prevent confusion of these |
| 3146 |
// private variables with any of the heir's private variables. Note that |
| 3147 |
// access control is different than visibility in C++, so all the variable |
| 3148 |
// names in a class hierarchy must be unique. |
| 3149 |
// |
| 3150 |
static bool __debug; |
| 3151 |
static bool __note; |
| 3152 |
static bool __warning; |
| 3153 |
static void (*__error_handler)(); // can't turn off errors |
| 3154 |
static void (*__fatal_handler)(); // can't turn off fatals |
| 3155 |
|
| 3156 |
static bool __partial_init; |
| 3157 |
static void __partial_initialize(); |
| 3158 |
static bool __full_init; |
| 3159 |
static void __full_initialize(const char *program); |
| 3160 |
static char *__program; |
| 3161 |
|
| 3162 |
static void __handle_error(); |
| 3163 |
static void __handle_fatal(); |
| 3164 |
static void __add_newline(const char *message); |
| 3165 |
static void __message_switch(bool value, bool& flag, const char *description); |
| 3166 |
static void __message_switch(bool value, bool& flag); |
| 3167 |
static const char *__describe_handler(zero_arg_error_handler_t handler); |
| 3168 |
|
| 3169 |
static bool __output_valid(); |
| 3170 |
static ostream *__output; |
| 3171 |
|
| 3172 |
// GPP_1_96_BUG |
| 3173 |
const char *class_name() const; |
| 3174 |
// GPP_1_96_BUG |
| 3175 |
}; |
| 3176 |
|
| 3177 |
|
| 3178 |
//# 29 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 |
| 3179 |
|
| 3180 |
|
| 3181 |
// |
| 3182 |
// GctObject class (is abstract) |
| 3183 |
// |
| 3184 |
class GctObject: virtual public GctErrorHandler /*, virtual public GttObject*/ { |
| 3185 |
protected: |
| 3186 |
GctObject(); |
| 3187 |
GctObject(const GctObject&); |
| 3188 |
virtual ~GctObject(); // ensure descendants have virtual destructors |
| 3189 |
|
| 3190 |
public: |
| 3191 |
// |
| 3192 |
// I/O Support |
| 3193 |
// |
| 3194 |
// The value typically persists only long enough for an i/o operation |
| 3195 |
// to be performed (see the defintion of output via operator<<(... ) below) |
| 3196 |
virtual const char *stringify(); |
| 3197 |
protected: |
| 3198 |
// This is the buffer into which the printed representation of this |
| 3199 |
// object will be put when the time comes. It is associated with the |
| 3200 |
// object so it will never go away (so long as the object exists). |
| 3201 |
// Use a pointer so that you only pay for the space when I/O is used |
| 3202 |
tostrstream *stringbuf; |
| 3203 |
void clear_stringbuf(); |
| 3204 |
|
| 3205 |
public: |
| 3206 |
// |
| 3207 |
// Consistency (global consistency) |
| 3208 |
// |
| 3209 |
// The global data invariant for the whole object (heirs included). |
| 3210 |
// This OK function will call the local invariant function ok() if |
| 3211 |
// necessary and in addition the OK functions of the heirs |
| 3212 |
// This is expected to compute the data invariant of the object. |
| 3213 |
// It will execute GctErrorHandler::fatal if there is wrong. |
| 3214 |
virtual void OK() const; |
| 3215 |
|
| 3216 |
protected: |
| 3217 |
// |
| 3218 |
// consistency (local consistency) |
| 3219 |
// |
| 3220 |
// This function computes the invariant which is local to this object. |
| 3221 |
// It does not call any of the ancestor's OK() or ok() functions. |
| 3222 |
// It is not a virtual function so that it can be called from within a |
| 3223 |
// constructor with impunity. Thus this function MUST NOT call any |
| 3224 |
// virtual functions either; it should call them by their full name if |
| 3225 |
// that is necessary. The global OK() function will call this function |
| 3226 |
// as necessary. |
| 3227 |
// |
| 3228 |
// This function must NOT NEVER EVER be made virtual. |
| 3229 |
void ok() const; |
| 3230 |
protected: |
| 3231 |
// |
| 3232 |
// Class Name |
| 3233 |
// |
| 3234 |
// This must return a static (constant) string which is the name |
| 3235 |
// of the class being declared. By convention, not all classes |
| 3236 |
// must have one of these, but the major root abstract class must |
| 3237 |
// have one in order to allow the stringify() to work approximately |
| 3238 |
// correctly. |
| 3239 |
virtual const char *class_name() const = 0; |
| 3240 |
|
| 3241 |
public: |
| 3242 |
// |
| 3243 |
// The ``id'' of this object |
| 3244 |
// |
| 3245 |
// NOTE - we explicitly allow the situation where this function |
| 3246 |
// can return the address of the object - the ``this'' pointer |
| 3247 |
// instead of a computed id field (the __object_id field below). |
| 3248 |
// |
| 3249 |
// This function is protected because we don't want too much dependence |
| 3250 |
// on this notion of object identity. I want to be able to rip it |
| 3251 |
// out if it becomes to cumbersome. |
| 3252 |
unsigned objectId() const; |
| 3253 |
private: |
| 3254 |
// |
| 3255 |
// Symbolic ID |
| 3256 |
// |
| 3257 |
// NOTE - Normally this would be implemented by the `this' pointer. |
| 3258 |
// TODO - remove this for production code |
| 3259 |
// |
| 3260 |
// However, in order to make the test suites run on all machines, we |
| 3261 |
// make this into a symbolic id that is maintained with each object. |
| 3262 |
// Thus the valid outputs are always consistent across all machines. |
| 3263 |
unsigned __object_id; |
| 3264 |
static unsigned __next_id; |
| 3265 |
}; |
| 3266 |
|
| 3267 |
//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 |
| 3268 |
// This is part of the iostream library, providing -*- C++ -*- input/output. |
| 3269 |
// Copyright (C) 1991 Per Bothner. |
| 3270 |
// |
| 3271 |
// This library is free software; you can redistribute it and/or |
| 3272 |
// modify it under the terms of the GNU Library General Public |
| 3273 |
// License as published by the Free Software Foundation; either |
| 3274 |
// version 2 of the License, or (at your option) any later version. |
| 3275 |
// |
| 3276 |
// This library is distributed in the hope that it will be useful, |
| 3277 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 3278 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 3279 |
// Library General Public License for more details. |
| 3280 |
// |
| 3281 |
// You should have received a copy of the GNU Library General Public |
| 3282 |
// License along with this library; if not, write to the Free |
| 3283 |
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 3284 |
|
| 3285 |
//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" |
| 3286 |
|
| 3287 |
//# 117 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 |
| 3288 |
|
| 3289 |
extern ostream& operator<<(ostream&, GctObject&); |
| 3290 |
|
| 3291 |
|
| 3292 |
//# 25 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 2 |
| 3293 |
|
| 3294 |
|
| 3295 |
// |
| 3296 |
// GctHashObject class (is abstract) |
| 3297 |
// |
| 3298 |
class GctHashObject: virtual public GctObject { |
| 3299 |
protected: |
| 3300 |
GctHashObject(); |
| 3301 |
GctHashObject(const GctHashObject&); |
| 3302 |
|
| 3303 |
public: |
| 3304 |
// |
| 3305 |
// hash support |
| 3306 |
// |
| 3307 |
virtual unsigned hash() const; |
| 3308 |
}; |
| 3309 |
|
| 3310 |
|
| 3311 |
//# 28 "../../GctSymbol.h" 2 |
| 3312 |
|
| 3313 |
|
| 3314 |
// |
| 3315 |
// GctSymbol |
| 3316 |
// |
| 3317 |
class GctSymbol: virtual public GctHashObject, String { |
| 3318 |
public: |
| 3319 |
GctSymbol(); // vacuous symbol required for genclass usage |
| 3320 |
GctSymbol(const char*); |
| 3321 |
GctSymbol(const String&); |
| 3322 |
GctSymbol(const GctSymbol&); |
| 3323 |
|
| 3324 |
operator const char *() const; |
| 3325 |
|
| 3326 |
bool operator==(const GctSymbol&) const; |
| 3327 |
bool operator!=(const GctSymbol&) const; |
| 3328 |
|
| 3329 |
bool operator<=(const GctSymbol&) const; |
| 3330 |
bool operator<(const GctSymbol&) const; |
| 3331 |
bool operator>=(const GctSymbol&) const; |
| 3332 |
bool operator>(const GctSymbol&) const; |
| 3333 |
|
| 3334 |
unsigned hash() const; |
| 3335 |
|
| 3336 |
// I/O Support |
| 3337 |
const char *stringify(); |
| 3338 |
|
| 3339 |
// Consistency |
| 3340 |
void OK() const; |
| 3341 |
private: |
| 3342 |
const char *class_name() const; |
| 3343 |
}; |
| 3344 |
|
| 3345 |
extern unsigned hash(GctSymbol&); // genclass support (no const) |
| 3346 |
|
| 3347 |
// |
| 3348 |
// Inline functions |
| 3349 |
// |
| 3350 |
// Note - none of the String operators save for operator const char *() |
| 3351 |
// are String member functions, instead, they are anonymous functions |
| 3352 |
// which work by overloading. |
| 3353 |
// |
| 3354 |
|
| 3355 |
|
| 3356 |
|
| 3357 |
|
| 3358 |
|
| 3359 |
GctSymbol::operator const char *() const |
| 3360 |
{ |
| 3361 |
|
| 3362 |
|
| 3363 |
|
| 3364 |
|
| 3365 |
|
| 3366 |
return String::operator const char *(); |
| 3367 |
} |
| 3368 |
|
| 3369 |
bool |
| 3370 |
GctSymbol::operator==(const GctSymbol& other) const |
| 3371 |
{ |
| 3372 |
|
| 3373 |
|
| 3374 |
|
| 3375 |
|
| 3376 |
|
| 3377 |
return (bool)::operator==(*this, other); |
| 3378 |
} |
| 3379 |
|
| 3380 |
bool |
| 3381 |
GctSymbol::operator!=(const GctSymbol& other) const |
| 3382 |
{ |
| 3383 |
|
| 3384 |
|
| 3385 |
|
| 3386 |
|
| 3387 |
|
| 3388 |
return (bool)::operator!=(*this, other); |
| 3389 |
} |
| 3390 |
|
| 3391 |
bool |
| 3392 |
GctSymbol::operator<=(const GctSymbol& other) const |
| 3393 |
{ |
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
|
| 3398 |
|
| 3399 |
return (bool)::operator<=(*this, other); |
| 3400 |
} |
| 3401 |
|
| 3402 |
bool |
| 3403 |
GctSymbol::operator<(const GctSymbol& other) const |
| 3404 |
{ |
| 3405 |
|
| 3406 |
|
| 3407 |
|
| 3408 |
|
| 3409 |
|
| 3410 |
return (bool)::operator<(*this, other); |
| 3411 |
} |
| 3412 |
|
| 3413 |
bool |
| 3414 |
GctSymbol::operator>=(const GctSymbol& other) const |
| 3415 |
{ |
| 3416 |
|
| 3417 |
|
| 3418 |
|
| 3419 |
|
| 3420 |
|
| 3421 |
return (bool)::operator>=(*this, other); |
| 3422 |
} |
| 3423 |
|
| 3424 |
bool |
| 3425 |
GctSymbol::operator>(const GctSymbol& other) const |
| 3426 |
{ |
| 3427 |
|
| 3428 |
|
| 3429 |
|
| 3430 |
|
| 3431 |
|
| 3432 |
return (bool)::operator>(*this, other); |
| 3433 |
} |
| 3434 |
|
| 3435 |
|
| 3436 |
//# 25 "GctSymbol.defs.h" 2 |
| 3437 |
|
| 3438 |
|
| 3439 |
// equality operator |
| 3440 |
|
| 3441 |
|
| 3442 |
|
| 3443 |
|
| 3444 |
// less-than-or-equal |
| 3445 |
|
| 3446 |
|
| 3447 |
|
| 3448 |
|
| 3449 |
// comparison : less-than -> 0 |
| 3450 |
|
| 3451 |
|
| 3452 |
|
| 3453 |
|
| 3454 |
// hash function |
| 3455 |
|
| 3456 |
extern unsigned int hash(GctSymbol&); |
| 3457 |
|
| 3458 |
|
| 3459 |
|
| 3460 |
// initial capacity for structures requiring one |
| 3461 |
|
| 3462 |
|
| 3463 |
|
| 3464 |
|
| 3465 |
|
| 3466 |
|
| 3467 |
|
| 3468 |
//# 27 "GctSymbol.GctSymbol.Map.h" 2 |
| 3469 |
|
| 3470 |
|
| 3471 |
class GctSymbolGctSymbolMap |
| 3472 |
{ |
| 3473 |
protected: |
| 3474 |
int count; |
| 3475 |
GctSymbol def; |
| 3476 |
|
| 3477 |
public: |
| 3478 |
GctSymbolGctSymbolMap(GctSymbol& dflt); |
| 3479 |
virtual ~GctSymbolGctSymbolMap(); |
| 3480 |
|
| 3481 |
int length(); // current number of items |
| 3482 |
int empty(); |
| 3483 |
|
| 3484 |
virtual int contains(GctSymbol& key); // is key mapped? |
| 3485 |
|
| 3486 |
virtual void clear(); // delete all items |
| 3487 |
|
| 3488 |
virtual GctSymbol& operator [] (GctSymbol& key) = 0; // access contents by key |
| 3489 |
|
| 3490 |
virtual void del(GctSymbol& key) = 0; // delete entry |
| 3491 |
|
| 3492 |
virtual Pix first() = 0; // Pix of first item or 0 |
| 3493 |
virtual void next(Pix& i) = 0; // advance to next or 0 |
| 3494 |
virtual GctSymbol& key(Pix i) = 0; // access key at i |
| 3495 |
virtual GctSymbol& contents(Pix i) = 0; // access contents at i |
| 3496 |
|
| 3497 |
virtual int owns(Pix i); // is i a valid Pix ? |
| 3498 |
virtual Pix seek(GctSymbol& key); // Pix of key |
| 3499 |
|
| 3500 |
GctSymbol& dflt(); // access default val |
| 3501 |
|
| 3502 |
void error(const char* msg); |
| 3503 |
virtual int OK() = 0; // rep invariant |
| 3504 |
}; |
| 3505 |
|
| 3506 |
|
| 3507 |
|
| 3508 |
inline GctSymbolGctSymbolMap::~GctSymbolGctSymbolMap() {} |
| 3509 |
|
| 3510 |
inline int GctSymbolGctSymbolMap::length() |
| 3511 |
{ |
| 3512 |
return count; |
| 3513 |
} |
| 3514 |
|
| 3515 |
inline int GctSymbolGctSymbolMap::empty() |
| 3516 |
{ |
| 3517 |
return count == 0; |
| 3518 |
} |
| 3519 |
|
| 3520 |
inline GctSymbol& GctSymbolGctSymbolMap::dflt() |
| 3521 |
{ |
| 3522 |
return def; |
| 3523 |
} |
| 3524 |
|
| 3525 |
inline GctSymbolGctSymbolMap::GctSymbolGctSymbolMap(GctSymbol& dflt) :def(dflt) |
| 3526 |
{ |
| 3527 |
count = 0; |
| 3528 |
} |
| 3529 |
|
| 3530 |
|
| 3531 |
|
| 3532 |
|
| 3533 |
//# 26 "GctSymbol.GctSymbol.CHMap.h" 2 |
| 3534 |
|
| 3535 |
|
| 3536 |
|
| 3537 |
|
| 3538 |
|
| 3539 |
struct GctSymbolGctSymbolCHNode |
| 3540 |
{ |
| 3541 |
GctSymbolGctSymbolCHNode* tl; |
| 3542 |
GctSymbol hd; |
| 3543 |
GctSymbol cont; |
| 3544 |
GctSymbolGctSymbolCHNode(); |
| 3545 |
GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t = 0); |
| 3546 |
~GctSymbolGctSymbolCHNode(); |
| 3547 |
}; |
| 3548 |
|
| 3549 |
|
| 3550 |
|
| 3551 |
inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode() {} |
| 3552 |
|
| 3553 |
inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t) |
| 3554 |
: hd(h), cont(c), tl(t) {} |
| 3555 |
|
| 3556 |
inline GctSymbolGctSymbolCHNode::~GctSymbolGctSymbolCHNode() {} |
| 3557 |
|
| 3558 |
|
| 3559 |
|
| 3560 |
|
| 3561 |
typedef GctSymbolGctSymbolCHNode* GctSymbolGctSymbolCHNodePtr; |
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
class GctSymbolGctSymbolCHMap : public GctSymbolGctSymbolMap |
| 3567 |
{ |
| 3568 |
protected: |
| 3569 |
GctSymbolGctSymbolCHNode** tab; |
| 3570 |
unsigned int size; |
| 3571 |
|
| 3572 |
public: |
| 3573 |
GctSymbolGctSymbolCHMap(GctSymbol& dflt,unsigned int sz=100 ); |
| 3574 |
GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a); |
| 3575 |
~GctSymbolGctSymbolCHMap(); |
| 3576 |
|
| 3577 |
GctSymbol& operator [] (GctSymbol& key); |
| 3578 |
|
| 3579 |
void del(GctSymbol& key); |
| 3580 |
|
| 3581 |
Pix first(); |
| 3582 |
void next(Pix& i); |
| 3583 |
GctSymbol& key(Pix i); |
| 3584 |
GctSymbol& contents(Pix i); |
| 3585 |
|
| 3586 |
Pix seek(GctSymbol& key); |
| 3587 |
int contains(GctSymbol& key); |
| 3588 |
|
| 3589 |
void clear(); |
| 3590 |
int OK(); |
| 3591 |
}; |
| 3592 |
|
| 3593 |
|
| 3594 |
|
| 3595 |
inline GctSymbolGctSymbolCHMap::~GctSymbolGctSymbolCHMap() |
| 3596 |
{ |
| 3597 |
clear(); |
| 3598 |
delete tab; |
| 3599 |
} |
| 3600 |
|
| 3601 |
inline int GctSymbolGctSymbolCHMap::contains(GctSymbol& key) |
| 3602 |
{ |
| 3603 |
return seek(key) != 0; |
| 3604 |
} |
| 3605 |
|
| 3606 |
inline GctSymbol& GctSymbolGctSymbolCHMap::key(Pix p) |
| 3607 |
{ |
| 3608 |
if (p == 0) error("null Pix"); |
| 3609 |
return ((GctSymbolGctSymbolCHNode*)p)->hd; |
| 3610 |
} |
| 3611 |
|
| 3612 |
inline GctSymbol& GctSymbolGctSymbolCHMap::contents(Pix p) |
| 3613 |
{ |
| 3614 |
if (p == 0) error("null Pix"); |
| 3615 |
return ((GctSymbolGctSymbolCHNode*)p)->cont; |
| 3616 |
} |
| 3617 |
|
| 3618 |
|
| 3619 |
|
| 3620 |
|
| 3621 |
//# 22 "GctSymbol.GctSymbol.CHMap.cc" 2 |
| 3622 |
|
| 3623 |
|
| 3624 |
// The nodes are linked together serially via a version |
| 3625 |
// of a trick used in some vtables: odd pointers are |
| 3626 |
// actually links to the next table entry. |
| 3627 |
// Not terrible, but not wonderful either |
| 3628 |
|
| 3629 |
static inline int goodCHptr(GctSymbolGctSymbolCHNode* t) |
| 3630 |
{ |
| 3631 |
return ((((unsigned)t) & 1) == 0); |
| 3632 |
} |
| 3633 |
|
| 3634 |
static inline GctSymbolGctSymbolCHNode* index_to_CHptr(int i) |
| 3635 |
{ |
| 3636 |
return (GctSymbolGctSymbolCHNode*)((i << 1) + 1); |
| 3637 |
} |
| 3638 |
|
| 3639 |
static inline int CHptr_to_index(GctSymbolGctSymbolCHNode* t) |
| 3640 |
{ |
| 3641 |
return ( ((unsigned) t) >> 1); |
| 3642 |
} |
| 3643 |
|
| 3644 |
GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbol& dflt, unsigned int sz) |
| 3645 |
:GctSymbolGctSymbolMap(dflt) |
| 3646 |
{ |
| 3647 |
tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = sz]); |
| 3648 |
for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); |
| 3649 |
count = 0; |
| 3650 |
} |
| 3651 |
|
| 3652 |
GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a) :GctSymbolGctSymbolMap(a.def) |
| 3653 |
{ |
| 3654 |
tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = a.size]); |
| 3655 |
for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); |
| 3656 |
count = 0; |
| 3657 |
for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); // { dg-bogus "" } type `GctSymbol' is derived from private `String' |
| 3658 |
} |