Changeset 119

Show
Ignore:
Timestamp:
10/17/07 07:49:55 (1 year ago)
Author:
Don Clugston
Message:

* Bugfix for itoa (thanks yidabu).
* More rank expression support.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/blade/BladeRank.d

    r117 r119  
    166166    } 
    167167    // For *, /, only scalar operations are permitted 
    168     if (lrank==0) return rrank; 
    169     if (rrank==0) return lrank; 
    170     assert(0, "Unsupported operation"); 
     168    if ((op=="*=" || op=="/=") && rrank==0) return lrank; 
     169    if (op=="*" || op=="/") { 
     170        if (lrank==0) return rrank; 
     171        if (rrank==0) return lrank; 
     172    } 
     173    // All other operations are only valid for scalars. 
     174    if (lrank==0 && rrank==0) return 0; 
     175     
     176    assert(0, "Unsupported vector operation `" ~ op ~ "`"); 
    171177    return 0; 
    172178} 
     
    176182    assert(exprRank("A+(B*C)", [0,0,0])==0); 
    177183    assert(exprRank("A=(B*C)", [2,0,2])==2); 
     184    assert(exprRank("B*=(C*A)", [0,1,0])==1); 
    178185    assert(exprRank("D+=((A+C)*B)", [2,0,2,2])==2); 
     186    assert(exprRank("D+=((A&C)*B)", [0,1,0,1])==1); 
    179187} 
    180188 
  • trunk/blade/BladeUtil.d

    r117 r119  
    1515    static if (is(T==byte)||is(T==short)||is(T==int)||is(T==long)) { 
    1616        if (x<0) { 
    17             s = "-"; 
    18             x = -x; 
     17            return "-" ~ itoa(-x); 
    1918        } 
    2019    } 
     
    2423    } while (x>0); 
    2524    return s; 
     25} 
     26 
     27unittest { 
     28    assert(blade.BladeUtil.itoa(-5)=="-5"); 
    2629} 
    2730