示例#1
0
 public void AddSwitchGroup(SwitchGroup group)
 {
     _groups.Add(group);
 }
        private Statement ProcessSwitchStatement(SwitchNode node)
        {
            Expression condition = _expressionBuilder.BuildExpression(node.Condition);
            if (condition is MemberExpression) {
                condition = _expressionBuilder.TransformMemberExpression((MemberExpression)condition);
            }

            SwitchStatement statement = new SwitchStatement(condition);

            foreach (SwitchSectionNode switchSectionNode in node.Cases) {
                SwitchGroup group = new SwitchGroup();

                foreach (StatementNode caseNode in switchSectionNode.Labels) {
                    if (caseNode is CaseLabelNode) {
                        CaseLabelNode labelNode = (CaseLabelNode)caseNode;
                        Expression labelValue = _expressionBuilder.BuildExpression(labelNode.Value);
                        if (labelValue is MemberExpression) {
                            labelValue = _expressionBuilder.TransformMemberExpression((MemberExpression)labelValue);
                        }

                        group.AddCase(labelValue);
                    }
                    else {
                        Debug.Assert(caseNode is DefaultLabelNode);
                        group.AddDefaultCase();
                    }
                }

                foreach (StatementNode statementNode in switchSectionNode.Statements) {
                    Statement childStatement = BuildStatement(statementNode);
                    if (childStatement != null) {
                        group.AddStatement(childStatement);
                    }
                }

                statement.AddSwitchGroup(group);
            }

            return statement;
        }
示例#3
0
 public void AddSwitchGroup(SwitchGroup group) {
     _groups.Add(group);
 }