internal SynthesizedLambdaMethod(NamedTypeSymbol containingType, MethodSymbol topLevelMethod, BoundLambda node, bool isStatic, TypeCompilationState compilationState) : base(containingType, node.Symbol, null, node.SyntaxTree.GetReference(node.Body.Syntax), node.Syntax.GetLocation(), GeneratedNames.MakeLambdaMethodName(topLevelMethod.Name, compilationState.GenerateTempNumber()), (containingType is LambdaFrame ? DeclarationModifiers.Internal : DeclarationModifiers.Private) | (isStatic ? DeclarationModifiers.Static : 0) | (node.Symbol.IsAsync ? DeclarationModifiers.Async : 0)) { TypeMap typeMap; ImmutableArray<TypeParameterSymbol> typeParameters; LambdaFrame lambdaFrame; if (!topLevelMethod.IsGenericMethod) { typeMap = TypeMap.Empty; typeParameters = ImmutableArray<TypeParameterSymbol>.Empty; } else if ((object)(lambdaFrame = this.ContainingType as LambdaFrame) != null) { typeMap = lambdaFrame.TypeMap; typeParameters = ImmutableArray<TypeParameterSymbol>.Empty; } else { typeMap = TypeMap.Empty.WithAlphaRename(topLevelMethod, this, out typeParameters); } AssignTypeMapAndTypeParameters(typeMap, typeParameters); }
internal SynthesizedLambdaMethod(NamedTypeSymbol containingType, MethodSymbol topLevelMethod, BoundLambda node, bool isStatic, TypeCompilationState compilationState) : base(containingType, node.Symbol, null, node.SyntaxTree.GetReference(node.Body.Syntax), node.Syntax.GetLocation(), GeneratedNames.MakeLambdaMethodName(topLevelMethod.Name, compilationState.GenerateTempNumber()), (containingType is LambdaFrame ? DeclarationModifiers.Internal : DeclarationModifiers.Private) | (isStatic ? DeclarationModifiers.Static : 0) | (node.Symbol.IsAsync ? DeclarationModifiers.Async : 0)) { TypeMap typeMap; ImmutableArray <TypeParameterSymbol> typeParameters; LambdaFrame lambdaFrame; if (!topLevelMethod.IsGenericMethod) { typeMap = TypeMap.Empty; typeParameters = ImmutableArray <TypeParameterSymbol> .Empty; } else if ((object)(lambdaFrame = this.ContainingType as LambdaFrame) != null) { typeMap = lambdaFrame.TypeMap; typeParameters = ImmutableArray <TypeParameterSymbol> .Empty; } else { typeMap = TypeMap.Empty.WithAlphaRename(topLevelMethod, this, out typeParameters); } AssignTypeMapAndTypeParameters(typeMap, typeParameters); }
public AsyncStruct(MethodSymbol method, TypeCompilationState compilationState) : base(method, GeneratedNames.MakeIteratorOrAsyncDisplayClassName(method.Name, compilationState.GenerateTempNumber()), TypeKind.Struct) { this.interfaces = ReadOnlyArray<NamedTypeSymbol>.CreateFrom( compilationState.EmitModule.Compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_IAsyncStateMachine)); this.constructor = new SynthesizedInstanceConstructor(this); }
public IteratorClass(MethodSymbol method, bool isEnumerable, TypeSymbol elementType, TypeCompilationState compilationState) : base(method, GeneratedNames.MakeIteratorOrAsyncDisplayClassName(method.Name, compilationState.GenerateTempNumber()), TypeKind.Class) { this.ElementType = TypeMap.SubstituteType(elementType); var interfaces = ArrayBuilder<NamedTypeSymbol>.GetInstance(); if (isEnumerable) { interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(ElementType)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerable)); } interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerator_T).Construct(ElementType)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_IDisposable)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerator)); this.interfaces = interfaces.ToImmutableAndFree(); this.constructor = new IteratorConstructor(this); }
public IteratorStateMachine(MethodSymbol iteratorMethod, bool isEnumerable, TypeSymbol elementType, TypeCompilationState compilationState) : base(GeneratedNames.MakeStateMachineTypeName(iteratorMethod.Name, compilationState.GenerateTempNumber()), iteratorMethod) { this.iteratorMethod = iteratorMethod; this.ElementType = TypeMap.SubstituteType(elementType); var interfaces = ArrayBuilder <NamedTypeSymbol> .GetInstance(); if (isEnumerable) { interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T).Construct(ElementType)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerable)); } interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerator_T).Construct(ElementType)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_IDisposable)); interfaces.Add(ContainingAssembly.GetSpecialType(SpecialType.System_Collections_IEnumerator)); this.interfaces = interfaces.ToImmutableAndFree(); this.constructor = new IteratorConstructor(this); }
internal LambdaFrame(MethodSymbol topLevelMethod, TypeCompilationState compilationState) : base(GeneratedNames.MakeAnonymousDisplayClassName(compilationState.GenerateTempNumber()), topLevelMethod) { this.topLevelMethod = topLevelMethod; this.constructor = new LambdaFrameConstructor(this); }
internal void AllocateField(BoundSpillTemp spill) { Debug.Assert(!realizedSpills.ContainsKey(spill)); FieldSymbol field; if (!allocatedFields.TryPop(spill.Type, out field)) { field = F.SynthesizeField(spill.Type, GeneratedNames.SpillTempName(CompilationState.GenerateTempNumber())); } realizedSpills[spill] = field; }
public AsyncStruct(MethodSymbol method, TypeCompilationState compilationState) : base(method, GeneratedNames.MakeIteratorOrAsyncDisplayClassName(method.Name, compilationState.GenerateTempNumber()), TypeKind.Struct) { this.interfaces = ReadOnlyArray <NamedTypeSymbol> .CreateFrom( compilationState.EmitModule.Compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_IAsyncStateMachine)); this.constructor = new SynthesizedInstanceConstructor(this); }
internal LambdaFrameLocalSymbol(MethodSymbol containingMethod, TypeSymbol type, TypeCompilationState compilationState) : base(containingMethod, type, GeneratedNames.MakeLambdaDisplayClassLocalName(compilationState.GenerateTempNumber()), declarationKind: LocalDeclarationKind.CompilerGeneratedLambdaDisplayClassLocal) { }
internal LambdaFrame(MethodSymbol topLevelMethod, TypeCompilationState compilationState) : base(topLevelMethod, GeneratedNames.MakeAnonymousDisplayClassName(compilationState.GenerateTempNumber()), TypeKind.Class) { this.constructor = new SynthesizedInstanceConstructor(this); }
internal LambdaFrameLocalSymbol(MethodSymbol containingMethod, TypeSymbol type, TypeCompilationState compilationState) : base(containingMethod, type, GeneratedNames.MakeLambdaDisplayClassLocalName(compilationState.GenerateTempNumber()), declarationKind: LocalDeclarationKind.CompilerGeneratedLambdaDisplayClassLocal) { }
internal LambdaFrame(MethodSymbol topLevelMethod, TypeCompilationState compilationState) : base(GeneratedNames.MakeAnonymousDisplayClassName(compilationState.GenerateTempNumber()), topLevelMethod) { this.topLevelMethod = topLevelMethod; this.constructor = new LambdaFrameConstructor(this); }
internal LambdaFrame(MethodSymbol topLevelMethod, TypeCompilationState compilationState) : base(topLevelMethod, GeneratedNames.MakeAnonymousDisplayClassName(compilationState.GenerateTempNumber()), TypeKind.Class) { this.constructor = new SynthesizedInstanceConstructor(this); }