Moved VB to consolidate the BoundNode stored in the operation.

上级 2d5d9cff
......@@ -6,6 +6,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Namespace Microsoft.CodeAnalysis.VisualBasic
Partial Friend Class BoundCall
Implements IBoundInvocable
Public Sub New(
syntax As SyntaxNode,
......@@ -67,6 +68,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Private ReadOnly Property IBoundInvocable_Call As BoundCall Implements IBoundInvocable.CallOpt
Get
Return Me
End Get
End Property
Private ReadOnly Property IBoundInvocable_InstanceOpt As BoundExpression Implements IBoundInvocable.InstanceOpt
Get
Return If(ReceiverOpt, MethodGroupOpt?.ReceiverOpt)
End Get
End Property
#If DEBUG Then
Private Sub Validate()
' if method group is specified it should not have receiver if it was moved to a bound call
......
' 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
Namespace Microsoft.CodeAnalysis.VisualBasic
Partial Friend Class BoundDimStatement
Implements IBoundLocalDeclarations
Private ReadOnly Property IBoundLocalDeclarations_Declarations As ImmutableArray(Of BoundLocalDeclarationBase) Implements IBoundLocalDeclarations.Declarations
Get
Return Me.LocalDeclarations
End Get
End Property
End Class
End Namespace
......@@ -5,6 +5,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Partial Class BoundDoLoopStatement
Implements IBoundConditionalLoop
''' <summary>
''' Gets a value indicating whether this do loop is a DoTopLoop or not. In syntax error cases
......@@ -56,5 +57,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Private ReadOnly Property IBoundConditionalLoop_Condition As BoundExpression Implements IBoundConditionalLoop.Condition
Get
Return ConditionOpt
End Get
End Property
Private ReadOnly Property IBoundConditionalLoop_IgnoredCondition As BoundExpression Implements IBoundConditionalLoop.IgnoredCondition
Get
If TopConditionOpt IsNot Nothing AndAlso BottomConditionOpt IsNot Nothing Then
Return BottomConditionOpt
Else
Return Nothing
End If
End Get
End Property
Private ReadOnly Property IBoundConditionalLoop_Body As BoundNode Implements IBoundConditionalLoop.Body
Get
Return Body
End Get
End Property
End Class
End Namespace
' 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.VisualBasic
Partial Friend Class BoundIfStatement
Implements IBoundConditional
Private ReadOnly Property IBoundConditional_WhenTrue As BoundNode Implements IBoundConditional.WhenTrue
Get
Return Me.Consequence
End Get
End Property
Private ReadOnly Property IBoundConditional_WhenFalseOpt As BoundNode Implements IBoundConditional.WhenFalseOpt
Get
Return Me.AlternativeOpt
End Get
End Property
Private ReadOnly Property IBoundConditional_Condition As BoundExpression Implements IBoundConditional.Condition
Get
Return Me.Condition
End Get
End Property
End Class
End Namespace
' 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.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Partial Class BoundLocalDeclaration
Implements IBoundLocalDeclarations
Public Sub New(syntax As SyntaxNode, localSymbol As LocalSymbol, initializerOpt As BoundExpression)
MyClass.New(syntax, localSymbol, initializerOpt, Nothing, False, False)
......@@ -17,6 +19,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
Private ReadOnly Property IBoundLocalDeclarations_Declarations As ImmutableArray(Of BoundLocalDeclarationBase) Implements IBoundLocalDeclarations.Declarations
Get
Return ImmutableArray.Create(Of BoundLocalDeclarationBase)(Me)
End Get
End Property
#If DEBUG Then
Private Sub Validate()
If InitializerOpt IsNot Nothing Then
......
......@@ -7,6 +7,19 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Partial Class BoundNullableIsTrueOperator
Implements IBoundInvocable
Private ReadOnly Property IBoundInvocable_CallOpt As BoundCall Implements IBoundInvocable.CallOpt
Get
Return Nothing
End Get
End Property
Private ReadOnly Property IBoundInvocable_InstanceOpt As BoundExpression Implements IBoundInvocable.InstanceOpt
Get
Return Me.Operand
End Get
End Property
#If DEBUG Then
Private Sub Validate()
......
......@@ -7,6 +7,25 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Partial Class BoundTernaryConditionalExpression
Implements IBoundConditional
Private ReadOnly Property IBoundConditional_Condition As BoundExpression Implements IBoundConditional.Condition
Get
Return Me.Condition
End Get
End Property
Private ReadOnly Property IBoundConditional_WhenTrue As BoundNode Implements IBoundConditional.WhenTrue
Get
Return Me.WhenTrue
End Get
End Property
Private ReadOnly Property IBoundConditional_WhenFalseOpt As BoundNode Implements IBoundConditional.WhenFalseOpt
Get
Return Me.WhenFalse
End Get
End Property
#If DEBUG Then
Private Sub Validate()
......
' 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.VisualBasic
Partial Friend Class BoundWhileStatement
Implements IBoundConditionalLoop
Private ReadOnly Property IBoundConditionalLoop_Condition As BoundExpression Implements IBoundConditionalLoop.Condition
Get
Return Condition
End Get
End Property
Private ReadOnly Property IBoundConditionalLoop_IgnoredCondition As BoundExpression Implements IBoundConditionalLoop.IgnoredCondition
Get
Return Nothing
End Get
End Property
Private ReadOnly Property IBoundConditionalLoop_Body As BoundNode Implements IBoundConditionalLoop.Body
Get
Return Body
End Get
End Property
End Class
End Namespace
' 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.VisualBasic
Friend Interface IBoundConditional
ReadOnly Property Condition As BoundExpression
ReadOnly Property WhenTrue As BoundNode
ReadOnly Property WhenFalseOpt As BoundNode
End Interface
End Namespace
' 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.VisualBasic
Friend Interface IBoundConditionalLoop
ReadOnly Property Condition As BoundExpression
ReadOnly Property IgnoredCondition As BoundExpression
ReadOnly Property Body As BoundNode
End Interface
End Namespace
' 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.VisualBasic
Friend Interface IBoundInvocable
ReadOnly Property CallOpt As BoundCall
ReadOnly Property InstanceOpt As BoundExpression
End Interface
End Namespace
' 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
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Interface IBoundLocalDeclarations
ReadOnly Property Declarations As ImmutableArray(Of BoundLocalDeclarationBase)
End Interface
End Namespace
......@@ -61,6 +61,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Property
End Class
Partial Friend Class BoundRaiseEventStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
Return ImmutableArray.Create(Of BoundNode)(Me.EventInvocation)
End Get
End Property
End Class
Partial Friend Class BoundResumeStatement
Protected Overrides ReadOnly Property Children As ImmutableArray(Of BoundNode)
Get
......
......@@ -254,17 +254,35 @@ Namespace Microsoft.CodeAnalysis.Operations
' put argument syntax to argument operation
Dim argument = If(valueNode.Syntax.Kind = SyntaxKind.OmittedArgument, valueNode.Syntax, TryCast(valueNode.Syntax?.Parent, ArgumentSyntax))
' if argument syntax doesn't exist, then this operation is implicit
Return New VisualBasicLazyArgumentOperation(
Me,
valueNode,
kind,
inConversion,
outConversion,
parameter,
semanticModel:=_semanticModel,
syntax:=If(argument, valueNode.Syntax),
isImplicit:=isImplicit OrElse argument Is Nothing)
If argument Is Nothing Then
' We don't create this lazily because, in the case of query nodes we may want to skip intermediate nodes and then
' use the same syntax as the underlying value for the containing Argument. So we need to actually create the child
' node to determine the correct syntax
Dim value = Create(valueNode)
Return New ArgumentOperation(
value,
kind,
parameter,
inConversion,
outConversion,
semanticModel:=_semanticModel,
syntax:=value.Syntax,
isImplicit:=True)
Else
Debug.Assert(argument IsNot valueNode.Syntax OrElse valueNode.Syntax Is CreateInternal(valueNode).Syntax)
Return New VisualBasicLazyArgumentOperation(
Me,
valueNode,
kind,
inConversion,
outConversion,
parameter,
semanticModel:=_semanticModel,
syntax:=argument,
isImplicit:=isImplicit)
End If
End Function
Friend Function CreateReceiverOperation(node As BoundNode, symbol As ISymbol) As IOperation
......@@ -364,7 +382,7 @@ Namespace Microsoft.CodeAnalysis.Operations
Return GetCaseClauseValue(clause.ValueOpt, clause.ConditionOpt)
End Function
Private Shared Function GetCaseClauseValue(valueOpt As BoundExpression, conditionOpt As BoundExpression) As BoundExpression
Friend Shared Function GetCaseClauseValue(valueOpt As BoundExpression, conditionOpt As BoundExpression) As BoundExpression
If valueOpt IsNot Nothing Then
Return valueOpt
End If
......@@ -477,11 +495,9 @@ Namespace Microsoft.CodeAnalysis.Operations
End Function
Friend Function GetAddRemoveHandlerStatementExpression(statement As BoundAddRemoveHandlerStatement) As IOperation
Dim eventAccess As BoundNode = statement.EventAccess
Dim handler As BoundNode = statement.Handler
Dim adds = statement.Kind = BoundKind.AddHandlerStatement
Return New VisualBasicLazyEventAssignmentOperation(
Me, eventAccess, handler, adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=True)
Me, statement, adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=True)
End Function
#Region "Conversions"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册