Files
PURErat-crack-scode/decompiled/Libraries/microsoft.codeanalysis.csharp/Microsoft.CodeAnalysis.CSharp/MethodCompiler.cs
T
2026-08-27 10:56:38 -06:00

1415 lines
72 KiB
C#

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CSharp.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Emit;
using Microsoft.CodeAnalysis.CSharp.Emit.NoPia;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.Debugging;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Symbols;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp;
internal sealed class MethodCompiler : CSharpSymbolVisitor<TypeCompilationState, object>
{
private readonly CSharpCompilation _compilation;
private readonly bool _emittingPdb;
private readonly CancellationToken _cancellationToken;
private readonly BindingDiagnosticBag _diagnostics;
private readonly bool _hasDeclarationErrors;
private readonly bool _emitMethodBodies;
private readonly PEModuleBuilder _moduleBeingBuiltOpt;
private readonly Predicate<Symbol> _filterOpt;
private readonly SynthesizedEntryPointSymbol.AsyncForwardEntryPoint _entryPointOpt;
private DebugDocumentProvider _lazyDebugDocumentProvider;
private ConcurrentStack<Task> _compilerTasks;
private bool _globalHasErrors;
private bool ReportNullableDiagnostics
{
get
{
PEModuleBuilder moduleBeingBuiltOpt = _moduleBeingBuiltOpt;
if (moduleBeingBuiltOpt == null)
{
return true;
}
return !((CommonPEModuleBuilder)moduleBeingBuiltOpt).IsEncDelta;
}
}
private void SetGlobalErrorIfTrue(bool arg)
{
if (arg)
{
_globalHasErrors = true;
}
}
internal MethodCompiler(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, bool emittingPdb, bool hasDeclarationErrors, bool emitMethodBodies, BindingDiagnosticBag diagnostics, Predicate<Symbol> filterOpt, SynthesizedEntryPointSymbol.AsyncForwardEntryPoint entryPointOpt, CancellationToken cancellationToken)
{
_compilation = compilation;
_moduleBeingBuiltOpt = moduleBeingBuiltOpt;
_emittingPdb = emittingPdb;
_cancellationToken = cancellationToken;
_diagnostics = diagnostics;
_filterOpt = filterOpt;
_entryPointOpt = entryPointOpt;
_hasDeclarationErrors = hasDeclarationErrors;
SetGlobalErrorIfTrue(hasDeclarationErrors);
_emitMethodBodies = emitMethodBodies;
}
public static void CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, bool emittingPdb, bool hasDeclarationErrors, bool emitMethodBodies, BindingDiagnosticBag diagnostics, Predicate<Symbol> filterOpt, CancellationToken cancellationToken)
{
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
hasDeclarationErrors |= compilation.CheckDuplicateInterceptions(diagnostics);
if (compilation.PreviousSubmission != null)
{
((Compilation)compilation.PreviousSubmission).EnsureAnonymousTypeTemplates(cancellationToken);
}
MethodSymbol methodSymbol = null;
if (filterOpt == null)
{
methodSymbol = GetEntryPoint(compilation, moduleBeingBuiltOpt, hasDeclarationErrors, emitMethodBodies, diagnostics, cancellationToken);
}
MethodCompiler methodCompiler = new MethodCompiler(compilation, moduleBeingBuiltOpt, emittingPdb, hasDeclarationErrors, emitMethodBodies, diagnostics, filterOpt, methodSymbol as SynthesizedEntryPointSymbol.AsyncForwardEntryPoint, cancellationToken);
if (((CompilationOptions)compilation.Options).ConcurrentBuild)
{
methodCompiler._compilerTasks = new ConcurrentStack<Task>();
}
methodCompiler.CompileNamespace(compilation.SourceModule.GlobalNamespace);
methodCompiler.WaitForWorkers();
if (moduleBeingBuiltOpt != null)
{
ImmutableArray<NamedTypeSymbol> additionalTopLevelTypes = ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBeingBuiltOpt).GetAdditionalTopLevelTypes();
methodCompiler.CompileSynthesizedMethods(additionalTopLevelTypes, diagnostics);
ImmutableArray<NamedTypeSymbol> embeddedTypes = moduleBeingBuiltOpt.GetEmbeddedTypes(diagnostics);
methodCompiler.CompileSynthesizedMethods(embeddedTypes, diagnostics);
if (emitMethodBodies)
{
compilation.AnonymousTypeManager.AssignTemplatesNamesAndCompile(methodCompiler, moduleBeingBuiltOpt, diagnostics);
}
methodCompiler.WaitForWorkers();
PrivateImplementationDetails val = ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBeingBuiltOpt).FreezePrivateImplementationDetails();
if (val != null)
{
methodCompiler.CompileSynthesizedMethods(val, diagnostics);
}
}
if (moduleBeingBuiltOpt != null && (methodCompiler._globalHasErrors || ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBeingBuiltOpt).SourceModule.HasBadAttributes) && !((BindingDiagnosticBag)diagnostics).HasAnyErrors() && !hasDeclarationErrors)
{
string text = (methodCompiler._globalHasErrors ? "UnableToDetermineSpecificCauseOfFailure" : "ModuleHasInvalidAttributes");
diagnostics.Add(ErrorCode.ERR_ModuleEmitFailure, NoLocation.Singleton, ((INamedEntity)moduleBeingBuiltOpt).Name, (object)new LocalizableResourceString(text, CodeAnalysisResources.ResourceManager, typeof(CodeAnalysisResources)));
}
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(compilation.AdditionalCodegenWarnings);
if (filterOpt == null)
{
WarnUnusedFields(compilation, diagnostics, cancellationToken);
if (moduleBeingBuiltOpt != null && methodSymbol != null && EnumBounds.IsApplication(((CompilationOptions)compilation.Options).OutputKind))
{
((CommonPEModuleBuilder)moduleBeingBuiltOpt).SetPEEntryPoint((IMethodSymbolInternal)(object)methodSymbol, ((BindingDiagnosticBag)diagnostics).DiagnosticBag);
}
}
}
private static MethodSymbol GetEntryPoint(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuilt, bool hasDeclarationErrors, bool emitMethodBodies, BindingDiagnosticBag diagnostics, CancellationToken cancellationToken)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
CSharpCompilation.EntryPoint entryPointAndDiagnostics = compilation.GetEntryPointAndDiagnostics(cancellationToken);
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange(entryPointAndDiagnostics.Diagnostics, true);
MethodSymbol methodSymbol = entryPointAndDiagnostics.MethodSymbol;
if ((object)methodSymbol == null)
{
return null;
}
SynthesizedEntryPointSymbol synthesizedEntryPointSymbol = methodSymbol as SynthesizedEntryPointSymbol;
if ((object)synthesizedEntryPointSymbol == null)
{
TypeSymbol returnType = methodSymbol.ReturnType;
if (returnType.IsGenericTaskType(compilation) || returnType.IsNonGenericTaskType(compilation))
{
synthesizedEntryPointSymbol = new SynthesizedEntryPointSymbol.AsyncForwardEntryPoint(compilation, methodSymbol.ContainingType, methodSymbol);
methodSymbol = synthesizedEntryPointSymbol;
((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBeingBuilt)?.AddSynthesizedDefinition(methodSymbol.ContainingType, (IMethodDefinition)(object)synthesizedEntryPointSymbol.GetCciAdapter());
}
}
if ((object)synthesizedEntryPointSymbol != null && moduleBeingBuilt != null && !hasDeclarationErrors && !((BindingDiagnosticBag)diagnostics).HasAnyErrors())
{
BoundStatement boundStatement = synthesizedEntryPointSymbol.CreateBody(diagnostics);
if (boundStatement.HasErrors || ((BindingDiagnosticBag)diagnostics).HasAnyErrors())
{
return methodSymbol;
}
VariableSlotAllocator lazyVariableSlotAllocator = null;
ArrayBuilder<LambdaDebugInfo> instance = ArrayBuilder<LambdaDebugInfo>.GetInstance();
ArrayBuilder<ClosureDebugInfo> instance2 = ArrayBuilder<ClosureDebugInfo>.GetInstance();
ArrayBuilder<StateMachineStateDebugInfo> instance3 = ArrayBuilder<StateMachineStateDebugInfo>.GetInstance();
StateMachineTypeSymbol stateMachineTypeOpt = null;
ImmutableArray<SourceSpan> codeCoverageSpans;
BoundStatement block = LowerBodyOrInitializer(synthesizedEntryPointSymbol, -1, boundStatement, null, new TypeCompilationState(synthesizedEntryPointSymbol.ContainingType, compilation, moduleBeingBuilt), MethodInstrumentation.Empty, null, out codeCoverageSpans, diagnostics, ref lazyVariableSlotAllocator, instance, instance2, instance3, out stateMachineTypeOpt);
instance.Free();
instance2.Free();
instance3.Free();
if (emitMethodBodies)
{
MethodBody val = GenerateMethodBody(moduleBeingBuilt, synthesizedEntryPointSymbol, -1, block, ImmutableArray<LambdaDebugInfo>.Empty, ImmutableArray<ClosureDebugInfo>.Empty, ImmutableArray<StateMachineStateDebugInfo>.Empty, null, null, diagnostics, null, null, emittingPdb: false, ImmutableArray<SourceSpan>.Empty, null);
((CommonPEModuleBuilder)moduleBeingBuilt).SetMethodBody((IMethodSymbolInternal)(object)synthesizedEntryPointSymbol, (IMethodBody)(object)val);
}
}
return methodSymbol;
}
private void WaitForWorkers()
{
ConcurrentStack<Task> compilerTasks = _compilerTasks;
if (compilerTasks != null)
{
Task result;
while (compilerTasks.TryPop(out result))
{
result.GetAwaiter().GetResult();
}
}
}
private static void WarnUnusedFields(CSharpCompilation compilation, BindingDiagnosticBag diagnostics, CancellationToken cancellationToken)
{
SourceAssemblySymbol sourceAssemblySymbol = (SourceAssemblySymbol)compilation.Assembly;
((BindingDiagnosticBag)diagnostics).AddRange<Diagnostic>(sourceAssemblySymbol.GetUnusedFieldWarnings(cancellationToken));
}
private DebugDocumentProvider GetDebugDocumentProvider(MethodInstrumentation instrumentation)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0038: Expected O, but got Unknown
if (_emittingPdb || ((MethodInstrumentation)(ref instrumentation)).Kinds.Contains((InstrumentationKind)1))
{
DebugDocumentProvider obj = _lazyDebugDocumentProvider;
if (obj == null)
{
DebugDocumentProvider val = (string path, string basePath) => ((CommonPEModuleBuilder)_moduleBeingBuiltOpt).DebugDocumentsBuilder.GetOrAddDebugDocument(path, basePath, (Func<string, DebugSourceDocument>)CreateDebugDocumentForFile);
DebugDocumentProvider val2 = val;
_lazyDebugDocumentProvider = val;
obj = val2;
}
return obj;
}
return null;
}
public override object VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg)
{
if (!PassesFilter(_filterOpt, symbol))
{
return null;
}
arg = null;
CancellationToken cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
if (((CompilationOptions)_compilation.Options).ConcurrentBuild)
{
Task item = CompileNamespaceAsAsync(symbol);
_compilerTasks.Push(item);
}
else
{
CompileNamespace(symbol);
}
return null;
}
private Task CompileNamespaceAsAsync(NamespaceSymbol symbol)
{
return Task.Run(UICultureUtilities.WithCurrentUICulture((Action)delegate
{
try
{
CompileNamespace(symbol);
}
catch (Exception ex) when (FatalError.ReportAndPropagateUnlessCanceled(ex, (ErrorSeverity)0))
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 385);
}
}), _cancellationToken);
}
private void CompileNamespace(NamespaceSymbol symbol)
{
ImmutableArray<Symbol>.Enumerator enumerator = symbol.GetMembersUnordered().GetEnumerator();
while (enumerator.MoveNext())
{
enumerator.Current.Accept(this, null);
}
}
public override object VisitNamedType(NamedTypeSymbol symbol, TypeCompilationState arg)
{
if (!PassesFilter(_filterOpt, symbol))
{
return null;
}
arg = null;
CancellationToken cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
if (((CompilationOptions)_compilation.Options).ConcurrentBuild)
{
Task item = CompileNamedTypeAsync(symbol);
_compilerTasks.Push(item);
}
else
{
CompileNamedType(symbol);
}
return null;
}
private Task CompileNamedTypeAsync(NamedTypeSymbol symbol)
{
return Task.Run(UICultureUtilities.WithCurrentUICulture((Action)delegate
{
try
{
CompileNamedType(symbol);
}
catch (Exception ex) when (FatalError.ReportAndPropagateUnlessCanceled(ex, (ErrorSeverity)0))
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 431);
}
}), _cancellationToken);
}
private void CompileNamedType(NamedTypeSymbol containingType)
{
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected I4, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Invalid comparison between Unknown and I4
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Invalid comparison between Unknown and I4
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Invalid comparison between Unknown and I4
//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Invalid comparison between Unknown and I4
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Invalid comparison between Unknown and I4
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Invalid comparison between Unknown and I4
TypeCompilationState typeCompilationState = new TypeCompilationState(containingType, _compilation, _moduleBeingBuiltOpt);
CancellationToken cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
SynthesizedInstanceConstructor synthesizedInstanceConstructor = null;
SynthesizedInteractiveInitializerMethod scriptInitializerOpt = null;
SynthesizedEntryPointSymbol synthesizedEntryPointSymbol = null;
int methodOrdinal = -1;
if (containingType.IsScriptClass)
{
synthesizedInstanceConstructor = containingType.GetScriptConstructor();
scriptInitializerOpt = containingType.GetScriptInitializer();
synthesizedEntryPointSymbol = containingType.GetScriptEntryPoint();
}
SynthesizedSubmissionFields synthesizedSubmissionFields = (containingType.IsSubmissionClass ? new SynthesizedSubmissionFields(_compilation, containingType) : null);
Binder.ProcessedFieldInitializers processedInitializers = default(Binder.ProcessedFieldInitializers);
Binder.ProcessedFieldInitializers processedInitializers2 = default(Binder.ProcessedFieldInitializers);
SourceMemberContainerTypeSymbol sourceMemberContainerTypeSymbol = containingType as SourceMemberContainerTypeSymbol;
if ((object)sourceMemberContainerTypeSymbol != null)
{
cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
Binder.BindFieldInitializers(_compilation, scriptInitializerOpt, sourceMemberContainerTypeSymbol.StaticInitializers, _diagnostics, ref processedInitializers);
cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
Binder.BindFieldInitializers(_compilation, scriptInitializerOpt, sourceMemberContainerTypeSymbol.InstanceInitializers, _diagnostics, ref processedInitializers2);
if (typeCompilationState.Emitting)
{
CompileSynthesizedExplicitImplementations(sourceMemberContainerTypeSymbol, typeCompilationState);
}
}
ImmutableArray<Symbol> members = containingType.GetMembers();
for (int i = 0; i < members.Length; i++)
{
Symbol symbol = members[i];
if (!PassesFilter(_filterOpt, symbol))
{
continue;
}
SymbolKind kind = symbol.Kind;
switch (kind - 5)
{
default:
if ((int)kind == 15 && symbol is SourcePropertySymbolBase { IsSealed: not false } sourcePropertySymbolBase && typeCompilationState.Emitting)
{
CompileSynthesizedSealedAccessors(sourcePropertySymbolBase, typeCompilationState);
}
break;
case 6:
symbol.Accept(this, typeCompilationState);
break;
case 4:
{
MethodSymbol methodSymbol = (MethodSymbol)symbol;
if (methodSymbol.IsScriptConstructor)
{
methodOrdinal = i;
}
else if ((object)methodSymbol != synthesizedEntryPointSymbol)
{
methodSymbol = GetMethodToCompile(methodSymbol);
if ((object)methodSymbol != null)
{
Binder.ProcessedFieldInitializers processedInitializers3 = (((int)methodSymbol.MethodKind == 1 || methodSymbol.IsScriptInitializer) ? processedInitializers2 : (((int)methodSymbol.MethodKind == 14) ? processedInitializers : default(Binder.ProcessedFieldInitializers)));
CompileMethod(methodSymbol, i, ref processedInitializers3, synthesizedSubmissionFields, typeCompilationState);
}
}
break;
}
case 0:
if (symbol is SourceEventSymbol { HasAssociatedField: not false, IsAbstract: false } sourceEventSymbol && typeCompilationState.Emitting)
{
CompileFieldLikeEventAccessor(sourceEventSymbol, isAddMethod: true);
CompileFieldLikeEventAccessor(sourceEventSymbol, isAddMethod: false);
}
break;
case 1:
{
FieldSymbol fieldSymbol = (FieldSymbol)symbol;
if (!(symbol is TupleErrorFieldSymbol))
{
if (fieldSymbol.IsConst)
{
ConstantValue constantValue = fieldSymbol.GetConstantValue(ConstantFieldsInProgress.Empty, earlyDecodingWellKnownAttributes: false);
SetGlobalErrorIfTrue(constantValue == (ConstantValue)null || constantValue.IsBad);
}
if (fieldSymbol.IsFixedSizeBuffer && typeCompilationState.Emitting)
{
fieldSymbol.FixedImplementationType(typeCompilationState.ModuleBuilderOpt);
}
}
break;
}
case 2:
case 3:
case 5:
break;
}
}
if (AnonymousTypeManager.IsAnonymousTypeTemplate(containingType))
{
Binder.ProcessedFieldInitializers processedInitializers4 = default(Binder.ProcessedFieldInitializers);
ImmutableArray<MethodSymbol>.Enumerator enumerator = AnonymousTypeManager.GetAnonymousTypeHiddenMethods(containingType).GetEnumerator();
while (enumerator.MoveNext())
{
MethodSymbol current = enumerator.Current;
CompileMethod(current, -1, ref processedInitializers4, synthesizedSubmissionFields, typeCompilationState);
}
}
bool flag;
bool flag2;
if (containingType.StaticConstructors.IsEmpty)
{
if (_moduleBeingBuiltOpt != null && !processedInitializers.BoundInitializers.IsDefaultOrEmpty)
{
MethodSymbol methodSymbol2 = new SynthesizedStaticConstructor(sourceMemberContainerTypeSymbol);
if (PassesFilter(_filterOpt, methodSymbol2))
{
CompileMethod(methodSymbol2, -1, ref processedInitializers, synthesizedSubmissionFields, typeCompilationState);
if (((CommonPEModuleBuilder)_moduleBeingBuiltOpt).GetMethodBody((IMethodSymbolInternal)(object)methodSymbol2) != null)
{
((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)_moduleBeingBuiltOpt).AddSynthesizedDefinition((NamedTypeSymbol)sourceMemberContainerTypeSymbol, (IMethodDefinition)(object)methodSymbol2.GetCciAdapter());
}
}
}
flag = processedInitializers.BoundInitializers.IsDefaultOrEmpty && _compilation.LanguageVersion >= MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion();
if (flag)
{
if ((object)containingType != null && !containingType.IsImplicitlyDeclared)
{
TypeKind typeKind = containingType.TypeKind;
if ((int)typeKind == 2 || (int)typeKind == 7 || (int)typeKind == 10)
{
flag2 = true;
goto IL_03da;
}
}
flag2 = false;
goto IL_03da;
}
goto IL_03de;
}
goto IL_0412;
IL_0412:
if (synthesizedInstanceConstructor != null && typeCompilationState.Emitting)
{
Binder.ProcessedFieldInitializers processedInitializers5 = new Binder.ProcessedFieldInitializers
{
BoundInitializers = ImmutableArray<BoundInitializer>.Empty
};
CompileMethod(synthesizedInstanceConstructor, methodOrdinal, ref processedInitializers5, synthesizedSubmissionFields, typeCompilationState);
synthesizedSubmissionFields?.AddToType(containingType, typeCompilationState.ModuleBuilderOpt);
}
if (_moduleBeingBuiltOpt != null)
{
CompileSynthesizedMethods(typeCompilationState);
}
typeCompilationState.Free();
return;
IL_03da:
flag = flag2;
goto IL_03de;
IL_03de:
if (flag && ReportNullableDiagnostics)
{
NullableWalker.AnalyzeIfNeeded(_compilation, new SynthesizedStaticConstructor(containingType), GetSynthesizedEmptyBody(containingType), ((BindingDiagnosticBag)_diagnostics).DiagnosticBag, useConstructorExitWarnings: true, null, getFinalNullableState: false, null, out NullableWalker.VariableState _);
}
goto IL_0412;
}
internal static MethodSymbol GetMethodToCompile(MethodSymbol method)
{
if (IsFieldLikeEventAccessor(method))
{
return null;
}
if (method.IsPartialDefinition())
{
return method.PartialImplementationPart;
}
return method;
}
private void CompileSynthesizedMethods(PrivateImplementationDetails privateImplClass, BindingDiagnosticBag diagnostics)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
TypeCompilationState typeCompilationState = new TypeCompilationState(null, _compilation, _moduleBeingBuiltOpt);
EmitContext val = default(EmitContext);
((EmitContext)(ref val))._002Ector((CommonPEModuleBuilder)(object)_moduleBeingBuiltOpt, (SyntaxNode)null, ((BindingDiagnosticBag)diagnostics).DiagnosticBag, false, true);
foreach (IMethodDefinition item in ((DefaultTypeDef)privateImplClass).GetMethods(val).Concat(privateImplClass.GetTopLevelTypeMethods(val)))
{
((MethodSymbol)(object)((IReference)item).GetInternalSymbol()).GenerateMethodBody(typeCompilationState, diagnostics);
}
CompileSynthesizedMethods(typeCompilationState);
typeCompilationState.Free();
}
private void CompileSynthesizedMethods(ImmutableArray<NamedTypeSymbol> additionalTypes, BindingDiagnosticBag diagnostics)
{
ImmutableArray<NamedTypeSymbol>.Enumerator enumerator = additionalTypes.GetEnumerator();
while (enumerator.MoveNext())
{
NamedTypeSymbol current = enumerator.Current;
TypeCompilationState typeCompilationState = new TypeCompilationState(current, _compilation, _moduleBeingBuiltOpt);
foreach (MethodSymbol item in current.GetMethodsToEmit())
{
item.GenerateMethodBody(typeCompilationState, diagnostics);
}
if (!((BindingDiagnosticBag)diagnostics).HasAnyErrors())
{
CompileSynthesizedMethods(typeCompilationState);
}
typeCompilationState.Free();
}
}
private void CompileSynthesizedMethods(TypeCompilationState compilationState)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<TypeCompilationState.MethodWithBody> synthesizedMethods = compilationState.SynthesizedMethods;
if (synthesizedMethods == null)
{
return;
}
ArrayBuilder<StateMachineStateDebugInfo> instance = ArrayBuilder<StateMachineStateDebugInfo>.GetInstance();
ImportChain currentImportChain = compilationState.CurrentImportChain;
try
{
Enumerator<TypeCompilationState.MethodWithBody> enumerator = synthesizedMethods.GetEnumerator();
while (enumerator.MoveNext())
{
TypeCompilationState.MethodWithBody current = enumerator.Current;
ImportChain importChain = (compilationState.CurrentImportChain = current.ImportChain);
BindingDiagnosticBag instance2 = BindingDiagnosticBag.GetInstance(_diagnostics);
MethodSymbol method = current.Method;
VariableSlotAllocator val = ((method is SynthesizedClosureMethod synthesizedClosureMethod) ? _moduleBeingBuiltOpt.TryCreateVariableSlotAllocator(synthesizedClosureMethod, synthesizedClosureMethod.TopLevelMethod, ((BindingDiagnosticBag)instance2).DiagnosticBag) : _moduleBeingBuiltOpt.TryCreateVariableSlotAllocator(method, method, ((BindingDiagnosticBag)instance2).DiagnosticBag));
MethodBody val2 = null;
try
{
IteratorStateMachine stateMachineType;
BoundStatement boundStatement = IteratorRewriter.Rewrite(current.Body, method, -1, instance, val, compilationState, instance2, out stateMachineType);
StateMachineTypeSymbol stateMachineTypeSymbol = stateMachineType;
if (!boundStatement.HasErrors)
{
boundStatement = AsyncRewriter.Rewrite(boundStatement, method, -1, instance, val, compilationState, instance2, out AsyncStateMachine stateMachineType2);
stateMachineTypeSymbol = stateMachineTypeSymbol ?? stateMachineType2;
}
SetGlobalErrorIfTrue(((BindingDiagnosticBag)instance2).HasAnyErrors());
if (_emitMethodBodies && !((BindingDiagnosticBag)instance2).HasAnyErrors() && !_globalHasErrors)
{
val2 = GenerateMethodBody(_moduleBeingBuiltOpt, method, -1, boundStatement, ImmutableArray<LambdaDebugInfo>.Empty, ImmutableArray<ClosureDebugInfo>.Empty, instance.ToImmutable(), stateMachineTypeSymbol, val, instance2, GetDebugDocumentProvider(MethodInstrumentation.Empty), method.GenerateDebugInfo ? importChain : null, _emittingPdb, ImmutableArray<SourceSpan>.Empty, _entryPointOpt);
}
}
catch (BoundTreeVisitor.CancelledByStackGuardException ex)
{
ex.AddAnError(_diagnostics);
}
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance2, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance2).Free();
if (_emitMethodBodies)
{
if (val2 == null)
{
break;
}
((CommonPEModuleBuilder)_moduleBeingBuiltOpt).SetMethodBody((IMethodSymbolInternal)(object)method, (IMethodBody)(object)val2);
}
instance.Clear();
}
}
finally
{
compilationState.CurrentImportChain = currentImportChain;
instance.Free();
}
}
private static bool IsFieldLikeEventAccessor(MethodSymbol method)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
Symbol associatedSymbol = method.AssociatedSymbol;
if ((object)associatedSymbol != null && (int)associatedSymbol.Kind == 5)
{
return ((EventSymbol)associatedSymbol).HasAssociatedField;
}
return false;
}
private void CompileSynthesizedExplicitImplementations(SourceMemberContainerTypeSymbol sourceTypeSymbol, TypeCompilationState compilationState)
{
if (!_globalHasErrors)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(_diagnostics);
ImmutableArray<SynthesizedExplicitImplementationForwardingMethod>.Enumerator enumerator = sourceTypeSymbol.GetSynthesizedExplicitImplementations(_cancellationToken).ForwardingMethods.GetEnumerator();
while (enumerator.MoveNext())
{
SynthesizedExplicitImplementationForwardingMethod current = enumerator.Current;
current.GenerateMethodBody(compilationState, instance);
((BindingDiagnosticBag)instance).DiagnosticBag.Clear();
((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)_moduleBeingBuiltOpt).AddSynthesizedDefinition((NamedTypeSymbol)sourceTypeSymbol, (IMethodDefinition)(object)current.GetCciAdapter());
}
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRangeAndFree((BindingDiagnosticBag<AssemblySymbol>)(object)instance);
}
}
private void CompileSynthesizedSealedAccessors(SourcePropertySymbolBase sourceProperty, TypeCompilationState compilationState)
{
SynthesizedSealedPropertyAccessor synthesizedSealedAccessorOpt = sourceProperty.SynthesizedSealedAccessorOpt;
if ((object)synthesizedSealedAccessorOpt != null && !_globalHasErrors)
{
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(_diagnostics);
synthesizedSealedAccessorOpt.GenerateMethodBody(compilationState, instance);
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddDependencies((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)_moduleBeingBuiltOpt).AddSynthesizedDefinition(sourceProperty.ContainingType, (IMethodDefinition)(object)synthesizedSealedAccessorOpt.GetCciAdapter());
}
}
private void CompileFieldLikeEventAccessor(SourceEventSymbol eventSymbol, bool isAddMethod)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
MethodSymbol methodSymbol = (isAddMethod ? eventSymbol.AddMethod : eventSymbol.RemoveMethod);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(_diagnostics);
try
{
BoundBlock block = MethodBodySynthesizer.ConstructFieldLikeEventAccessorBody(eventSymbol, isAddMethod, _compilation, instance);
bool flag = ((BindingDiagnosticBag)instance).HasAnyErrors();
SetGlobalErrorIfTrue(flag);
if (!flag && !_hasDeclarationErrors && _emitMethodBodies)
{
MethodInstrumentation methodBodyInstrumentations = _moduleBeingBuiltOpt.GetMethodBodyInstrumentations(methodSymbol);
MethodBody val = GenerateMethodBody(_moduleBeingBuiltOpt, methodSymbol, -1, block, ImmutableArray<LambdaDebugInfo>.Empty, ImmutableArray<ClosureDebugInfo>.Empty, ImmutableArray<StateMachineStateDebugInfo>.Empty, null, null, instance, GetDebugDocumentProvider(methodBodyInstrumentations), null, emittingPdb: false, ImmutableArray<SourceSpan>.Empty, null);
((CommonPEModuleBuilder)_moduleBeingBuiltOpt).SetMethodBody((IMethodSymbolInternal)(object)methodSymbol, (IMethodBody)(object)val);
}
}
finally
{
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
}
public override object VisitMethod(MethodSymbol symbol, TypeCompilationState arg)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 919);
}
public override object VisitProperty(PropertySymbol symbol, TypeCompilationState argument)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 924);
}
public override object VisitEvent(EventSymbol symbol, TypeCompilationState argument)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 929);
}
public override object VisitField(FieldSymbol symbol, TypeCompilationState argument)
{
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs", 934);
}
private void CompileMethod(MethodSymbol methodSymbol, int methodOrdinal, ref Binder.ProcessedFieldInitializers processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
{
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_0606: Unknown result type (might be due to invalid IL or missing references)
//IL_0609: Unknown result type (might be due to invalid IL or missing references)
//IL_0596: Unknown result type (might be due to invalid IL or missing references)
//IL_05a0: Expected O, but got Unknown
//IL_07a2: Unknown result type (might be due to invalid IL or missing references)
//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
//IL_08dd: Unknown result type (might be due to invalid IL or missing references)
CancellationToken cancellationToken = _cancellationToken;
cancellationToken.ThrowIfCancellationRequested();
SourceMemberMethodSymbol sourceMemberMethodSymbol = methodSymbol as SourceMemberMethodSymbol;
if (!methodSymbol.IsAbstract)
{
NamedTypeSymbol containingType = methodSymbol.ContainingType;
if ((object)containingType == null || !containingType.IsDelegateType())
{
if (_moduleBeingBuiltOpt == null && (object)sourceMemberMethodSymbol != null)
{
ImmutableArray<Diagnostic> diagnostics = sourceMemberMethodSymbol.Diagnostics;
if (!diagnostics.IsDefault)
{
((BindingDiagnosticBag)_diagnostics).AddRange<Diagnostic>(diagnostics);
return;
}
}
ImportChain currentImportChain = compilationState.CurrentImportChain;
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(_diagnostics);
try
{
if (methodSymbol.SynthesizesLoweredBoundBody)
{
if (_moduleBeingBuiltOpt != null)
{
methodSymbol.GenerateMethodBody(compilationState, instance);
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
}
}
else
{
if (methodSymbol.IsDefaultValueTypeConstructor())
{
return;
}
bool flag = false;
bool originalBodyNested = false;
MethodInstrumentation instrumentation = compilationState.ModuleBuilderOpt?.GetMethodBodyInstrumentations(methodSymbol) ?? MethodInstrumentation.Empty;
BoundStatementList boundStatementList = null;
MethodBodySemanticModel.InitialState forSemanticModel = default(MethodBodySemanticModel.InitialState);
ImportChain importChain = null;
bool hasTrailingExpression = false;
BoundBlock boundBlock;
ImmutableArray<FieldSymbol> implicitlyInitializedFieldsOpt;
if (methodSymbol.IsScriptConstructor)
{
boundBlock = new BoundBlock((SyntaxNode)(object)methodSymbol.GetNonNullSyntaxNode(), ImmutableArray<LocalSymbol>.Empty, ImmutableArray<BoundStatement>.Empty)
{
WasCompilerGenerated = true
};
}
else if (methodSymbol.IsScriptInitializer)
{
BoundTypeOrInstanceInitializers boundTypeOrInstanceInitializers = InitializerRewriter.RewriteScriptInitializer(processedInitializers.BoundInitializers, (SynthesizedInteractiveInitializerMethod)methodSymbol, out hasTrailingExpression);
boundBlock = BoundBlock.SynthesizedNoLocals(boundTypeOrInstanceInitializers.Syntax, boundTypeOrInstanceInitializers.Statements);
if (ReportNullableDiagnostics)
{
NullableWalker.AnalyzeIfNeeded(_compilation, methodSymbol, boundTypeOrInstanceInitializers, ((BindingDiagnosticBag)instance).DiagnosticBag, useConstructorExitWarnings: false, null, getFinalNullableState: true, null, out NullableWalker.VariableState _);
}
DiagnosticBag instance2 = DiagnosticBag.GetInstance();
DefiniteAssignmentPass.Analyze(_compilation, methodSymbol, boundTypeOrInstanceInitializers, instance2, out implicitlyInitializedFieldsOpt, requireOutParamsAssigned: false);
DiagnosticsPass.IssueDiagnostics(_compilation, boundTypeOrInstanceInitializers, BindingDiagnosticBag.Discarded, methodSymbol);
instance2.Free();
}
else
{
bool flag2 = methodSymbol.IncludeFieldInitializersInBody();
flag = flag2 && !processedInitializers.BoundInitializers.IsDefaultOrEmpty;
if (flag && processedInitializers.LoweredInitializers == null)
{
boundStatementList = InitializerRewriter.RewriteConstructor(processedInitializers.BoundInitializers, methodSymbol);
processedInitializers.HasErrors = processedInitializers.HasErrors || boundStatementList.HasAnyErrors;
RefSafetyAnalysis.Analyze(_compilation, methodSymbol, new BoundBlock(boundStatementList.Syntax, ImmutableArray<LocalSymbol>.Empty, boundStatementList.Statements), instance);
}
boundBlock = BindMethodBody(methodSymbol, compilationState, instance, flag2, boundStatementList, ReportNullableDiagnostics, out importChain, out originalBodyNested, out bool prependedDefaultValueTypeConstructorInitializer, out forSemanticModel);
if (((BindingDiagnosticBag)instance).HasAnyErrors() && boundBlock != null)
{
boundBlock = (BoundBlock)boundBlock.WithHasErrors();
}
if (flag && processedInitializers.LoweredInitializers == null)
{
if (boundBlock != null && ((methodSymbol.ContainingType.IsStructType() && !methodSymbol.IsImplicitConstructor) || methodSymbol is SynthesizedPrimaryConstructor || ((MethodInstrumentation)(ref instrumentation)).Kinds.Contains((InstrumentationKind)1) || ((MethodInstrumentation)(ref instrumentation)).Kinds.Contains((InstrumentationKind)(-1))))
{
if (methodSymbol.IsImplicitConstructor && (((MethodInstrumentation)(ref instrumentation)).Kinds.Contains((InstrumentationKind)1) || ((MethodInstrumentation)(ref instrumentation)).Kinds.Contains((InstrumentationKind)(-1))))
{
DefiniteAssignmentPass.Analyze(_compilation, methodSymbol, boundStatementList, ((BindingDiagnosticBag)instance).DiagnosticBag, out implicitlyInitializedFieldsOpt, requireOutParamsAssigned: false);
}
int index = 0;
if (originalBodyNested && prependedDefaultValueTypeConstructorInitializer)
{
index = 1;
}
boundBlock = boundBlock.Update(boundBlock.Locals, boundBlock.LocalFunctions, boundBlock.HasUnsafeModifier, boundBlock.Instrumentation, boundBlock.Statements.Insert(index, boundStatementList));
flag = false;
boundStatementList = null;
}
else
{
DefiniteAssignmentPass.Analyze(_compilation, methodSymbol, boundStatementList, ((BindingDiagnosticBag)instance).DiagnosticBag, out implicitlyInitializedFieldsOpt, requireOutParamsAssigned: false);
DiagnosticsPass.IssueDiagnostics(_compilation, boundStatementList, instance, methodSymbol);
}
}
}
importChain = (compilationState.CurrentImportChain = importChain ?? processedInitializers.FirstImportChain);
if (boundBlock != null)
{
DiagnosticsPass.IssueDiagnostics(_compilation, boundBlock, instance, methodSymbol);
}
BoundBlock boundBlock2 = null;
if (boundBlock != null)
{
boundBlock2 = FlowAnalysisPass.Rewrite(methodSymbol, boundBlock, compilationState, instance, hasTrailingExpression, originalBodyNested);
}
bool flag3 = _hasDeclarationErrors || ((BindingDiagnosticBag)instance).HasAnyErrors() || processedInitializers.HasErrors;
SetGlobalErrorIfTrue(flag3);
ImmutableBindingDiagnostic<AssemblySymbol> val = ((BindingDiagnosticBag<AssemblySymbol>)(object)instance).ToReadOnly();
if (sourceMemberMethodSymbol != null)
{
((Compilation)_compilation).RegisterPossibleUpcomingEventEnqueue();
try
{
val = new ImmutableBindingDiagnostic<AssemblySymbol>(sourceMemberMethodSymbol.SetDiagnostics(val.Diagnostics, out var diagsWritten), val.Dependencies);
if (diagsWritten && !methodSymbol.IsImplicitlyDeclared && ((Compilation)_compilation).EventQueue != null)
{
SyntaxTreeSemanticModel semanticModelWithCachedBoundNodes = null;
if (boundBlock != null)
{
CSharpSyntaxNode syntax = forSemanticModel.Syntax;
if (syntax != null)
{
SemanticModelProvider semanticModelProvider = ((Compilation)_compilation).SemanticModelProvider;
CachingSemanticModelProvider val2 = (CachingSemanticModelProvider)(object)((semanticModelProvider is CachingSemanticModelProvider) ? semanticModelProvider : null);
if (val2 != null)
{
SyntaxNode syntax2 = boundBlock.Syntax;
semanticModelWithCachedBoundNodes = (SyntaxTreeSemanticModel)(object)((SemanticModelProvider)val2).GetSemanticModel(syntax2.SyntaxTree, (Compilation)(object)_compilation, false);
semanticModelWithCachedBoundNodes.GetOrAddModel(syntax, (CSharpSyntaxNode rootSyntax) => MethodBodySemanticModel.Create(semanticModelWithCachedBoundNodes, methodSymbol, forSemanticModel));
}
}
}
((Compilation)_compilation).EventQueue.TryEnqueue((CompilationEvent)new SymbolDeclaredCompilationEvent((Compilation)(object)_compilation, (ISymbolInternal)(object)methodSymbol, (SemanticModel)(object)semanticModelWithCachedBoundNodes));
}
}
finally
{
((Compilation)_compilation).UnregisterPossibleUpcomingEventEnqueue();
}
}
if (!(_moduleBeingBuiltOpt == null || flag3))
{
bool flag4 = boundBlock2 != null;
VariableSlotAllocator lazyVariableSlotAllocator = null;
StateMachineTypeSymbol stateMachineTypeOpt = null;
ArrayBuilder<LambdaDebugInfo> instance3 = ArrayBuilder<LambdaDebugInfo>.GetInstance();
ArrayBuilder<ClosureDebugInfo> instance4 = ArrayBuilder<ClosureDebugInfo>.GetInstance();
ArrayBuilder<StateMachineStateDebugInfo> instance5 = ArrayBuilder<StateMachineStateDebugInfo>.GetInstance();
BoundStatement boundStatement = null;
try
{
ImmutableArray<SourceSpan> codeCoverageSpans;
if (flag4)
{
boundStatement = LowerBodyOrInitializer(methodSymbol, methodOrdinal, boundBlock2, previousSubmissionFields, compilationState, instrumentation, GetDebugDocumentProvider(instrumentation), out codeCoverageSpans, instance, ref lazyVariableSlotAllocator, instance3, instance4, instance5, out stateMachineTypeOpt);
}
else
{
boundStatement = null;
codeCoverageSpans = ImmutableArray<SourceSpan>.Empty;
}
flag3 = flag3 || (flag4 && boundStatement.HasErrors) || ((BindingDiagnosticBag)instance).HasAnyErrors();
SetGlobalErrorIfTrue(flag3);
CSharpSyntaxNode nonNullSyntaxNode = methodSymbol.GetNonNullSyntaxNode();
if (!flag3 && (flag4 || flag))
{
ImmutableArray<BoundStatement> immutableArray;
if (methodSymbol.IsScriptConstructor)
{
immutableArray = MethodBodySynthesizer.ConstructScriptConstructorBody(boundStatement, methodSymbol, previousSubmissionFields, _compilation);
}
else
{
immutableArray = ImmutableArray<BoundStatement>.Empty;
if (methodSymbol is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor)
{
IReadOnlyDictionary<ParameterSymbol, FieldSymbol> capturedParameters = synthesizedPrimaryConstructor.GetCapturedParameters();
if (capturedParameters.Count != 0)
{
SyntheticBoundNodeFactory syntheticBoundNodeFactory = new SyntheticBoundNodeFactory(methodSymbol, (SyntaxNode)(object)nonNullSyntaxNode, compilationState, instance);
ArrayBuilder<BoundStatement> instance6 = ArrayBuilder<BoundStatement>.GetInstance(capturedParameters.Count);
ParameterSymbol parameterSymbol = default(ParameterSymbol);
FieldSymbol fieldSymbol = default(FieldSymbol);
foreach (KeyValuePair<ParameterSymbol, FieldSymbol> item in capturedParameters.OrderBy((KeyValuePair<ParameterSymbol, FieldSymbol> pair) => pair.Key.Ordinal))
{
KeyValuePairUtil.Deconstruct<ParameterSymbol, FieldSymbol>(item, ref parameterSymbol, ref fieldSymbol);
ParameterSymbol p = parameterSymbol;
FieldSymbol f = fieldSymbol;
instance6.Add((BoundStatement)syntheticBoundNodeFactory.Assignment(syntheticBoundNodeFactory.Field(syntheticBoundNodeFactory.This(), f), syntheticBoundNodeFactory.Parameter(p)));
}
immutableArray = immutableArray.Insert(0, syntheticBoundNodeFactory.HiddenSequencePoint(syntheticBoundNodeFactory.StatementList(instance6.ToImmutableAndFree())));
}
}
if (boundStatementList != null)
{
ImmutableArray<SourceSpan> codeCoverageSpans2;
StateMachineTypeSymbol stateMachineTypeOpt2;
BoundStatement boundStatement2 = (processedInitializers.LoweredInitializers = LowerBodyOrInitializer(methodSymbol, methodOrdinal, boundStatementList, previousSubmissionFields, compilationState, instrumentation, GetDebugDocumentProvider(instrumentation), out codeCoverageSpans2, instance, ref lazyVariableSlotAllocator, instance3, instance4, instance5, out stateMachineTypeOpt2));
flag3 = boundStatement2.HasAnyErrors || ((BindingDiagnosticBag)instance).HasAnyErrors();
SetGlobalErrorIfTrue(flag3);
if (flag3)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
return;
}
processedInitializers.LoweredInitializers = (BoundStatementList)boundStatement2;
}
if (flag)
{
if (processedInitializers.LoweredInitializers.Kind == BoundKind.StatementList)
{
BoundStatementList boundStatementList2 = (BoundStatementList)processedInitializers.LoweredInitializers;
immutableArray = ImmutableArrayExtensions.Concat<BoundStatement>(immutableArray, boundStatementList2.Statements);
}
else
{
immutableArray = immutableArray.Add(processedInitializers.LoweredInitializers);
}
}
if (flag4)
{
immutableArray = ImmutableArrayExtensions.Concat<BoundStatement>(immutableArray, boundStatement);
}
flag3 = ((BindingDiagnosticBag)instance).HasAnyErrors();
SetGlobalErrorIfTrue(flag3);
if (flag3)
{
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
return;
}
}
if (_emitMethodBodies && (!(methodSymbol is SynthesizedStaticConstructor synthesizedStaticConstructor) || synthesizedStaticConstructor.ShouldEmit(processedInitializers.BoundInitializers)))
{
BoundStatementList block = BoundStatementList.Synthesized((SyntaxNode)(object)nonNullSyntaxNode, immutableArray);
MethodBody val3 = GenerateMethodBody(_moduleBeingBuiltOpt, methodSymbol, methodOrdinal, block, instance3.ToImmutable(), instance4.ToImmutable(), instance5.ToImmutable(), stateMachineTypeOpt, lazyVariableSlotAllocator, instance, GetDebugDocumentProvider(instrumentation), importChain, _emittingPdb, codeCoverageSpans, null);
((CommonPEModuleBuilder)_moduleBeingBuiltOpt).SetMethodBody((IMethodSymbolInternal)(object)(methodSymbol.PartialDefinitionPart ?? methodSymbol), (IMethodBody)(object)val3);
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
return;
}
finally
{
instance3.Free();
instance4.Free();
instance5.Free();
}
}
((BindingDiagnosticBag<AssemblySymbol>)(object)_diagnostics).AddRange(val, false);
}
return;
}
finally
{
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
compilationState.CurrentImportChain = currentImportChain;
}
}
}
if ((object)sourceMemberMethodSymbol != null)
{
sourceMemberMethodSymbol.SetDiagnostics(ImmutableArray<Diagnostic>.Empty, out var diagsWritten2);
if (diagsWritten2 && !methodSymbol.IsImplicitlyDeclared && ((Compilation)_compilation).EventQueue != null)
{
_compilation.SymbolDeclaredEvent(methodSymbol);
}
}
}
internal static BoundStatement LowerBodyOrInitializer(MethodSymbol method, int methodOrdinal, BoundStatement body, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState, MethodInstrumentation instrumentation, DebugDocumentProvider debugDocumentProvider, out ImmutableArray<SourceSpan> codeCoverageSpans, BindingDiagnosticBag diagnostics, ref VariableSlotAllocator lazyVariableSlotAllocator, ArrayBuilder<LambdaDebugInfo> lambdaDebugInfoBuilder, ArrayBuilder<ClosureDebugInfo> closureDebugInfoBuilder, ArrayBuilder<StateMachineStateDebugInfo> stateMachineStateDebugInfoBuilder, out StateMachineTypeSymbol stateMachineTypeOpt)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
stateMachineTypeOpt = null;
if (body.HasErrors)
{
codeCoverageSpans = ImmutableArray<SourceSpan>.Empty;
return body;
}
try
{
bool sawLambdas;
bool sawLocalFunctions;
bool sawAwaitInExceptionHandler;
BoundStatement boundStatement = LocalRewriter.Rewrite(method.DeclaringCompilation, method, methodOrdinal, method.ContainingType, body, compilationState, previousSubmissionFields, allowOmissionOfConditionalCalls: true, instrumentation, debugDocumentProvider, diagnostics, out codeCoverageSpans, out sawLambdas, out sawLocalFunctions, out sawAwaitInExceptionHandler);
if (boundStatement.HasErrors)
{
return boundStatement;
}
if (sawAwaitInExceptionHandler)
{
boundStatement = AsyncExceptionHandlerRewriter.Rewrite(method, method.ContainingType, boundStatement, compilationState, diagnostics);
}
if (boundStatement.HasErrors)
{
return boundStatement;
}
if (lazyVariableSlotAllocator == null)
{
lazyVariableSlotAllocator = compilationState.ModuleBuilderOpt.TryCreateVariableSlotAllocator(method, method, ((BindingDiagnosticBag)diagnostics).DiagnosticBag);
}
BoundStatement boundStatement2 = boundStatement;
if (sawLambdas || sawLocalFunctions)
{
boundStatement2 = ClosureConversion.Rewrite(boundStatement, method.ContainingType, method.ThisParameter, method, methodOrdinal, null, lambdaDebugInfoBuilder, closureDebugInfoBuilder, lazyVariableSlotAllocator, compilationState, diagnostics, null);
}
if (boundStatement2.HasErrors)
{
return boundStatement2;
}
IteratorStateMachine stateMachineType;
BoundStatement boundStatement3 = IteratorRewriter.Rewrite(boundStatement2, method, methodOrdinal, stateMachineStateDebugInfoBuilder, lazyVariableSlotAllocator, compilationState, diagnostics, out stateMachineType);
if (boundStatement3.HasErrors)
{
return boundStatement3;
}
AsyncStateMachine stateMachineType2;
BoundStatement result = AsyncRewriter.Rewrite(boundStatement3, method, methodOrdinal, stateMachineStateDebugInfoBuilder, lazyVariableSlotAllocator, compilationState, diagnostics, out stateMachineType2);
stateMachineTypeOpt = (StateMachineTypeSymbol)(((object)stateMachineType) ?? ((object)stateMachineType2));
return result;
}
catch (BoundTreeVisitor.CancelledByStackGuardException ex)
{
codeCoverageSpans = ImmutableArray<SourceSpan>.Empty;
ex.AddAnError(diagnostics);
return new BoundBadStatement(body.Syntax, ImmutableArray.Create((BoundNode)body), hasErrors: true);
}
}
private static MethodBody GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, int methodOrdinal, BoundStatement block, ImmutableArray<LambdaDebugInfo> lambdaDebugInfo, ImmutableArray<ClosureDebugInfo> closureDebugInfo, ImmutableArray<StateMachineStateDebugInfo> stateMachineStateDebugInfos, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, BindingDiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, bool emittingPdb, ImmutableArray<SourceSpan> codeCoverageSpans, SynthesizedEntryPointSymbol.AsyncForwardEntryPoint entryPointOpt)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Expected O, but got Unknown
CSharpCompilation compilation = ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBuilder).Compilation;
LocalSlotManager val = new LocalSlotManager(variableSlotAllocatorOpt);
OptimizationLevel optimizationLevel = ((CompilationOptions)compilation.Options).OptimizationLevel;
ILBuilder val2 = new ILBuilder((ITokenDeferral)(object)moduleBuilder, val, optimizationLevel, method.AreLocalsZeroed);
BindingDiagnosticBag instance = BindingDiagnosticBag.GetInstance(withDiagnostics: true, ((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AccumulatesDependencies);
try
{
StateMachineMoveNextBodyDebugInfo val3 = null;
CodeGenerator codeGenerator = new CodeGenerator(method, block, val2, moduleBuilder, instance, optimizationLevel, emittingPdb);
if (((BindingDiagnosticBag)instance).HasAnyErrors())
{
return null;
}
bool flag;
MethodSymbol kickoffMethod;
if (method is SynthesizedStateMachineMethod synthesizedStateMachineMethod && method.Name == "MoveNext")
{
kickoffMethod = synthesizedStateMachineMethod.StateMachineType.KickoffMethod;
flag = kickoffMethod.IsAsync;
kickoffMethod = kickoffMethod.PartialDefinitionPart ?? kickoffMethod;
}
else
{
kickoffMethod = null;
flag = false;
}
bool hasStackalloc;
if (flag)
{
codeGenerator.Generate(out var asyncCatchHandlerOffset, out var asyncYieldPoints, out var asyncResumePoints, out hasStackalloc);
bool flag2 = entryPointOpt?.UserMain.Equals(kickoffMethod) ?? false;
val3 = (StateMachineMoveNextBodyDebugInfo)new AsyncMoveNextBodyDebugInfo((IMethodDefinition)(object)kickoffMethod.GetCciAdapter(), (kickoffMethod.ReturnsVoid || flag2) ? asyncCatchHandlerOffset : (-1), asyncYieldPoints, asyncResumePoints);
}
else
{
codeGenerator.Generate(out hasStackalloc);
if ((object)kickoffMethod != null)
{
val3 = (StateMachineMoveNextBodyDebugInfo)new IteratorMoveNextBodyDebugInfo((IMethodDefinition)(object)kickoffMethod.GetCciAdapter());
}
}
ImmutableArray<StateMachineHoistedLocalScope> immutableArray = (((object)kickoffMethod != null) ? val2.GetHoistedLocalScopes() : default(ImmutableArray<StateMachineHoistedLocalScope>));
IImportScope val4 = importChainOpt?.Translate(moduleBuilder, ((BindingDiagnosticBag)instance).DiagnosticBag);
ImmutableArray<ILocalDefinition> immutableArray2 = val2.LocalSlotManager.LocalsInOrder();
if (immutableArray2.Length > 65534)
{
instance.Add(ErrorCode.ERR_TooManyLocals, method.GetFirstLocation());
}
if (((BindingDiagnosticBag)instance).HasAnyErrors())
{
return null;
}
CompilationTestData testData = ((CommonPEModuleBuilder)moduleBuilder).TestData;
if (testData != null)
{
testData.SetMethodILBuilder((IMethodSymbolInternal)(object)method, val2.GetSnapshot());
}
ImmutableArray<EncHoistedLocalInfo> hoistedVariableSlots = default(ImmutableArray<EncHoistedLocalInfo>);
ImmutableArray<ITypeReference> awaiterSlots = default(ImmutableArray<ITypeReference>);
if ((int)optimizationLevel == 0 && (object)stateMachineTypeOpt != null)
{
GetStateMachineSlotDebugInfo(moduleBuilder, ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBuilder).GetSynthesizedFields((NamedTypeSymbol)stateMachineTypeOpt), variableSlotAllocatorOpt, instance, out hoistedVariableSlots, out awaiterSlots);
}
return new MethodBody(val2.RealizedIL, val2.MaxStack, (IMethodDefinition)(object)(method.PartialDefinitionPart ?? method).GetCciAdapter(), (DebugId)(((_003F?)((variableSlotAllocatorOpt != null) ? variableSlotAllocatorOpt.MethodId : ((DebugId?)null))) ?? new DebugId(methodOrdinal, ((CommonPEModuleBuilder)moduleBuilder).CurrentGenerationOrdinal)), immutableArray2, val2.RealizedSequencePoints, debugDocumentProvider, val2.RealizedExceptionHandlers, val2.AreLocalsZeroed, hasStackalloc, val2.GetAllScopes(), val2.HasDynamicLocal, val4, lambdaDebugInfo, closureDebugInfo, stateMachineTypeOpt?.Name, immutableArray, hoistedVariableSlots, awaiterSlots, StateMachineStatesDebugInfo.Create(variableSlotAllocatorOpt, stateMachineStateDebugInfos), val3, codeCoverageSpans, method is SynthesizedPrimaryConstructor);
}
finally
{
val2.FreeBasicBlocks();
((BindingDiagnosticBag<AssemblySymbol>)(object)diagnostics).AddRange((BindingDiagnosticBag<AssemblySymbol>)(object)instance, false);
((BindingDiagnosticBag<AssemblySymbol>)(object)instance).Free();
}
}
private static void GetStateMachineSlotDebugInfo(PEModuleBuilder moduleBuilder, IEnumerable<IFieldDefinition> fieldDefs, VariableSlotAllocator variableSlotAllocatorOpt, BindingDiagnosticBag diagnostics, out ImmutableArray<EncHoistedLocalInfo> hoistedVariableSlots, out ImmutableArray<ITypeReference> awaiterSlots)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
ArrayBuilder<EncHoistedLocalInfo> instance = ArrayBuilder<EncHoistedLocalInfo>.GetInstance();
ArrayBuilder<ITypeReference> instance2 = ArrayBuilder<ITypeReference>.GetInstance();
foreach (StateMachineFieldSymbol fieldDef in fieldDefs)
{
int slotIndex = fieldDef.SlotIndex;
if ((int)fieldDef.SlotDebugInfo.SynthesizedKind == 256)
{
while (slotIndex >= instance2.Count)
{
instance2.Add((ITypeReference)null);
}
instance2[slotIndex] = ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBuilder).EncTranslateLocalVariableType(fieldDef.Type, ((BindingDiagnosticBag)diagnostics).DiagnosticBag);
}
else if (!((LocalDebugId)(ref fieldDef.SlotDebugInfo.Id)).IsNone)
{
while (slotIndex >= instance.Count)
{
instance.Add(new EncHoistedLocalInfo(true));
}
instance[slotIndex] = new EncHoistedLocalInfo(fieldDef.SlotDebugInfo, ((PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, EmbeddedTypesManager, ModuleCompilationState>)moduleBuilder).EncTranslateLocalVariableType(fieldDef.Type, ((BindingDiagnosticBag)diagnostics).DiagnosticBag));
}
}
if (variableSlotAllocatorOpt != null)
{
int previousAwaiterSlotCount = variableSlotAllocatorOpt.PreviousAwaiterSlotCount;
while (instance2.Count < previousAwaiterSlotCount)
{
instance2.Add((ITypeReference)null);
}
int previousHoistedLocalSlotCount = variableSlotAllocatorOpt.PreviousHoistedLocalSlotCount;
while (instance.Count < previousHoistedLocalSlotCount)
{
instance.Add(new EncHoistedLocalInfo(true));
}
}
hoistedVariableSlots = instance.ToImmutableAndFree();
awaiterSlots = instance2.ToImmutableAndFree();
}
internal static BoundBlock? BindSynthesizedMethodBody(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
{
ImportChain importChain;
bool originalBodyNested;
bool prependedDefaultValueTypeConstructorInitializer;
MethodBodySemanticModel.InitialState forSemanticModel;
return BindMethodBody(method, compilationState, diagnostics, includeInitializersInBody: false, null, reportNullableDiagnostics: true, out importChain, out originalBodyNested, out prependedDefaultValueTypeConstructorInitializer, out forSemanticModel);
}
private static BoundBlock? BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, bool includeInitializersInBody, BoundNode? initializersBody, bool reportNullableDiagnostics, out ImportChain? importChain, out bool originalBodyNested, out bool prependedDefaultValueTypeConstructorInitializer, out MethodBodySemanticModel.InitialState forSemanticModel)
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Invalid comparison between Unknown and I4
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Invalid comparison between Unknown and I4
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
originalBodyNested = false;
prependedDefaultValueTypeConstructorInitializer = false;
importChain = null;
forSemanticModel = default(MethodBodySemanticModel.InitialState);
NullableWalker.VariableState variableState = null;
if (initializersBody == null)
{
initializersBody = GetSynthesizedEmptyBody(method);
}
NullableWalker.VariableState finalNullableState;
BoundBlock boundBlock;
if (method is SynthesizedPrimaryConstructor synthesizedPrimaryConstructor && method.ContainingType.IsStructType())
{
boundBlock = BoundBlock.SynthesizedNoLocals((SyntaxNode)(object)synthesizedPrimaryConstructor.GetSyntax());
variableState = getInitializerState(boundBlock);
}
else if (method is SourceMemberMethodSymbol { SyntaxNode: var syntaxNode } sourceMemberMethodSymbol)
{
if ((int)method.MethodKind == 14 && syntaxNode is ConstructorDeclarationSyntax { Initializer: not null } constructorDeclarationSyntax)
{
BindingDiagnosticBag bindingDiagnosticBag = diagnostics;
SyntaxToken val = constructorDeclarationSyntax.Initializer.ThisOrBaseKeyword;
Location location = ((SyntaxToken)(ref val)).GetLocation();
object[] array = new object[1];
val = constructorDeclarationSyntax.Identifier;
array[0] = ((SyntaxToken)(ref val)).ValueText;
bindingDiagnosticBag.Add(ErrorCode.ERR_StaticConstructorWithExplicitConstructorCall, location, array);
}
if (sourceMemberMethodSymbol.IsExtern)
{
return null;
}
Binder binder = sourceMemberMethodSymbol.TryGetBodyBinder();
if (binder == null)
{
if (sourceMemberMethodSymbol.AssociatedSymbol is SourcePropertySymbolBase { IsAutoPropertyWithGetAccessor: not false })
{
return MethodBodySynthesizer.ConstructAutoPropertyAccessorBody(sourceMemberMethodSymbol);
}
return null;
}
importChain = binder.ImportChain;
BoundNode boundNode = binder.BindMethodBody(syntaxNode, diagnostics);
BoundNode bodyOpt = boundNode;
NullableWalker.SnapshotManager snapshotManager = null;
ImmutableDictionary<Symbol, Symbol> remappedSymbols = null;
CSharpCompilation compilation = binder.Compilation;
variableState = getInitializerState(boundNode);
if (reportNullableDiagnostics)
{
if (compilation.IsNullableAnalysisEnabledIn(method))
{
bool flag = compilation.LanguageVersion >= MessageID.IDS_FeatureNullableReferenceTypes.RequiredVersion();
bodyOpt = NullableWalker.AnalyzeAndRewrite(compilation, method, boundNode, binder, variableState, (DiagnosticBag)(flag ? ((object)((BindingDiagnosticBag)diagnostics).DiagnosticBag) : ((object)new DiagnosticBag())), createSnapshots: true, out snapshotManager, ref remappedSymbols);
}
else
{
NullableWalker.AnalyzeIfNeeded(compilation, method, boundNode, ((BindingDiagnosticBag)diagnostics).DiagnosticBag, useConstructorExitWarnings: true, variableState, getFinalNullableState: false, null, out finalNullableState);
}
}
forSemanticModel = new MethodBodySemanticModel.InitialState(syntaxNode, bodyOpt, binder, snapshotManager, remappedSymbols);
RefSafetyAnalysis.Analyze(compilation, method, boundNode, diagnostics);
switch (boundNode.Kind)
{
case BoundKind.ConstructorMethodBody:
{
BoundConstructorMethodBody boundConstructorMethodBody = (BoundConstructorMethodBody)boundNode;
boundBlock = boundConstructorMethodBody.BlockBody ?? boundConstructorMethodBody.ExpressionBody;
if (boundConstructorMethodBody.Initializer is BoundExpressionStatement boundExpressionStatement)
{
ReportCtorInitializerCycles(method, boundExpressionStatement.Expression, compilationState, diagnostics);
if (boundBlock == null)
{
boundBlock = new BoundBlock(boundConstructorMethodBody.Syntax, boundConstructorMethodBody.Locals, ImmutableArray.Create(boundConstructorMethodBody.Initializer));
}
else
{
boundBlock = new BoundBlock(boundConstructorMethodBody.Syntax, boundConstructorMethodBody.Locals, ImmutableArray.Create(boundConstructorMethodBody.Initializer, boundBlock));
originalBodyNested = true;
int num;
if (boundExpressionStatement.Expression is BoundCall boundCall)
{
MethodSymbol method2 = boundCall.Method;
num = (method2.IsDefaultValueTypeConstructor() ? 1 : 0);
}
else
{
num = 0;
}
prependedDefaultValueTypeConstructorInitializer = (byte)num != 0;
}
}
return boundBlock;
}
case BoundKind.NonConstructorMethodBody:
{
BoundNonConstructorMethodBody boundNonConstructorMethodBody = (BoundNonConstructorMethodBody)boundNode;
boundBlock = boundNonConstructorMethodBody.BlockBody ?? boundNonConstructorMethodBody.ExpressionBody;
break;
}
case BoundKind.Block:
boundBlock = (BoundBlock)boundNode;
break;
default:
throw ExceptionUtilities.UnexpectedValue((object)boundNode.Kind);
}
}
else if (method is SynthesizedInstanceConstructor synthesizedInstanceConstructor)
{
CSharpSyntaxNode nonNullSyntaxNode = synthesizedInstanceConstructor.GetNonNullSyntaxNode();
SyntheticBoundNodeFactory factory = new SyntheticBoundNodeFactory(synthesizedInstanceConstructor, (SyntaxNode)(object)nonNullSyntaxNode, compilationState, diagnostics);
ArrayBuilder<BoundStatement> instance = ArrayBuilder<BoundStatement>.GetInstance();
synthesizedInstanceConstructor.GenerateMethodBodyStatements(factory, instance, diagnostics);
boundBlock = BoundBlock.SynthesizedNoLocals((SyntaxNode)(object)nonNullSyntaxNode, instance.ToImmutableAndFree());
variableState = getInitializerState(boundBlock);
}
else
{
boundBlock = null;
variableState = getInitializerState(null);
}
if (reportNullableDiagnostics && method.IsConstructor() && method.IsImplicitlyDeclared && variableState != null)
{
NullableWalker.AnalyzeIfNeeded(compilationState.Compilation, method, boundBlock ?? GetSynthesizedEmptyBody(method), ((BindingDiagnosticBag)diagnostics).DiagnosticBag, useConstructorExitWarnings: true, variableState, getFinalNullableState: false, null, out finalNullableState);
}
if ((int)method.MethodKind == 4 && boundBlock != null)
{
return MethodBodySynthesizer.ConstructDestructorBody(method, boundBlock);
}
BoundStatement boundStatement = BindImplicitConstructorInitializerIfAny(method, compilationState, diagnostics);
ImmutableArray<BoundStatement> statements;
if (boundStatement == null)
{
if (boundBlock != null)
{
return boundBlock;
}
statements = ImmutableArray<BoundStatement>.Empty;
}
else if (boundBlock == null)
{
statements = ImmutableArray.Create(boundStatement);
}
else
{
statements = ImmutableArray.Create(boundStatement, boundBlock);
originalBodyNested = true;
}
return BoundBlock.SynthesizedNoLocals((SyntaxNode)(object)method.GetNonNullSyntaxNode(), statements);
NullableWalker.VariableState? getInitializerState(BoundNode? body)
{
if (reportNullableDiagnostics && includeInitializersInBody)
{
return NullableWalker.GetAfterInitializersState(compilationState.Compilation, method, initializersBody, body, diagnostics);
}
return null;
}
}
private static BoundBlock GetSynthesizedEmptyBody(Symbol symbol)
{
return BoundBlock.SynthesizedNoLocals((SyntaxNode)(object)symbol.GetNonNullSyntaxNode());
}
private static BoundStatement BindImplicitConstructorInitializerIfAny(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)method.MethodKind == 1 && !method.IsExtern)
{
CSharpCompilation declaringCompilation = method.DeclaringCompilation;
BoundExpression boundExpression = Binder.BindImplicitConstructorInitializer(method, diagnostics, declaringCompilation);
if (boundExpression != null)
{
ReportCtorInitializerCycles(method, boundExpression, compilationState, diagnostics);
return new BoundExpressionStatement(boundExpression.Syntax, boundExpression)
{
WasCompilerGenerated = method.IsImplicitlyDeclared
};
}
}
return null;
}
private static void ReportCtorInitializerCycles(MethodSymbol method, BoundExpression initializerInvocation, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
{
if (initializerInvocation is BoundCall { HasAnyErrors: false } boundCall && boundCall.Method != method && TypeSymbol.Equals(boundCall.Method.ContainingType, method.ContainingType, (TypeCompareKind)0))
{
compilationState.ReportCtorInitializerCycles(method, boundCall.Method, boundCall.Syntax, diagnostics);
}
}
private static DebugSourceDocument CreateDebugDocumentForFile(string normalizedPath)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
return new DebugSourceDocument(normalizedPath, DebugSourceDocument.CorSymLanguageTypeCSharp);
}
private static bool PassesFilter(Predicate<Symbol> filterOpt, Symbol symbol)
{
return filterOpt?.Invoke(symbol) ?? true;
}
}