public override IPhpStatement Simplify(IPhpSimplifier s) { var newCondition = s.Simplify(_condition); var newStatement = s.Simplify(_statement); if (newCondition == _condition && newStatement == _statement) return this; return new PhpWhileStatement(newCondition, newStatement); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var __collection = s.Simplify(collection); var __statement = s.Simplify(statement); if (__collection == collection && __statement == statement) return this; if (string.IsNullOrEmpty(keyVarname)) return new PhpForEachStatement(valueVarname, __collection, __statement); return new PhpForEachStatement(keyVarname, valueVarname, __collection, __statement); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var newCondition = s.Simplify(Condition); var newStatement = s.Simplify(Statement); if (newCondition == Condition && newStatement == Statement) { return(this); } return(new PhpWhileStatement(newCondition, newStatement)); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var newIfTrue = s.Simplify(_ifTrue); var newIfFalse = s.Simplify(_ifFalse); var newCondition = s.Simplify(Condition); if (newIfTrue == _ifTrue && newIfFalse == _ifFalse && newCondition == Condition) { return(this); } return(new PhpIfStatement(newCondition, newIfTrue, newIfFalse)); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var __collection = s.Simplify(collection); var __statement = s.Simplify(statement); if (__collection == collection && __statement == statement) { return(this); } if (string.IsNullOrEmpty(keyVarname)) { return(new PhpForEachStatement(valueVarname, __collection, __statement)); } return(new PhpForEachStatement(keyVarname, valueVarname, __collection, __statement)); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var collection = s.Simplify(Collection); var statement = s.Simplify(Statement); if (collection == Collection && statement == Statement) { return(this); } if (string.IsNullOrEmpty(_keyVarname)) { return(new PhpForEachStatement(_valueVarname, collection, statement)); } return(new PhpForEachStatement(_keyVarname, _valueVarname, collection, statement)); }
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 }); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var changed = false; var e1 = s.Simplify(expression); if (!EqualCode(e1, expression)) changed = true; var s1 = new List<PhpSwitchSection>(); foreach (var i in sections) { bool wasChanged; var n = i.Simplify(s, out wasChanged); if (wasChanged) changed = true; s1.Add(n); } if (!changed) return this; return new PhpSwitchStatement() { Expression = e1, Sections = s1 }; }
public override IPhpStatement Simplify(IPhpSimplifier s) { var changed = false; var e1 = s.Simplify(expression); if (!EqualCode(e1, expression)) { changed = true; } var s1 = new List <PhpSwitchSection>(); foreach (var i in sections) { bool wasChanged; var n = i.Simplify(s, out wasChanged); if (wasChanged) { changed = true; } s1.Add(n); } if (!changed) { return(this); } return(new PhpSwitchStatement() { Expression = e1, Sections = s1 }); }
public override IPhpStatement Simplify(IPhpSimplifier s) { if (_returnValue == null) return this; var newReturnValue = s.Simplify(_returnValue); return _returnValue == newReturnValue ? this : new PhpReturnStatement(newReturnValue); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var _initVariables = initVariables == null ? null : initVariables.Select(u => s.Simplify(u)).Cast <PhpAssignExpression>().ToArray(); var _condition = s.Simplify(condition); var _statement = s.Simplify(statement); var _incrementors = incrementors == null ? null : incrementors.Select(u => s.Simplify(u)).ToArray(); var theSame = EqualCode(_condition, condition) && EqualCode(_statement, statement) && EqualCode_Array(_initVariables, initVariables) && EqualCode_Array(_incrementors, incrementors); if (theSame) { return(this); } return(new PhpForStatement(_initVariables, _condition, _statement, _incrementors)); }
public override IPhpStatement Simplify(IPhpSimplifier s) { if (_returnValue == null) { return(this); } var newReturnValue = s.Simplify(_returnValue); return(_returnValue == newReturnValue ? this : new PhpReturnStatement(newReturnValue)); }
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; }
public override IPhpStatement Simplify(IPhpSimplifier s) { var initVariables = InitVariables == null ? null : InitVariables.Select(u => s.Simplify(u)).Cast <PhpAssignExpression>().ToArray(); var condition = s.Simplify(Condition); var statement = s.Simplify(Statement); var incrementors = Incrementors == null ? null : Incrementors.Select(u => s.Simplify(u)).ToArray(); var theSame = EqualCode(condition, Condition) && EqualCode(statement, Statement) && EqualCode_Array(initVariables, InitVariables) && EqualCode_Array(incrementors, Incrementors); if (theSame) { return(this); } return(new PhpForStatement(initVariables, condition, statement, incrementors)); }
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); }
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 }; }
public override IPhpStatement Simplify(IPhpSimplifier s) { var newIfTrue = s.Simplify(_ifTrue); var newIfFalse = s.Simplify(_ifFalse); var newCondition = s.Simplify(_condition); if (newIfTrue == _ifTrue && newIfFalse == _ifFalse && newCondition == _condition) return this; return new PhpIfStatement(newCondition, newIfTrue, newIfFalse); }
public override IPhpStatement Simplify(IPhpSimplifier s) { var _initVariables = initVariables == null ? null : initVariables.Select(u => s.Simplify(u)).Cast<PhpAssignExpression>().ToArray(); var _condition = s.Simplify(condition); var _statement = s.Simplify(statement); var _incrementors = incrementors == null ? null : incrementors.Select(u => s.Simplify(u)).ToArray(); var theSame = EqualCode(_condition, condition) && EqualCode(_statement, statement) && EqualCode_Array(_initVariables, initVariables) && EqualCode_Array(_incrementors, incrementors); if (theSame) return this; return new PhpForStatement(_initVariables, _condition, _statement, _incrementors); }