Changeset 119
- Timestamp:
- 10/17/07 07:49:55 (1 year ago)
- Files:
-
- trunk/blade/BladeRank.d (modified) (2 diffs)
- trunk/blade/BladeUtil.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/blade/BladeRank.d
r117 r119 166 166 } 167 167 // 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 ~ "`"); 171 177 return 0; 172 178 } … … 176 182 assert(exprRank("A+(B*C)", [0,0,0])==0); 177 183 assert(exprRank("A=(B*C)", [2,0,2])==2); 184 assert(exprRank("B*=(C*A)", [0,1,0])==1); 178 185 assert(exprRank("D+=((A+C)*B)", [2,0,2,2])==2); 186 assert(exprRank("D+=((A&C)*B)", [0,1,0,1])==1); 179 187 } 180 188 trunk/blade/BladeUtil.d
r117 r119 15 15 static if (is(T==byte)||is(T==short)||is(T==int)||is(T==long)) { 16 16 if (x<0) { 17 s = "-"; 18 x = -x; 17 return "-" ~ itoa(-x); 19 18 } 20 19 } … … 24 23 } while (x>0); 25 24 return s; 25 } 26 27 unittest { 28 assert(blade.BladeUtil.itoa(-5)=="-5"); 26 29 } 27 30
