示例#1
0
文件: Printer.cs 项目: vorov2/dyalect
    public static string Format(DyObject obj, ExecutionContext ctx, bool notype = false, int maxLen = 0)
    {
        string fmt;

        try
        {
            fmt = obj.ToLiteral(ctx).ToString();
        }
        catch (Exception ex)
        {
            return($"Formatting failed:\n{(ex is DyCodeException c ? c.ToString() : ex.Message)}");
        }

        if (maxLen > 0 && fmt.Length > maxLen)
        {
            fmt = fmt[..maxLen] + "...";