提交 d2d1f848 编写于 作者: C CyrusNajmabadi

Remove EnC specific methods from the Syntax API.

上级 8eafb6f4
......@@ -286,6 +286,7 @@
<Compile Include="DocumentationComments\PEDocumentationCommentUtils.cs" />
<Compile Include="DocumentationComments\SourceDocumentationCommentUtils.cs" />
<Compile Include="Emitter\EditAndContinue\CSharpDefinitionMap.cs" />
<Compile Include="Emitter\EditAndContinue\CSharpEncVariableSlotAllocator.cs" />
<Compile Include="Emitter\EditAndContinue\EmitHelpers.cs" />
<Compile Include="Emitter\EditAndContinue\PEDeltaAssemblyBuilder.cs" />
<Compile Include="Emitter\EditAndContinue\CSharpSymbolMatcher.cs" />
......@@ -925,4 +926,4 @@
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -5,10 +5,12 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection.Metadata;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Symbols;
namespace Microsoft.CodeAnalysis.CSharp.Emit
{
......@@ -35,6 +37,25 @@ internal sealed partial class CSharpDefinitionMap : DefinitionMap<CSharpSymbolMa
internal override CommonMessageProvider MessageProvider => CSharp.MessageProvider.Instance;
protected override VariableSlotAllocator CreateSlotAllocator(
CSharpSymbolMatcher symbolMap,
Func<SyntaxNode, SyntaxNode> syntaxMap,
IMethodSymbolInternal previousMethod,
DebugId methodId,
ImmutableArray<EncLocalInfo> previousLocals,
IReadOnlyDictionary<int, KeyValuePair<DebugId, int>> lambdaMap,
IReadOnlyDictionary<int, DebugId> closureMap,
string stateMachineTypeNameOpt,
int hoistedLocalSlotCount,
IReadOnlyDictionary<EncHoistedLocalInfo, int> hoistedLocalMap,
int awaiterSlotCount,
IReadOnlyDictionary<ITypeReference, int> awaiterMap)
{
return new CSharpEncVariableSlotAllocator(symbolMap, syntaxMap, previousMethod,
methodId, previousLocals, lambdaMap, closureMap, stateMachineTypeNameOpt,
hoistedLocalSlotCount, hoistedLocalMap, awaiterSlotCount, awaiterMap);
}
internal bool TryGetAnonymousTypeName(NamedTypeSymbol template, out string name, out int index)
{
return this.mapToPrevious.TryGetAnonymousTypeName(template, out name, out index);
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Symbols;
namespace Microsoft.CodeAnalysis.CSharp.Emit
{
internal class CSharpEncVariableSlotAllocator : EncVariableSlotAllocator
{
public CSharpEncVariableSlotAllocator(
SymbolMatcher symbolMap,
Func<SyntaxNode, SyntaxNode> syntaxMapOpt,
IMethodSymbolInternal previousTopLevelMethod,
DebugId methodId,
ImmutableArray<EncLocalInfo> previousLocals,
IReadOnlyDictionary<int, KeyValuePair<DebugId, int>> lambdaMapOpt,
IReadOnlyDictionary<int, DebugId> closureMapOpt,
string stateMachineTypeNameOpt,
int hoistedLocalSlotCount,
IReadOnlyDictionary<EncHoistedLocalInfo, int>
hoistedLocalSlotsOpt, int awaiterCount, IReadOnlyDictionary<ITypeReference, int> awaiterMapOpt)
: base(symbolMap, syntaxMapOpt, previousTopLevelMethod, methodId,
previousLocals, lambdaMapOpt, closureMapOpt, stateMachineTypeNameOpt,
hoistedLocalSlotCount, hoistedLocalSlotsOpt, awaiterCount, awaiterMapOpt)
{
}
protected override SyntaxNode GetLambda(SyntaxNode lambdaOrLambdaBodySyntax)
{
return LambdaUtilities.GetLambda(lambdaOrLambdaBodySyntax);
}
protected override SyntaxNode TryGetCorrespondingLambdaBody(
SyntaxNode previousLambdaSyntax,
SyntaxNode lambdaOrLambdaBodySyntax)
{
return LambdaUtilities.TryGetCorrespondingLambdaBody(
lambdaOrLambdaBodySyntax, previousLambdaSyntax);
}
}
}
\ No newline at end of file
......@@ -447,16 +447,6 @@ public new IEnumerable<Diagnostic> GetDiagnostics()
return this.SyntaxTree.GetDiagnostics(this);
}
internal sealed override SyntaxNode TryGetCorrespondingLambdaBody(SyntaxNode body)
{
return LambdaUtilities.TryGetCorrespondingLambdaBody(body, this);
}
internal override SyntaxNode GetLambda()
{
return LambdaUtilities.GetLambda(this);
}
#region Directives
internal IList<DirectiveTriviaSyntax> GetDirectives(Func<DirectiveTriviaSyntax, bool> filter = null)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Reflection.Metadata;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using Microsoft.Cci;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.Symbols;
using System.Reflection.Metadata.Ecma335;
using Roslyn.Utilities;
using System.IO;
namespace Microsoft.CodeAnalysis.Emit
{
......@@ -302,7 +303,7 @@ internal VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBaseline basel
symbolMap = mapToMetadata;
}
return new EncVariableSlotAllocator(
return CreateSlotAllocator(
symbolMap,
mappedMethod.SyntaxMap,
mappedMethod.PreviousMethod,
......@@ -317,6 +318,8 @@ internal VariableSlotAllocator TryCreateVariableSlotAllocator(EmitBaseline basel
awaiterMap);
}
protected abstract VariableSlotAllocator CreateSlotAllocator(TSymbolMatcher symbolMap, Func<SyntaxNode, SyntaxNode> syntaxMap, IMethodSymbolInternal previousMethod, DebugId methodId, ImmutableArray<EncLocalInfo> previousLocals, IReadOnlyDictionary<int, KeyValuePair<DebugId, int>> lambdaMap, IReadOnlyDictionary<int, DebugId> closureMap, string stateMachineTypeNameOpt, int hoistedLocalSlotCount, IReadOnlyDictionary<EncHoistedLocalInfo, int> hoistedLocalMap, int awaiterSlotCount, IReadOnlyDictionary<ITypeReference, int> awaiterMap);
private void ReportMissingStateMachineAttribute(DiagnosticBag diagnostics, IMethodSymbolInternal method, string stateMachineAttributeFullName)
{
diagnostics.Add(MessageProvider.CreateDiagnostic(
......
......@@ -11,7 +11,7 @@
namespace Microsoft.CodeAnalysis.Emit
{
internal sealed class EncVariableSlotAllocator : VariableSlotAllocator
internal abstract class EncVariableSlotAllocator : VariableSlotAllocator
{
// symbols:
private readonly SymbolMatcher _symbolMap;
......@@ -36,7 +36,7 @@ internal sealed class EncVariableSlotAllocator : VariableSlotAllocator
private readonly IReadOnlyDictionary<int, KeyValuePair<DebugId, int>> _lambdaMapOpt; // SyntaxOffset -> (Lambda Id, Closure Ordinal)
private readonly IReadOnlyDictionary<int, DebugId> _closureMapOpt; // SyntaxOffset -> Id
public EncVariableSlotAllocator(
protected EncVariableSlotAllocator(
SymbolMatcher symbolMap,
Func<SyntaxNode, SyntaxNode> syntaxMapOpt,
IMethodSymbolInternal previousTopLevelMethod,
......@@ -249,7 +249,7 @@ private bool TryGetPreviousLambdaSyntaxOffset(SyntaxNode lambdaOrLambdaBodySynta
{
// Syntax map contains mapping for lambdas, but not their bodies.
// Map the lambda first and then determine the corresponding body.
var currentLambdaSyntax = isLambdaBody ? lambdaOrLambdaBodySyntax.GetLambda() : lambdaOrLambdaBodySyntax;
var currentLambdaSyntax = isLambdaBody ? GetLambda(lambdaOrLambdaBodySyntax) : lambdaOrLambdaBodySyntax;
// no syntax map
// => the source of the current method is the same as the source of the previous method
......@@ -265,7 +265,7 @@ private bool TryGetPreviousLambdaSyntaxOffset(SyntaxNode lambdaOrLambdaBodySynta
SyntaxNode previousSyntax;
if (isLambdaBody)
{
previousSyntax = previousLambdaSyntax.TryGetCorrespondingLambdaBody(lambdaOrLambdaBodySyntax);
previousSyntax = TryGetCorrespondingLambdaBody(previousLambdaSyntax, lambdaOrLambdaBodySyntax);
if (previousSyntax == null)
{
previousSyntaxOffset = 0;
......@@ -281,6 +281,18 @@ private bool TryGetPreviousLambdaSyntaxOffset(SyntaxNode lambdaOrLambdaBodySynta
return true;
}
protected abstract SyntaxNode GetLambda(SyntaxNode lambdaOrLambdaBodySyntax);
/// <summary>
/// When invoked on a node that represents an anonymous function or a query clause [1]
/// with a <paramref name="lambdaOrLambdaBodySyntax"/> of another anonymous function or a query clause of the same kind [2],
/// returns the body of the [1] that positionally corresponds to the specified <paramref name="lambdaOrLambdaBodySyntax"/>.
///
/// E.g. join clause declares left expression and right expression -- each of these expressions is a lambda body.
/// JoinClause1.GetCorrespondingLambdaBody(JoinClause2.RightExpression) returns JoinClause1.RightExpression.
/// </summary>
protected abstract SyntaxNode TryGetCorrespondingLambdaBody(SyntaxNode previousLambdaSyntax, SyntaxNode lambdaOrLambdaBodySyntax);
public override bool TryGetPreviousClosure(SyntaxNode scopeSyntax, out DebugId closureId)
{
int syntaxOffset;
......
......@@ -551,18 +551,6 @@ public SyntaxReference GetReference()
return this.SyntaxTree.GetReference(this);
}
/// <summary>
/// When invoked on a node that represents an anonymous function or a query clause [1]
/// with a <paramref name="body"/> of another anonymous function or a query clause of the same kind [2],
/// returns the body of the [1] that positionally corresponds to the specified <paramref name="body"/>.
///
/// E.g. join clause declares left expression and right expression -- each of these expressions is a lambda body.
/// JoinClause1.GetCorrespondingLambdaBody(JoinClause2.RightExpression) returns JoinClause1.RightExpression.
/// </summary>
internal abstract SyntaxNode TryGetCorrespondingLambdaBody(SyntaxNode body);
internal abstract SyntaxNode GetLambda();
#region Node Lookup
/// <summary>
......
......@@ -350,6 +350,7 @@
<Compile Include="Emit\EditAndContinue\VisualBasicDefinitionMap.vb" />
<Compile Include="Emit\EditAndContinue\EmitHelpers.vb" />
<Compile Include="Emit\EditAndContinue\PEDeltaAssemblyBuilder.vb" />
<Compile Include="Emit\EditAndContinue\VisualBasicEncVariableSlotAllocator.vb" />
<Compile Include="Emit\EditAndContinue\VisualBasicSymbolMatcher.vb" />
<Compile Include="Emit\EventSymbolAdapter.vb" />
<Compile Include="Emit\FieldSymbolAdapter.vb" />
......@@ -1016,4 +1017,4 @@
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -2,10 +2,11 @@
Imports System.Collections.Immutable
Imports System.Reflection.Metadata
Imports System.Reflection.Metadata.Ecma335
Imports System.Runtime.InteropServices
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.Emit
Imports Microsoft.CodeAnalysis.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
......@@ -38,6 +39,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
End Get
End Property
Protected Overrides Function CreateSlotAllocator(symbolMap As VisualBasicSymbolMatcher, syntaxMap As Func(Of SyntaxNode, SyntaxNode), previousMethod As IMethodSymbolInternal, methodId As DebugId, previousLocals As ImmutableArray(Of EncLocalInfo), lambdaMap As IReadOnlyDictionary(Of Integer, KeyValuePair(Of DebugId, Integer)), closureMap As IReadOnlyDictionary(Of Integer, DebugId), stateMachineTypeNameOpt As String, hoistedLocalSlotCount As Integer, hoistedLocalMap As IReadOnlyDictionary(Of EncHoistedLocalInfo, Integer), awaiterSlotCount As Integer, awaiterMap As IReadOnlyDictionary(Of ITypeReference, Integer)) As VariableSlotAllocator
Return New VisualBasicEncVariableSlotAllocator(symbolMap, syntaxMap, previousMethod,
methodId, previousLocals, lambdaMap, closureMap, stateMachineTypeNameOpt,
hoistedLocalSlotCount, hoistedLocalMap, awaiterSlotCount, awaiterMap)
End Function
Friend Function TryGetAnonymousTypeName(template As NamedTypeSymbol, <Out> ByRef name As String, <Out> ByRef index As Integer) As Boolean
Return Me.mapToPrevious.TryGetAnonymousTypeName(template, name, index)
End Function
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.Emit
Imports Microsoft.CodeAnalysis.Symbols
Namespace Microsoft.CodeAnalysis.VisualBasic.Emit
Friend Class VisualBasicEncVariableSlotAllocator
Inherits EncVariableSlotAllocator
Public Sub New(symbolMap As SymbolMatcher,
syntaxMapOpt As Func(Of SyntaxNode, SyntaxNode),
previousTopLevelMethod As IMethodSymbolInternal,
methodId As DebugId,
previousLocals As ImmutableArray(Of EncLocalInfo),
lambdaMapOpt As IReadOnlyDictionary(Of Integer, KeyValuePair(Of DebugId, Integer)),
closureMapOpt As IReadOnlyDictionary(Of Integer, DebugId),
stateMachineTypeNameOpt As String,
hoistedLocalSlotCount As Integer,
hoistedLocalSlotsOpt As IReadOnlyDictionary(Of EncHoistedLocalInfo, Integer),
awaiterCount As Integer,
awaiterMapOpt As IReadOnlyDictionary(Of ITypeReference, Integer))
MyBase.New(symbolMap, syntaxMapOpt, previousTopLevelMethod, methodId,
previousLocals, lambdaMapOpt, closureMapOpt, stateMachineTypeNameOpt,
hoistedLocalSlotCount, hoistedLocalSlotsOpt, awaiterCount, awaiterMapOpt)
End Sub
Protected Overrides Function GetLambda(lambdaOrLambdaBodySyntax As SyntaxNode) As SyntaxNode
Return LambdaUtilities.GetLambda(lambdaOrLambdaBodySyntax)
End Function
Protected Overrides Function TryGetCorrespondingLambdaBody(previousLambdaSyntax As SyntaxNode, lambdaOrLambdaBodySyntax As SyntaxNode) As SyntaxNode
Return LambdaUtilities.GetCorrespondingLambdaBody(lambdaOrLambdaBodySyntax, previousLambdaSyntax)
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -616,13 +616,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Protected Overrides Function IsEquivalentToCore(node As SyntaxNode, Optional topLevel As Boolean = False) As Boolean
Return SyntaxFactory.AreEquivalent(Me, DirectCast(node, VisualBasicSyntaxNode), topLevel)
End Function
Friend Overrides Function TryGetCorrespondingLambdaBody(body As SyntaxNode) As SyntaxNode
Return LambdaUtilities.GetCorrespondingLambdaBody(body, Me)
End Function
Friend Overrides Function GetLambda() As SyntaxNode
Return LambdaUtilities.GetLambda(Me)
End Function
End Class
End Namespace
End Namespace
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>cd77a8cc-2885-47a7-b99c-fbf13353400b</ProjectGuid>
<ProjectGuid>c1930979-c824-496b-a630-70f5369a636f</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册