private static FunctionDeclaration DetermineEntryPoint(
            FixedList <Declaration> declarations,
            Diagnostics diagnostics)
        {
            var mainFunctions = declarations.OfType <FunctionDeclaration>()
                                .Where(f => f.FullName.UnqualifiedName.Text == "main" && !f.FullName.UnqualifiedName.IsSpecial)
                                .ToList();

            // TODO warn on and remove main functions that don't have correct parameters or types

            // TODO compiler error on multiple main functions

            return(mainFunctions.SingleOrDefault());
        }
示例#2
0
        private static FunctionIL DetermineEntryPoint(
            FixedList <DeclarationIL> declarations,
            Diagnostics diagnostics)
        {
            var mainFunctions = declarations.OfType <FunctionIL>()
                                .Where(f => f.Symbol.Name == "main")
                                .ToList();

            // TODO warn on and remove main functions that don't have correct parameters or types
            _ = diagnostics;
            // TODO compiler error on multiple main functions

            return(mainFunctions.SingleOrDefault());
        }
示例#3
0
        public static void Transform(
            FixedList <MemberDeclarationSyntax> memberDeclarations,
            FixedDictionary <FunctionDeclarationSyntax, LiveVariables> liveness)
        {
            var inserter = new DeleteInserter();

            foreach (var function in memberDeclarations.OfType <FunctionDeclarationSyntax>())
            {
                if (liveness.TryGetValue(function, out var functionLiveness))
                {
                    inserter.Transform(function, functionLiveness);
                }
            }
        }
示例#4
0
        public static FixedDictionary <FunctionDeclarationSyntax, LiveVariables> Analyze(FixedList <MemberDeclarationSyntax> memberDeclarations)
        {
            var analyses         = new Dictionary <FunctionDeclarationSyntax, LiveVariables>();
            var livenessAnalyzer = new LivenessAnalyzer();

            foreach (var function in memberDeclarations.OfType <FunctionDeclarationSyntax>())
            {
                var liveness = livenessAnalyzer.AnalyzeFunction(function);
                if (liveness != null)
                {
                    analyses.Add(function, liveness);
                }
            }

            return(analyses.ToFixedDictionary());
        }