// 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(); }
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); }
// 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(); }
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)); }
protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s) { value = PhpParenthesizedExpression.Strip(value); value = s.Simplify(value); return(value); }
protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s) { value = PhpParenthesizedExpression.Strip(value); value = s.Simplify(value); return value; }