提交 2898c124 编写于 作者: H Heejae Chang

regenerated xml.generated file

上级 23bba453
...@@ -180,8 +180,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy ...@@ -180,8 +180,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
{ {
case ConversionKind.ExplicitDynamic: case ConversionKind.ExplicitDynamic:
case ConversionKind.ImplicitDynamic: case ConversionKind.ImplicitDynamic:
// Since the input was `dynamic`, which is equivalent to `object`, there must also // Since the input was `dynamic`, which is equivalent to `object`, there must also
// exist some unboxing, identity, or reference conversion as well, making the conversion legal. // exist some unboxing, identity, or reference conversion as well, making the conversion legal.
case ConversionKind.Boxing: case ConversionKind.Boxing:
case ConversionKind.ExplicitNullable: case ConversionKind.ExplicitNullable:
case ConversionKind.ExplicitReference: case ConversionKind.ExplicitReference:
...@@ -245,7 +245,7 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy ...@@ -245,7 +245,7 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
case SyntaxKind.SingleVariableDesignation: case SyntaxKind.SingleVariableDesignation:
break; break;
case SyntaxKind.DiscardDesignation: case SyntaxKind.DiscardDesignation:
return new BoundDeclarationPattern(node, null, boundDeclType, isVar, hasErrors); return new BoundDeclarationPattern(node, null, new BoundDiscardExpression(node, boundDeclType.Type), boundDeclType, isVar, hasErrors);
default: default:
throw ExceptionUtilities.UnexpectedValue(node.Designation.Kind()); throw ExceptionUtilities.UnexpectedValue(node.Designation.Kind());
} }
...@@ -271,7 +271,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy ...@@ -271,7 +271,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
hasErrors = CheckRestrictedTypeInAsync(this.ContainingMemberOrLambda, declType, diagnostics, typeSyntax); hasErrors = CheckRestrictedTypeInAsync(this.ContainingMemberOrLambda, declType, diagnostics, typeSyntax);
} }
return new BoundDeclarationPattern(node, localSymbol, boundDeclType, isVar, hasErrors); var expression = localSymbol == null ? new BoundDiscardExpression(node, boundDeclType.Type) : (BoundExpression)new BoundLocal(node, localSymbol, null, boundDeclType.Type);
return new BoundDeclarationPattern(node, localSymbol, expression, boundDeclType, isVar, hasErrors);
} }
else else
{ {
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if false
using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Semantics; using Microsoft.CodeAnalysis.Semantics;
using System.Collections.Immutable; using System.Collections.Immutable;
...@@ -262,8 +263,8 @@ public override void Accept(OperationVisitor visitor) ...@@ -262,8 +263,8 @@ public override void Accept(OperationVisitor visitor)
internal partial class BoundForEachStatement : IForEachLoopStatement internal partial class BoundForEachStatement : IForEachLoopStatement
{ {
ILocalSymbol IForEachLoopStatement.IterationVariable => this.IterationVariables.Length == 1? ILocalSymbol IForEachLoopStatement.IterationVariable => this.IterationVariables.Length == 1 ?
this.IterationVariables.FirstOrDefault(): this.IterationVariables.FirstOrDefault() :
null; null;
IOperation IForEachLoopStatement.Collection => this.Expression; IOperation IForEachLoopStatement.Collection => this.Expression;
...@@ -612,7 +613,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables ...@@ -612,7 +613,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables
get get
{ {
return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this, return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this,
declaration => ImmutableArray.Create<IVariableDeclaration>(new VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax))); declaration => ImmutableArray.Create<IVariableDeclaration>(OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
} }
} }
...@@ -641,7 +642,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables ...@@ -641,7 +642,7 @@ ImmutableArray<IVariableDeclaration> IVariableDeclarationStatement.Variables
return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this, return (ImmutableArray<IVariableDeclaration>)s_variablesMappings.GetValue(this,
multipleDeclarations => multipleDeclarations =>
multipleDeclarations.LocalDeclarations.SelectAsArray(declaration => multipleDeclarations.LocalDeclarations.SelectAsArray(declaration =>
(IVariableDeclaration)new VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax))); (IVariableDeclaration)OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)));
} }
} }
...@@ -837,3 +838,4 @@ public override void Accept(OperationVisitor visitor) ...@@ -837,3 +838,4 @@ public override void Accept(OperationVisitor visitor)
} }
} }
} }
#endif
\ No newline at end of file
...@@ -103,7 +103,7 @@ public override CSharpSemanticModel ParentModel ...@@ -103,7 +103,7 @@ public override CSharpSemanticModel ParentModel
internal override MemberSemanticModel GetMemberModel(SyntaxNode node) internal override MemberSemanticModel GetMemberModel(SyntaxNode node)
{ {
// We do have to override this method, but should never call it because it might not do the right thing. // We do have to override this method, but should never call it because it might not do the right thing.
Debug.Assert(false); Debug.Assert(false);
return IsInTree(node) ? this : null; return IsInTree(node) ? this : null;
} }
...@@ -591,7 +591,7 @@ private LocalFunctionSymbol GetDeclaredLocalFunction(LocalFunctionStatementSynta ...@@ -591,7 +591,7 @@ private LocalFunctionSymbol GetDeclaredLocalFunction(LocalFunctionStatementSynta
private static LocalFunctionSymbol GetDeclaredLocalFunction(Binder enclosingBinder, SyntaxToken declaredIdentifier) private static LocalFunctionSymbol GetDeclaredLocalFunction(Binder enclosingBinder, SyntaxToken declaredIdentifier)
{ {
for (var binder = enclosingBinder ; binder != null; binder = binder.Next) for (var binder = enclosingBinder; binder != null; binder = binder.Next)
{ {
foreach (var localFunction in binder.LocalFunctions) foreach (var localFunction in binder.LocalFunctions)
{ {
...@@ -929,7 +929,7 @@ public override ISymbol GetDeclaredSymbol(ArgumentSyntax declaratorSyntax, Cance ...@@ -929,7 +929,7 @@ public override ISymbol GetDeclaredSymbol(ArgumentSyntax declaratorSyntax, Cance
{ {
var elements = tupleLiteralType.TupleElements; var elements = tupleLiteralType.TupleElements;
if(!elements.IsDefault) if (!elements.IsDefault)
{ {
var idx = tupleLiteral.Arguments.IndexOf(declaratorSyntax); var idx = tupleLiteral.Arguments.IndexOf(declaratorSyntax);
return elements[idx]; return elements[idx];
...@@ -978,7 +978,7 @@ internal override IOperation GetOperationWorker(CSharpSyntaxNode node, GetOperat ...@@ -978,7 +978,7 @@ internal override IOperation GetOperationWorker(CSharpSyntaxNode node, GetOperat
break; break;
} }
return result as IOperation; return CSharpOperationFactory.Create(result);
} }
internal override SymbolInfo GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken)) internal override SymbolInfo GetSymbolInfoWorker(CSharpSyntaxNode node, SymbolInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
...@@ -1520,7 +1520,7 @@ private static Binder GetQueryEnclosingBinder(int position, CSharpSyntaxNode sta ...@@ -1520,7 +1520,7 @@ private static Binder GetQueryEnclosingBinder(int position, CSharpSyntaxNode sta
} }
while (node != null); while (node != null);
done: done:
return GetEnclosingBinderInternalWithinRoot(AdjustStartingNodeAccordingToNewRoot(startingNode, queryClause.Syntax), return GetEnclosingBinderInternalWithinRoot(AdjustStartingNodeAccordingToNewRoot(startingNode, queryClause.Syntax),
position, queryClause.Binder, queryClause.Syntax); position, queryClause.Binder, queryClause.Syntax);
} }
...@@ -1805,7 +1805,7 @@ protected CSharpSyntaxNode GetBindableParentNode(CSharpSyntaxNode node) ...@@ -1805,7 +1805,7 @@ protected CSharpSyntaxNode GetBindableParentNode(CSharpSyntaxNode node)
{ {
return null; return null;
} }
throw new ArgumentException($"The parent of {nameof(node)} must not be null unless this is a speculative semantic model.", nameof(node)); throw new ArgumentException($"The parent of {nameof(node)} must not be null unless this is a speculative semantic model.", nameof(node));
} }
......
...@@ -56,18 +56,6 @@ public bool HasLocals ...@@ -56,18 +56,6 @@ public bool HasLocals
} }
} }
protected override OperationKind ExpressionKind => OperationKind.None;
public override void Accept(OperationVisitor visitor)
{
throw ExceptionUtilities.Unreachable;
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
throw ExceptionUtilities.Unreachable;
}
public ImmutableArray<LocalSymbol> GetLocals() public ImmutableArray<LocalSymbol> GetLocals()
{ {
return (_locals == null) ? ImmutableArray<LocalSymbol>.Empty : _locals.ToImmutable(); return (_locals == null) ? ImmutableArray<LocalSymbol>.Empty : _locals.ToImmutable();
...@@ -772,8 +760,8 @@ public override BoundNode VisitCall(BoundCall node) ...@@ -772,8 +760,8 @@ public override BoundNode VisitCall(BoundCall node)
private static RefKind ReceiverSpillRefKind(BoundExpression receiver) private static RefKind ReceiverSpillRefKind(BoundExpression receiver)
{ {
return LocalRewriter.WouldBeAssignableIfUsedAsMethodReceiver(receiver) ? return LocalRewriter.WouldBeAssignableIfUsedAsMethodReceiver(receiver) ?
RefKind.Ref : RefKind.Ref :
RefKind.None; RefKind.None;
} }
......
...@@ -29,23 +29,5 @@ internal class PartiallyLoweredLocalFunctionReference : BoundExpression ...@@ -29,23 +29,5 @@ internal class PartiallyLoweredLocalFunctionReference : BoundExpression
public override BoundNode Accept(BoundTreeVisitor visitor) => public override BoundNode Accept(BoundTreeVisitor visitor) =>
visitor.Visit(this); visitor.Visit(this);
protected override OperationKind ExpressionKind
{
get
{
throw new InvalidOperationException();
}
}
public override void Accept(OperationVisitor visitor)
{
throw new InvalidOperationException();
}
public override TResult Accept<TArgument, TResult>(OperationVisitor<TArgument, TResult> visitor, TArgument argument)
{
throw new InvalidOperationException();
}
} }
} }
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
<Compile Include="Operations\BranchKind.cs" /> <Compile Include="Operations\BranchKind.cs" />
<Compile Include="Operations\CaseKind.cs" /> <Compile Include="Operations\CaseKind.cs" />
<Compile Include="Operations\ConversionKind.cs" /> <Compile Include="Operations\ConversionKind.cs" />
<Compile Include="Operations\Expressions.cs" />
<Compile Include="Operations\IAddressOfExpression.cs" /> <Compile Include="Operations\IAddressOfExpression.cs" />
<Compile Include="Operations\IArgument.cs" /> <Compile Include="Operations\IArgument.cs" />
<Compile Include="Operations\IArrayCreationExpression.cs" /> <Compile Include="Operations\IArrayCreationExpression.cs" />
...@@ -131,6 +130,7 @@ ...@@ -131,6 +130,7 @@
<Compile Include="Operations\IWhileUntilLoopStatement.cs" /> <Compile Include="Operations\IWhileUntilLoopStatement.cs" />
<Compile Include="Operations\IWithStatement.cs" /> <Compile Include="Operations\IWithStatement.cs" />
<Compile Include="Operations\LoopKind.cs" /> <Compile Include="Operations\LoopKind.cs" />
<Compile Include="Operations\OperationFactory.cs" />
<Compile Include="Operations\SimpleBinaryOperationKind.cs" /> <Compile Include="Operations\SimpleBinaryOperationKind.cs" />
<Compile Include="Operations\SimpleUnaryOperationKind.cs" /> <Compile Include="Operations\SimpleUnaryOperationKind.cs" />
<Compile Include="Operations\SyntheticLocalKind.cs" /> <Compile Include="Operations\SyntheticLocalKind.cs" />
...@@ -403,7 +403,6 @@ ...@@ -403,7 +403,6 @@
<Compile Include="Compilation\SemanticModel.cs" /> <Compile Include="Compilation\SemanticModel.cs" />
<Compile Include="Compilation\SourceReferenceResolver.cs" /> <Compile Include="Compilation\SourceReferenceResolver.cs" />
<Compile Include="Compilation\SpeculativeBindingOption.cs" /> <Compile Include="Compilation\SpeculativeBindingOption.cs" />
<Compile Include="Operations\Statement.cs" />
<Compile Include="Compilation\SubsystemVersion.cs" /> <Compile Include="Compilation\SubsystemVersion.cs" />
<Compile Include="Compilation\SymbolInfo.cs" /> <Compile Include="Compilation\SymbolInfo.cs" />
<Compile Include="Compilation\TypeInfo.cs" /> <Compile Include="Compilation\TypeInfo.cs" />
......
...@@ -1913,12 +1913,19 @@ public override void Accept(OperationVisitor visitor) ...@@ -1913,12 +1913,19 @@ public override void Accept(OperationVisitor visitor)
/// </summary> /// </summary>
internal sealed partial class IndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression internal sealed partial class IndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression
{ {
public IndexedPropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : public IndexedPropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue) base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue)
{ {
ArgumentsInParameterOrder = argumentsInParameterOrder;
Instance = instance ?? throw new System.ArgumentNullException("instance"); Instance = instance ?? throw new System.ArgumentNullException("instance");
} }
/// <summary> /// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary>
/// Instance of the type. Null if the reference is to a static/shared member. /// Instance of the type. Null if the reference is to a static/shared member.
/// </summary> /// </summary>
public override IOperation Instance { get; } public override IOperation Instance { get; }
...@@ -1938,11 +1945,20 @@ public override void Accept(OperationVisitor visitor) ...@@ -1938,11 +1945,20 @@ public override void Accept(OperationVisitor visitor)
internal sealed partial class LazyIndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression internal sealed partial class LazyIndexedPropertyReferenceExpression : PropertyReferenceExpressionBase, IHasArgumentsExpression, IIndexedPropertyReferenceExpression
{ {
private readonly Lazy<IOperation> _lazyInstance; private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyIndexedPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, ISymbol member, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue) public LazyIndexedPropertyReferenceExpression(IPropertySymbol property, Lazy<IOperation> instance, ISymbol member, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(property, member, OperationKind.IndexedPropertyReferenceExpression, isInvalid, syntax, type, constantValue)
{ {
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
_lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); _lazyInstance = instance ?? throw new System.ArgumentNullException("instance");
} }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
/// <summary> /// <summary>
/// Instance of the type. Null if the reference is to a static/shared member. /// Instance of the type. Null if the reference is to a static/shared member.
/// </summary> /// </summary>
...@@ -2051,6 +2067,12 @@ internal abstract partial class InvocationExpressionBase : Operation, IHasArgume ...@@ -2051,6 +2067,12 @@ internal abstract partial class InvocationExpressionBase : Operation, IHasArgume
/// unless supplied in source. /// unless supplied in source.
/// </summary> /// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInSourceOrder { get; } public abstract ImmutableArray<IArgument> ArgumentsInSourceOrder { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
public override void Accept(OperationVisitor visitor) public override void Accept(OperationVisitor visitor)
{ {
visitor.VisitInvocationExpression(this); visitor.VisitInvocationExpression(this);
...@@ -2066,11 +2088,12 @@ public override void Accept(OperationVisitor visitor) ...@@ -2066,11 +2088,12 @@ public override void Accept(OperationVisitor visitor)
/// </summary> /// </summary>
internal sealed partial class InvocationExpression : InvocationExpressionBase, IHasArgumentsExpression, IInvocationExpression internal sealed partial class InvocationExpression : InvocationExpressionBase, IHasArgumentsExpression, IInvocationExpression
{ {
public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray<IArgument> argumentsInSourceOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray<IArgument> argumentsInSourceOrder, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue) base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue)
{ {
Instance = instance ?? throw new System.ArgumentNullException("instance"); Instance = instance ?? throw new System.ArgumentNullException("instance");
ArgumentsInSourceOrder = argumentsInSourceOrder; ArgumentsInSourceOrder = argumentsInSourceOrder;
ArgumentsInParameterOrder = argumentsInParameterOrder;
} }
/// <summary> /// <summary>
/// 'This' or 'Me' instance to be supplied to the method, or null if the method is static. /// 'This' or 'Me' instance to be supplied to the method, or null if the method is static.
...@@ -2082,6 +2105,12 @@ internal sealed partial class InvocationExpression : InvocationExpressionBase, I ...@@ -2082,6 +2105,12 @@ internal sealed partial class InvocationExpression : InvocationExpressionBase, I
/// unless supplied in source. /// unless supplied in source.
/// </summary> /// </summary>
public override ImmutableArray<IArgument> ArgumentsInSourceOrder { get; } public override ImmutableArray<IArgument> ArgumentsInSourceOrder { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
} }
/// <summary> /// <summary>
...@@ -2091,11 +2120,13 @@ internal sealed partial class LazyInvocationExpression : InvocationExpressionBas ...@@ -2091,11 +2120,13 @@ internal sealed partial class LazyInvocationExpression : InvocationExpressionBas
{ {
private readonly Lazy<IOperation> _lazyInstance; private readonly Lazy<IOperation> _lazyInstance;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInSourceOrder; private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInSourceOrder;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> instance, bool isVirtual, Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue) public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> instance, bool isVirtual, Lazy<ImmutableArray<IArgument>> argumentsInSourceOrder, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(targetMethod, isVirtual, isInvalid, syntax, type, constantValue)
{ {
_lazyInstance = instance ?? throw new System.ArgumentNullException("instance"); _lazyInstance = instance ?? throw new System.ArgumentNullException("instance");
_lazyArgumentsInSourceOrder = argumentsInSourceOrder; _lazyArgumentsInSourceOrder = argumentsInSourceOrder;
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
} }
/// <summary> /// <summary>
/// 'This' or 'Me' instance to be supplied to the method, or null if the method is static. /// 'This' or 'Me' instance to be supplied to the method, or null if the method is static.
...@@ -2108,6 +2139,13 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins ...@@ -2108,6 +2139,13 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy<IOperation> ins
/// unless supplied in source. /// unless supplied in source.
/// </summary> /// </summary>
public override ImmutableArray<IArgument> ArgumentsInSourceOrder => _lazyArgumentsInSourceOrder.Value; public override ImmutableArray<IArgument> ArgumentsInSourceOrder => _lazyArgumentsInSourceOrder.Value;
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
} }
/// <summary> /// <summary>
...@@ -2677,6 +2715,12 @@ internal abstract partial class ObjectCreationExpressionBase : Operation, IHasAr ...@@ -2677,6 +2715,12 @@ internal abstract partial class ObjectCreationExpressionBase : Operation, IHasAr
/// Explicitly-specified member initializers. /// Explicitly-specified member initializers.
/// </summary> /// </summary>
public abstract ImmutableArray<ISymbolInitializer> MemberInitializers { get; } public abstract ImmutableArray<ISymbolInitializer> MemberInitializers { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public abstract ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
public override void Accept(OperationVisitor visitor) public override void Accept(OperationVisitor visitor)
{ {
visitor.VisitObjectCreationExpression(this); visitor.VisitObjectCreationExpression(this);
...@@ -2692,15 +2736,22 @@ public override void Accept(OperationVisitor visitor) ...@@ -2692,15 +2736,22 @@ public override void Accept(OperationVisitor visitor)
/// </summary> /// </summary>
internal sealed partial class ObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression internal sealed partial class ObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression
{ {
public ObjectCreationExpression(IMethodSymbol constructor, ImmutableArray<ISymbolInitializer> memberInitializers, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : public ObjectCreationExpression(IMethodSymbol constructor, ImmutableArray<ISymbolInitializer> memberInitializers, ImmutableArray<IArgument> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
base(constructor, isInvalid, syntax, type, constantValue) base(constructor, isInvalid, syntax, type, constantValue)
{ {
MemberInitializers = memberInitializers; MemberInitializers = memberInitializers;
ArgumentsInParameterOrder = argumentsInParameterOrder;
} }
/// <summary> /// <summary>
/// Explicitly-specified member initializers. /// Explicitly-specified member initializers.
/// </summary> /// </summary>
public override ImmutableArray<ISymbolInitializer> MemberInitializers { get; } public override ImmutableArray<ISymbolInitializer> MemberInitializers { get; }
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
} }
/// <summary> /// <summary>
...@@ -2709,15 +2760,24 @@ internal sealed partial class ObjectCreationExpression : ObjectCreationExpressio ...@@ -2709,15 +2760,24 @@ internal sealed partial class ObjectCreationExpression : ObjectCreationExpressio
internal sealed partial class LazyObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression internal sealed partial class LazyObjectCreationExpression : ObjectCreationExpressionBase, IHasArgumentsExpression, IObjectCreationExpression
{ {
private readonly Lazy<ImmutableArray<ISymbolInitializer>> _lazyMemberInitializers; private readonly Lazy<ImmutableArray<ISymbolInitializer>> _lazyMemberInitializers;
private readonly Lazy<ImmutableArray<IArgument>> _lazyArgumentsInParameterOrder;
public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(constructor, isInvalid, syntax, type, constantValue) public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy<ImmutableArray<ISymbolInitializer>> memberInitializers, Lazy<ImmutableArray<IArgument>> argumentsInParameterOrder, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : base(constructor, isInvalid, syntax, type, constantValue)
{ {
_lazyMemberInitializers = memberInitializers; _lazyMemberInitializers = memberInitializers;
_lazyArgumentsInParameterOrder = argumentsInParameterOrder;
} }
/// <summary> /// <summary>
/// Explicitly-specified member initializers. /// Explicitly-specified member initializers.
/// </summary> /// </summary>
public override ImmutableArray<ISymbolInitializer> MemberInitializers => _lazyMemberInitializers.Value; public override ImmutableArray<ISymbolInitializer> MemberInitializers => _lazyMemberInitializers.Value;
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public override ImmutableArray<IArgument> ArgumentsInParameterOrder => _lazyArgumentsInParameterOrder.Value;
} }
/// <summary> /// <summary>
......
// 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.Linq;
namespace Microsoft.CodeAnalysis.Semantics
{
internal sealed partial class ConditionalChoiceExpression : IConditionalChoiceExpression
{
public ConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SyntaxNode syntax) :
this(condition,
ifTrue,
ifFalse,
IsInvalidOperation(condition, ifTrue, ifFalse, resultType),
syntax,
resultType,
default(Optional<object>))
{
}
private static bool IsInvalidOperation(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType)
{
return (condition == null || condition.IsInvalid || ifTrue == null || ifTrue.IsInvalid || ifFalse == null || ifFalse.IsInvalid || resultType == null);
}
}
internal sealed partial class ExpressionStatement : IExpressionStatement
{
public ExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax) :
this(new AssignmentExpression(target, value, IsInvalidOperation(target, value), syntax, target.Type, default(Optional<object>)),
syntax)
{
}
public ExpressionStatement(IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, IMethodSymbol operatorMethod, SyntaxNode syntax) :
this(new CompoundAssignmentExpression(
binaryOperationKind,
target,
value,
operatorMethod != null,
operatorMethod,
IsInvalidOperation(target, value),
syntax,
target.Type,
default(Optional<object>)),
syntax)
{
}
private ExpressionStatement(IOperation expression, SyntaxNode syntax) :
this(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>))
{
}
private static bool IsInvalidOperation(IOperation target, IOperation value)
{
return target == null || target.IsInvalid || value == null || value.IsInvalid;
}
}
internal sealed partial class LiteralExpression : ILiteralExpression
{
public LiteralExpression(long value, ITypeSymbol resultType, SyntaxNode syntax) :
this(value.ToString(), isInvalid: false, syntax: syntax, type: resultType, constantValue: new Optional<object>(value))
{
}
public LiteralExpression(ConstantValue value, ITypeSymbol resultType, SyntaxNode syntax) :
this(value.GetValueToDisplay(), value.IsBad, syntax, resultType, new Optional<object>(value.Value))
{
}
}
internal sealed partial class BinaryOperatorExpression : IBinaryOperatorExpression
{
public BinaryOperatorExpression(BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SyntaxNode syntax) :
this(binaryOperationKind, left, right,
usesOperatorMethod: false, operatorMethod: null,
isInvalid: IsInvalidOperation(binaryOperationKind, left, right, resultType),
syntax: syntax, type: resultType, constantValue: default(Optional<object>))
{
}
private static bool IsInvalidOperation(BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol type)
{
return left == null || left.IsInvalid || right == null
|| right.IsInvalid || binaryOperationKind == BinaryOperationKind.Invalid || type == null;
}
}
internal sealed partial class ArrayCreationExpression : IArrayCreationExpression
{
public ArrayCreationExpression(IArrayTypeSymbol arrayType, ImmutableArray<IOperation> elementValues, SyntaxNode syntax) :
this(arrayType.ElementType,
ImmutableArray.Create<IOperation>(new LiteralExpression(elementValues.Count(), resultType: null, syntax: syntax)),
new ArrayInitializer(elementValues, elementValues.Any(v => v.IsInvalid), syntax, arrayType, default(Optional<object>)),
syntax,
arrayType,
default(Optional<object>))
{
}
private ArrayCreationExpression(ITypeSymbol elementType, ImmutableArray<IOperation> dimensionSizes, IArrayInitializer initializer, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) :
this(elementType, dimensionSizes, initializer, initializer.IsInvalid, syntax, type, constantValue)
{
}
}
internal partial class InvalidExpression : IInvalidExpression
{
public InvalidExpression(SyntaxNode syntax) :
this(isInvalid: true, syntax: syntax, type: null, constantValue: default(Optional<object>))
{
}
}
}
...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics ...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{ {
internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpression internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpression
{ {
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary> /// <summary>
/// Find the argument supplied for a given parameter of the target method. /// Find the argument supplied for a given parameter of the target method.
/// </summary> /// </summary>
...@@ -19,18 +13,12 @@ internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpress ...@@ -19,18 +13,12 @@ internal partial class IndexedPropertyReferenceExpression : IHasArgumentsExpress
/// <returns>Argument corresponding to the parameter.</returns> /// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter) public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{ {
throw new System.NotImplementedException(); return this.ArgumentsInParameterOrder[parameter.Ordinal];
} }
} }
internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExpression internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExpression
{ {
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary> /// <summary>
/// Find the argument supplied for a given parameter of the target method. /// Find the argument supplied for a given parameter of the target method.
/// </summary> /// </summary>
...@@ -38,7 +26,7 @@ internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExp ...@@ -38,7 +26,7 @@ internal partial class LazyIndexedPropertyReferenceExpression : IHasArgumentsExp
/// <returns>Argument corresponding to the parameter.</returns> /// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter) public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{ {
throw new System.NotImplementedException(); return this.ArgumentsInParameterOrder[parameter.Ordinal];
} }
} }
} }
...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics ...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{ {
internal partial class InvocationExpressionBase : IHasArgumentsExpression internal partial class InvocationExpressionBase : IHasArgumentsExpression
{ {
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary> /// <summary>
/// Find the argument supplied for a given parameter of the target method. /// Find the argument supplied for a given parameter of the target method.
/// </summary> /// </summary>
...@@ -19,7 +13,7 @@ internal partial class InvocationExpressionBase : IHasArgumentsExpression ...@@ -19,7 +13,7 @@ internal partial class InvocationExpressionBase : IHasArgumentsExpression
/// <returns>Argument corresponding to the parameter.</returns> /// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter) public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{ {
throw new System.NotImplementedException(); return this.ArgumentsInParameterOrder[parameter.Ordinal];
} }
} }
} }
...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics ...@@ -6,12 +6,6 @@ namespace Microsoft.CodeAnalysis.Semantics
{ {
internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression
{ {
/// <summary>
/// Arguments of the invocation, excluding the instance argument. Arguments are in parameter order,
/// and params/ParamArray arguments have been collected into arrays. Default values are supplied for
/// optional arguments missing in source.
/// </summary>
public ImmutableArray<IArgument> ArgumentsInParameterOrder { get; }
/// <summary> /// <summary>
/// Find the argument supplied for a given parameter of the target method. /// Find the argument supplied for a given parameter of the target method.
/// </summary> /// </summary>
...@@ -19,7 +13,7 @@ internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression ...@@ -19,7 +13,7 @@ internal partial class ObjectCreationExpressionBase : IHasArgumentsExpression
/// <returns>Argument corresponding to the parameter.</returns> /// <returns>Argument corresponding to the parameter.</returns>
public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter) public IArgument GetArgumentMatchingParameter(IParameterSymbol parameter)
{ {
throw new System.NotImplementedException(); return this.ArgumentsInParameterOrder[parameter.Ordinal];
} }
} }
} }
// 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.Linq;
namespace Microsoft.CodeAnalysis.Semantics
{
internal static class OperationFactory
{
public static VariableDeclaration CreateVariableDeclaration(ILocalSymbol variable, IOperation initialValue, SyntaxNode syntax)
{
return new VariableDeclaration(
variable,
initialValue,
variable == null || (initialValue != null && initialValue.IsInvalid),
syntax,
type: null,
constantValue: default(Optional<object>));
}
public static ConditionalChoiceExpression CreateConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SyntaxNode syntax)
{
var isInvalid = (condition == null || condition.IsInvalid || ifTrue == null || ifTrue.IsInvalid || ifFalse == null || ifFalse.IsInvalid || resultType == null);
return new ConditionalChoiceExpression(
condition,
ifTrue,
ifFalse,
isInvalid,
syntax,
resultType,
default(Optional<object>));
}
public static ExpressionStatement CreateAssignmentExpressionStatement(IOperation target, IOperation value, SyntaxNode syntax)
{
var isInvalid = target == null || target.IsInvalid || value == null || value.IsInvalid;
var expression = new AssignmentExpression(target, value, isInvalid, syntax, target.Type, default(Optional<object>));
return new ExpressionStatement(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>));
}
public static ExpressionStatement CreateCompoundAssignmentExpressionStatement(
IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, IMethodSymbol operatorMethod, SyntaxNode syntax)
{
var isInvalid = target == null || target.IsInvalid || value == null || value.IsInvalid;
var expression = new CompoundAssignmentExpression(
binaryOperationKind,
target,
value,
operatorMethod != null,
operatorMethod,
isInvalid,
syntax,
target.Type,
default(Optional<object>));
return new ExpressionStatement(expression, expression.IsInvalid, syntax, type: null, constantValue: default(Optional<object>));
}
public static LiteralExpression CreateLiteralExpression(long value, ITypeSymbol resultType, SyntaxNode syntax)
{
return new LiteralExpression(value.ToString(), isInvalid: false, syntax: syntax, type: resultType, constantValue: new Optional<object>(value));
}
public static LiteralExpression CreateLiteralExpression(ConstantValue value, ITypeSymbol resultType, SyntaxNode syntax)
{
return new LiteralExpression(value.GetValueToDisplay(), value.IsBad, syntax, resultType, new Optional<object>(value.Value));
}
public static BinaryOperatorExpression CreateBinaryOperatorExpression(
BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SyntaxNode syntax)
{
var isInvalid = left == null || left.IsInvalid || right == null || right.IsInvalid || binaryOperationKind == BinaryOperationKind.Invalid || resultType == null;
return new BinaryOperatorExpression(
binaryOperationKind, left, right,
usesOperatorMethod: false, operatorMethod: null,
isInvalid: isInvalid, syntax: syntax, type: resultType, constantValue: default(Optional<object>));
}
public static ArrayCreationExpression CreateArrayCreationExpression(
IArrayTypeSymbol arrayType, ImmutableArray<IOperation> elementValues, SyntaxNode syntax)
{
var initializer = new ArrayInitializer(elementValues, elementValues.Any(v => v.IsInvalid), syntax, arrayType, default(Optional<object>));
return new ArrayCreationExpression(
arrayType.ElementType,
ImmutableArray.Create<IOperation>(CreateLiteralExpression(elementValues.Count(), resultType: null, syntax: syntax)),
initializer,
initializer.IsInvalid,
syntax,
arrayType,
default(Optional<object>));
}
public static InvalidExpression CreateInvalidExpression(SyntaxNode syntax)
{
return new InvalidExpression(isInvalid: true, syntax: syntax, type: null, constantValue: default(Optional<object>));
}
}
}
\ No newline at end of file
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.CodeAnalysis.Semantics
{
internal partial class VariableDeclaration : IVariableDeclaration
{
public VariableDeclaration(ILocalSymbol variable, IOperation initialValue, SyntaxNode syntax) :
this(variable,
initialValue,
variable == null || (initialValue != null && initialValue.IsInvalid),
syntax,
type: null,
constantValue: default(Optional<object>))
{
}
}
}
\ No newline at end of file
...@@ -58,7 +58,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -58,7 +58,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If End If
End If End If
Return New InvalidExpression(parent.Syntax) Return OperationFactory.CreateInvalidExpression(parent.Syntax)
End Function End Function
End Class End Class
......
...@@ -569,7 +569,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -569,7 +569,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If End If
Dim stepOperand As IOperation = If(stepValue.IsConstant, DirectCast(stepValue, IOperation), New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, stepValue)) Dim stepOperand As IOperation = If(stepValue.IsConstant, DirectCast(stepValue, IOperation), New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, stepValue))
statements.Add(New ExpressionStatement(controlReference, stepOperand, Semantics.Expression.DeriveAdditionKind(controlType), Nothing, stepValue.Syntax)) statements.Add(OperationFactory.CreateCompoundAssignmentExpressionStatement(controlReference, stepOperand, Semantics.Expression.DeriveAdditionKind(controlType), Nothing, stepValue.Syntax))
End If End If
End If End If
...@@ -592,17 +592,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -592,17 +592,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' ControlVariable = InitialValue ' ControlVariable = InitialValue
Dim controlReference As IOperation = BoundFor.ControlVariable Dim controlReference As IOperation = BoundFor.ControlVariable
If controlReference IsNot Nothing Then If controlReference IsNot Nothing Then
statements.Add(New ExpressionStatement(controlReference, BoundFor.InitialValue, BoundFor.InitialValue.Syntax)) statements.Add(OperationFactory.CreateAssignmentExpressionStatement(controlReference, BoundFor.InitialValue, BoundFor.InitialValue.Syntax))
End If End If
' T0 = LimitValue ' T0 = LimitValue
If Not Me.LimitValue.IsConstant Then If Not Me.LimitValue.IsConstant Then
statements.Add(New ExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopLimitValue, BoundFor, BoundFor.LimitValue), BoundFor.LimitValue, BoundFor.LimitValue.Syntax)) statements.Add(OperationFactory.CreateAssignmentExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopLimitValue, BoundFor, BoundFor.LimitValue), BoundFor.LimitValue, BoundFor.LimitValue.Syntax))
End If End If
' T1 = StepValue ' T1 = StepValue
If BoundFor.StepValue IsNot Nothing AndAlso Not BoundFor.StepValue.IsConstant Then If BoundFor.StepValue IsNot Nothing AndAlso Not BoundFor.StepValue.IsConstant Then
statements.Add(New ExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue), BoundFor.StepValue, BoundFor.StepValue.Syntax)) statements.Add(OperationFactory.CreateAssignmentExpressionStatement(New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue), BoundFor.StepValue, BoundFor.StepValue.Syntax))
End If End If
Return statements.ToImmutableAndFree() Return statements.ToImmutableAndFree()
...@@ -640,25 +640,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -640,25 +640,25 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Either ControlVariable <= LimitValue or ControlVariable >= LimitValue, depending on whether the step value is negative. ' Either ControlVariable <= LimitValue or ControlVariable >= LimitValue, depending on whether the step value is negative.
Dim relationalCode As BinaryOperationKind = DeriveBinaryOperationKind(If(BoundFor.StepValue IsNot Nothing AndAlso BoundFor.StepValue.ConstantValueOpt.IsNegativeNumeric, BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThanOrEqual), controlVariable) Dim relationalCode As BinaryOperationKind = DeriveBinaryOperationKind(If(BoundFor.StepValue IsNot Nothing AndAlso BoundFor.StepValue.ConstantValueOpt.IsNegativeNumeric, BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThanOrEqual), controlVariable)
Return New BinaryOperatorExpression(relationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax) Return OperationFactory.CreateBinaryOperatorExpression(relationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Else Else
' If(StepValue >= 0, ControlVariable <= LimitValue, ControlVariable >= LimitValue) ' If(StepValue >= 0, ControlVariable <= LimitValue, ControlVariable >= LimitValue)
Dim stepValue As IOperation = New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue) Dim stepValue As IOperation = New Temporary(SyntheticLocalKind.ForLoopStepValue, BoundFor, BoundFor.StepValue)
Dim stepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, BoundFor.StepValue) Dim stepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, BoundFor.StepValue)
Dim stepCondition As IOperation = New BinaryOperatorExpression(stepRelationalCode, Dim stepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(stepRelationalCode,
stepValue, stepValue,
New LiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValue.Type, 0), BoundFor.StepValue.Type, BoundFor.StepValue.Syntax), OperationFactory.CreateLiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValue.Type, 0), BoundFor.StepValue.Type, BoundFor.StepValue.Syntax),
booleanType, booleanType,
BoundFor.StepValue.Syntax) BoundFor.StepValue.Syntax)
Dim positiveStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.LessThanOrEqual, controlVariable) Dim positiveStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.LessThanOrEqual, controlVariable)
Dim positiveStepCondition As IOperation = New BinaryOperatorExpression(positiveStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax) Dim positiveStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(positiveStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Dim negativeStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, controlVariable) Dim negativeStepRelationalCode As BinaryOperationKind = DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, controlVariable)
Dim negativeStepCondition As IOperation = New BinaryOperatorExpression(negativeStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax) Dim negativeStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(negativeStepRelationalCode, controlVariable, limitValue, booleanType, limitValue.Syntax)
Return New ConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, limitValue.Syntax) Return OperationFactory.CreateConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, limitValue.Syntax)
End If End If
End If End If
End Function) End Function)
...@@ -1058,11 +1058,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -1058,11 +1058,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
For Each base In dimStatement.LocalDeclarations For Each base In dimStatement.LocalDeclarations
If base.Kind = BoundKind.LocalDeclaration Then If base.Kind = BoundKind.LocalDeclaration Then
Dim declaration = DirectCast(base, BoundLocalDeclaration) Dim declaration = DirectCast(base, BoundLocalDeclaration)
builder.Add(New VariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax)) builder.Add(OperationFactory.CreateVariableDeclaration(declaration.LocalSymbol, declaration.InitializerOpt, declaration.Syntax))
ElseIf base.Kind = BoundKind.AsNewLocalDeclarations Then ElseIf base.Kind = BoundKind.AsNewLocalDeclarations Then
Dim asNewDeclarations = DirectCast(base, BoundAsNewLocalDeclarations) Dim asNewDeclarations = DirectCast(base, BoundAsNewLocalDeclarations)
For Each asNewDeclaration In asNewDeclarations.LocalDeclarations For Each asNewDeclaration In asNewDeclarations.LocalDeclarations
builder.Add(New VariableDeclaration(asNewDeclaration.LocalSymbol, asNewDeclarations.Initializer, asNewDeclaration.Syntax)) builder.Add(OperationFactory.CreateVariableDeclaration(asNewDeclaration.LocalSymbol, asNewDeclarations.Initializer, asNewDeclaration.Syntax))
Next Next
End If End If
Next Next
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册