public override void visit(match_with matchWith)
        {
            desugaredMatchWith = null;
            _previousIf        = null;

            // Кэшируем выражение для однократного вычисления
            //var cachedExpression = NewGeneralName();
            //AddDefinitionsInUpperStatementList(matchWith, new[] { new var_statement(cachedExpression, matchWith.expr) });

            // Преобразование из сахара в известную конструкцию каждого case
            var usedDeconstructionTypes = new HashSet <string>();

            foreach (var patternCase in matchWith.case_list.elements)
            {
                if (patternCase == null)
                {
                    continue;
                }

                if (patternCase.pattern is deconstructor_pattern)
                {
                    // Проверяем встречался ли уже такой тип при деконструкции
                    // SSM 02.01.19 пока закомментировал этот кусок т.к. при этом коде падает стандартный пример ArithmSimplify.cs. #1408 снова открыл

                    /*var deconstructionType = (patternCase.pattern as deconstructor_pattern).
                     *  type as named_type_reference;
                     * if (deconstructionType != null &&
                     *  deconstructionType.names != null &&
                     *  deconstructionType.names.Count != 0)
                     * {
                     *  var deconstructionTypeName = deconstructionType.names[0].name;
                     *  if (usedDeconstructionTypes.Contains(deconstructionTypeName))
                     *  {
                     *      throw new SyntaxVisitorError("REPEATED_DECONSTRUCTION_TYPE",
                     *                                   patternCase.pattern.source_context);
                     *  }
                     *  usedDeconstructionTypes.Add(deconstructionTypeName);
                     * } */

                    DesugarDeconstructorPatternCase(matchWith.expr, patternCase);
                }
            }

            if (matchWith.defaultAction != null)
            {
                AddDefaultCase(matchWith.defaultAction as statement_list);
            }

            if (desugaredMatchWith == null)
            {
                desugaredMatchWith = new empty_statement();
            }

            // Замена выражения match with на новое несахарное поддерево и его обход
            ReplaceUsingParent(matchWith, desugaredMatchWith);
            visit(desugaredMatchWith);
        }
        public override void visit(match_with matchWith)
        {
            desugaredMatchWith = null;
            _previousIf        = null;

            // Кэшируем выражение для однократного вычисления
            //var cachedExpression = NewGeneralName();
            //AddDefinitionsInUpperStatementList(matchWith, new[] { new var_statement(cachedExpression, matchWith.expr) });

            // Преобразование из сахара в известную конструкцию каждого case
            foreach (var patternCase in matchWith.case_list.elements)
            {
                if (patternCase == null)
                {
                    continue;
                }

                if (patternCase.pattern is deconstructor_pattern)
                {
                    DesugarDeconstructorPatternCase(matchWith.expr, patternCase);
                }
            }

            if (matchWith.defaultAction != null)
            {
                AddDefaultCase(matchWith.defaultAction as statement_list);
            }

            if (desugaredMatchWith == null)
            {
                desugaredMatchWith = new empty_statement();
            }

            // Замена выражения match with на новое несахарное поддерево и его обход
            ReplaceUsingParent(matchWith, desugaredMatchWith);
            visit(desugaredMatchWith);
        }
 public virtual void visit(match_with _match_with)
 {
     DefaultVisit(_match_with);
 }
        public override void visit(match_with matchWith)
        {
            desugaredMatchWith = null;
            _previousIf        = null;

            matchedExprVarDeclaration = new var_statement(
                new ident(GeneratedMatchExprVariableName, matchWith.expr.source_context),
                matchWith.expr.Clone() as expression,
                matchWith.expr.source_context);
            ReplaceUsingParent(matchWith.expr, new ident(GeneratedMatchExprVariableName, matchWith.expr.source_context));

            /*if (matchWith.Parent is statement_list stl)
             * {
             *  stl.InsertBefore(matchWith, matchedExprVarDeclaration);
             * }
             * else
             * {
             *  var enclosingStl = new statement_list(matchedExprVarDeclaration, matchWith);
             *  enclosingStl.source_context = matchWith.source_context;
             *  ReplaceUsingParent(matchWith, enclosingStl);
             * }*/

            // Кэшируем выражение для однократного вычисления
            //var cachedExpression = NewGeneralName();
            //AddDefinitionsInUpperStatementList(matchWith, new[] { new var_statement(cachedExpression, matchWith.expr) });

            // Преобразование из сахара в известную конструкцию каждого case
            var usedDeconstructionTypes = new HashSet <string>();

            foreach (var patternCase in matchWith.case_list.elements)
            {
                if (patternCase == null)
                {
                    continue;
                }
                DefaultDesugarPattern(matchWith.expr, patternCase);

                /*switch (patternCase.pattern)
                 * {
                 *  case deconstructor_pattern pattern:
                 *      {
                 *          // Проверяем встречался ли уже такой тип при деконструкции
                 *          // SSM 02.01.19 пока закомментировал этот кусок т.к. при этом коде падает стандартный пример ArithmSimplify.cs. #1408 снова открыл
                 *          var deconstructionType = (patternCase.pattern as deconstructor_pattern).
                 *              type as named_type_reference;
                 *          if (deconstructionType != null &&
                 *              deconstructionType.names != null &&
                 *              deconstructionType.names.Count != 0)
                 *          {
                 *              var deconstructionTypeName = deconstructionType.names[0].name;
                 *              if (usedDeconstructionTypes.Contains(deconstructionTypeName))
                 *              {
                 *                  throw new SyntaxVisitorError("REPEATED_DECONSTRUCTION_TYPE",
                 *                                               patternCase.pattern.source_context);
                 *              }
                 *              usedDeconstructionTypes.Add(deconstructionTypeName);
                 *          }
                 *
                 * DefaultDesugarPattern(matchWith.expr, patternCase);
                 *          break;
                 *      }
                 *  case const_pattern p:
                 *      {
                 *          //DesugarConstPatternCase(matchWith.expr, patternCase);
                 *          DefaultDesugarPattern(matchWith.expr, patternCase);
                 *          break;
                 *      }
                 *  case collection_pattern p:
                 *      {
                 *          DefaultDesugarPattern(matchWith.expr, patternCase);
                 *          break;
                 *      }
                 *  case tuple_pattern p:
                 *      {
                 *          DefaultDesugarPattern(matchWith.expr, patternCase);
                 *          break;
                 *      }
                 * }*/
            }

            if (matchWith.defaultAction != null)
            {
                AddDefaultCase(matchWith.defaultAction as statement_list);
            }

            if (desugaredMatchWith == null)
            {
                desugaredMatchWith = new empty_statement();
            }

            if (typeChecks.Count != 0)
            {
                typeChecks.Add(desugaredMatchWith);
                desugaredMatchWith = new statement_list(typeChecks);
            }

            desugaredMatchWith = new statement_list(matchedExprVarDeclaration, desugaredMatchWith);

            // Замена выражения match with на новое несахарное поддерево и его обход
            ReplaceUsingParent(matchWith, desugaredMatchWith);
            visit(desugaredMatchWith);
        }