示例#1
0
 internal BoundSwitchExpressionArm BindSwitchExpressionArm(
     SwitchExpressionArmSyntax node,
     BindingDiagnosticBag diagnostics
     )
 {
     Debug.Assert(node == _arm);
     (TypeSymbol inputType, uint valEscape) =
         _switchExpressionBinder.GetInputTypeAndValEscape();
     return(BindSwitchExpressionArm(node, inputType, valEscape, diagnostics));
 }
        public override void VisitSwitchExpressionArm(SwitchExpressionArmSyntax node)
        {
            SyntaxNode previousNodeToBind = _nodeToBind;

            _nodeToBind = node;
            Visit(node.Pattern);
            Visit(node.WhenClause?.Condition);
            Visit(node.Expression);
            _nodeToBind = previousNodeToBind;
        }
示例#3
0
 public SwitchExpressionArmBinder(
     SwitchExpressionArmSyntax arm,
     ExpressionVariableBinder armScopeBinder,
     SwitchExpressionBinder switchExpressionBinder
     ) : base(armScopeBinder)
 {
     this._arm                    = arm;
     this._armScopeBinder         = armScopeBinder;
     this._switchExpressionBinder = switchExpressionBinder;
 }
示例#4
0
 internal SwitchCase(Context cx, SwitchExpressionArmSyntax arm, Switch parent, int child) :
     base(new ExpressionInfo(cx, parent.SwitchedExpr.Type, cx.Create(arm.GetLocation()), ExprKind.SWITCH_CASE, parent, child, false, null))
 {
     cx.CreatePattern(arm.Pattern, this, 0);
     if (arm.WhenClause is WhenClauseSyntax when)
     {
         Expression.Create(cx, when.Condition, this, 1);
     }
     Expression.Create(cx, arm.Expression, this, 2);
 }
示例#5
0
 internal override BoundSwitchExpressionArm BindSwitchExpressionArm(
     SwitchExpressionArmSyntax node,
     TypeSymbol switchGoverningType,
     uint switchGoverningValEscape,
     BindingDiagnosticBag diagnostics
     )
 {
     // There's supposed to be an overrider of this method (e.g. SwitchExpressionArmBinder) for the arm in the chain.
     throw ExceptionUtilities.Unreachable;
 }
示例#6
0
        internal override BoundSwitchExpressionArm BindSwitchExpressionArm(SwitchExpressionArmSyntax node, BindingDiagnosticBag diagnostics)
        {
            Debug.Assert(node == _arm);
            Binder armBinder = this.GetBinder(node);
            bool   hasErrors = _switchExpressionBinder.SwitchGoverningType.IsErrorType();
            ImmutableArray <LocalSymbol> locals = _armScopeBinder.Locals;
            BoundPattern    pattern             = armBinder.BindPattern(node.Pattern, _switchExpressionBinder.SwitchGoverningType, _switchExpressionBinder.SwitchGoverningValEscape, permitDesignations: true, hasErrors, diagnostics);
            BoundExpression whenClause          = node.WhenClause != null
                ? armBinder.BindBooleanExpression(node.WhenClause.Condition, diagnostics)
                : null;

            BoundExpression armResult = armBinder.BindValue(node.Expression, diagnostics, BindValueKind.RValue);
            var             label     = new GeneratedLabelSymbol("arm");

            return(new BoundSwitchExpressionArm(node, locals, pattern, whenClause, armResult, label, hasErrors | pattern.HasErrors));
        }
示例#7
0
 internal override BoundSwitchExpressionArm BindSwitchExpressionArm(SwitchExpressionArmSyntax node, DiagnosticBag diagnostics)
 {
     // There's supposed to be an overrider of this method (e.g. SwitchExpressionArmBinder) for the arm in the chain.
     throw ExceptionUtilities.Unreachable;
 }
示例#8
0
 public override void VisitSwitchExpressionArm(SwitchExpressionArmSyntax node)
 {
     Log(node, "Unsupported Syntax !");
 }