public static AbstractType Demangle(string mangledString, out ITypeDeclaration qualifier, out bool isCFunction) { if (string.IsNullOrEmpty(mangledString)) { throw new ArgumentException("строка ввода должна не быть пустой или null!"); } if (!mangledString.StartsWith("_D")) { isCFunction = true; if (mangledString.StartsWith("__D")) { mangledString = mangledString.Substring(1); } // C Functions else if (mangledString.StartsWith("_")) { qualifier = new IdentifierDeclaration(mangledString.Substring(1)); return(null); } } //TODO: What about C functions that start with 'D'? isCFunction = false; var dmng = new Demangler(mangledString); return(dmng.MangledName(out qualifier)); }
public static ITypeDeclaration DemangleQualifier(string mangledString) { if (mangledString == "_Dmain") { return(new IdentifierDeclaration("main")); } else if (!mangledString.StartsWith("_D")) { if (mangledString.StartsWith("__D")) { mangledString = mangledString.Substring(1); } // C Functions else if (mangledString.StartsWith("_")) { return(new IdentifierDeclaration(mangledString.Substring(1))); } } var dmng = new Demangler(mangledString); dmng.r.Read(); // Skip _ dmng.r.Read(); // SKip D return(RemoveNestedTemplateRefsFromQualifier(dmng.QualifiedName())); }
public static ITypeDeclaration DemangleQualifier(string mangledString) { if (mangledString == "_Dmain") return new IdentifierDeclaration ("main"); else if (!mangledString.StartsWith("_D")) { if (mangledString.StartsWith("__D")) mangledString = mangledString.Substring(1); // C Functions else if (mangledString.StartsWith("_")) return new IdentifierDeclaration(mangledString.Substring(1)); } var dmng = new Demangler(mangledString); dmng.r.Read(); // Skip _ dmng.r.Read(); // SKip D return RemoveNestedTemplateRefsFromQualifier(dmng.QualifiedName()); }
public static AbstractType DemangleAndResolve(string mangledString, ResolutionContext ctxt, out ITypeDeclaration qualifier) { bool isCFunction; Demangler.Demangle(mangledString, out qualifier, out isCFunction); // Seek for C functions | Functions that have no direct module association (e.g. _Dmain) if (qualifier is IdentifierDeclaration && qualifier.InnerDeclaration == null) { var id = (qualifier as IdentifierDeclaration).Id; return(Resolver.ASTScanner.NameScan.ScanForCFunction(ctxt, id, isCFunction)); } bool seekCtor = false; if (qualifier is IdentifierDeclaration) { var id = (qualifier as IdentifierDeclaration).Id; if ((seekCtor = (id == DMethod.ConstructorIdentifier)) || id == "__Class" || id == "__ModuleInfo") { qualifier = qualifier.InnerDeclaration; } } var resSym = TypeDeclarationResolver.ResolveSingle(qualifier, ctxt); if (seekCtor && resSym is UserDefinedType) { var ctor = (resSym as TemplateIntermediateType).Definition[DMethod.ConstructorIdentifier].FirstOrDefault(); if (ctor != null) { resSym = new MemberSymbol(ctor as DNode, null, null); } } return(resSym); }
public static AbstractType Demangle(string mangledString, out ITypeDeclaration qualifier, out bool isCFunction) { if(string.IsNullOrEmpty(mangledString)) throw new ArgumentException("строка ввода должна не быть пустой или null!"); if (!mangledString.StartsWith("_D")) { isCFunction = true; if (mangledString.StartsWith ("__D")) mangledString = mangledString.Substring (1); // C Functions else if (mangledString.StartsWith ("_")) { qualifier = new IdentifierDeclaration (mangledString.Substring (1)); return null; } } //TODO: What about C functions that start with 'D'? isCFunction = false; var dmng = new Demangler(mangledString); return dmng.MangledName(out qualifier); }