Changeset 120 for trunk/infrastructure/meta
- Timestamp:
- 07/26/07 20:06:38 (1 year ago)
- Files:
-
- trunk/infrastructure/meta/Demangle.d (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/infrastructure/meta/Demangle.d
r40 r120 29 29 * Pretty-prints a mangled type string. 30 30 */ 31 template demangleType( char[]str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName)31 template demangleType(string str, MangledNameType wantQualifiedNames = MangledNameType.PrettyName) 32 32 { 33 33 static if (wantQualifiedNames != MangledNameType.PrettyName) { … … 70 70 // split these off because they're numerous and simple 71 71 // Note: For portability, could replace "v" with void.mangleof, etc. 72 template demangleBasicType( char []str)72 template demangleBasicType(string str) 73 73 { 74 74 static if (str == "v") const char [] demangleBasicType = "void"; … … 106 106 } 107 107 108 template demangleTypeConsumed( char []str)108 template demangleTypeConsumed(string str) 109 109 { 110 110 static if (str[0]=='A') … … 132 132 133 133 // For static arrays, count number of digits used (eg, return 3 for "674") 134 template countLeadingDigits( char []str)134 template countLeadingDigits(string str) 135 135 { 136 136 static if (str.length>0 && beginsWithDigit!( str)) … … 147 147 // (this happens with templates, when the name being 'lengthed' is itself an Lname). 148 148 // We guard against this by ensuring that the L is less than the length of the string. 149 template getLname( char []str)149 template getLname(string str) 150 150 { 151 151 static if (str.length <= 9+1 || !beginsWithDigit!(str[1..$]) ) … … 163 163 // Deal with the case where an Lname contains an embedded "__D". 164 164 // This can happen when classes, typedefs, etc are declared inside a function. 165 template pretty_Dname( char []str, int dotnameconsumed, MangledNameType wantQualifiedNames)165 template pretty_Dname(string str, int dotnameconsumed, MangledNameType wantQualifiedNames) 166 166 { 167 167 static if ( isMangledFunction!( (str[2+dotnameconsumed]))) { … … 181 181 // Deal with the case where an Lname contains an embedded ("__D") function. 182 182 // Split into a seperate function because it's so complicated. 183 template pretty_Dfunction( char []str, int dotnameconsumed, int paramlistconsumed,183 template pretty_Dfunction(string str, int dotnameconsumed, int paramlistconsumed, 184 184 MangledNameType wantQualifiedNames) 185 185 { … … 203 203 204 204 // for an Lname that begins with "_D" 205 template get_DnameConsumed( char []str)205 template get_DnameConsumed(string str) 206 206 { 207 207 const int get_DnameConsumed = 2 + getQualifiedNameConsumed!(str[2..$]) … … 210 210 211 211 // If Lname is a template, shows it as a template 212 template prettyLname( char []str, MangledNameType wantQualifiedNames)212 template prettyLname(string str, MangledNameType wantQualifiedNames) 213 213 { 214 214 static if (str.length>3 && str[0..3] == "__T") // Template instance name … … 231 231 // str must start with an lname: first chars give the length 232 232 // how many chars are taken up with length digits + the name itself 233 template getLnameConsumed( char []str)233 template getLnameConsumed(string str) 234 234 { 235 235 static if (str.length==0) … … 245 245 } 246 246 247 template getQualifiedName( char [] str, MangledNameType wantQualifiedNames, char []dotstr = "")247 template getQualifiedName(string str, MangledNameType wantQualifiedNames, string dotstr = "") 248 248 { 249 249 static if (str.length==0) const char [] getQualifiedName=""; … … 269 269 } 270 270 271 template getQualifiedNameConsumed ( char []str)271 template getQualifiedNameConsumed (string str) 272 272 { 273 273 static if ( str.length>1 && beginsWithDigit!(str) ) { … … 290 290 * or "function " or "delegate " 291 291 */ 292 template demangleFunctionOrDelegate( char [] str, char []funcOrDelegStr, MangledNameType wantQualifiedNames)292 template demangleFunctionOrDelegate(string str, string funcOrDelegStr, MangledNameType wantQualifiedNames) 293 293 { 294 294 const char [] demangleFunctionOrDelegate = demangleExtern!(( str[0] )) … … 301 301 // Special case: types that are in function parameters 302 302 // For function parameters, the type can also contain 'lazy', 'out' or 'inout'. 303 template demangleFunctionParamType( char[]str, MangledNameType wantQualifiedNames)303 template demangleFunctionParamType(string str, MangledNameType wantQualifiedNames) 304 304 { 305 305 static if (str[0]=='L') … … 313 313 314 314 // Deal with 'out' and 'inout' parameters 315 template demangleFunctionParamTypeConsumed( char[]str)315 template demangleFunctionParamTypeConsumed(string str) 316 316 { 317 317 static if (str[0]=='K' || str[0]=='J' || str[0]=='L') … … 338 338 // Skip through the string until we find the return value. It can either be Z for normal 339 339 // functions, or Y for vararg functions. 340 template demangleReturnValue( char []str, MangledNameType wantQualifiedNames)340 template demangleReturnValue(string str, MangledNameType wantQualifiedNames) 341 341 { 342 342 static assert(str.length>=1, "Demangle error(Function): No return value found"); … … 347 347 348 348 // Stop when we get to the return value 349 template demangleParamList( char [] str, MangledNameType wantQualifiedNames, char[]commastr = "")349 template demangleParamList(string str, MangledNameType wantQualifiedNames, string commastr = "") 350 350 { 351 351 static if (str[0] == 'Z') … … 362 362 363 363 // How many characters are used in the parameter list and return value 364 template demangleParamListAndRetValConsumed( char []str)364 template demangleParamListAndRetValConsumed(string str) 365 365 { 366 366 static assert (str.length>0, "Demangle error(ParamList): No return value found"); … … 376 376 // TEMPLATES 377 377 378 template templateValueArgConsumed( char []str)378 template templateValueArgConsumed(string str) 379 379 { 380 380 static if (str[0]=='n') const int templateValueArgConsumed = 1; … … 387 387 388 388 // pretty-print a template value argument. 389 template prettyValueArg( char []str)389 template prettyValueArg(string str) 390 390 { 391 391 static if (str[0]=='n') const char [] prettyValueArg = "null"; … … 398 398 399 399 // Pretty-print a template argument 400 template prettyTemplateArg( char []str, MangledNameType wantQualifiedNames)400 template prettyTemplateArg(string str, MangledNameType wantQualifiedNames) 401 401 { 402 402 static if (str[0]=='S') // symbol name … … 411 411 } 412 412 413 template templateArgConsumed( char []str)413 template templateArgConsumed(string str) 414 414 { 415 415 static if (str[0]=='S') // symbol name … … 425 425 // Like function parameter lists, template parameter lists also end in a Z, 426 426 // but they don't have a return value at the end. 427 template prettyTemplateArgList( char [] str, MangledNameType wantQualifiedNames, char []commastr="")427 template prettyTemplateArgList(string str, MangledNameType wantQualifiedNames, string commastr="") 428 428 { 429 429 static if (str[0]=='Z') … … 435 435 } 436 436 437 template templateArgListConsumed( char []str)437 template templateArgListConsumed(string str) 438 438 { 439 439 static assert(str.length>0, "No Z found at end of template argument list"); … … 452 452 * it allows us to avoid the ugly double parentheses. 453 453 */ 454 template beginsWithDigit( char []s)454 template beginsWithDigit(string s) 455 455 { 456 456 static if (s[0]>='0' && s[0]<='9')
