Ejemplo n.º 1
0
        private OutputKind OutputAssemblyTypeToOutputKind(OutputAssemblyType outputType)
        {
            switch (outputType)
            {
            case OutputAssemblyType.Library:
                return(OutputKind.DynamicallyLinkedLibrary);

            case OutputAssemblyType.ConsoleApplication:
                return(OutputKind.ConsoleApplication);

            case OutputAssemblyType.WindowsApplication:
                return(OutputKind.WindowsApplication);

            default:
                throw new ArgumentOutOfRangeException("outputType");
            }
        }
Ejemplo n.º 2
0
        public static string GetNodeType(string data, ref OutputAssemblyType type)
        {
            Match match = entryPointRegex.Match(data);

            if (match.Success)
            {
                if (string.IsNullOrWhiteSpace(match.Groups[1].Value))
                {
                    type = OutputAssemblyType.Console;
                }
                else
                {
                    type = OutputAssemblyType.Executable;
                }

                return(entryPointRegex.Replace(data, "*"));
            }
            else
            {
                return(data);
            }
        }
Ejemplo n.º 3
0
 private OutputKind OutputAssemblyTypeToOutputKind(OutputAssemblyType outputType)
 {
     switch (outputType)
     {
         case OutputAssemblyType.Library:
             return OutputKind.DynamicallyLinkedLibrary;
         case OutputAssemblyType.ConsoleApplication:
             return OutputKind.ConsoleApplication;
         case OutputAssemblyType.WindowsApplication:
             return OutputKind.WindowsApplication;
         default:
             throw new ArgumentOutOfRangeException("outputType");
     }
 }
Ejemplo n.º 4
0
        public override void FetchExports()
        {
            string content = file.GetText(Encoding.UTF8);

            content = CodeParser.Prepare(content);

            OutputAssemblyType nodeType = OutputAssemblyType.Library;

            content = CodeParser.GetNodeType(content, ref nodeType);
            if (nodeType != OutputAssemblyType.Library)
            {
                flags.Add((UInt16)nodeType);
            }

            content = CodeParser.GetUsingDirectives(content, namespaceReferences);
            content = CodeParser.GetDeclarations(content, namespaces, declarations);
            namespaces.Insert(0, GlobalNamespace);

            Dictionary <int, List <KeyValuePair <int, string> > > declarationsByNamespace = new Dictionary <int, List <KeyValuePair <int, string> > >();

            for (int i = 0; i < namespaces.Count; i++)
            {
                int start = namespaces[i].Key;
                int end   = ((namespaces.Count > i + 1) ? namespaces[i + 1].Key : int.MaxValue);

                List <KeyValuePair <int, string> > lst = new List <KeyValuePair <int, string> >();
                foreach (KeyValuePair <int, string> declaration in declarations)
                {
                    if (declaration.Key >= start && declaration.Key < end)
                    {
                        if (lst.Where(x => x.Value == declaration.Value).Count() == 0)
                        {
                            lst.Add(declaration);
                        }
                    }
                }

                if (lst.Count > 0)
                {
                    declarationsByNamespace.Add(start, lst);
                }
            }

            declarations.Clear();
            foreach (List <KeyValuePair <int, string> > lst in declarationsByNamespace.Values)
            {
                declarations.AddRange(lst);
            }

            CodeParser.GetReferences(content, typeReferences);

            declarationsByNamespace.Clear();
            for (int i = 0; i < namespaces.Count; i++)
            {
                int start = namespaces[i].Key;
                int end   = ((namespaces.Count > i + 1) ? namespaces[i + 1].Key : int.MaxValue);

                List <KeyValuePair <int, string> > lst = new List <KeyValuePair <int, string> >();
                foreach (KeyValuePair <int, string> reference in typeReferences)
                {
                    if (reference.Key >= start && reference.Key < end)
                    {
                        if (lst.Where(x => x.Value == reference.Value).Count() == 0)
                        {
                            lst.Add(reference);
                        }
                    }
                }

                if (lst.Count > 0)
                {
                    declarationsByNamespace.Add(start, lst);
                }
            }

            typeReferences.Clear();
            foreach (List <KeyValuePair <int, string> > lst in declarationsByNamespace.Values)
            {
                typeReferences.AddRange(lst);
            }

            for (int i = 0; i < typeReferences.Count; i++)
            {
                if (typeReferences[i].Value.Contains("."))
                {
                    string[] v = typeReferences[i].Value.Split('.');
                    typeReferences[i] = new KeyValuePair <int, string>(typeReferences[i].Key, v[0].Trim());
                }
            }

            namespaces.RemoveAt(0);
        }