Mercurial > projects > ldc
annotate dmd2/root/lstring.h @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 638d16625da2 |
children |
rev | line source |
---|---|
1452
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
1 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
2 // lstring.h |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
3 // length-prefixed strings |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
4 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
5 // Copyright (c) 1999-2002 by Digital Mars |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
6 // All Rights Reserved |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
7 // written by Walter Bright |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
8 // www.digitalmars.com |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
9 // License for redistribution is by either the Artistic License |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
10 // in artistic.txt, or the GNU General Public License in gnu.txt. |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
11 // See the included readme.txt for details. |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
12 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
13 #ifndef LSTRING_H |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
14 #define LSTRING_H 1 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
15 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
16 #include "dchar.h" |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
17 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
18 struct Lstring |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
19 { |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
20 unsigned length; |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
21 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
22 // Disable warning about nonstandard extension |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
23 #pragma warning (disable : 4200) |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
24 dchar string[]; |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
25 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
26 static Lstring zero; // 0 length string |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
27 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
28 // No constructors because we want to be able to statically |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
29 // initialize Lstring's, and Lstrings are of variable size. |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
30 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
31 #if M_UNICODE |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
32 #define LSTRING(p,length) { length, L##p } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
33 #else |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
34 #define LSTRING(p,length) { length, p } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
35 #endif |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
36 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
37 #if __GNUC__ |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
38 #define LSTRING_EMPTY() { 0 } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
39 #else |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
40 #define LSTRING_EMPTY() LSTRING("", 0) |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
41 #endif |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
42 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
43 static Lstring *ctor(const dchar *p) { return ctor(p, Dchar::len(p)); } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
44 static Lstring *ctor(const dchar *p, unsigned length); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
45 static unsigned size(unsigned length) { return sizeof(Lstring) + (length + 1) * sizeof(dchar); } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
46 static Lstring *alloc(unsigned length); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
47 Lstring *clone(); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
48 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
49 unsigned len() { return length; } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
50 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
51 dchar *toDchars() { return string; } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
52 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
53 hash_t hash() { return Dchar::calcHash(string, length); } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
54 hash_t ihash() { return Dchar::icalcHash(string, length); } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
55 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
56 static int cmp(const Lstring *s1, const Lstring *s2) |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
57 { |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
58 int c = s2->length - s1->length; |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
59 return c ? c : Dchar::memcmp(s1->string, s2->string, s1->length); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
60 } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
61 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
62 static int icmp(const Lstring *s1, const Lstring *s2) |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
63 { |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
64 int c = s2->length - s1->length; |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
65 return c ? c : Dchar::memicmp(s1->string, s2->string, s1->length); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
66 } |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
67 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
68 Lstring *append(const Lstring *s); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
69 Lstring *substring(int start, int end); |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
70 }; |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
71 |
638d16625da2
LDC 2 compiles again.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff
changeset
|
72 #endif |