Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4a416a9a
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,发现更多精彩内容 >>
提交
4a416a9a
编写于
5月 27, 2016
作者:
N
Neal Gafter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Snapshot of working status
上级
805ca66a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
33 deletion
+22
-33
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
...ing/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
+15
-3
src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
...ers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
+7
-30
未找到文件。
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_PatternSwitchStatement.cs
浏览文件 @
4a416a9a
...
...
@@ -110,7 +110,7 @@ private void LowerDecisionTree(DecisionTree.ByType byType, HashSet<LabelSymbol>
BoundExpression
notNull
=
byType
.
Type
.
IsNullableType
()
?
this
.
RewriteNullableNullEquality
(
_factory
.
Syntax
,
BinaryOperatorKind
.
NullableNullNotEqual
,
byType
.
Expression
,
nullValue
,
_factory
.
SpecialType
(
SpecialType
.
System_Boolean
))
:
_factory
.
ObjectNotEqual
(
byType
.
Expression
,
nullValue
);
result
.
Add
(
_factory
.
If
(
notNull
,
_factory
.
Goto
(
notNullLabel
)
));
result
.
Add
(
_factory
.
ConditionalGoto
(
notNull
,
notNullLabel
,
true
));
LowerDecisionTree
(
byType
.
WhenNull
,
usedLabels
,
usedTemps
,
result
);
result
.
Add
(
_factory
.
Goto
(
defaultLabel
));
result
.
Add
(
_factory
.
Label
(
notNullLabel
));
...
...
@@ -125,8 +125,8 @@ private void LowerDecisionTree(DecisionTree.ByType byType, HashSet<LabelSymbol>
var
type
=
td
.
Key
;
var
decision
=
td
.
Value
;
var
failLabel
=
_factory
.
GenerateLabel
(
"failedDecision"
);
grep
(
"if there is a fresh temp needed, copy to it and add the temp from "
,
decision
.
Expression
,
" to "
,
usedTemps
);
grep
(
"test for the type "
,
type
,
" into that temp and goto failLabel when that fails"
);
var
testAndCopy
=
TypeTestAndCopyToTemp
(
byType
.
Expression
,
decision
.
Expression
);
result
.
Add
(
_factory
.
ConditionalGoto
(
testAndCopy
,
failLabel
,
false
)
);
LowerDecisionTree
(
decision
,
usedLabels
,
usedTemps
,
result
);
result
.
Add
(
_factory
.
Label
(
failLabel
));
}
...
...
@@ -135,6 +135,18 @@ private void LowerDecisionTree(DecisionTree.ByType byType, HashSet<LabelSymbol>
LowerDecisionTree
(
byType
.
Default
,
usedLabels
,
usedTemps
,
result
);
}
private
BoundExpression
TypeTestAndCopyToTemp
(
BoundExpression
input
,
BoundExpression
temp
)
{
if
(
input
==
temp
)
{
// if the expression is the same, no need to type test and copy to temp
return
_factory
.
Literal
(
true
);
}
Debug
.
Assert
(
temp
.
Kind
==
BoundKind
.
Local
);
return
MakeDeclarationPattern
(
_factory
.
Syntax
,
input
,
((
BoundLocal
)
temp
).
LocalSymbol
);
}
private
void
LowerDecisionTree
(
DecisionTree
.
ByValue
byValue
,
HashSet
<
LabelSymbol
>
usedLabels
,
HashSet
<
LocalSymbol
>
usedTemps
,
ArrayBuilder
<
BoundStatement
>
result
)
{
throw
new
NotImplementedException
();
...
...
src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
浏览文件 @
4a416a9a
...
...
@@ -646,6 +646,11 @@ public BoundStatement If(BoundExpression condition, BoundStatement thenClause, B
return
If
(
condition
,
ImmutableArray
<
LocalSymbol
>.
Empty
,
thenClause
,
elseClauseOpt
);
}
public
BoundStatement
ConditionalGoto
(
BoundExpression
condition
,
LabelSymbol
label
,
bool
jumpIfTrue
)
{
return
new
BoundConditionalGoto
(
Syntax
,
condition
,
jumpIfTrue
,
label
)
{
WasCompilerGenerated
=
true
};
}
public
BoundStatement
If
(
BoundExpression
condition
,
ImmutableArray
<
LocalSymbol
>
locals
,
BoundStatement
thenClause
,
BoundStatement
elseClauseOpt
=
null
)
{
// We translate
...
...
@@ -668,7 +673,7 @@ public BoundStatement If(BoundExpression condition, ImmutableArray<LocalSymbol>
{
var
alt
=
new
GeneratedLabelSymbol
(
"alternative"
);
statements
.
Add
(
new
BoundConditionalGoto
(
Syntax
,
condition
,
false
,
alt
)
{
WasCompilerGenerated
=
true
}
);
statements
.
Add
(
ConditionalGoto
(
condition
,
alt
,
false
)
);
statements
.
Add
(
thenClause
);
statements
.
Add
(
Goto
(
afterif
));
if
(!
locals
.
IsDefaultOrEmpty
)
...
...
@@ -683,7 +688,7 @@ public BoundStatement If(BoundExpression condition, ImmutableArray<LocalSymbol>
}
else
{
statements
.
Add
(
new
BoundConditionalGoto
(
Syntax
,
condition
,
false
,
afterif
)
{
WasCompilerGenerated
=
true
}
);
statements
.
Add
(
ConditionalGoto
(
condition
,
afterif
,
false
)
);
statements
.
Add
(
thenClause
);
if
(!
locals
.
IsDefaultOrEmpty
)
{
...
...
@@ -697,34 +702,6 @@ public BoundStatement If(BoundExpression condition, ImmutableArray<LocalSymbol>
return
Block
(
statements
.
ToImmutableAndFree
());
}
public
BoundStatement
For
(
BoundExpression
initialization
,
BoundExpression
termination
,
BoundExpression
increment
,
BoundStatement
body
)
{
// for(<initialization>; <increment>; <termination>)
// {
// <body>;
// }
// Lowered form:
// <initialization>;
// goto LoopCondition;
// LoopStart:
// <body>
// <increment>
// LoopCondition:
// if(<termination>)
// goto LoopStart;
var
lLoopStart
=
GenerateLabel
(
"LoopStart"
);
var
lLoopCondition
=
GenerateLabel
(
"LoopCondition"
);
return
Block
(
ExpressionStatement
(
initialization
),
Goto
(
lLoopCondition
),
Label
(
lLoopStart
),
body
,
ExpressionStatement
(
increment
),
Label
(
lLoopCondition
),
If
(
termination
,
Goto
(
lLoopStart
)));
}
public
BoundThrowStatement
Throw
(
BoundExpression
e
=
null
)
{
return
new
BoundThrowStatement
(
Syntax
,
e
)
{
WasCompilerGenerated
=
true
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录