Files

47 lines
2.7 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.PooledObjects;
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
internal sealed class SynthesizedPrivateImplementationDetailsStaticConstructor : SynthesizedGlobalMethodSymbol
{
public override MethodKind MethodKind => (MethodKind)14;
internal override bool HasSpecialName => true;
internal SynthesizedPrivateImplementationDetailsStaticConstructor(SourceModuleSymbol containingModule, PrivateImplementationDetails privateImplementationType, NamedTypeSymbol voidType)
: base(containingModule, privateImplementationType, voidType, ".cctor")
{
SetParameters(ImmutableArray<ParameterSymbol>.Empty);
}
internal override void GenerateMethodBody(TypeCompilationState compilationState, BindingDiagnosticBag diagnostics)
{
CSharpSyntaxNode nonNullSyntaxNode = this.GetNonNullSyntaxNode();
SyntheticBoundNodeFactory syntheticBoundNodeFactory = new SyntheticBoundNodeFactory(this, (SyntaxNode)(object)nonNullSyntaxNode, compilationState, diagnostics);
syntheticBoundNodeFactory.CurrentFunction = this;
ArrayBuilder<BoundStatement> instance = ArrayBuilder<BoundStatement>.GetInstance();
try
{
foreach (KeyValuePair<int, InstrumentationPayloadRootField> instrumentationPayloadRoot in base.ContainingPrivateImplementationDetailsType.GetInstrumentationPayloadRoots())
{
int key = instrumentationPayloadRoot.Key;
ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol)(object)((IReference)((SynthesizedStaticField)instrumentationPayloadRoot.Value).Type).GetInternalSymbol();
BoundStatement boundStatement = syntheticBoundNodeFactory.Assignment(syntheticBoundNodeFactory.InstrumentationPayloadRoot(key, arrayTypeSymbol), syntheticBoundNodeFactory.Array(arrayTypeSymbol.ElementType, syntheticBoundNodeFactory.Binary(BinaryOperatorKind.Addition, syntheticBoundNodeFactory.SpecialType((SpecialType)13), syntheticBoundNodeFactory.MaximumMethodDefIndex(), syntheticBoundNodeFactory.Literal(1))));
instance.Add(boundStatement);
}
instance.Add((BoundStatement)syntheticBoundNodeFactory.Assignment(syntheticBoundNodeFactory.ModuleVersionId(), syntheticBoundNodeFactory.New(syntheticBoundNodeFactory.WellKnownMethod((WellKnownMember)40), syntheticBoundNodeFactory.ModuleVersionIdString())));
}
catch (SyntheticBoundNodeFactory.MissingPredefinedMember missingPredefinedMember)
{
((BindingDiagnosticBag)diagnostics).Add(missingPredefinedMember.Diagnostic);
}
BoundStatement boundStatement2 = syntheticBoundNodeFactory.Return();
instance.Add(boundStatement2);
syntheticBoundNodeFactory.CloseMethod(syntheticBoundNodeFactory.Block(instance.ToImmutableAndFree()));
}
}