Example #1
0
        public static AbstractType Demangle(string mangledString, ResolutionContext ctxt, out ITypeDeclaration qualifier, out bool isCFunction)
        {
            if(string.IsNullOrEmpty(mangledString))
                throw new ArgumentException("input string must not be null or empty!");

            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) { ctxt = ctxt };

            return dmng.MangledName(out qualifier);
        }
Example #2
0
        public static AbstractType Demangle(string mangledString, out ITypeDeclaration qualifier, out bool isCFunction)
        {
            if (string.IsNullOrEmpty(mangledString))
            {
                throw new ArgumentException("input string must not be null or empty!");
            }

            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));
        }
Example #3
0
        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()));
        }
Example #4
0
		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());
		}
Example #5
0
        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);
        }