Exemplo n.º 1
0
        public PySwitchSection Simplify(IPySimplifier s, out bool wasChanged)
        {
            wasChanged = false;
            var nLabels = new List <PySwitchLabel>();

            foreach (var lab in Labels)
            {
                nLabels.Add(lab.Simplify(s, out var labelWasChanged));
                if (labelWasChanged)
                {
                    wasChanged = true;
                }
            }

            var nStatement = s.Simplify(Statement);

            if (!PySourceBase.EqualCode(nStatement, Statement))
            {
                wasChanged = true;
            }
            if (!wasChanged)
            {
                return(this);
            }
            return(new PySwitchSection
            {
                Labels = nLabels.ToArray(),
                Statement = nStatement
            });
        }
Exemplo n.º 2
0
        public PySwitchLabel Simplify(IPySimplifier s, out bool wasChanged)
        {
            wasChanged = false;
            if (IsDefault)
            {
                return(this);
            }
            var e1 = s.Simplify(Value);

            wasChanged = !PySourceBase.EqualCode(e1, Value);
            if (wasChanged)
            {
                return(new PySwitchLabel(e1));
            }
            return(this);
        }