Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
3cb2531e
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,发现更多精彩内容 >>
提交
3cb2531e
编写于
11月 02, 2016
作者:
N
Neal Gafter
提交者:
GitHub
11月 02, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a hidden sequence point around the code that assigns pattern variables in switch (#14790)
Fixes #14740
上级
ad7fb97f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
20 deletion
+13
-20
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
...ing/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
+13
-20
未找到文件。
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
浏览文件 @
3cb2531e
...
...
@@ -371,35 +371,28 @@ private void LowerConstantValueDecision(DecisionTree.ByValue byValue)
/// that binds the pattern variables.
/// </summary>
/// <param name="bindings">The source/destination pairs for the assignments</param>
private
BoundStatement
BindingsForCase
(
ImmutableArray
<
KeyValuePair
<
BoundExpression
,
BoundExpression
>>
bindings
)
/// <param name="addBindings">A builder to which the label and binding assignments are added</param>
private
void
AddBindingsForCase
(
ImmutableArray
<
KeyValuePair
<
BoundExpression
,
BoundExpression
>>
bindings
,
ArrayBuilder
<
BoundStatement
>
addBindings
)
{
var
patternMatched
=
_factory
.
GenerateLabel
(
"patternMatched"
);
_loweredDecisionTree
.
Add
(
_factory
.
Goto
(
patternMatched
));
var
addBindings
=
ArrayBuilder
<
BoundStatement
>.
GetInstance
();
// Hide the code that binds pattern variables in a hidden sequence point
addBindings
.
Add
(
_factory
.
HiddenSequencePoint
());
addBindings
.
Add
(
_factory
.
Label
(
patternMatched
));
if
(!
bindings
.
IsDefaultOrEmpty
)
{
foreach
(
var
kv
in
bindings
)
{
var
source
=
kv
.
Key
;
var
dest
=
kv
.
Value
;
var
rewriter
=
_localRewriter
;
var
loweredRight
=
kv
.
Key
;
var
loweredLeft
=
kv
.
Value
;
addBindings
.
Add
(
_factory
.
ExpressionStatement
(
r
ewriter
.
MakeStaticAssignmentOperator
(
_factory
.
Syntax
,
rewriter
.
VisitExpression
(
dest
),
rewriter
.
VisitExpression
(
source
),
RefKind
.
None
,
des
t
.
Type
,
false
)));
_localR
ewriter
.
MakeStaticAssignmentOperator
(
_factory
.
Syntax
,
loweredLeft
,
loweredRight
,
RefKind
.
None
,
loweredLef
t
.
Type
,
false
)));
}
}
BoundStatement
result
=
_factory
.
Block
(
addBindings
.
ToImmutableAndFree
());
if
(
_localRewriter
.
Instrument
)
{
// Hide the code that binds pattern variables in a hidden sequence point
result
=
_localRewriter
.
_instrumenter
.
InstrumentPatternSwitchBindCasePatternVariables
(
result
);
}
return
result
;
}
private
void
LowerDecisionTree
(
DecisionTree
.
Guarded
guarded
)
...
...
@@ -418,14 +411,14 @@ private void LowerDecisionTree(DecisionTree.Guarded guarded)
else
{
// with bindings
sectionBuilder
.
Add
(
BindingsForCase
(
guarded
.
Bindings
)
);
AddBindingsForCase
(
guarded
.
Bindings
,
sectionBuilder
);
sectionBuilder
.
Add
(
_factory
.
Goto
(
targetLabel
));
}
}
else
{
sectionBuilder
.
Add
(
BindingsForCase
(
guarded
.
Bindings
)
);
var
guardTest
=
_factory
.
ConditionalGoto
(
_localRewriter
.
VisitExpression
(
guarded
.
Guard
)
,
targetLabel
,
true
);
AddBindingsForCase
(
guarded
.
Bindings
,
sectionBuilder
);
var
guardTest
=
_factory
.
ConditionalGoto
(
guarded
.
Guard
,
targetLabel
,
true
);
// Only add instrumentation (such as a sequence point) if the node is not compiler-generated.
if
(!
guarded
.
Guard
.
WasCompilerGenerated
&&
_localRewriter
.
Instrument
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录