Merged dmd 2.059beta

This commit is contained in:
Alexey Prokhin
2012-04-05 11:47:00 +04:00
77 changed files with 6909 additions and 2243 deletions

View File

@@ -119,11 +119,11 @@ const char *Token::toChars()
break;
case TOKint64v:
sprintf(buffer,"%jdL",(intmax_t)int64value);
sprintf(buffer,"%lldL",(intmax_t)int64value);
break;
case TOKuns64v:
sprintf(buffer,"%juUL",(uintmax_t)uns64value);
sprintf(buffer,"%lluUL",(uintmax_t)uns64value);
break;
#if IN_GCC
@@ -141,27 +141,32 @@ const char *Token::toChars()
break;
#else
case TOKfloat32v:
sprintf(buffer,"%Lgf", float80value);
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "f");
break;
case TOKfloat64v:
sprintf(buffer,"%Lg", float80value);
ld_sprint(buffer, 'g', float80value);
break;
case TOKfloat80v:
sprintf(buffer,"%LgL", float80value);
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "L");
break;
case TOKimaginary32v:
sprintf(buffer,"%Lgfi", float80value);
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "fi");
break;
case TOKimaginary64v:
sprintf(buffer,"%Lgi", float80value);
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "i");
break;
case TOKimaginary80v:
sprintf(buffer,"%LgLi", float80value);
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "Li");
break;
#endif
@@ -300,7 +305,7 @@ void Lexer::error(const char *format, ...)
{
va_list ap;
va_start(ap, format);
verror(loc, format, ap);
verror(tokenLoc(), format, ap);
va_end(ap);
}
@@ -363,7 +368,6 @@ Token *Lexer::peek(Token *ct)
{
t = new Token();
scan(t);
t->next = NULL;
ct->next = t;
}
return t;
@@ -1222,9 +1226,21 @@ void Lexer::scan(Token *t)
#undef DOUBLE
case '#':
{
p++;
pragma();
continue;
Token *n = peek(t);
if (n->value == TOKidentifier && n->ident == Id::line)
{
nextToken();
poundLine();
continue;
}
else
{
t->value = TOKpound;
return;
}
}
default:
{ unsigned c = *p;
@@ -2567,22 +2583,17 @@ done:
}
/*********************************************
* Do pragma.
* Currently, the only pragma supported is:
* parse:
* #line linnum [filespec]
*/
void Lexer::pragma()
void Lexer::poundLine()
{
Token tok;
int linnum;
char *filespec = NULL;
Loc loc = this->loc;
scan(&tok);
if (tok.value != TOKidentifier || tok.ident != Id::line)
goto Lerr;
scan(&tok);
if (tok.value == TOKint32v || tok.value == TOKint64v)
{ linnum = tok.uns64value - 1;
@@ -2866,6 +2877,38 @@ unsigned char *Lexer::combineComments(unsigned char *c1, unsigned char *c2)
return c;
}
/*******************************************
* Search actual location of current token
* even when infinite look-ahead was done.
*/
Loc Lexer::tokenLoc()
{
Loc result = this->loc;
Token* last = &token;
while (last->next)
last = last->next;
unsigned char* start = token.ptr;
unsigned char* stop = last->ptr;
for (unsigned char* p = start; p < stop; ++p)
{
switch (*p)
{
case '\n':
result.linnum--;
break;
case '\r':
if (p[1] != '\n')
result.linnum--;
break;
default:
break;
}
}
return result;
}
/********************************************
* Create an identifier in the string table.
*/
@@ -3165,6 +3208,7 @@ void Lexer::initKeywords()
Token::tochars[TOKpow] = "^^";
Token::tochars[TOKpowass] = "^^=";
Token::tochars[TOKgoesto] = "=>";
Token::tochars[TOKpound] = "#";
#endif
// For debugging