Example #1
0
        // Protected Methods 

        protected IPhpValue SimplifyForFieldAcces(IPhpValue src, IPhpExpressionSimplifier s)
        {
            src = s.Simplify(src);
            if (!(src is PhpParenthesizedExpression)) return src;
            var inside = (src as PhpParenthesizedExpression).Expression;
            if (inside is PhpVariableExpression)
                return inside;
            if (inside is PhpMethodCallExpression)
                return (inside as PhpMethodCallExpression).IsConstructorCall ? src : inside;
            if (inside is PhpBinaryOperatorExpression || inside is PhpConditionalExpression)
                return src;
            throw new NotSupportedException();
        }
Example #2
0
        public override IPhpValue Simplify(IPhpExpressionSimplifier s)
        {
            var _right = StripBracketsAndSimplify(right, s);
            var _left = s.Simplify(left);
            if (_left is PhpPropertyAccessExpression)
            {
                var e = _left as PhpPropertyAccessExpression;
                var a = e.MakeSetValueExpression(_right);
                if (a is PhpAssignExpression && (a as PhpAssignExpression).left is PhpPropertyAccessExpression)
                    if (EqualCode(a, this))
                        return this;
                return a;

            }
            if (EqualCode(_left, left) && EqualCode(_right, right))
                return this;
            return new PhpAssignExpression(_left, _right, optionalOperator);
        }
Example #3
0
        // Protected Methods 

        protected IPhpValue SimplifyForFieldAcces(IPhpValue src, IPhpExpressionSimplifier s)
        {
            src = s.Simplify(src);
            if (!(src is PhpParenthesizedExpression))
            {
                return(src);
            }
            var inside = (src as PhpParenthesizedExpression).Expression;

            if (inside is PhpVariableExpression)
            {
                return(inside);
            }
            if (inside is PhpMethodCallExpression)
            {
                return((inside as PhpMethodCallExpression).IsConstructorCall ? src : inside);
            }
            if (inside is PhpBinaryOperatorExpression || inside is PhpConditionalExpression)
            {
                return(src);
            }
            throw new NotSupportedException();
        }
Example #4
0
        public override IPhpValue Simplify(IPhpExpressionSimplifier s)
        {
            var _right = StripBracketsAndSimplify(right, s);
            var _left  = s.Simplify(left);

            if (_left is PhpPropertyAccessExpression)
            {
                var e = _left as PhpPropertyAccessExpression;
                var a = e.MakeSetValueExpression(_right);
                if (a is PhpAssignExpression && (a as PhpAssignExpression).left is PhpPropertyAccessExpression)
                {
                    if (EqualCode(a, this))
                    {
                        return(this);
                    }
                }
                return(a);
            }
            if (EqualCode(_left, left) && EqualCode(_right, right))
            {
                return(this);
            }
            return(new PhpAssignExpression(_left, _right, optionalOperator));
        }
Example #5
0
 protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s)
 {
     value = PhpParenthesizedExpression.Strip(value);
     value = s.Simplify(value);
     return(value);
 }
Example #6
0
 protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s)
 {
     value = PhpParenthesizedExpression.Strip(value);
     value = s.Simplify(value);
     return value;
 }