private static string MakeName(VariableSlotAllocator slotAllocatorOpt, SyntaxNode scopeSyntaxOpt, MethodDebugId methodId, int closureOrdinal) { if (scopeSyntaxOpt == null) { // Display class is shared among static non-generic lambdas accross generations, method ordinal is -1 in that case. // A new display class of a static generic lambda is created for each method and each generation. return(GeneratedNames.MakeStaticLambdaDisplayClassName(methodId.Ordinal, methodId.Generation)); } int previousClosureOrdinal; if (slotAllocatorOpt != null && slotAllocatorOpt.TryGetPreviousClosure(scopeSyntaxOpt, out previousClosureOrdinal)) { methodId = slotAllocatorOpt.PreviousMethodId; closureOrdinal = previousClosureOrdinal; } // If we haven't found existing closure in the previous generation, use the current generation method ordinal. // That is, don't try to reuse previous generation method ordinal as that might create name conflict. // E.g. // Gen0 Gen1 // F() { new closure } // ordinal 0 // G() { } // ordinal 0 G() { new closure } // ordinal 1 // // In the example above G is updated and F is added. // G's ordinal in Gen0 is 0. If we used that ordinal for updated G's new closure it would conflict with F's ordinal. Debug.Assert(methodId.Ordinal >= 0); return(GeneratedNames.MakeLambdaDisplayClassName(methodId.Ordinal, methodId.Generation, closureOrdinal)); }
private static string MakeName(SyntaxNode scopeSyntaxOpt, DebugId methodId, DebugId closureId) { if (scopeSyntaxOpt == null) { // Display class is shared among static non-generic lambdas across generations, method ordinal is -1 in that case. // A new display class of a static generic lambda is created for each method and each generation. return(GeneratedNames.MakeStaticLambdaDisplayClassName(methodId.Ordinal, methodId.Generation)); } Debug.Assert(methodId.Ordinal >= 0); return(GeneratedNames.MakeLambdaDisplayClassName(methodId.Ordinal, methodId.Generation, closureId.Ordinal, closureId.Generation)); }
private static string MakeName(VariableSlotAllocator slotAllocatorOpt, TypeCompilationState compilationState, int methodOrdinal, int scopeOrdinal, bool isStatic) { // TODO: slotAllocatorOpt?.GetPrevious() int generation = compilationState.ModuleBuilderOpt.CurrentGenerationOrdinal; if (isStatic) { // Display class is shared among static non-generic lambdas and also accross generations, method ordinal is -1. Debug.Assert(methodOrdinal >= -1); return(GeneratedNames.MakeStaticLambdaDisplayClassName(methodOrdinal, generation)); } Debug.Assert(methodOrdinal >= 0); return(GeneratedNames.MakeLambdaDisplayClassName(methodOrdinal, generation, scopeOrdinal)); }