private BoundStatement MakeSwitchStatementWithNonNullableExpression(
            CSharpSyntaxNode syntax,
            BoundExpression rewrittenExpression,
            ImmutableArray <BoundSwitchSection> rewrittenSections,
            LabelSymbol constantTargetOpt,
            ImmutableArray <LocalSymbol> locals,
            GeneratedLabelSymbol breakLabel,
            BoundSwitchStatement oldNode)
        {
            Debug.Assert(!rewrittenExpression.Type.IsNullableType());
            Debug.Assert((object)oldNode.StringEquality == null);

            // If we are emitting a hash table based string switch,
            // we need to generate a helper method for computing
            // string hash value in <PrivateImplementationDetails> class.

            MethodSymbol stringEquality = null;

            if (rewrittenExpression.Type.SpecialType == SpecialType.System_String)
            {
                EnsureStringHashFunction(rewrittenSections, syntax);
                stringEquality = GetSpecialTypeMethod(syntax, SpecialMember.System_String__op_Equality);
            }

            return(oldNode.Update(
                       boundExpression: rewrittenExpression,
                       constantTargetOpt: constantTargetOpt,
                       innerLocals: locals,
                       switchSections: rewrittenSections,
                       breakLabel: breakLabel,
                       stringEquality: stringEquality));
        }
Example #2
0
        public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
        {
            BoundSpillSequence2 ss = null;
            BoundExpression     boundExpression = VisitExpression(ref ss, node.BoundExpression);
            ImmutableArray <BoundSwitchSection> switchSections = (ImmutableArray <BoundSwitchSection>) this.VisitList(node.SwitchSections);

            return(UpdateStatement(ss, node.Update(node.OuterLocals, boundExpression, node.ConstantTargetOpt, node.InnerLocals, switchSections, node.BreakLabel, node.StringEquality)));
        }
Example #3
0
        public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
        {
            EnterStatement(node);

            BoundSpillSequenceBuilder builder = null;
            var boundExpression = VisitExpression(ref builder, node.BoundExpression);
            var switchSections  = this.VisitList(node.SwitchSections);

            return(UpdateStatement(builder, node.Update(boundExpression, node.ConstantTargetOpt, node.InnerLocals, switchSections, node.BreakLabel, node.StringEquality), substituteTemps: true));
        }
        public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
        {
            var expression = (BoundExpression)this.Visit(node.BoundExpression);
            ReadOnlyArray <BoundSwitchSection> switchSections = this.VisitList(node.SwitchSections);

            if (expression.Kind != BoundKind.SpillSequence)
            {
                return(node.Update(expression, node.ConstantTargetOpt, node.LocalsOpt, switchSections, node.BreakLabel));
            }

            var spill = (BoundSpillSequence)expression;

            var newSwitchStatement = node.Update(
                spill.Value,
                node.ConstantTargetOpt,
                node.LocalsOpt,
                switchSections,
                node.BreakLabel);

            return(RewriteSpillSequenceAsBlock(spill, newSwitchStatement));
        }
        private BoundStatement MakeSwitchStatementWithNonNullableExpression(
            CSharpSyntaxNode syntax,
            BoundStatement preambleOpt,
            BoundExpression rewrittenExpression,
            ImmutableArray<BoundSwitchSection> rewrittenSections,
            LabelSymbol constantTargetOpt,
            ImmutableArray<LocalSymbol> locals,
            GeneratedLabelSymbol breakLabel,
            BoundSwitchStatement oldNode)
        {
            Debug.Assert(!rewrittenExpression.Type.IsNullableType());
            Debug.Assert((object)oldNode.StringEquality == null);

            // If we are emitting a hash table based string switch,
            // we need to generate a helper method for computing
            // string hash value in <PrivateImplementationDetails> class.

            MethodSymbol stringEquality = null;
            if (rewrittenExpression.Type.SpecialType == SpecialType.System_String)
            {
                EnsureStringHashFunction(rewrittenSections, syntax);
                stringEquality = GetSpecialTypeMethod(syntax, SpecialMember.System_String__op_Equality);
            }

            return oldNode.Update(
                loweredPreambleOpt: preambleOpt,
                boundExpression: rewrittenExpression,
                constantTargetOpt: constantTargetOpt,
                innerLocals: locals,
                switchSections: rewrittenSections,
                breakLabel: breakLabel,
                stringEquality: stringEquality);
        }
Example #6
0
 public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
 {
     BoundSpillSequence2 ss = null;
     BoundExpression boundExpression = VisitExpression(ref ss, node.BoundExpression);
     ImmutableArray<BoundSwitchSection> switchSections = (ImmutableArray<BoundSwitchSection>)this.VisitList(node.SwitchSections);
     return UpdateStatement(ss, node.Update(node.OuterLocals, boundExpression, node.ConstantTargetOpt, node.InnerLocals, switchSections, node.BreakLabel, node.StringEquality));
 }
        public override BoundNode VisitSwitchStatement(BoundSwitchStatement node)
        {
            var expression = (BoundExpression)this.Visit(node.BoundExpression);
            ReadOnlyArray<BoundSwitchSection> switchSections = this.VisitList(node.SwitchSections);

            if (expression.Kind != BoundKind.SpillSequence)
            {
                return node.Update(expression, node.ConstantTargetOpt, node.LocalsOpt, switchSections, node.BreakLabel);
            }
            
            var spill = (BoundSpillSequence)expression;

            var newSwitchStatement = node.Update(
                    spill.Value,
                    node.ConstantTargetOpt,
                    node.LocalsOpt,
                    switchSections,
                    node.BreakLabel);

            return RewriteSpillSequenceAsBlock(spill, newSwitchStatement);
        }