Example #1
0
        /// <summary>
        /// Actually build the switch node, given the supplied expression.
        /// </summary>
        /// <param name="expression">Either a bitfield or a bitfield set.</param>
        /// <returns>Bitfield node object.</returns>
        private SwitchNode BuildSwitch(SwitchableNode expression)
        {
            if (spec.Config.Verbose)
            {
                Console.WriteLine("Building switch node for {0}.", expression.ToString());
            }

            var node = new SwitchNode(spec, expression);

            // iterate through every possible value of 'expression'
            for (int value = 0; value < expression.NumValues; value++)
            {
                // store child in switch node's table
                node[value] = BuildSwitchCase(node, value);
            }

            if (spec.Config.Verbose)
            {
                Console.WriteLine("Switch completed.");
            }

            return(node);
        }