protected override IPhpValue VisitParenthesizedExpression(ParenthesizedExpression src) { var e = TransValue(src.Expression); var a = new PhpParenthesizedExpression(e); return(SimplifyPhpExpression(a)); }
void Append(IPhpValue value) { if (value is PhpBinaryOperatorExpression) { var v1 = value as PhpBinaryOperatorExpression; if (v1.Operator == ".") { Append(v1.Left); Append(v1.Right); return; } } if (value is PhpConstValue) { var vv = (PhpConstValue)value; if (vv.Value is string) { Append((string)vv.Value); return; } if (vv.Value is int) { Append(((int)vv.Value).ToString()); return; } } if (value is PhpConditionalExpression || value is PhpBinaryOperatorExpression) { var p = new PhpParenthesizedExpression(value); Append(p); return; } list.Add(value); }
protected virtual T VisitPhpParenthesizedExpression(PhpParenthesizedExpression node) { if (ThrowNotImplementedException) { throw new NotImplementedException(string.Format("Method {0} is not supported in class {1}", "VisitPhpParenthesizedExpression", this.GetType().FullName)); } return(default(T)); }
protected override IPhpValue VisitPhpParenthesizedExpression(PhpParenthesizedExpression node) { // zdejmowanie wielokrotnych nawiasów if (node.Expression is PhpParenthesizedExpression) { return(node.Expression); } if (node.Expression is PhpMethodCallExpression) { var t = node.Expression as PhpMethodCallExpression; if (!t.IsConstructorCall) { return(node.Expression); } } return(node); }
public IPhpValue TranslateToPhp(IExternalTranslationContext ctx, ClassFieldAccessExpression src) { var t = src.Member.DeclaringType; string n = src.Member.Name; if (t == typeof(Wp)) { if (n == "DoingAutosave") { // if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) var a1 = new PhpMethodCallExpression("defined", new PhpConstValue("DOING_AUTOSAVE")); var a2 = new PhpDefinedConstExpression("DOING_AUTOSAVE", null); var a3 = new PhpBinaryOperatorExpression("&&", a1, a2); var a4 = new PhpParenthesizedExpression(a3); return(a4); } if (n == "HookSuffix") { var a1 = new PhpVariableExpression("hook_suffix", PhpVariableKind.Global); return(a1); } } return(null); }
protected override IPhpValue VisitPhpUnaryOperatorExpression(PhpUnaryOperatorExpression node) { if (node.Operator == "!" && node.Operand is PhpBinaryOperatorExpression) { var bin = node.Operand as PhpBinaryOperatorExpression; if (bin.Operator == "!==") { var bin2 = new PhpBinaryOperatorExpression("===", bin.Left, bin.Right); return(bin2); } var be = new PhpParenthesizedExpression(node.Operand); node = new PhpUnaryOperatorExpression(be, node.Operator); return(node); } if (node.Operator == "!" && node.Operand is PhpUnaryOperatorExpression) { var bin = node.Operand as PhpUnaryOperatorExpression; if (bin.Operator == "!") { return(Simplify(bin.Operand)); } } return(node); }