protected override void DoBuild(
            EmitSyntax emit,
            Pipe <EmitSyntax> ldvalue,
            SwitchGeneratorAction action)
        {
            this.action = action;

#if false
            var decisionTree = new BinaryDecisionTreeBuilder(intMap.DefaultValue, platformInfo);
            var node         = decisionTree.Build(intMap.Enumerate().ToArray());
#else
            this.builder = new DecisionTreeBuilder(platformInfo);
            var node = builder.Build(
                intMap,
                possibleBounds,
                frequency);
#endif
            this.emit    = emit;
            this.ldvalue = ldvalue;
            this.labels  = new List <Ref <Labels> >();

            strategy.PlanCode(node);
            strategy.GenerateCode();

            // Debug.Write(node);
        }
        private bool TryBuildElementaryTree(IIntMap <int> map, out Decision result)
        {
            result = null;

            int count = 0;

            foreach (var arrow in map.Enumerate())
            {
                if (arrow.Value == map.DefaultValue)
                {
                    continue;
                }

                ++count;
                if (count > platform.MaxLinearCount || arrow.Key.LongSize != 1)
                {
                    return(false);
                }
            }

            RelationalBranchDecision lastParent = null;

            foreach (var arrow in map.Enumerate())
            {
                if (arrow.Value == map.DefaultValue)
                {
                    continue;
                }

                var node = new RelationalBranchDecision(RelationalOperator.Equal, arrow.Key.First);
                node.Left = GetActionDecision(arrow.Value);
                if (lastParent == null)
                {
                    result = node;
                }
                else
                {
                    lastParent.Right = node;
                }

                lastParent = node;
            }

            lastParent.Right = DefaultActionDecision;

            return(true);
        }
        private bool TryBuildElementaryTree(IIntMap<int> map, out Decision result)
        {
            result = null;

            int count = 0;
            foreach (var arrow in map.Enumerate())
            {
                if (arrow.Value == map.DefaultValue)
                {
                    continue;
                }

                ++count;
                if (count > platform.MaxLinearCount || arrow.Key.LongSize != 1)
                {
                    return false;
                }
            }

            RelationalBranchDecision lastParent = null;
            foreach (var arrow in map.Enumerate())
            {
                if (arrow.Value == map.DefaultValue)
                {
                    continue;
                }

                var node = new RelationalBranchDecision(RelationalOperator.Equal, arrow.Key.First);
                node.Left = GetActionDecision(arrow.Value);
                if (lastParent == null)
                {
                    result = node;
                }
                else
                {
                    lastParent.Right = node;
                }

                lastParent = node;
            }

            lastParent.Right = DefaultActionDecision;

            return true;
        }