mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 16:43:13 +01:00
Upgraded frontend to DMD 1.035
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#include "../gen/enums.h"
|
||||
#include "../gen/logger.h"
|
||||
|
||||
extern void obj_includelib(char *name);
|
||||
extern void obj_includelib(const char *name);
|
||||
void obj_startaddress(Symbol *s);
|
||||
|
||||
|
||||
|
||||
20
dmd/class.c
20
dmd/class.c
@@ -477,10 +477,22 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
if (storage_class & STCstatic)
|
||||
error("static class cannot inherit from nested class %s", baseClass->toChars());
|
||||
if (toParent2() != baseClass->toParent2())
|
||||
error("super class %s is nested within %s, not %s",
|
||||
{
|
||||
if (toParent2())
|
||||
{
|
||||
error("is nested within %s, but super class %s is nested within %s",
|
||||
toParent2()->toChars(),
|
||||
baseClass->toChars(),
|
||||
baseClass->toParent2()->toChars(),
|
||||
toParent2()->toChars());
|
||||
baseClass->toParent2()->toChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
error("is not nested, but super class %s is nested within %s",
|
||||
baseClass->toChars(),
|
||||
baseClass->toParent2()->toChars());
|
||||
}
|
||||
isnested = 0;
|
||||
}
|
||||
}
|
||||
else if (!(storage_class & STCstatic))
|
||||
{ Dsymbol *s = toParent2();
|
||||
@@ -579,7 +591,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
* They must be in this class, not in a base class.
|
||||
*/
|
||||
ctor = (CtorDeclaration *)search(0, Id::ctor, 0);
|
||||
if (ctor && ctor->toParent() != this)
|
||||
if (ctor && (ctor->toParent() != this || !ctor->isCtorDeclaration()))
|
||||
ctor = NULL;
|
||||
|
||||
// dtor = (DtorDeclaration *)search(Id::dtor, 0);
|
||||
|
||||
@@ -706,7 +706,11 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
||||
{ StringExp *es1 = (StringExp *)e1;
|
||||
StringExp *es2 = (StringExp *)e2;
|
||||
|
||||
assert(es1->sz == es2->sz);
|
||||
if (es1->sz != es2->sz)
|
||||
{
|
||||
assert(global.errors);
|
||||
return EXP_CANT_INTERPRET;
|
||||
}
|
||||
if (es1->len == es2->len &&
|
||||
memcmp(es1->string, es2->string, es1->sz * es1->len) == 0)
|
||||
cmp = 1;
|
||||
@@ -1344,7 +1348,14 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
||||
size_t len = es1->len + es2->len;
|
||||
int sz = es1->sz;
|
||||
|
||||
assert(sz == es2->sz);
|
||||
if (sz != es2->sz)
|
||||
{
|
||||
/* Can happen with:
|
||||
* auto s = "foo"d ~ "bar"c;
|
||||
*/
|
||||
assert(global.errors);
|
||||
return e;
|
||||
}
|
||||
s = mem.malloc((len + 1) * sz);
|
||||
memcpy(s, es1->string, es1->len * sz);
|
||||
memcpy((unsigned char *)s + es1->len * sz, es2->string, es2->len * sz);
|
||||
|
||||
@@ -898,6 +898,9 @@ void VarDeclaration::semantic(Scope *sc)
|
||||
|
||||
if (init)
|
||||
{
|
||||
sc = sc->push();
|
||||
sc->stc &= ~(STCconst | STCinvariant | STCpure);
|
||||
|
||||
ArrayInitializer *ai = init->isArrayInitializer();
|
||||
if (ai && tb->ty == Taarray)
|
||||
{
|
||||
@@ -1031,6 +1034,7 @@ void VarDeclaration::semantic(Scope *sc)
|
||||
init = i2; // no errors, keep result
|
||||
}
|
||||
}
|
||||
sc = sc->pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,9 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||
//printf("function storage_class = x%x\n", storage_class);
|
||||
Dsymbol *parent = toParent();
|
||||
|
||||
if (ident == Id::ctor && !isCtorDeclaration())
|
||||
error("_ctor is reserved for constructors");
|
||||
|
||||
if (isConst() || isAuto() || isScope())
|
||||
error("functions cannot be const or auto");
|
||||
|
||||
@@ -2543,7 +2546,7 @@ void StaticDtorDeclaration::semantic(Scope *sc)
|
||||
sa->push(s);
|
||||
Expression *e = new IdentifierExp(0, id);
|
||||
e = new AddAssignExp(0, e, new IntegerExp(-1));
|
||||
e = new EqualExp(TOKnotequal, 0, e, new IntegerExp(1));
|
||||
e = new EqualExp(TOKnotequal, 0, e, new IntegerExp(0));
|
||||
s = new IfStatement(0, NULL, e, new ReturnStatement(0, NULL), NULL);
|
||||
sa->push(s);
|
||||
if (fbody)
|
||||
|
||||
4
dmd/id.c
4
dmd/id.c
@@ -164,9 +164,9 @@ Identifier *Id::aaLen;
|
||||
Identifier *Id::aaKeys;
|
||||
Identifier *Id::aaValues;
|
||||
Identifier *Id::aaRehash;
|
||||
Identifier *Id::GNU_asm;
|
||||
Identifier *Id::lib;
|
||||
Identifier *Id::msg;
|
||||
Identifier *Id::GNU_asm;
|
||||
Identifier *Id::intrinsic;
|
||||
Identifier *Id::va_intrinsic;
|
||||
Identifier *Id::no_typeinfo;
|
||||
@@ -346,9 +346,9 @@ void Id::initialize()
|
||||
aaKeys = Lexer::idPool("_aaKeys");
|
||||
aaValues = Lexer::idPool("_aaValues");
|
||||
aaRehash = Lexer::idPool("_aaRehash");
|
||||
GNU_asm = Lexer::idPool("GNU_asm");
|
||||
lib = Lexer::idPool("lib");
|
||||
msg = Lexer::idPool("msg");
|
||||
GNU_asm = Lexer::idPool("GNU_asm");
|
||||
intrinsic = Lexer::idPool("intrinsic");
|
||||
va_intrinsic = Lexer::idPool("va_intrinsic");
|
||||
no_typeinfo = Lexer::idPool("no_typeinfo");
|
||||
|
||||
2
dmd/id.h
2
dmd/id.h
@@ -166,9 +166,9 @@ struct Id
|
||||
static Identifier *aaKeys;
|
||||
static Identifier *aaValues;
|
||||
static Identifier *aaRehash;
|
||||
static Identifier *GNU_asm;
|
||||
static Identifier *lib;
|
||||
static Identifier *msg;
|
||||
static Identifier *GNU_asm;
|
||||
static Identifier *intrinsic;
|
||||
static Identifier *va_intrinsic;
|
||||
static Identifier *no_typeinfo;
|
||||
|
||||
20
dmd/idgen.c
20
dmd/idgen.c
@@ -1,6 +1,6 @@
|
||||
|
||||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 1999-2006 by Digital Mars
|
||||
// Copyright (c) 1999-2008 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
struct Msgtable
|
||||
{
|
||||
char *ident; // name to use in DMD source
|
||||
char *name; // name in D executable
|
||||
const char *ident; // name to use in DMD source
|
||||
const char *name; // name in D executable
|
||||
};
|
||||
|
||||
Msgtable msgtable[] =
|
||||
@@ -209,9 +209,9 @@ Msgtable msgtable[] =
|
||||
{ "aaRehash", "_aaRehash" },
|
||||
|
||||
// For pragma's
|
||||
{ "GNU_asm" },
|
||||
{ "lib" },
|
||||
{ "msg" },
|
||||
{ "GNU_asm" },
|
||||
|
||||
// LLVMDC pragma's
|
||||
{ "intrinsic" },
|
||||
@@ -225,7 +225,7 @@ Msgtable msgtable[] =
|
||||
{ "vaarg", "va_arg" },
|
||||
{ "llvmdc" },
|
||||
|
||||
// For toHash/toString
|
||||
// For special functions
|
||||
{ "tohash", "toHash" },
|
||||
{ "tostring", "toString" },
|
||||
|
||||
@@ -260,7 +260,7 @@ int main()
|
||||
fprintf(fp, "{\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ char *id = msgtable[i].ident;
|
||||
{ const char *id = msgtable[i].ident;
|
||||
|
||||
fprintf(fp," static Identifier *%s;\n", id);
|
||||
}
|
||||
@@ -285,8 +285,8 @@ int main()
|
||||
fprintf(fp, "#include \"lexer.h\"\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ char *id = msgtable[i].ident;
|
||||
char *p = msgtable[i].name;
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
|
||||
if (!p)
|
||||
p = id;
|
||||
@@ -297,8 +297,8 @@ int main()
|
||||
fprintf(fp, "{\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ char *id = msgtable[i].ident;
|
||||
char *p = msgtable[i].name;
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
|
||||
if (!p)
|
||||
p = id;
|
||||
|
||||
@@ -77,10 +77,11 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//printf("test2 %d, %p\n", semanticRun, scope);
|
||||
if (semanticRun == 0 && scope)
|
||||
{
|
||||
semantic3(scope);
|
||||
if (global.errors) // if errors compiling this function
|
||||
return NULL;
|
||||
}
|
||||
if (semanticRun < 2)
|
||||
return NULL;
|
||||
|
||||
27
dmd/lexer.c
27
dmd/lexer.c
@@ -88,7 +88,7 @@ static void cmtable_init()
|
||||
|
||||
/************************* Token **********************************************/
|
||||
|
||||
char *Token::tochars[TOKMAX];
|
||||
const char *Token::tochars[TOKMAX];
|
||||
|
||||
void *Token::operator new(size_t size)
|
||||
{ Token *t;
|
||||
@@ -110,8 +110,8 @@ void Token::print()
|
||||
}
|
||||
#endif
|
||||
|
||||
char *Token::toChars()
|
||||
{ char *p;
|
||||
const char *Token::toChars()
|
||||
{ const char *p;
|
||||
static char buffer[3 + 3 * sizeof(value) + 1];
|
||||
|
||||
p = buffer;
|
||||
@@ -239,8 +239,8 @@ char *Token::toChars()
|
||||
return p;
|
||||
}
|
||||
|
||||
char *Token::toChars(enum TOK value)
|
||||
{ char *p;
|
||||
const char *Token::toChars(enum TOK value)
|
||||
{ const char *p;
|
||||
static char buffer[3 + 3 * sizeof(value) + 1];
|
||||
|
||||
p = tochars[value];
|
||||
@@ -467,7 +467,7 @@ int Lexer::isValidIdentifier(char *p)
|
||||
while (p[idx])
|
||||
{ dchar_t dc;
|
||||
|
||||
char *q = utf_decodeChar((unsigned char *)p, len, &idx, &dc);
|
||||
const char *q = utf_decodeChar((unsigned char *)p, len, &idx, &dc);
|
||||
if (q)
|
||||
goto Linvalid;
|
||||
|
||||
@@ -718,7 +718,7 @@ void Lexer::scan(Token *t)
|
||||
{ unsigned major = 0;
|
||||
unsigned minor = 0;
|
||||
|
||||
for (char *p = global.version + 1; 1; p++)
|
||||
for (const char *p = global.version + 1; 1; p++)
|
||||
{
|
||||
char c = *p;
|
||||
if (isdigit(c))
|
||||
@@ -2186,13 +2186,15 @@ done:
|
||||
break;
|
||||
if (d >= r)
|
||||
break;
|
||||
if (n && n * r + d <= n)
|
||||
uinteger_t n2 = n * r;
|
||||
//printf("n2 / r = %llx, n = %llx\n", n2/r, n);
|
||||
if (n2 / r != n || n2 + d < n)
|
||||
{
|
||||
error ("integer overflow");
|
||||
break;
|
||||
}
|
||||
|
||||
n = n * r + d;
|
||||
n = n2 + d;
|
||||
p++;
|
||||
}
|
||||
#endif
|
||||
@@ -2603,7 +2605,7 @@ unsigned Lexer::decodeUTF()
|
||||
unsigned char *s = p;
|
||||
size_t len;
|
||||
size_t idx;
|
||||
char *msg;
|
||||
const char *msg;
|
||||
|
||||
c = *s;
|
||||
assert(c & 0x80);
|
||||
@@ -2801,7 +2803,7 @@ Identifier *Lexer::uniqueId(const char *s)
|
||||
*/
|
||||
|
||||
struct Keyword
|
||||
{ char *name;
|
||||
{ const char *name;
|
||||
enum TOK value;
|
||||
};
|
||||
|
||||
@@ -2928,6 +2930,7 @@ static Keyword keywords[] =
|
||||
{ "__overloadset", TOKoverloadset },
|
||||
{ "__FILE__", TOKfile },
|
||||
{ "__LINE__", TOKline },
|
||||
{ "shared", TOKshared },
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -2953,7 +2956,7 @@ void Lexer::initKeywords()
|
||||
cmtable_init();
|
||||
|
||||
for (u = 0; u < nkeywords; u++)
|
||||
{ char *s;
|
||||
{ const char *s;
|
||||
|
||||
//printf("keyword[%d] = '%s'\n",u, keywords[u].name);
|
||||
s = keywords[u].name;
|
||||
|
||||
@@ -158,6 +158,7 @@ enum TOK
|
||||
TOKtls,
|
||||
TOKline,
|
||||
TOKfile,
|
||||
TOKshared,
|
||||
#endif
|
||||
|
||||
// LLVMDC specific
|
||||
@@ -240,13 +241,13 @@ struct Token
|
||||
real_t float80value; // can't use this in a union!
|
||||
#endif
|
||||
|
||||
static char *tochars[TOKMAX];
|
||||
static const char *tochars[TOKMAX];
|
||||
static void *operator new(size_t sz);
|
||||
|
||||
int isKeyword();
|
||||
void print();
|
||||
char *toChars();
|
||||
static char *toChars(enum TOK);
|
||||
const char *toChars();
|
||||
static const char *toChars(enum TOK);
|
||||
};
|
||||
|
||||
struct Lexer
|
||||
|
||||
@@ -65,7 +65,7 @@ Global::Global()
|
||||
|
||||
copyright = "Copyright (c) 1999-2008 by Digital Mars and Tomas Lindquist Olsen";
|
||||
written = "written by Walter Bright and Tomas Lindquist Olsen";
|
||||
version = "v1.034";
|
||||
version = "v1.035";
|
||||
llvmdc_version = "0.1";
|
||||
global.structalign = 8;
|
||||
|
||||
|
||||
@@ -789,8 +789,8 @@ int Type::hasPointers()
|
||||
|
||||
TypeBasic::TypeBasic(TY ty)
|
||||
: Type(ty, NULL)
|
||||
{ char *c;
|
||||
char *d;
|
||||
{ const char *c;
|
||||
const char *d;
|
||||
unsigned flags;
|
||||
|
||||
#define TFLAGSintegral 1
|
||||
@@ -935,7 +935,7 @@ Type *TypeBasic::syntaxCopy()
|
||||
|
||||
char *TypeBasic::toChars()
|
||||
{
|
||||
return dstring;
|
||||
return (char *)dstring;
|
||||
}
|
||||
|
||||
void TypeBasic::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
||||
|
||||
@@ -266,8 +266,8 @@ struct Type : Object
|
||||
|
||||
struct TypeBasic : Type
|
||||
{
|
||||
char *dstring;
|
||||
char *cstring;
|
||||
const char *dstring;
|
||||
const char *cstring;
|
||||
unsigned flags;
|
||||
|
||||
TypeBasic(TY ty);
|
||||
|
||||
42
dmd/parse.c
42
dmd/parse.c
@@ -2374,6 +2374,7 @@ Initializer *Parser::parseInitializer()
|
||||
Loc loc = this->loc;
|
||||
Token *t;
|
||||
int braces;
|
||||
int brackets;
|
||||
|
||||
switch (token.value)
|
||||
{
|
||||
@@ -2461,6 +2462,39 @@ Initializer *Parser::parseInitializer()
|
||||
return is;
|
||||
|
||||
case TOKlbracket:
|
||||
/* Scan ahead to see if it is an array initializer or
|
||||
* an expression.
|
||||
* If it ends with a ';', it is an array initializer.
|
||||
*/
|
||||
brackets = 1;
|
||||
for (t = peek(&token); 1; t = peek(t))
|
||||
{
|
||||
switch (t->value)
|
||||
{
|
||||
case TOKlbracket:
|
||||
brackets++;
|
||||
continue;
|
||||
|
||||
case TOKrbracket:
|
||||
if (--brackets == 0)
|
||||
{ t = peek(t);
|
||||
if (t->value != TOKsemicolon &&
|
||||
t->value != TOKcomma &&
|
||||
t->value != TOKrcurly)
|
||||
goto Lexpression;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
||||
case TOKeof:
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ia = new ArrayInitializer(loc);
|
||||
nextToken();
|
||||
comma = 0;
|
||||
@@ -4247,7 +4281,7 @@ Expression *Parser::parsePrimaryExp()
|
||||
nextToken();
|
||||
if (token.value != TOKrbracket)
|
||||
{
|
||||
while (1)
|
||||
while (token.value != TOKeof)
|
||||
{
|
||||
Expression *e = parseAssignExp();
|
||||
if (token.value == TOKcolon && (keys || values->dim == 0))
|
||||
@@ -4525,10 +4559,13 @@ Expression *Parser::parseUnaryExp()
|
||||
tk = peek(tk); // skip over right parenthesis
|
||||
switch (tk->value)
|
||||
{
|
||||
case TOKnot:
|
||||
tk = peek(tk);
|
||||
if (tk->value == TOKis) // !is
|
||||
break;
|
||||
case TOKdot:
|
||||
case TOKplusplus:
|
||||
case TOKminusminus:
|
||||
case TOKnot:
|
||||
case TOKdelete:
|
||||
case TOKnew:
|
||||
case TOKlparen:
|
||||
@@ -5149,6 +5186,7 @@ Expression *Parser::parseNewExp(Expression *thisexp)
|
||||
void Parser::addComment(Dsymbol *s, unsigned char *blockComment)
|
||||
{
|
||||
s->addComment(combineComments(blockComment, token.lineComment));
|
||||
token.lineComment = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
16
dmd/root.c
16
dmd/root.c
@@ -188,7 +188,7 @@ void Object::print()
|
||||
|
||||
char *Object::toChars()
|
||||
{
|
||||
return "Object";
|
||||
return (char *)"Object";
|
||||
}
|
||||
|
||||
dchar *Object::toDchars()
|
||||
@@ -312,13 +312,13 @@ FileName::FileName(char *str, int ref)
|
||||
{
|
||||
}
|
||||
|
||||
char *FileName::combine(char *path, char *name)
|
||||
char *FileName::combine(const char *path, const char *name)
|
||||
{ char *f;
|
||||
size_t pathlen;
|
||||
size_t namelen;
|
||||
|
||||
if (!path || !*path)
|
||||
return name;
|
||||
return (char *)name;
|
||||
pathlen = strlen(path);
|
||||
namelen = strlen(name);
|
||||
f = (char *)mem.malloc(pathlen + 1 + namelen + 1);
|
||||
@@ -744,16 +744,16 @@ void FileName::CopyTo(FileName *to)
|
||||
* cwd if !=0, search current directory before searching path
|
||||
*/
|
||||
|
||||
char *FileName::searchPath(Array *path, char *name, int cwd)
|
||||
char *FileName::searchPath(Array *path, const char *name, int cwd)
|
||||
{
|
||||
if (absolute(name))
|
||||
{
|
||||
return exists(name) ? name : NULL;
|
||||
return exists(name) ? (char *)name : NULL;
|
||||
}
|
||||
if (cwd)
|
||||
{
|
||||
if (exists(name))
|
||||
return name;
|
||||
return (char *)name;
|
||||
}
|
||||
if (path)
|
||||
{ unsigned i;
|
||||
@@ -1438,7 +1438,7 @@ void OutBuffer::writedstring(const wchar_t *string)
|
||||
#endif
|
||||
}
|
||||
|
||||
void OutBuffer::prependstring(char *string)
|
||||
void OutBuffer::prependstring(const char *string)
|
||||
{ unsigned len;
|
||||
|
||||
len = strlen(string);
|
||||
@@ -1698,7 +1698,7 @@ void OutBuffer::bracket(char left, char right)
|
||||
* Return index just past right.
|
||||
*/
|
||||
|
||||
unsigned OutBuffer::bracket(unsigned i, char *left, unsigned j, char *right)
|
||||
unsigned OutBuffer::bracket(unsigned i, const char *left, unsigned j, const char *right)
|
||||
{
|
||||
size_t leftlen = strlen(left);
|
||||
size_t rightlen = strlen(right);
|
||||
|
||||
@@ -131,14 +131,14 @@ struct FileName : String
|
||||
static char *path(const char *);
|
||||
static char *replaceName(char *path, char *name);
|
||||
|
||||
static char *combine(char *path, char *name);
|
||||
static char *combine(const char *path, const char *name);
|
||||
static Array *splitPath(const char *path);
|
||||
static FileName *defaultExt(const char *name, const char *ext);
|
||||
static FileName *forceExt(const char *name, const char *ext);
|
||||
int equalsExt(const char *ext);
|
||||
|
||||
void CopyTo(FileName *to);
|
||||
static char *searchPath(Array *path, char *name, int cwd);
|
||||
static char *searchPath(Array *path, const char *name, int cwd);
|
||||
static int exists(const char *name);
|
||||
static void ensurePathExists(const char *path);
|
||||
};
|
||||
@@ -267,7 +267,7 @@ struct OutBuffer : Object
|
||||
void writestring(const char *string);
|
||||
void writedstring(const char *string);
|
||||
void writedstring(const wchar_t *string);
|
||||
void prependstring(char *string);
|
||||
void prependstring(const char *string);
|
||||
void writenl(); // write newline
|
||||
void writeByte(unsigned b);
|
||||
void writebyte(unsigned b) { writeByte(b); }
|
||||
@@ -288,7 +288,7 @@ struct OutBuffer : Object
|
||||
void printf(const unsigned short *format, ...);
|
||||
#endif
|
||||
void bracket(char left, char right);
|
||||
unsigned bracket(unsigned i, char *left, unsigned j, char *right);
|
||||
unsigned bracket(unsigned i, const char *left, unsigned j, const char *right);
|
||||
void spread(unsigned offset, unsigned nbytes);
|
||||
unsigned insert(unsigned offset, const void *data, unsigned nbytes);
|
||||
void remove(unsigned offset, unsigned nbytes);
|
||||
|
||||
Reference in New Issue
Block a user