Skip to content

Commit

Permalink
Remove special handling of IN_GCC real_t code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain Buclaw committed Jun 29, 2013
1 parent 5a97c27 commit f8389bd
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 57 deletions.
32 changes: 0 additions & 32 deletions src/expression.c
Expand Up @@ -1980,11 +1980,7 @@ real_t Expression::toImaginary()
complex_t Expression::toComplex()
{
error("Floating point constant expression expected instead of %s", toChars());
#ifdef IN_GCC
return complex_t(real_t(0)); // %% nicer
#else
return 0.0;
#endif
}

StringExp *Expression::toString()
Expand Down Expand Up @@ -2874,20 +2870,12 @@ char *RealExp::toChars()

dinteger_t RealExp::toInteger()
{
#ifdef IN_GCC
return (sinteger_t) toReal().toInt();
#else
return (sinteger_t) toReal();
#endif
}

uinteger_t RealExp::toUInteger()
{
#ifdef IN_GCC
return (uinteger_t) toReal().toInt();
#else
return (uinteger_t) toReal();
#endif
}

real_t RealExp::toReal()
Expand Down Expand Up @@ -2951,12 +2939,8 @@ Expression *RealExp::semantic(Scope *sc)

int RealExp::isBool(int result)
{
#ifdef IN_GCC
return result ? (! value.isZero()) : (value.isZero());
#else
return result ? (value != 0)
: (value == 0);
#endif
}

void floatToBuffer(OutBuffer *buf, Type *type, real_t value)
Expand Down Expand Up @@ -3086,20 +3070,12 @@ char *ComplexExp::toChars()

dinteger_t ComplexExp::toInteger()
{
#ifdef IN_GCC
return (sinteger_t) toReal().toInt();
#else
return (sinteger_t) toReal();
#endif
}

uinteger_t ComplexExp::toUInteger()
{
#ifdef IN_GCC
return (uinteger_t) toReal().toInt();
#else
return (uinteger_t) toReal();
#endif
}

real_t ComplexExp::toReal()
Expand Down Expand Up @@ -3156,19 +3132,11 @@ void ComplexExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
/* Print as:
* (re+imi)
*/
#ifdef IN_GCC
char buf1[sizeof(value) * 3 + 8 + 1];
char buf2[sizeof(value) * 3 + 8 + 1];
creall(value).format(buf1, sizeof(buf1));
cimagl(value).format(buf2, sizeof(buf2));
buf->printf("(%s+%si)", buf1, buf2);
#else
buf->writeByte('(');
floatToBuffer(buf, type, creall(value));
buf->writeByte('+');
floatToBuffer(buf, type, cimagl(value));
buf->writestring("i)");
#endif
}

void ComplexExp::toMangleBuffer(OutBuffer *buf)
Expand Down
23 changes: 0 additions & 23 deletions src/lexer.c
Expand Up @@ -97,22 +97,14 @@ const char *Token::toChars()
switch (value)
{
case TOKint32v:
#ifdef IN_GCC
sprintf(buffer,"%d",(d_int32)int64value);
#else
sprintf(buffer,"%d",int32value);
#endif
break;

case TOKuns32v:
case TOKcharv:
case TOKwcharv:
case TOKdcharv:
#ifdef IN_GCC
sprintf(buffer,"%uU",(d_uns32)uns64value);
#else
sprintf(buffer,"%uU",uns32value);
#endif
break;

case TOKint64v:
Expand All @@ -123,20 +115,6 @@ const char *Token::toChars()
sprintf(buffer,"%lluUL",(ulonglong)uns64value);
break;

#ifdef IN_GCC
case TOKfloat32v:
case TOKfloat64v:
case TOKfloat80v:
float80value.format(buffer, sizeof(buffer));
break;
case TOKimaginary32v:
case TOKimaginary64v:
case TOKimaginary80v:
float80value.format(buffer, sizeof(buffer));
// %% buffer
strcat(buffer, "i");
break;
#else
case TOKfloat32v:
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "f");
Expand Down Expand Up @@ -165,7 +143,6 @@ const char *Token::toChars()
ld_sprint(buffer, 'g', float80value);
strcat(buffer, "Li");
break;
#endif

case TOKstring:
{ OutBuffer buf;
Expand Down
3 changes: 1 addition & 2 deletions src/mtype.h
Expand Up @@ -43,8 +43,7 @@ class Parameter;

// Back end
#ifdef IN_GCC
typedef union tree_node TYPE;
typedef TYPE type;
typedef union tree_node type;
#else
typedef struct TYPE type;
#endif
Expand Down

0 comments on commit f8389bd

Please sign in to comment.