Changeset 126 for trunk/meta/conv.d

Show
Ignore:
Timestamp:
01/26/06 04:45:25 (3 years ago)
Author:
Don Clugston
Message:

meta: Folded in DMD 0.144 changes. Also: qualtest shows that local variable names are (in theory) obtainable via a mixin. demo/tabledemo.d shows that for integral types we can now create lookup tables at compile time, without reverting to a preprocessor! Compiler bugs prevent calcpi.d from working. regexp seems to be broken, too (DMD 0.144 is quite buggy, but being able to use $ in string expressions gives an amazing improvement in code clarity).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/meta/conv.d

    r118 r126  
    2525        const char [] itoa = decimaldigit!(n); 
    2626    } else { 
    27         const char [] itoa = .itoa!(n/10L) ~ decimaldigit!(n%10L); 
     27        const char [] itoa = itoa!(n/10L) ~ decimaldigit!(n%10L); 
    2828    } 
    2929} 
     
    3434        const char [] toHexString = hexdigit!(n); 
    3535    } else { 
    36         const char [] toHexString = .toHexString!(n >> 4) ~ hexdigit!(n&0xF); 
     36        const char [] toHexString = toHexString!(n >> 4) ~ hexdigit!(n&0xF); 
    3737    } 
    3838} 
     
    5757        const int countleadingdigits=indx; 
    5858    } else static if (indx==0 && s[indx]=='-')  { 
    59         const int countleadingdigits = .countleadingdigits!(s, indx+1); 
     59        const int countleadingdigits = countleadingdigits!(s, indx+1); 
    6060    } else static if (!isdigit!( (s[indx]) )) { 
    6161        const int countleadingdigits=indx; 
    6262    } else { 
    63         const int countleadingdigits = .countleadingdigits!(s, indx+1); 
     63        const int countleadingdigits = countleadingdigits!(s, indx+1); 
    6464    } 
    6565} 
     
    8282        } 
    8383    } else static if ( s[p]=='.'|| (p==0 && s[p]=='-') ) { 
    84         const int sigFigs = .sigFigs!(s, p+1, stillzero); 
     84        const int sigFigs = sigFigs!(s, p+1, stillzero); 
    8585    } else static if (s[p]=='0' && stillzero) { 
    86         const int sigFigs = .sigFigs!(s, p+1, stillzero); 
     86        const int sigFigs = sigFigs!(s, p+1, stillzero); 
    8787    } else static if ( isdigit!((s[p])) ) { 
    88         const int sigFigs = 1 + .sigFigs!(s, p+1, false); 
     88        const int sigFigs = 1 + sigFigs!(s, p+1, false); 
    8989    } else static if ( s[p]=='e' || s[p]=='E' ) { 
    9090        // abort once we reach the exponent 
     
    101101{ 
    102102  static if (maxdigs==0 || x==0) const char [] afterdec = ""; 
    103   else const char [] afterdec = .decimaldigit!(cast(int)(x*10)) ~ .afterdec!(x*10-cast(int)(x*10), maxdigs-1); 
     103  else const char [] afterdec = decimaldigit!(cast(int)(x*10)) ~ afterdec!(x*10-cast(int)(x*10), maxdigs-1); 
    104104} 
    105105 
     
    134134  else static if (x<0) const char [] pcvt =  "-" ~ .pcvt!(-x); 
    135135  else static if (x==real.infinity) const char [] pcvt = "inf"; 
    136   else const char [] pcvt = "0x1." ~ .toHexString!(cast(ulong)(0x1000000 *(.binaryMantissa!(x)-1.0)) ) ~ "p" ~ itoaWithSign!(.binaryExponent!(x)); 
     136  else const char [] pcvt = "0x1." ~ toHexString!(cast(ulong)(0x1000000 *(binaryMantissa!(x)-1.0)) ) ~ "p" ~ itoaWithSign!(binaryExponent!(x)); 
    137137} 
    138138 
    139139version(testmeta) { 
    140140 private import meta.strhacks; 
    141   
    142  static assert( streq!(itoa!(5638), "5638")); 
     141 
    143142 static assert( streq!(pcvt!(0x1.12345p954L), "0x1.123450p+954") ); 
    144143 static assert( streq!(fcvt!(12.345), "12.345") ); 
     144 
    145145 static assert( atoi!("3580abc")==3580); 
    146146 static assert( atoi!("-0326")==-326);