mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Minimize differences between original dmd source and ldc1.
Mainly affects formatting but I also found some code differences.
This commit is contained in:
@@ -257,7 +257,7 @@ struct ClassDeclaration : AggregateDeclaration
|
||||
ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration
|
||||
int com; // !=0 if this is a COM class (meaning
|
||||
// it derives from IUnknown)
|
||||
int isscope; // !=0 if this is a scope class
|
||||
int isscope; // !=0 if this is an auto class
|
||||
int isabstract; // !=0 if abstract class
|
||||
#if DMDV1
|
||||
int isnested; // !=0 if is nested
|
||||
|
||||
188
dmd/argtypes.c
Normal file
188
dmd/argtypes.c
Normal file
@@ -0,0 +1,188 @@
|
||||
|
||||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 2010-2011 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// http://www.dsource.org/projects/dmd/browser/branches/dmd-1.x/src/argtypes.c
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "mars.h"
|
||||
#include "dsymbol.h"
|
||||
#include "mtype.h"
|
||||
#include "scope.h"
|
||||
#include "init.h"
|
||||
#include "expression.h"
|
||||
#include "attrib.h"
|
||||
#include "declaration.h"
|
||||
#include "template.h"
|
||||
#include "id.h"
|
||||
#include "enum.h"
|
||||
#include "import.h"
|
||||
#include "aggregate.h"
|
||||
#include "hdrgen.h"
|
||||
|
||||
/****************************************************
|
||||
* This breaks a type down into 'simpler' types that can be passed to a function
|
||||
* in registers, and returned in registers.
|
||||
* It's highly platform dependent.
|
||||
* Returning a tuple of zero length means the type cannot be passed/returned in registers.
|
||||
*/
|
||||
|
||||
|
||||
TypeTuple *Type::toArgTypes()
|
||||
{
|
||||
return NULL; // not valid for a parameter
|
||||
}
|
||||
|
||||
|
||||
TypeTuple *TypeBasic::toArgTypes()
|
||||
{ Type *t1 = NULL;
|
||||
Type *t2 = NULL;
|
||||
switch (ty)
|
||||
{
|
||||
case Tvoid:
|
||||
return NULL;
|
||||
|
||||
case Tbool:
|
||||
case Tint8:
|
||||
case Tuns8:
|
||||
case Tint16:
|
||||
case Tuns16:
|
||||
case Tint32:
|
||||
case Tuns32:
|
||||
case Tfloat32:
|
||||
case Tint64:
|
||||
case Tuns64:
|
||||
case Tfloat64:
|
||||
case Tfloat80:
|
||||
t1 = this;
|
||||
break;
|
||||
|
||||
case Timaginary32:
|
||||
t1 = Type::tfloat32;
|
||||
break;
|
||||
|
||||
case Timaginary64:
|
||||
t1 = Type::tfloat64;
|
||||
break;
|
||||
|
||||
case Timaginary80:
|
||||
t1 = Type::tfloat80;
|
||||
break;
|
||||
|
||||
case Tcomplex32:
|
||||
if (global.params.is64bit)
|
||||
t1 = Type::tfloat64; // weird, eh?
|
||||
else
|
||||
{
|
||||
t1 = Type::tfloat64;
|
||||
t2 = Type::tfloat64;
|
||||
}
|
||||
break;
|
||||
|
||||
case Tcomplex64:
|
||||
//t1 = Type::tfloat64;
|
||||
//t2 = Type::tfloat64;
|
||||
break;
|
||||
|
||||
case Tcomplex80:
|
||||
t1 = Type::tfloat80;
|
||||
t2 = Type::tfloat80;
|
||||
break;
|
||||
|
||||
case Tascii:
|
||||
t1 = Type::tuns8;
|
||||
break;
|
||||
|
||||
case Twchar:
|
||||
t1 = Type::tuns16;
|
||||
break;
|
||||
|
||||
case Tdchar:
|
||||
t1 = Type::tuns32;
|
||||
break;
|
||||
|
||||
default: assert(0);
|
||||
}
|
||||
|
||||
TypeTuple *t;
|
||||
if (t1)
|
||||
{
|
||||
if (t2)
|
||||
t = new TypeTuple(t1, t2);
|
||||
else
|
||||
t = new TypeTuple(t1);
|
||||
}
|
||||
else
|
||||
t = new TypeTuple();
|
||||
return t;
|
||||
}
|
||||
|
||||
TypeTuple *TypeSArray::toArgTypes()
|
||||
{
|
||||
#if DMDV2
|
||||
return new TypeTuple(); // pass on the stack for efficiency
|
||||
#else
|
||||
return new TypeTuple(Type::tvoidptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
TypeTuple *TypeDArray::toArgTypes()
|
||||
{
|
||||
return new TypeTuple(); // pass on the stack for efficiency
|
||||
}
|
||||
|
||||
TypeTuple *TypeAArray::toArgTypes()
|
||||
{
|
||||
return new TypeTuple(Type::tvoidptr);
|
||||
}
|
||||
|
||||
TypeTuple *TypePointer::toArgTypes()
|
||||
{
|
||||
return new TypeTuple(this);
|
||||
}
|
||||
|
||||
TypeTuple *TypeDelegate::toArgTypes()
|
||||
{
|
||||
return new TypeTuple(); // pass on the stack for efficiency
|
||||
}
|
||||
|
||||
TypeTuple *TypeStruct::toArgTypes()
|
||||
{
|
||||
d_uns64 sz = size(0);
|
||||
assert(sz < 0xFFFFFFFF);
|
||||
switch ((unsigned)sz)
|
||||
{
|
||||
case 1:
|
||||
return new TypeTuple(Type::tint8);
|
||||
case 2:
|
||||
return new TypeTuple(Type::tint16);
|
||||
case 4:
|
||||
return new TypeTuple(Type::tint32);
|
||||
case 8:
|
||||
return new TypeTuple(Type::tint64);
|
||||
}
|
||||
return new TypeTuple(); // pass on the stack
|
||||
}
|
||||
|
||||
TypeTuple *TypeEnum::toArgTypes()
|
||||
{
|
||||
return toBasetype()->toArgTypes();
|
||||
}
|
||||
|
||||
TypeTuple *TypeTypedef::toArgTypes()
|
||||
{
|
||||
return sym->basetype->toArgTypes();
|
||||
}
|
||||
|
||||
TypeTuple *TypeClass::toArgTypes()
|
||||
{
|
||||
return new TypeTuple(Type::tvoidptr);
|
||||
}
|
||||
|
||||
10
dmd/attrib.c
10
dmd/attrib.c
@@ -714,12 +714,15 @@ void AlignDeclaration::setScope(Scope *sc)
|
||||
|
||||
void AlignDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
// LDC
|
||||
// we only support packed structs, as from the spec: align(1) struct Packed { ... }
|
||||
// other alignments are simply ignored. my tests show this is what llvm-gcc does too ...
|
||||
// LDC
|
||||
// we only support packed structs, as from the spec: align(1) struct Packed { ... }
|
||||
// other alignments are simply ignored. my tests show this is what llvm-gcc does too ...
|
||||
if (decl)
|
||||
{
|
||||
semanticNewSc(sc, sc->stc, sc->linkage, sc->protection, sc->explicitProtection, salign);
|
||||
}
|
||||
else
|
||||
assert(0 && "what kind of align use triggers this?");
|
||||
}
|
||||
|
||||
|
||||
@@ -1130,6 +1133,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
goto Lnodecl;
|
||||
}
|
||||
else
|
||||
error("unrecognized pragma(%s)", ident->toChars());
|
||||
|
||||
@@ -57,7 +57,7 @@ struct AttribDeclaration : Dsymbol
|
||||
AttribDeclaration *isAttribDeclaration() { return this; }
|
||||
|
||||
#if IN_DMD
|
||||
virtual void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
int cvMember(unsigned char *p);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -404,12 +404,11 @@ MATCH StringExp::implicitConvTo(Type *t)
|
||||
printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n",
|
||||
toChars(), committed, type->toChars(), t->toChars());
|
||||
#endif
|
||||
if (!committed)
|
||||
{
|
||||
if (!committed && t->ty == Tpointer && t->next->ty == Tvoid)
|
||||
{
|
||||
return MATCHnomatch;
|
||||
}
|
||||
if (!committed)
|
||||
if (type->ty == Tsarray || type->ty == Tarray || type->ty == Tpointer)
|
||||
{
|
||||
if (type->next->ty == Tchar)
|
||||
@@ -428,12 +427,13 @@ MATCH StringExp::implicitConvTo(Type *t)
|
||||
L1:
|
||||
if (t->next->ty == Tchar)
|
||||
return MATCHexact;
|
||||
else if (t->next->ty == Twchar)
|
||||
else if (!committed)
|
||||
{ if (t->next->ty == Twchar)
|
||||
return MATCHexact;
|
||||
else if (t->next->ty == Tdchar)
|
||||
return MATCHexact;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ int ComplexExp::isConst()
|
||||
|
||||
int NullExp::isConst()
|
||||
{
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SymOffExp::isConst()
|
||||
|
||||
@@ -671,7 +671,11 @@ void AliasDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
if (haliassym)
|
||||
{
|
||||
#if !IN_LLVM
|
||||
haliassym->toCBuffer(buf, hgs);
|
||||
#else
|
||||
buf->writestring(haliassym->toChars());
|
||||
#endif
|
||||
buf->writeByte(' ');
|
||||
buf->writestring(ident->toChars());
|
||||
}
|
||||
@@ -683,7 +687,11 @@ void AliasDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
if (aliassym)
|
||||
{
|
||||
#if !IN_LLVM
|
||||
aliassym->toCBuffer(buf, hgs);
|
||||
#else
|
||||
buf->writestring(aliassym->toChars());
|
||||
#endif
|
||||
buf->writeByte(' ');
|
||||
buf->writestring(ident->toChars());
|
||||
}
|
||||
@@ -1496,7 +1504,7 @@ int VarDeclaration::isSameAsInitializer()
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* If a variable has an scope destructor call, return call for it.
|
||||
* If a variable has a scope destructor call, return call for it.
|
||||
* Otherwise, return NULL.
|
||||
*/
|
||||
|
||||
@@ -1504,7 +1512,7 @@ Expression *VarDeclaration::callScopeDtor(Scope *sc)
|
||||
{ Expression *e = NULL;
|
||||
|
||||
//printf("VarDeclaration::callScopeDtor() %s\n", toChars());
|
||||
if (storage_class & STCscope && !noscope)
|
||||
if (storage_class & (STCauto | STCscope) && !noscope)
|
||||
{
|
||||
for (ClassDeclaration *cd = type->isClassHandle();
|
||||
cd;
|
||||
|
||||
@@ -91,6 +91,8 @@ enum STC
|
||||
#define STCtrusted 0x400000000LL
|
||||
#define STCsystem 0x800000000LL
|
||||
#define STCctfe 0x1000000000LL // can be used in CTFE, even if it is static
|
||||
#define STCdisable 0x2000000000LL // for functions that are not callable
|
||||
#define STCresult 0x4000000000LL // for result variables passed to out contracts
|
||||
|
||||
struct Match
|
||||
{
|
||||
@@ -270,7 +272,7 @@ struct VarDeclaration : Declaration
|
||||
{
|
||||
Initializer *init;
|
||||
unsigned offset;
|
||||
int noscope; // no scope semantics
|
||||
int noscope; // no auto semantics
|
||||
#if DMDV2
|
||||
FuncDeclarations nestedrefs; // referenced by these lexically nested functions
|
||||
bool isargptr; // if parameter that _argptr points to
|
||||
@@ -329,8 +331,8 @@ struct VarDeclaration : Declaration
|
||||
virtual int isSameAsInitializer();
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toSymbol();
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
int cvMember(unsigned char *p);
|
||||
#endif
|
||||
|
||||
@@ -423,8 +425,8 @@ struct TypeInfoDeclaration : VarDeclaration
|
||||
void toJsonBuffer(OutBuffer *buf);
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toSymbol();
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
virtual void toDt(dt_t **pdt);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype)
|
||||
sinit = NULL;
|
||||
#endif
|
||||
isdeprecated = 0;
|
||||
isdone = 0;
|
||||
}
|
||||
|
||||
Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#if _MSC_VER
|
||||
#include <complex>
|
||||
#else
|
||||
#include <complex>
|
||||
#endif
|
||||
|
||||
#if _WIN32 && __DMC__
|
||||
@@ -1357,6 +1358,7 @@ Expressions *Expression::arraySyntaxCopy(Expressions *exps)
|
||||
for (size_t i = 0; i < a->dim; i++)
|
||||
{ Expression *e = (Expression *)exps->data[i];
|
||||
|
||||
if (e)
|
||||
e = e->syntaxCopy();
|
||||
a->data[i] = e;
|
||||
}
|
||||
@@ -3189,7 +3191,7 @@ void ArrayLiteralExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
void ArrayLiteralExp::toMangleBuffer(OutBuffer *buf)
|
||||
{
|
||||
size_t dim = elements ? elements->dim : 0;
|
||||
buf->printf("A%zu", dim);
|
||||
buf->printf("A%u", dim);
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
{ Expression *e = elements->tdata()[i];
|
||||
e->toMangleBuffer(buf);
|
||||
@@ -3291,7 +3293,7 @@ void AssocArrayLiteralExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
void AssocArrayLiteralExp::toMangleBuffer(OutBuffer *buf)
|
||||
{
|
||||
size_t dim = keys->dim;
|
||||
buf->printf("A%zu", dim);
|
||||
buf->printf("A%u", dim);
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
{ Expression *key = (Expression *)keys->data[i];
|
||||
Expression *value = (Expression *)values->data[i];
|
||||
@@ -3545,7 +3547,7 @@ void StructLiteralExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
void StructLiteralExp::toMangleBuffer(OutBuffer *buf)
|
||||
{
|
||||
size_t dim = elements ? elements->dim : 0;
|
||||
buf->printf("S%zu", dim);
|
||||
buf->printf("S%u", dim);
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
{ Expression *e = (Expression *)elements->data[i];
|
||||
if (e)
|
||||
@@ -5047,6 +5049,17 @@ Expression *IsExp::semantic(Scope *sc)
|
||||
goto Lno;
|
||||
break;
|
||||
|
||||
case TOKargTypes:
|
||||
/* Generate a type tuple of the equivalent types used to determine if a
|
||||
* function argument of this type can be passed in registers.
|
||||
* The results of this are highly platform dependent, and intended
|
||||
* primarly for use in implementing va_arg().
|
||||
*/
|
||||
tded = targ->toArgTypes();
|
||||
if (!tded)
|
||||
goto Lno; // not valid for a parameter
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -9631,7 +9644,7 @@ Expression *MulExp::semantic(Scope *sc)
|
||||
if (t2->isimaginary())
|
||||
{ Expression *e;
|
||||
|
||||
switch (t1->ty)
|
||||
switch (t1->toBasetype()->ty)
|
||||
{
|
||||
case Timaginary32: type = Type::tfloat32; break;
|
||||
case Timaginary64: type = Type::tfloat64; break;
|
||||
@@ -9705,7 +9718,7 @@ Expression *DivExp::semantic(Scope *sc)
|
||||
{
|
||||
if (t2->isimaginary())
|
||||
{
|
||||
switch (t1->ty)
|
||||
switch (t1->toBasetype()->ty)
|
||||
{
|
||||
case Timaginary32: type = Type::tfloat32; break;
|
||||
case Timaginary64: type = Type::tfloat64; break;
|
||||
|
||||
@@ -52,7 +52,6 @@ enum TOK;
|
||||
#if IN_DMD
|
||||
// Back end
|
||||
struct IRState;
|
||||
|
||||
struct dt_t;
|
||||
struct elem;
|
||||
struct Symbol; // back end symbol
|
||||
@@ -470,6 +469,9 @@ struct ArrayLiteralExp : Expression
|
||||
int apply(apply_fp_t fp, void *param);
|
||||
Expression *semantic(Scope *sc);
|
||||
int isBool(int result);
|
||||
#if IN_DMD
|
||||
elem *toElem(IRState *irs);
|
||||
#endif
|
||||
int checkSideEffect(int flag);
|
||||
StringExp *toString();
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
@@ -478,14 +480,14 @@ struct ArrayLiteralExp : Expression
|
||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||
MATCH implicitConvTo(Type *t);
|
||||
Expression *castTo(Scope *sc, Type *t);
|
||||
#if IN_DMD
|
||||
dt_t **toDt(dt_t **pdt);
|
||||
#endif
|
||||
|
||||
Expression *doInline(InlineDoState *ids);
|
||||
Expression *inlineScan(InlineScanState *iss);
|
||||
|
||||
#if IN_DMD
|
||||
elem *toElem(IRState *irs);
|
||||
dt_t **toDt(dt_t **pdt);
|
||||
#elif IN_LLVM
|
||||
#if IN_LLVM
|
||||
DValue* toElem(IRState* irs);
|
||||
llvm::Constant *toConstElem(IRState *irs);
|
||||
#endif
|
||||
@@ -544,21 +546,24 @@ struct StructLiteralExp : Expression
|
||||
Expression *semantic(Scope *sc);
|
||||
Expression *getField(Type *type, unsigned offset);
|
||||
int getFieldIndex(Type *type, unsigned offset);
|
||||
#if IN_DMD
|
||||
elem *toElem(IRState *irs);
|
||||
#endif
|
||||
int checkSideEffect(int flag);
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
void toMangleBuffer(OutBuffer *buf);
|
||||
Expression *optimize(int result);
|
||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||
#if IN_DMD
|
||||
dt_t **toDt(dt_t **pdt);
|
||||
#endif
|
||||
Expression *toLvalue(Scope *sc, Expression *e);
|
||||
|
||||
int inlineCost3(InlineCostState *ics);
|
||||
Expression *doInline(InlineDoState *ids);
|
||||
Expression *inlineScan(InlineScanState *iss);
|
||||
|
||||
#if IN_DMD
|
||||
elem *toElem(IRState *irs);
|
||||
dt_t **toDt(dt_t **pdt);
|
||||
#elif IN_LLVM
|
||||
#if IN_LLVM
|
||||
DValue* toElem(IRState* irs);
|
||||
llvm::Constant *toConstElem(IRState *irs);
|
||||
llvm::StructType *constType;
|
||||
|
||||
@@ -55,6 +55,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
|
||||
#if IN_GCC
|
||||
v_argptr = NULL;
|
||||
#endif
|
||||
v_argsave = NULL;
|
||||
parameters = NULL;
|
||||
labtab = NULL;
|
||||
overnext = NULL;
|
||||
@@ -216,7 +217,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||
error("_ctor is reserved for constructors");
|
||||
|
||||
if (isConst() || isAuto() || isScope())
|
||||
error("functions cannot be const, auto or scope");
|
||||
error("functions cannot be const or auto");
|
||||
|
||||
if (isAbstract() && !isVirtual())
|
||||
error("non-virtual functions cannot be abstract");
|
||||
@@ -1381,7 +1382,8 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||
e = new AssignExp(0, e1, e);
|
||||
e->type = t;
|
||||
a->push(new ExpStatement(0, e));
|
||||
#endif // IN_GCC
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_arguments)
|
||||
@@ -2632,7 +2634,7 @@ int FuncDeclaration::needsClosure()
|
||||
{ FuncDeclaration *f = (FuncDeclaration *)v->nestedrefs.data[j];
|
||||
assert(f != this);
|
||||
|
||||
//printf("\t\tf = %s, %d, %d\n", f->toChars(), f->isVirtual(), f->tookAddressOf);
|
||||
//printf("\t\tf = %s, %d, %p, %d\n", f->toChars(), f->isVirtual(), f->isThis(), f->tookAddressOf);
|
||||
if (f->isThis() || f->tookAddressOf)
|
||||
goto Lyes; // assume f escapes this function's scope
|
||||
|
||||
|
||||
45
dmd/html.c
45
dmd/html.c
@@ -1,10 +1,10 @@
|
||||
|
||||
// Copyright (c) 1999-2006 by Digital Mars
|
||||
// Copyright (c) 1999-2009 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// in artistic.txt, or the GNU General Public License in gpl.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
|
||||
@@ -21,8 +21,46 @@
|
||||
#include "mars.h"
|
||||
#include "html.h"
|
||||
|
||||
#if MARS || IN_LLVM
|
||||
#include <assert.h>
|
||||
#include "root.h"
|
||||
//#include "../mars/mars.h"
|
||||
#else
|
||||
#include "outbuf.h"
|
||||
#include "msgs2.h"
|
||||
|
||||
extern void html_err(const char *, unsigned, unsigned, ...);
|
||||
|
||||
static char __file__[] = __FILE__; /* for tassert.h */
|
||||
#include "tassert.h"
|
||||
#endif
|
||||
|
||||
#if __GNUC__
|
||||
int memicmp(const char *s1, const char *s2, int n);
|
||||
#if 0
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{ char c1 = s1[i];
|
||||
char c2 = s2[i];
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int HtmlNamedEntity(unsigned char *p, int length);
|
||||
|
||||
@@ -530,7 +568,7 @@ void Html::scanCDATA()
|
||||
* right.
|
||||
*/
|
||||
linnum++;
|
||||
dbuf->writeUTF8('\n');
|
||||
dbuf->writeByte('\n');
|
||||
p += lineSepLength;
|
||||
continue;
|
||||
}
|
||||
@@ -550,6 +588,7 @@ void Html::scanCDATA()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************
|
||||
* Convert an HTML character entity into a character.
|
||||
* Forms are:
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
|
||||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 1999-2006 by Digital Mars
|
||||
// Copyright (c) 1999-2009 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// in artistic.txt, or the GNU General Public License in gpl.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
#ifndef DMD_HTML_H
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// http://www.dsource.org/projects/dmd/browser/branches/dmd-1.x/src/idgen.c
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// See the included readme.txt for details.
|
||||
@@ -92,6 +93,7 @@ Msgtable msgtable[] =
|
||||
{ "_arguments" },
|
||||
{ "_argptr" },
|
||||
{ "_match" },
|
||||
{ "m_align" },
|
||||
|
||||
{ "LINE", "__LINE__" },
|
||||
{ "FILE", "__FILE__" },
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mars.h"
|
||||
|
||||
/******************************************
|
||||
* Looks for undefined identifier s to see
|
||||
* if it might be undefined because an import
|
||||
|
||||
@@ -484,7 +484,7 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||
}
|
||||
|
||||
if ((unsigned long) dim * t->nextOf()->size() >= amax)
|
||||
{ error(loc, "array dimension %u exceeds max of %ju", dim, amax / t->nextOf()->size());
|
||||
{ error(loc, "array dimension %u exceeds max of %u", dim, amax / t->nextOf()->size());
|
||||
goto Lerr;
|
||||
}
|
||||
return this;
|
||||
@@ -540,6 +540,7 @@ Expression *ArrayInitializer::toExpression()
|
||||
|
||||
elements = new Expressions();
|
||||
elements->setDim(edim);
|
||||
elements->zero();
|
||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||
{
|
||||
if (index[i])
|
||||
|
||||
@@ -1802,4 +1802,3 @@ Expression *Expression::inlineCopy(Scope *sc)
|
||||
return e;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 1999-2011 by Digital Mars
|
||||
// All Rights Reserved
|
||||
|
||||
@@ -3027,6 +3027,7 @@ static Keyword keywords[] =
|
||||
//{ "manifest", TOKmanifest },
|
||||
|
||||
// Added after 1.0
|
||||
{ "__argTypes", TOKargTypes },
|
||||
{ "ref", TOKref },
|
||||
{ "macro", TOKmacro },
|
||||
#if DMDV2
|
||||
|
||||
@@ -152,6 +152,7 @@ enum TOK
|
||||
TOKunittest,
|
||||
|
||||
// Added after 1.0
|
||||
TOKargTypes,
|
||||
TOKref,
|
||||
TOKmacro,
|
||||
#if DMDV2
|
||||
|
||||
32
dmd/mtype.c
32
dmd/mtype.c
@@ -95,12 +95,6 @@ int REALALIGNSIZE = 2;
|
||||
int Tsize_t = Tuns32;
|
||||
int Tptrdiff_t = Tint32;
|
||||
|
||||
#if _WIN32 && !(defined __MINGW32__ || defined _MSC_VER)
|
||||
static double zero = 0;
|
||||
double Port::nan = NAN;
|
||||
double Port::infinity = 1/zero;
|
||||
#endif
|
||||
|
||||
/***************************** Type *****************************/
|
||||
|
||||
ClassDeclaration *Type::typeinfo;
|
||||
@@ -2477,7 +2471,7 @@ Type *TypeAArray::semantic(Loc loc, Scope *sc)
|
||||
break;
|
||||
}
|
||||
if (next->isscope())
|
||||
error(loc, "cannot have array of scope %s", next->toChars());
|
||||
error(loc, "cannot have array of auto %s", next->toChars());
|
||||
|
||||
return merge();
|
||||
}
|
||||
@@ -4423,6 +4417,7 @@ Expression *TypeEnum::defaultInit(Loc loc)
|
||||
|
||||
int TypeEnum::isZeroInit(Loc loc)
|
||||
{
|
||||
//printf("TypeEnum::isZeroInit() '%s'\n", toChars());
|
||||
if (!sym->isdone && sym->scope)
|
||||
{ // Enum is forward referenced. We need to resolve the whole thing.
|
||||
sym->semantic(NULL);
|
||||
@@ -5503,6 +5498,29 @@ TypeTuple::TypeTuple(Expressions *exps)
|
||||
this->arguments = arguments;
|
||||
}
|
||||
|
||||
/*******************************************
|
||||
* Type tuple with 0, 1 or 2 types in it.
|
||||
*/
|
||||
TypeTuple::TypeTuple()
|
||||
: Type(Ttuple, NULL)
|
||||
{
|
||||
arguments = new Parameters();
|
||||
}
|
||||
|
||||
TypeTuple::TypeTuple(Type *t1)
|
||||
: Type(Ttuple, NULL)
|
||||
{
|
||||
arguments = new Parameters();
|
||||
arguments->push(new Parameter(0, t1, NULL, NULL));
|
||||
}
|
||||
|
||||
TypeTuple::TypeTuple(Type *t1, Type *t2)
|
||||
: Type(Ttuple, NULL)
|
||||
{
|
||||
arguments = new Parameters();
|
||||
arguments->push(new Parameter(0, t1, NULL, NULL));
|
||||
arguments->push(new Parameter(0, t2, NULL, NULL));
|
||||
}
|
||||
Type *TypeTuple::syntaxCopy()
|
||||
{
|
||||
Parameters *args = Parameter::arraySyntaxCopy(arguments);
|
||||
|
||||
30
dmd/mtype.h
30
dmd/mtype.h
@@ -50,12 +50,11 @@ struct Parameter;
|
||||
#if IN_GCC
|
||||
union tree_node; typedef union tree_node TYPE;
|
||||
typedef TYPE type;
|
||||
#endif
|
||||
|
||||
#if IN_DMD
|
||||
#else
|
||||
typedef struct TYPE type;
|
||||
struct Symbol;
|
||||
#endif
|
||||
struct Symbol;
|
||||
struct TypeTuple;
|
||||
|
||||
enum TY
|
||||
{
|
||||
@@ -270,6 +269,7 @@ struct Type : Object
|
||||
virtual Type *reliesOnTident();
|
||||
virtual Expression *toExpression();
|
||||
virtual int hasPointers();
|
||||
virtual TypeTuple *toArgTypes();
|
||||
Type *next;
|
||||
Type *nextOf() { return next; }
|
||||
|
||||
@@ -359,6 +359,7 @@ struct TypeBasic : Type
|
||||
Expression *defaultInit(Loc loc);
|
||||
int isZeroInit(Loc loc);
|
||||
int builtinTypeInfo();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
// For eliminating dynamic_cast
|
||||
TypeBasic *isTypeBasic();
|
||||
@@ -398,6 +399,7 @@ struct TypeSArray : TypeArray
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
Expression *toExpression();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -424,6 +426,7 @@ struct TypeDArray : TypeArray
|
||||
int builtinTypeInfo();
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -449,6 +452,7 @@ struct TypeAArray : TypeArray
|
||||
int checkBoolean();
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
// Back end
|
||||
@@ -473,6 +477,7 @@ struct TypePointer : Type
|
||||
int isZeroInit(Loc loc);
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -500,7 +505,11 @@ struct TypeFunction : Type
|
||||
{
|
||||
Parameters *parameters; // function parameters
|
||||
int varargs; // 1: T t, ...) style for variable number of arguments
|
||||
// if extern (C) then this is C style va_args
|
||||
// if extern (D) then D style va_args
|
||||
// 2: T t ...) style for variable number of arguments
|
||||
// where the args are stored in a local, and a
|
||||
// dynamic array is passed to the function
|
||||
enum LINK linkage; // calling convention
|
||||
|
||||
int inuse;
|
||||
@@ -549,6 +558,7 @@ struct TypeDelegate : Type
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -642,6 +652,7 @@ struct TypeStruct : Type
|
||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
#if CPP_MANGLE
|
||||
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
||||
#endif
|
||||
@@ -661,10 +672,10 @@ struct TypeEnum : Type
|
||||
EnumDeclaration *sym;
|
||||
|
||||
TypeEnum(EnumDeclaration *sym);
|
||||
Type *syntaxCopy();
|
||||
d_uns64 size(Loc loc);
|
||||
unsigned alignsize();
|
||||
char *toChars();
|
||||
Type *syntaxCopy();
|
||||
Type *semantic(Loc loc, Scope *sc);
|
||||
Dsymbol *toDsymbol(Scope *sc);
|
||||
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
||||
@@ -682,6 +693,10 @@ struct TypeEnum : Type
|
||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
#if CPP_MANGLE
|
||||
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
||||
#endif
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -722,6 +737,7 @@ struct TypeTypedef : Type
|
||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
|
||||
#if IN_DMD
|
||||
type *toCtype();
|
||||
@@ -752,6 +768,7 @@ struct TypeClass : Type
|
||||
int checkBoolean();
|
||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||
int hasPointers();
|
||||
TypeTuple *toArgTypes();
|
||||
int builtinTypeInfo();
|
||||
#if DMDV2
|
||||
Type *toHeadMutable();
|
||||
@@ -774,6 +791,9 @@ struct TypeTuple : Type
|
||||
|
||||
TypeTuple(Parameters *arguments);
|
||||
TypeTuple(Expressions *exps);
|
||||
TypeTuple();
|
||||
TypeTuple(Type *t1);
|
||||
TypeTuple(Type *t1, Type *t2);
|
||||
Type *syntaxCopy();
|
||||
Type *semantic(Loc loc, Scope *sc);
|
||||
int equals(Object *o);
|
||||
|
||||
@@ -4494,6 +4494,7 @@ Expression *Parser::parsePrimaryExp()
|
||||
token.value == TOKsuper ||
|
||||
token.value == TOKenum ||
|
||||
token.value == TOKinterface ||
|
||||
token.value == TOKargTypes ||
|
||||
#if DMDV2
|
||||
token.value == TOKconst && peek(&token)->value == TOKrparen ||
|
||||
token.value == TOKinvariant && peek(&token)->value == TOKrparen ||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "mars.h"
|
||||
#include "init.h"
|
||||
#include "identifier.h"
|
||||
#include "scope.h"
|
||||
#include "attrib.h"
|
||||
#include "dsymbol.h"
|
||||
#include "scope.h"
|
||||
#include "declaration.h"
|
||||
#include "aggregate.h"
|
||||
#include "module.h"
|
||||
|
||||
@@ -2937,7 +2937,6 @@ Statement *CaseStatement::semantic(Scope *sc)
|
||||
{ SwitchStatement *sw = sc->sw;
|
||||
|
||||
//printf("CaseStatement::semantic() %s\n", toChars());
|
||||
|
||||
exp = exp->semantic(sc);
|
||||
if (sw)
|
||||
{
|
||||
@@ -3126,7 +3125,6 @@ Statement *DefaultStatement::syntaxCopy()
|
||||
Statement *DefaultStatement::semantic(Scope *sc)
|
||||
{
|
||||
//printf("DefaultStatement::semantic()\n");
|
||||
|
||||
if (sc->sw)
|
||||
{
|
||||
if (sc->sw->sdefault)
|
||||
@@ -4635,6 +4633,9 @@ LabelDsymbol::LabelDsymbol(Identifier *ident)
|
||||
: Dsymbol(ident)
|
||||
{
|
||||
statement = NULL;
|
||||
#if IN_GCC
|
||||
asmLabelNum = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
LabelDsymbol *LabelDsymbol::isLabel() // is this a LabelDsymbol()?
|
||||
|
||||
@@ -143,7 +143,7 @@ struct Statement : Object
|
||||
virtual CompoundStatement *isCompoundStatement() { return NULL; }
|
||||
virtual ReturnStatement *isReturnStatement() { return NULL; }
|
||||
virtual IfStatement *isIfStatement() { return NULL; }
|
||||
virtual CaseStatement* isCaseStatement() { return NULL; }
|
||||
virtual CaseStatement *isCaseStatement() { return NULL; }
|
||||
virtual DefaultStatement *isDefaultStatement() { return NULL; }
|
||||
virtual LabelStatement* isLabelStatement() { return NULL; }
|
||||
|
||||
@@ -883,6 +883,9 @@ struct LabelStatement : Statement
|
||||
struct LabelDsymbol : Dsymbol
|
||||
{
|
||||
LabelStatement *statement;
|
||||
#if IN_GCC
|
||||
unsigned asmLabelNum; // GCC-specific
|
||||
#endif
|
||||
|
||||
LabelDsymbol(Identifier *ident);
|
||||
LabelDsymbol *isLabel();
|
||||
|
||||
41
dmd/struct.c
41
dmd/struct.c
@@ -229,7 +229,7 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
memalignsize = sc->structalign;
|
||||
if (alignsize < memalignsize)
|
||||
alignsize = memalignsize;
|
||||
//printf("\talignsize = %d\n", alignsize);
|
||||
//printf("\t%s: alignsize = %d\n", toChars(), alignsize);
|
||||
|
||||
v->storage_class |= STCfield;
|
||||
//printf(" addField '%s' to '%s' at offset %d, size = %d\n", v->toChars(), toChars(), v->offset, memsize);
|
||||
@@ -298,6 +298,7 @@ StructDeclaration::StructDeclaration(Loc loc, Identifier *id)
|
||||
hasIdentityAssign = 0;
|
||||
cpctor = NULL;
|
||||
postblit = NULL;
|
||||
eq = NULL;
|
||||
#endif
|
||||
|
||||
// For forward references
|
||||
@@ -320,9 +321,9 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
Scope *sc2;
|
||||
|
||||
//printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars());
|
||||
//printf("+StructDeclaration::semantic(this=%p, '%s', sizeok = %d)\n", this, toChars(), sizeok);
|
||||
|
||||
//static int count; if (++count == 20) *(char*)0=0;
|
||||
//static int count; if (++count == 20) halt();
|
||||
|
||||
assert(type);
|
||||
if (!members) // if forward reference
|
||||
@@ -479,6 +480,40 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
#endif
|
||||
#if DMDV2
|
||||
/* Try to find the opEquals function. Build it if necessary.
|
||||
*/
|
||||
TypeFunction *tfeqptr;
|
||||
{ // bool opEquals(const T*) const;
|
||||
Parameters *parameters = new Parameters;
|
||||
#if STRUCTTHISREF
|
||||
// bool opEquals(ref const T) const;
|
||||
Parameter *param = new Parameter(STCref, type->constOf(), NULL, NULL);
|
||||
#else
|
||||
// bool opEquals(const T*) const;
|
||||
Parameter *param = new Parameter(STCin, type->pointerTo(), NULL, NULL);
|
||||
#endif
|
||||
|
||||
parameters->push(param);
|
||||
tfeqptr = new TypeFunction(parameters, Type::tbool, 0, LINKd);
|
||||
tfeqptr->mod = MODconst;
|
||||
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, sc2);
|
||||
|
||||
Dsymbol *s = search_function(this, Id::eq);
|
||||
FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL;
|
||||
if (fdx)
|
||||
{
|
||||
eq = fdx->overloadExactMatch(tfeqptr);
|
||||
if (!eq)
|
||||
fdx->error("type signature should be %s not %s", tfeqptr->toChars(), fdx->type->toChars());
|
||||
}
|
||||
|
||||
TemplateDeclaration *td = s ? s->isTemplateDeclaration() : NULL;
|
||||
// BUG: should also check that td is a function template, not just a template
|
||||
|
||||
if (!eq && !td)
|
||||
eq = buildOpEquals(sc2);
|
||||
}
|
||||
|
||||
dtor = buildDtor(sc2);
|
||||
postblit = buildPostBlit(sc2);
|
||||
cpctor = buildCpCtor(sc2);
|
||||
|
||||
@@ -13,14 +13,11 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if !IN_LLVM
|
||||
#endif
|
||||
#include "root.h"
|
||||
#include "aav.h"
|
||||
#include "rmem.h"
|
||||
#include "stringtable.h"
|
||||
#include "mars.h"
|
||||
#include "identifier.h"
|
||||
|
||||
#include "mtype.h"
|
||||
#include "template.h"
|
||||
#include "init.h"
|
||||
@@ -30,6 +27,9 @@
|
||||
#include "aggregate.h"
|
||||
#include "declaration.h"
|
||||
#include "dsymbol.h"
|
||||
#include "mars.h"
|
||||
#include "dsymbol.h"
|
||||
#include "identifier.h"
|
||||
#include "hdrgen.h"
|
||||
|
||||
#if WINDOWS_SEH
|
||||
|
||||
@@ -384,4 +384,3 @@ Dsymbol *getDsymbol(Object *o);
|
||||
void ObjectToCBuffer(OutBuffer *buf, HdrGenState *hgs, Object *oarg);
|
||||
|
||||
#endif /* DMD_TEMPLATE_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user