Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
101194fe
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
101194fe
编写于
8月 24, 2017
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added IsDeclaration to IFieldReferenceExpression.
上级
a298f642
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
11 deletion
+23
-11
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
...lers/CSharp/Portable/Operations/CSharpOperationFactory.cs
+4
-2
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalReferenceExpression.cs
...c/IOperation/IOperationTests_ILocalReferenceExpression.cs
+0
-2
src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs
...ilers/Core/Portable/Generated/Operations.xml.Generated.cs
+7
-5
src/Compilers/Core/Portable/Operations/IFieldReferenceExpression.cs
...ers/Core/Portable/Operations/IFieldReferenceExpression.cs
+8
-0
src/Compilers/Core/Portable/Operations/OperationCloner.cs
src/Compilers/Core/Portable/Operations/OperationCloner.cs
+1
-1
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
+1
-0
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
...lBasic/Portable/Operations/VisualBasicOperationFactory.vb
+2
-1
未找到文件。
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
浏览文件 @
101194fe
...
...
@@ -334,13 +334,14 @@ private ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal boundLoca
private
IFieldReferenceExpression
CreateBoundFieldAccessOperation
(
BoundFieldAccess
boundFieldAccess
)
{
IFieldSymbol
field
=
boundFieldAccess
.
FieldSymbol
;
bool
isDeclaration
=
boundFieldAccess
.
IsDeclaration
;
Lazy
<
IOperation
>
instance
=
new
Lazy
<
IOperation
>(()
=>
Create
(
boundFieldAccess
.
FieldSymbol
.
IsStatic
?
null
:
boundFieldAccess
.
ReceiverOpt
));
ISymbol
member
=
boundFieldAccess
.
FieldSymbol
;
SyntaxNode
syntax
=
boundFieldAccess
.
Syntax
;
ITypeSymbol
type
=
boundFieldAccess
.
Type
;
Optional
<
object
>
constantValue
=
ConvertToOptional
(
boundFieldAccess
.
ConstantValue
);
bool
isImplicit
=
boundFieldAccess
.
WasCompilerGenerated
;
return
new
LazyFieldReferenceExpression
(
field
,
instance
,
member
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
return
new
LazyFieldReferenceExpression
(
field
,
i
sDeclaration
,
i
nstance
,
member
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
}
private
IPropertyReferenceExpression
CreateBoundPropertyAccessOperation
(
BoundPropertyAccess
boundPropertyAccess
)
...
...
@@ -550,7 +551,8 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B
{
case
SymbolKind
.
Field
:
var
field
=
(
FieldSymbol
)
boundObjectInitializerMember
.
MemberSymbol
;
return
new
LazyFieldReferenceExpression
(
field
,
instance
,
field
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
bool
isDeclaration
=
false
;
return
new
LazyFieldReferenceExpression
(
field
,
isDeclaration
,
instance
,
field
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
case
SymbolKind
.
Event
:
var
eventSymbol
=
(
EventSymbol
)
boundObjectInitializerMember
.
MemberSymbol
;
return
new
LazyEventReferenceExpression
(
eventSymbol
,
instance
,
eventSymbol
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
);
...
...
src/Compilers/CSharp/Test/Semantic/IOperation/IOperationTests_ILocalReferenceExpression.cs
浏览文件 @
101194fe
...
...
@@ -88,7 +88,5 @@ public virtual void M1()
VerifyOperationTreeAndDiagnosticsForTest
<
DeclarationExpressionSyntax
>(
source
,
expectedOperationTree
,
expectedDiagnostics
);
}
}
}
src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs
浏览文件 @
101194fe
...
...
@@ -1598,15 +1598,17 @@ internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFiel
/// </summary>
internal
abstract
partial
class
BaseFieldReferenceExpression
:
MemberReferenceExpression
,
IFieldReferenceExpression
{
public
BaseFieldReferenceExpression
(
IFieldSymbol
field
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
public
BaseFieldReferenceExpression
(
IFieldSymbol
field
,
bool
isDeclaration
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
base
(
member
,
OperationKind
.
FieldReferenceExpression
,
semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
{
Field
=
field
;
IsDeclaration
=
isDeclaration
;
}
/// <summary>
/// Referenced field.
/// </summary>
public
IFieldSymbol
Field
{
get
;
}
public
bool
IsDeclaration
{
get
;
}
public
override
IEnumerable
<
IOperation
>
Children
{
get
...
...
@@ -1630,8 +1632,8 @@ public override void Accept(OperationVisitor visitor)
/// </summary>
internal
sealed
partial
class
FieldReferenceExpression
:
BaseFieldReferenceExpression
,
IFieldReferenceExpression
{
public
FieldReferenceExpression
(
IFieldSymbol
field
,
IOperation
instance
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
base
(
field
,
member
,
semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
public
FieldReferenceExpression
(
IFieldSymbol
field
,
bool
isDeclaration
,
IOperation
instance
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
base
(
field
,
isDeclaration
,
member
,
semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
{
InstanceImpl
=
instance
;
}
...
...
@@ -1645,8 +1647,8 @@ internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceE
{
private
readonly
Lazy
<
IOperation
>
_lazyInstance
;
public
LazyFieldReferenceExpression
(
IFieldSymbol
field
,
Lazy
<
IOperation
>
instance
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
base
(
field
,
member
,
semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
public
LazyFieldReferenceExpression
(
IFieldSymbol
field
,
bool
isDeclaration
,
Lazy
<
IOperation
>
instance
,
ISymbol
member
,
SemanticModel
semanticModel
,
SyntaxNode
syntax
,
ITypeSymbol
type
,
Optional
<
object
>
constantValue
,
bool
isImplicit
)
:
base
(
field
,
isDeclaration
,
member
,
semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
{
_lazyInstance
=
instance
??
throw
new
System
.
ArgumentNullException
(
nameof
(
instance
));
}
...
...
src/Compilers/Core/Portable/Operations/IFieldReferenceExpression.cs
浏览文件 @
101194fe
...
...
@@ -17,6 +17,14 @@ public interface IFieldReferenceExpression : IMemberReferenceExpression
/// Referenced field.
/// </summary>
IFieldSymbol
Field
{
get
;
}
/// <summary>
/// If the field reference is also where the field was declared.
/// </summary>
/// <remarks>
/// This is only ever true in CSharp scripts, where a top-level statement creates a new variable
/// in a reference, such as an out variable declaration or a tuple deconstruction declaration.
/// </remarks>
bool
IsDeclaration
{
get
;
}
}
}
src/Compilers/Core/Portable/Operations/OperationCloner.cs
浏览文件 @
101194fe
...
...
@@ -216,7 +216,7 @@ public override IOperation VisitInstanceReferenceExpression(IInstanceReferenceEx
public
override
IOperation
VisitFieldReferenceExpression
(
IFieldReferenceExpression
operation
,
object
argument
)
{
return
new
FieldReferenceExpression
(
operation
.
Field
,
Visit
(
operation
.
Instance
),
operation
.
Member
,
((
Operation
)
operation
).
SemanticModel
,
operation
.
Syntax
,
operation
.
Type
,
operation
.
ConstantValue
,
operation
.
IsImplicit
);
return
new
FieldReferenceExpression
(
operation
.
Field
,
operation
.
IsDeclaration
,
Visit
(
operation
.
Instance
),
operation
.
Member
,
((
Operation
)
operation
).
SemanticModel
,
operation
.
Syntax
,
operation
.
Type
,
operation
.
ConstantValue
,
operation
.
IsImplicit
);
}
public
override
IOperation
VisitMethodBindingExpression
(
IMethodBindingExpression
operation
,
object
argument
)
...
...
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
浏览文件 @
101194fe
...
...
@@ -428,6 +428,7 @@ Microsoft.CodeAnalysis.Semantics.IFieldInitializer
Microsoft.CodeAnalysis.Semantics.IFieldInitializer.InitializedFields.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.IFieldSymbol>
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol
Microsoft.CodeAnalysis.Semantics.IFieldReferenceExpression.IsDeclaration.get -> bool
Microsoft.CodeAnalysis.Semantics.IFixedStatement
Microsoft.CodeAnalysis.Semantics.IFixedStatement.Body.get -> Microsoft.CodeAnalysis.IOperation
Microsoft.CodeAnalysis.Semantics.IFixedStatement.Variables.get -> Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement
...
...
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
浏览文件 @
101194fe
...
...
@@ -695,6 +695,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Private
Function
CreateBoundFieldAccessOperation
(
boundFieldAccess
As
BoundFieldAccess
)
As
IFieldReferenceExpression
Dim
field
As
IFieldSymbol
=
boundFieldAccess
.
FieldSymbol
Dim
isDeclaration
As
Boolean
=
False
Dim
instance
As
Lazy
(
Of
IOperation
)
=
New
Lazy
(
Of
IOperation
)(
Function
()
If
boundFieldAccess
.
FieldSymbol
.
IsShared
Then
...
...
@@ -709,7 +710,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Dim
type
As
ITypeSymbol
=
boundFieldAccess
.
Type
Dim
constantValue
As
[
Optional
]
(
Of
Object
)
=
ConvertToOptional
(
boundFieldAccess
.
ConstantValueOpt
)
Dim
isImplicit
As
Boolean
=
boundFieldAccess
.
WasCompilerGenerated
Return
New
LazyFieldReferenceExpression
(
field
,
instance
,
member
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
Return
New
LazyFieldReferenceExpression
(
field
,
i
sDeclaration
,
i
nstance
,
member
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
End
Function
Private
Function
CreateBoundConditionalAccessOperation
(
boundConditionalAccess
As
BoundConditionalAccess
)
As
IConditionalAccessExpression
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录