Esempio n. 1
0
        public string Visit(FunctionCallExpression call)
        {
            var codeWriter       = new XzaarCodeWriter();
            var indent           = IsInsideExpression ? 0 : currentIndent;
            var instance         = call.GetInstance();
            var methodInvocation = call.MethodName + "(";
            var instanceText     = string.Empty;

            if (instance != null)
            {
                instanceText = instance is VariableDefinitionExpression instanceExpr
                    ? instanceExpr.Name + "."
                    : Visit(instance) + ".";
            }
            codeWriter.Write(instanceText + methodInvocation, indent);

            insideExpressionCount++;

            for (int index = 0; index < call.Arguments.Count; index++)
            {
                var arg = call.Arguments[index];
                codeWriter.Write(Visit(arg));
                if (index + 1 < call.ArgumentCount)
                {
                    codeWriter.Write(", ");
                }
            }
            insideExpressionCount--;
            codeWriter.Write(")");
            if (!IsInsideExpression)
            {
                codeWriter.NewLine();
            }
            return(codeWriter.ToString());
        }
        public string Visit(FunctionCallExpression call)
        {
            var codeWriter = new XzaarCodeWriter();
            var indent     = isInsideExpression ? 0 : currentIndent;
            var instance   = call.GetInstance();

            if (instance != null)
            {
                codeWriter.Write(Visit(instance));
                codeWriter.Write("." + call.MethodName + "(");
            }
            else
            {
                codeWriter.Write(call.MethodName + "(", indent);
            }

            for (int index = 0; index < call.Arguments.Count; index++)
            {
                var arg = call.Arguments[index];
                codeWriter.Write(Visit(arg));
                if (index + 1 < call.ArgumentCount)
                {
                    codeWriter.Write(", ");
                }
            }

            codeWriter.Write(")");
            if (!isInsideExpression)
            {
                codeWriter.NewLine();
            }
            return(codeWriter.ToString());
        }