public override string GetPhpCode(PhpEmitStyle style) { var join = style == null || style.Compression == EmitStyleCompression.Beauty ? ", " : ","; var xstyle = PhpEmitStyle.xClone(style); var arguments = string.Join(join, Arguments.Select(i => i.GetPhpCode(xstyle))); if (IsConstructorCall) { var a = string.Format("new {0}({1})", _className.NameForEmit(style), arguments); return(a); } var name = _name; if (!_className.IsEmpty) { name = _className.NameForEmit(style) + "::" + name; } else if (TargetObject != null) { var to = TargetObject; if (TargetObject is PhpMethodCallExpression && (TargetObject as PhpMethodCallExpression).IsConstructorCall) { to = new PhpParenthesizedExpression(to); } name = to.GetPhpCode(style) + "->" + name; } var code = string.Format(name == "echo" ? "{0} {1}" : "{0}({1})", name, arguments); return(code); }
public override string GetPhpCode(PhpEmitStyle style) { if (expression == (object)null) { throw new Exception("Unable to get code from empty expression"); } var ex = PhpParenthesizedExpression.Strip(expression); var a = expression.GetPhpCode(style); if (byRef) { a = "&" + a; } return(a); }
protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s) { value = PhpParenthesizedExpression.Strip(value); value = s.Simplify(value); return(value); }
public override string GetPhpCode(PhpEmitStyle style) { var join = style == null || style.Compression == EmitStyleCompression.Beauty ? ", " : ","; var xstyle = PhpEmitStyle.xClone(style); var arguments = string.Join(join, _arguments.Select(i => i.GetPhpCode(xstyle))); if (IsConstructorCall) { var a = string.Format("new {0}({1})", _className.NameForEmit(style), arguments); return a; } var name = _name; if (!_className.IsEmpty) name = _className.NameForEmit(style) + "::" + name; else if (_targetObject != null) { var to = _targetObject; if (_targetObject is PhpMethodCallExpression && (_targetObject as PhpMethodCallExpression).IsConstructorCall) to = new PhpParenthesizedExpression(to); name = to.GetPhpCode(style) + "->" + name; } var code = string.Format(name == "echo" ? "{0} {1}" : "{0}({1})", name, arguments); return code; }
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); }