提交 5d3e45e8 编写于 作者: N Neal Gafter

Snapshot of working state

上级 6a15f474
......@@ -32,7 +32,7 @@ internal static SwitchBinder Create(Binder next, SwitchStatementSyntax switchSyn
// compatible with the existing syntax and semantics, we will remove *this* binder
// and use the new one for binding all switch statements.
return
((switchSyntax?.SyntaxTree?.Options as CSharpParseOptions)?.IsFeatureEnabled(MessageID.IDS_FeaturePatternMatching) != false)
true || ((switchSyntax?.SyntaxTree?.Options as CSharpParseOptions)?.IsFeatureEnabled(MessageID.IDS_FeaturePatternMatching) != false)
? new PatternSwitchBinder(next, switchSyntax)
: new SwitchBinder(next, switchSyntax);
}
......
......@@ -67,6 +67,7 @@ private BoundNode VisitPatternSwitchStatement_Ifchain(BoundPatternSwitchStatemen
}
statements.Add(_factory.Label(node.BreakLabel));
_factory.Syntax = node.Syntax;
return _factory.Block(node.InnerLocals.Add(switchExpressionTemp.LocalSymbol), node.InnerLocalFunctions, statements.ToImmutableAndFree());
}
}
......
......@@ -19,12 +19,13 @@ internal partial class LocalRewriter
// then we use the transitional code which translates a pattern switch into a series of
// if-then-else statements. Ultimately we need the new translation to be used to generate
// switch IL instructions for ordinary old-style switch statements.
private static bool UseNewTranslation(BoundPatternSwitchStatement node) => false;
private static bool UseNewTranslation(BoundPatternSwitchStatement node) => true;
public override BoundNode VisitPatternSwitchStatement(BoundPatternSwitchStatement node)
{
// Until this is all implemented, we use a dumb series of if-then-else
// statements to translate the switch statement.
_factory.Syntax = node.Syntax;
if (!UseNewTranslation(node)) return VisitPatternSwitchStatement_Ifchain(node);
var usedLabels = new HashSet<LabelSymbol>();
......
......@@ -519,10 +519,10 @@ public static object TestSwitch(int val)
{
switch (val)
{
case (int)int.MinValue:
case (int)int.MinValue + 1:
case (int)short.MinValue:
case (int)short.MinValue + 1:
case (int)int.MinValue:
case (int)int.MinValue + 1:
case (int)short.MinValue:
case (int)short.MinValue + 1:
case (int)sbyte.MinValue: return 0;
case (int)-1: return -1;
case (int)0: return 0;
......@@ -531,7 +531,7 @@ public static object TestSwitch(int val)
case (int)0xFE: return 0;
case (int)0xFF: return 0;
case (int)0x7FFE: return 0;
case (int)0xFFFE:
case (int)0xFFFE:
case (int)0x7FFFFFFF: return 0;
default: return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册