Flutter Engine
The Flutter Engine
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
dart::Report Class Reference

#include <report.h>

Inheritance diagram for dart::Report:
dart::AllStatic

Public Types

enum  Kind { kWarning , kError , kBailout }
 

Static Public Member Functions

static DART_NORETURN void LongJump (const Error &error)
 
static DART_NORETURN void LongJumpF (const Error &prev_error, const Script &script, TokenPosition token_pos, const char *format,...) PRINTF_ATTRIBUTE(4
 
static DART_NORETURN void static DART_NORETURN void LongJumpV (const Error &prev_error, const Script &script, TokenPosition token_pos, const char *format, va_list args)
 
static void MessageF (Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const char *format,...) PRINTF_ATTRIBUTE(5
 
static void static void MessageV (Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const char *format, va_list args)
 
static StringPtr PrependSnippet (Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const String &message)
 

Static Public Attributes

static constexpr bool AtLocation = false
 
static constexpr bool AfterLocation = true
 

Detailed Description

Definition at line 21 of file report.h.

Member Enumeration Documentation

◆ Kind

Enumerator
kWarning 
kError 
kBailout 

Definition at line 23 of file report.h.

23 {
25 kError,
27 };
@ kBailout
Definition: report.h:26
@ kWarning
Definition: report.h:24

Member Function Documentation

◆ LongJump()

void dart::Report::LongJump ( const Error error)
static

Definition at line 86 of file report.cc.

86 {
89}
#define UNREACHABLE()
Definition: assert.h:248
DART_NORETURN void Jump(int value, const Error &error)
Definition: longjump.cc:22
LongJumpScope * long_jump_base() const
Definition: thread_state.h:47
static Thread * Current()
Definition: thread.h:362
const uint8_t uint32_t uint32_t GError ** error

◆ LongJumpF()

void dart::Report::LongJumpF ( const Error prev_error,
const Script script,
TokenPosition  token_pos,
const char *  format,
  ... 
)
static

Definition at line 91 of file report.cc.

95 {
96 va_list args;
98 LongJumpV(prev_error, script, token_pos, format, args);
99 va_end(args);
100 UNREACHABLE();
101}
static DART_NORETURN void static DART_NORETURN void LongJumpV(const Error &prev_error, const Script &script, TokenPosition token_pos, const char *format, va_list args)
Definition: report.cc:103
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
va_start(args, format)
va_end(args)

◆ LongJumpV()

void dart::Report::LongJumpV ( const Error prev_error,
const Script script,
TokenPosition  token_pos,
const char *  format,
va_list  args 
)
static

Definition at line 103 of file report.cc.

107 {
108 // If an isolate is being killed a [UnwindError] will be propagated up the
109 // stack. In such a case we cannot wrap the unwind error in a new
110 // [LanguageError]. Instead we simply continue propagating the [UnwindError]
111 // upwards.
112 if (prev_error.IsUnwindError()) {
113 LongJump(prev_error);
114 UNREACHABLE();
115 }
117 prev_error, script, token_pos, Report::AtLocation, kError, Heap::kOld,
118 format, args));
120 UNREACHABLE();
121}
@ kOld
Definition: heap.h:39
static LanguageErrorPtr static LanguageErrorPtr NewFormattedV(const Error &prev_error, const Script &script, TokenPosition token_pos, bool report_after_token, Report::Kind kind, Heap::Space space, const char *format, va_list args)
Definition: object.cc:19834
static Object & Handle()
Definition: object.h:407
static DART_NORETURN void LongJump(const Error &error)
Definition: report.cc:86
static constexpr bool AtLocation
Definition: report.h:29

◆ MessageF()

void dart::Report::MessageF ( Kind  kind,
const Script script,
TokenPosition  token_pos,
bool  report_after_token,
const char *  format,
  ... 
)
static

Definition at line 123 of file report.cc.

128 {
129 va_list args;
131 MessageV(kind, script, token_pos, report_after_token, format, args);
132 va_end(args);
133}
static void static void MessageV(Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const char *format, va_list args)
Definition: report.cc:135

◆ MessageV()

void dart::Report::MessageV ( Kind  kind,
const Script script,
TokenPosition  token_pos,
bool  report_after_token,
const char *  format,
va_list  args 
)
static

Definition at line 135 of file report.cc.

140 {
141 if (kind < kError) {
142 // Reporting a warning.
143 if (FLAG_silent_warnings) {
144 return;
145 }
146 if (!FLAG_warning_as_error) {
147 const String& msg = String::Handle(String::NewFormattedV(format, args));
148 const String& snippet_msg = String::Handle(
149 PrependSnippet(kind, script, token_pos, report_after_token, msg));
150 OS::PrintErr("%s", snippet_msg.ToCString());
151 return;
152 }
153 }
154 // Reporting an error (or a warning as error).
156 Error::Handle(), // No previous error.
157 script, token_pos, report_after_token, kind, Heap::kOld, format, args));
159 UNREACHABLE();
160}
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static StringPtr PrependSnippet(Kind kind, const Script &script, TokenPosition token_pos, bool report_after_token, const String &message)
Definition: report.cc:20
static StringPtr static StringPtr static StringPtr NewFormattedV(const char *format, va_list args, Heap::Space space=Heap::kNew)
Definition: object.cc:24022

◆ PrependSnippet()

StringPtr dart::Report::PrependSnippet ( Kind  kind,
const Script script,
TokenPosition  token_pos,
bool  report_after_token,
const String message 
)
static

Definition at line 20 of file report.cc.

24 {
25 const char* message_header;
26 switch (kind) {
27 case kWarning:
28 message_header = "warning";
29 break;
30 case kError:
31 message_header = "error";
32 break;
33 case kBailout:
34 message_header = "bailout";
35 break;
36 default:
37 message_header = "";
39 }
40 String& result = String::Handle();
41 if (!script.IsNull() && script.HasSource()) {
42 const String& script_url = String::Handle(script.url());
43 intptr_t line, column;
44 if (script.GetTokenLocation(token_pos, &line, &column)) {
45 const intptr_t token_len = script.GetTokenLength(token_pos);
46 if (report_after_token) {
47 column += token_len < 0 ? 1 : token_len;
48 }
49 // Allocate formatted strings in old space as they may be created during
50 // optimizing compilation. Those strings are created rarely and should not
51 // pollute old space.
53 Heap::kOld, "'%s': %s: line %" Pd " pos %" Pd ": ",
54 script_url.ToCString(), message_header, line, column);
55 // Append the formatted error or warning message.
56 const Array& strs = Array::Handle(Array::New(6, Heap::kOld));
57 strs.SetAt(0, result);
58 strs.SetAt(1, message);
59 // Append the source line.
60 const String& script_line =
62 ASSERT(!script_line.IsNull());
63 strs.SetAt(2, Symbols::NewLine());
64 strs.SetAt(3, script_line);
65 strs.SetAt(4, Symbols::NewLine());
66 // Append the column marker.
67 const String& column_line = String::Handle(String::NewFormatted(
68 Heap::kOld, "%*s\n", static_cast<int>(column), "^"));
69 strs.SetAt(5, column_line);
71 } else {
72 // Token position is unknown.
74 Heap::kOld, "'%s': %s: ", script_url.ToCString(), message_header);
76 }
77 } else {
78 // Script is unknown.
79 // Append the formatted error or warning message.
80 result = String::NewFormatted(Heap::kOld, "%s: ", message_header);
82 }
83 return result.ptr();
84}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
static StringPtr NewFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: object.cc:24004
static StringPtr ConcatAll(const Array &strings, Heap::Space space=Heap::kNew)
Definition: object.cc:24048
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition: object.cc:24037
static const String & NewLine()
Definition: symbols.h:651
#define ASSERT(E)
GAsyncResult * result
Win32Message message
#define Pd
Definition: globals.h:408

Member Data Documentation

◆ AfterLocation

constexpr bool dart::Report::AfterLocation = true
staticconstexpr

Definition at line 30 of file report.h.

◆ AtLocation

constexpr bool dart::Report::AtLocation = false
staticconstexpr

Definition at line 29 of file report.h.


The documentation for this class was generated from the following files: