Skip to content

Commit 31d85d0

Browse files
committed
Merge pull request #398 from ldc-developers/merge-2.063
DMD 2.063.1 merge
2 parents 40926ea + 46e699b commit 31d85d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+10760
-8405
lines changed

dmd2/aggregate.h

+29-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
// Compiler implementation of the D programming language
3-
// Copyright (c) 1999-2012 by Digital Mars
3+
// Copyright (c) 1999-2013 by Digital Mars
44
// All Rights Reserved
55
// written by Walter Bright
66
// http://www.digitalmars.com
@@ -18,6 +18,7 @@
1818
#include "root.h"
1919

2020
#include "dsymbol.h"
21+
#include "declaration.h"
2122

2223
#if IN_LLVM
2324
#include <vector>
@@ -74,29 +75,32 @@ struct AggregateDeclaration : ScopeDsymbol
7475
bool isdeprecated; // !=0 if deprecated
7576

7677
#if DMDV2
77-
bool isnested; // !=0 if is nested
78+
Dsymbol *enclosing; /* !=NULL if is nested
79+
* pointing to the dsymbol that directly enclosing it.
80+
* 1. The function that enclosing it (nested struct and class)
81+
* 2. The class that enclosing it (nested class only)
82+
* 3. If enclosing aggregate is template, its enclosing dsymbol.
83+
* See AggregateDeclaraton::makeNested for the details.
84+
*/
7885
VarDeclaration *vthis; // 'this' parameter if this aggregate is nested
7986
#endif
8087
// Special member functions
81-
InvariantDeclaration *inv; // invariant
88+
FuncDeclarations invs; // Array of invariants
89+
FuncDeclaration *inv; // invariant
8290
NewDeclaration *aggNew; // allocator
8391
DeleteDeclaration *aggDelete; // deallocator
8492

8593
#if DMDV2
86-
//CtorDeclaration *ctor;
8794
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
88-
CtorDeclaration *defaultCtor; // default constructor
95+
CtorDeclaration *defaultCtor; // default constructor - should have no arguments, because
96+
// it would be stored in TypeInfo_Class.defaultConstructor
8997
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
9098
bool noDefaultCtor; // no default construction
9199
#endif
92100

93101
FuncDeclarations dtors; // Array of destructors
94102
FuncDeclaration *dtor; // aggregate destructor
95103

96-
#ifdef IN_GCC
97-
Expressions *attributes; // GCC decl/type attributes
98-
#endif
99-
100104
Expression *getRTInfo; // pointer to GC info generated by object.RTInfo(this)
101105

102106
AggregateDeclaration(Loc loc, Identifier *id);
@@ -112,18 +116,21 @@ struct AggregateDeclaration : ScopeDsymbol
112116
Type *getType();
113117
int firstFieldInUnion(int indx); // first field in union that includes indx
114118
int numFieldsInUnion(int firstIndex); // #fields in union starting at index
115-
int isDeprecated(); // is aggregate deprecated?
119+
bool isDeprecated(); // is aggregate deprecated?
116120
FuncDeclaration *buildDtor(Scope *sc);
117-
int isNested();
121+
FuncDeclaration *buildInv(Scope *sc);
122+
bool isNested();
123+
void makeNested();
118124
int isExport();
119125

120126
void emitComment(Scope *sc);
121127
void toJson(JsonOut *json);
122128
void toDocBuffer(OutBuffer *buf, Scope *sc);
123129

124-
FuncDeclaration *hasIdentityOpAssign(Scope *sc, Dsymbol *assign);
130+
FuncDeclaration *hasIdentityOpAssign(Scope *sc);
131+
FuncDeclaration *hasIdentityOpEquals(Scope *sc);
125132

126-
char *mangle(bool isv = false);
133+
const char *mangle(bool isv = false);
127134

128135
// For access checking
129136
virtual PROT getAccess(Dsymbol *smember); // determine access to smember
@@ -173,7 +180,7 @@ struct StructDeclaration : AggregateDeclaration
173180
void semantic(Scope *sc);
174181
Dsymbol *search(Loc, Identifier *ident, int flags);
175182
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
176-
char *mangle(bool isv = false);
183+
const char *mangle(bool isv = false);
177184
const char *kind();
178185
void finalizeSize(Scope *sc);
179186
bool isPOD();
@@ -184,12 +191,10 @@ struct StructDeclaration : AggregateDeclaration
184191
int needOpAssign();
185192
int needOpEquals();
186193
FuncDeclaration *buildOpAssign(Scope *sc);
187-
FuncDeclaration *buildOpEquals(Scope *sc);
188194
FuncDeclaration *buildPostBlit(Scope *sc);
189195
FuncDeclaration *buildCpCtor(Scope *sc);
190-
196+
FuncDeclaration *buildOpEquals(Scope *sc);
191197
FuncDeclaration *buildXopEquals(Scope *sc);
192-
void makeNested();
193198
#endif
194199
void toDocBuffer(OutBuffer *buf, Scope *sc);
195200

@@ -273,16 +278,16 @@ struct ClassDeclaration : AggregateDeclaration
273278

274279
BaseClasses *vtblInterfaces; // array of base interfaces that have
275280
// their own vtbl[]
281+
276282
TypeInfoClassDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration
277283
int com; // !=0 if this is a COM class (meaning
278284
// it derives from IUnknown)
279-
int isscope; // !=0 if this is an auto class
285+
int isscope; // !=0 if this is an auto class
280286
int isabstract; // !=0 if abstract class
281-
#if DMDV1
282-
bool isnested; // !=0 if is nested
283-
VarDeclaration *vthis; // 'this' parameter if this class is nested
284-
#endif
285287
int inuse; // to prevent recursive attempts
288+
enum Semantic doAncestorsSemantic; // Before searching symbol, whole ancestors should finish
289+
// calling semantic() at least once, due to fill symtab
290+
// and do addMember(). [== Semantic(Start,In,Done)]
286291

287292
ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
288293
Dsymbol *syntaxCopy(Dsymbol *s);
@@ -295,15 +300,12 @@ struct ClassDeclaration : AggregateDeclaration
295300

296301
virtual int isBaseInfoComplete();
297302
Dsymbol *search(Loc, Identifier *ident, int flags);
298-
Dsymbol *searchBase(Loc, Identifier *ident);
303+
ClassDeclaration *searchBase(Loc, Identifier *ident);
299304
#if DMDV2
300305
int isFuncHidden(FuncDeclaration *fd);
301306
#endif
302307
FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf);
303308
void interfaceSemantic(Scope *sc);
304-
#if DMDV1
305-
int isNested();
306-
#endif
307309
int isCOMclass();
308310
virtual int isCOMinterface();
309311
#if DMDV2
@@ -312,7 +314,7 @@ struct ClassDeclaration : AggregateDeclaration
312314
int isAbstract();
313315
virtual int vtblOffset();
314316
const char *kind();
315-
char *mangle(bool isv = false);
317+
const char *mangle(bool isv = false);
316318
void toDocBuffer(OutBuffer *buf, Scope *sc);
317319

318320
PROT getAccess(Dsymbol *smember); // determine access to smember

dmd2/aliasthis.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,22 @@ Expression *resolveAliasThis(Scope *sc, Expression *e)
3636
L1:
3737
if (ad && ad->aliasthis)
3838
{
39+
bool isstatic = (e->op == TOKtype);
3940
e = new DotIdExp(e->loc, e, ad->aliasthis->ident);
4041
e = e->semantic(sc);
42+
if (isstatic && ad->aliasthis->needThis())
43+
{
44+
/* non-@property function is not called inside typeof(),
45+
* so resolve it ahead.
46+
*/
47+
int save = sc->intypeof;
48+
sc->intypeof = 1; // bypass "need this" error check
49+
e = resolveProperties(sc, e);
50+
sc->intypeof = save;
51+
52+
e = new TypeExp(e->loc, new TypeTypeof(e->loc, e));
53+
e = e->semantic(sc);
54+
}
4155
e = resolveProperties(sc, e);
4256
}
4357
}
@@ -74,7 +88,7 @@ void AliasThis::semantic(Scope *sc)
7488
assert(ad->members);
7589
Dsymbol *s = ad->search(loc, ident, 0);
7690
if (!s)
77-
{ s = sc->search(loc, ident, 0);
91+
{ s = sc->search(loc, ident, NULL);
7892
if (s)
7993
::error(loc, "%s is not a member of %s", s->toChars(), ad->toChars());
8094
else

dmd2/apply.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ int Expression::apply(fp_t fp, void *param)
3636
/******************************
3737
* Perform apply() on an t if not null
3838
*/
39-
template<typename T>
40-
int condApply(T* t, fp_t fp, void* param)
41-
{
42-
return t ? t->apply(fp, param) : 0;
43-
}
44-
39+
#define condApply(t, fp, param) (t ? t->apply(fp, param) : 0)
4540

4641
int NewExp::apply(int (*fp)(Expression *, void *), void *param)
4742
{
@@ -129,14 +124,20 @@ int AssocArrayLiteralExp::apply(fp_t fp, void *param)
129124

130125
int StructLiteralExp::apply(fp_t fp, void *param)
131126
{
132-
return condApply(elements, fp, param) ||
127+
if(stageflags & stageApply) return 0;
128+
int old = stageflags;
129+
stageflags |= stageApply;
130+
int ret = condApply(elements, fp, param) ||
133131
(*fp)(this, param);
132+
stageflags = old;
133+
return ret;
134134
}
135135

136136

137137
int TupleExp::apply(fp_t fp, void *param)
138138
{
139-
return condApply(exps, fp, param) ||
139+
return (e0 ? (*fp)(e0, param) : 0) ||
140+
condApply(exps, fp, param) ||
140141
(*fp)(this, param);
141142
}
142143

dmd2/argtypes.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include "aggregate.h"
2727
#include "hdrgen.h"
2828

29-
#define tfloat2 tfloat64
30-
//#define tfloat2 tcomplex32
31-
3229
/****************************************************
3330
* This breaks a type down into 'simpler' types that can be passed to a function
3431
* in registers, and returned in registers.
@@ -84,7 +81,7 @@ TypeTuple *TypeBasic::toArgTypes()
8481

8582
case Tcomplex32:
8683
if (global.params.is64bit)
87-
t1 = Type::tfloat2;
84+
t1 = Type::tfloat64;
8885
else
8986
{
9087
t1 = Type::tfloat64;
@@ -223,16 +220,16 @@ Type *argtypemerge(Type *t1, Type *t2, unsigned offset2)
223220
if (!t2)
224221
return t1;
225222

226-
unsigned sz1 = t1->size(0);
227-
unsigned sz2 = t2->size(0);
223+
unsigned sz1 = t1->size(Loc());
224+
unsigned sz2 = t2->size(Loc());
228225

229226
if (t1->ty != t2->ty &&
230227
(t1->ty == Tfloat80 || t2->ty == Tfloat80))
231228
return NULL;
232229

233230
// [float,float] => [cfloat]
234231
if (t1->ty == Tfloat32 && t2->ty == Tfloat32 && offset2 == 4)
235-
return Type::tfloat2;
232+
return Type::tfloat64;
236233

237234
// Merging floating and non-floating types produces the non-floating type
238235
if (t1->isfloating())
@@ -287,7 +284,7 @@ TypeTuple *TypeStruct::toArgTypes()
287284
}
288285
Type *t1 = NULL;
289286
Type *t2 = NULL;
290-
d_uns64 sz = size(0);
287+
d_uns64 sz = size(Loc());
291288
assert(sz < 0xFFFFFFFF);
292289
switch ((unsigned)sz)
293290
{
@@ -349,7 +346,7 @@ TypeTuple *TypeStruct::toArgTypes()
349346
goto Lmemory;
350347

351348
// Fields that overlap the 8byte boundary goto Lmemory
352-
unsigned fieldsz = f->type->size(0);
349+
unsigned fieldsz = f->type->size(Loc());
353350
if (f->offset < 8 && (f->offset + fieldsz) > 8)
354351
goto Lmemory;
355352
}

0 commit comments

Comments
 (0)