# HG changeset patch # User Aziz K?ksal # Date 1198014367 -3600 # Node ID 3418027c391451f68b38a655d9ab4dc25c2e9bfa # Parent d0d40bcca9c63a7bfc93dc333bed85819e2ab5ba Added semantic() method to RealExpression. Added code to IntExpression.semantic(). diff -r d0d40bcca9c6 -r 3418027c3914 trunk/src/dil/Expressions.d --- a/trunk/src/dil/Expressions.d Tue Dec 18 22:22:30 2007 +0100 +++ b/trunk/src/dil/Expressions.d Tue Dec 18 22:46:07 2007 +0100 @@ -748,24 +748,64 @@ this(token.ulong_, type); } - Expression semantic(Scope scop) + Expression semantic(Scope) { if (type) return this; + + if (number & 0x8000_0000_0000_0000) + type = Types.Ulong; // 0xFFFF_FFFF_FFFF_FFFF + else if (number & 0xFFFF_FFFF_0000_0000) + type = Types.Long; // 0x7FFF_FFFF_FFFF_FFFF + else if (number & 0x8000_0000) + type = Types.Uint; // 0xFFFF_FFFF + else + type = Types.Int; // 0x7FFF_FFFF return this; } } class RealExpression : Expression { - TOK type; real number; - this(TOK type, real number) + + this(real number, Type type) { mixin(set_kind); this.number = number; this.type = type; } + + this(Token* token) + { + auto type = Types.Float; // Most common case? + switch (token.type) + { + // case T.Float32: + // type = Types.Float; break; + case TOK.Float64: + type = Types.Double; break; + case TOK.Float80: + type = Types.Double; break; + case TOK.Imaginary32: + type = Types.Ifloat; break; + case TOK.Imaginary64: + type = Types.Idouble; break; + case TOK.Imaginary80: + type = Types.Ireal; break; + default: + assert(token.type == TOK.Float32); + } + this(token.real_, type); + } + + Expression semantic(Scope) + { + if (type) + return this; + type = Types.Double; + return this; + } } class CharExpression : Expression diff -r d0d40bcca9c6 -r 3418027c3914 trunk/src/dil/Parser.d --- a/trunk/src/dil/Parser.d Tue Dec 18 22:22:30 2007 +0100 +++ b/trunk/src/dil/Parser.d Tue Dec 18 22:46:07 2007 +0100 @@ -2754,7 +2754,7 @@ break; case T.Float32, T.Float64, T.Float80, T.Imaginary32, T.Imaginary64, T.Imaginary80: - e = new RealExpression(token.type, token.real_); + e = new RealExpression(token); nT(); break; case T.Dollar: @@ -3307,7 +3307,7 @@ break; case T.Float32, T.Float64, T.Float80, T.Imaginary32, T.Imaginary64, T.Imaginary80: - e = new RealExpression(token.type, token.real_); + e = new RealExpression(token); nT(); break; case T.CharLiteral: