Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1d709b4b
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,发现更多精彩内容 >>
提交
1d709b4b
编写于
3月 27, 2017
作者:
V
vsadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CR feedback
上级
48d2ae37
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
17 deletion
+10
-17
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
...Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
+1
-1
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
...s/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
+9
-16
未找到文件。
src/Compilers/CSharp/Portable/Lowering/AsyncRewriter/AwaitExpressionSpiller.cs
浏览文件 @
1d709b4b
...
...
@@ -772,7 +772,7 @@ public override BoundNode VisitCall(BoundCall node)
private
static
RefKind
ReceiverSpillRefKind
(
BoundExpression
receiver
)
{
return
LocalRewriter
.
ReceiverCanBeAssigned
(
receiver
)
?
return
LocalRewriter
.
WouldBeAssignableIfUsedAsMethodReceiver
(
receiver
)
?
RefKind
.
Ref
:
RefKind
.
None
;
}
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter.cs
浏览文件 @
1d709b4b
...
...
@@ -500,31 +500,24 @@ private static bool ShouldOptimizeOutInitializer(BoundStatement initializer)
}
/// <summary>
/// Receivers of struct methods are
alowed to be RValues or LValu
es.
/// Receivers of struct methods are
required to be at least RValues but can be assignable variabl
es.
/// Whether the mutations from the method are propagated back to the
/// receiver instance is conditional on whether the receiver is an LValue.
/// receiver instance is conditional on whether the receiver is a variable that can be assigned.
/// If not, then the invokation is performed on a copy.
///
/// An inconvenient situation may arise when
an the receiver is an RValue expression
,
/// An inconvenient situation may arise when
the receiver is an RValue expression (like a ternary operator)
,
/// which is trivially reduced during lowering to one of its operands and
/// such operand happens to be an
LValue
. That operation alone would
/// such operand happens to be an
assignable variable (like a local)
. That operation alone would
/// expose the operand to mutations while it would not be exposed otherwise.
/// I.E. the transformation becomes semantically observable.
///
/// To prevent such situations, we will wrap the operand into a node whose only
/// purpose is to never be an
LValue
.
/// purpose is to never be an
assignable expression
.
/// </summary>
private
static
BoundExpression
EnsureNot
Lvalue
Receiver
(
BoundExpression
expr
)
private
static
BoundExpression
EnsureNot
AssignableIfUsedAsMethod
Receiver
(
BoundExpression
expr
)
{
// Leave as-is where receiver mutations cannot happen.
if
(!
ReceiverCanBeAssigned
(
expr
))
{
return
expr
;
}
// - reference type receivers are byval
// - special value types do not have mutating members
var
type
=
expr
.
Type
.
OriginalDefinition
;
if
(
type
.
IsReferenceType
||
type
.
SpecialType
!=
SpecialType
.
None
)
if
(!
WouldBeAssignableIfUsedAsMethodReceiver
(
expr
))
{
return
expr
;
}
...
...
@@ -540,7 +533,7 @@ private static BoundExpression EnsureNotLvalueReceiver(BoundExpression expr)
{
WasCompilerGenerated
=
true
};
}
internal
static
bool
ReceiverCanBeAssigned
(
BoundExpression
receiver
)
internal
static
bool
WouldBeAssignableIfUsedAsMethodReceiver
(
BoundExpression
receiver
)
{
// - reference type receivers are byval
// - special value types (int32, Nullable<T>, . .) do not have mutating members
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录