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()); }
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()); }
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); } } }
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()); }