Example #1
0
        public PhpSwitchSection Simplify(IPhpSimplifier s, out bool wasChanged)
        {
            wasChanged = false;
            var nLabels = new List <PhpSwitchLabel>();

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

            if (!PhpSourceBase.EqualCode(nStatement, statement))
            {
                wasChanged = true;
            }
            if (!wasChanged)
            {
                return(this);
            }
            return(new PhpSwitchSection()
            {
                labels = nLabels.ToArray(),
                statement = nStatement
            });
        }
Example #2
0
        public PhpSwitchLabel Simplify(IPhpSimplifier s, out bool wasChanged)
        {
            wasChanged = false;
            if (isDefault)
            {
                return(this);
            }
            var e1 = s.Simplify(Value);

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