OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_REPORT_H_ | 5 #ifndef VM_REPORT_H_ |
6 #define VM_REPORT_H_ | 6 #define VM_REPORT_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/token_position.h" | 9 #include "vm/token_position.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class Error; | 14 class Error; |
15 class ICData; | 15 class ICData; |
16 class RawString; | 16 class RawString; |
17 class Script; | 17 class Script; |
18 class StackFrame; | 18 class StackFrame; |
19 class String; | 19 class String; |
20 | 20 |
21 class Report : AllStatic { | 21 class Report : AllStatic { |
22 public: | 22 public: |
23 enum Kind { | 23 enum Kind { |
24 kWarning, | 24 kWarning, |
25 kJSWarning, | |
26 kError, | 25 kError, |
27 kMalformedType, | 26 kMalformedType, |
28 kMalboundedType, | 27 kMalboundedType, |
29 kBailout, | 28 kBailout, |
30 }; | 29 }; |
31 | 30 |
32 static const bool AtLocation = false; | 31 static const bool AtLocation = false; |
33 static const bool AfterLocation = true; | 32 static const bool AfterLocation = true; |
34 | 33 |
35 // Report an already formatted error via a long jump. | 34 // Report an already formatted error via a long jump. |
(...skipping 12 matching lines...) Expand all Loading... |
48 const Script& script, | 47 const Script& script, |
49 TokenPosition token_pos, | 48 TokenPosition token_pos, |
50 bool report_after_token, | 49 bool report_after_token, |
51 const char* format, ...) PRINTF_ATTRIBUTE(5, 6); | 50 const char* format, ...) PRINTF_ATTRIBUTE(5, 6); |
52 static void MessageV(Kind kind, | 51 static void MessageV(Kind kind, |
53 const Script& script, | 52 const Script& script, |
54 TokenPosition token_pos, | 53 TokenPosition token_pos, |
55 bool report_after_token, | 54 bool report_after_token, |
56 const char* format, va_list args); | 55 const char* format, va_list args); |
57 | 56 |
58 // Support to report Javascript compatibility warnings. Note that a | |
59 // JavascriptCompatibilityError is thrown if --warning_as_error is specified. | |
60 // If a warning is issued by the various JSWarning calls, the warning is also | |
61 // emitted in the trace buffer of the current isolate. | |
62 | |
63 // Report a Javascript compatibility warning at the call site given by | |
64 // ic_data, unless one has already been emitted at that location. | |
65 static void JSWarningFromIC(const ICData& ic_data, const char* msg); | |
66 | |
67 // Report a Javascript compatibility warning at the current native call, | |
68 // unless one has already been emitted at that location. | |
69 static void JSWarningFromNative(bool is_static_native, const char* msg); | |
70 | |
71 // Report a Javascript compatibility warning at the call site given by | |
72 // caller_frame. | |
73 static void JSWarningFromFrame(StackFrame* caller_frame, const char* msg); | |
74 | |
75 // Prepend a source snippet to the message. | 57 // Prepend a source snippet to the message. |
76 // A null script means no source and a negative token_pos means no position. | 58 // A null script means no source and a negative token_pos means no position. |
77 static RawString* PrependSnippet(Kind kind, | 59 static RawString* PrependSnippet(Kind kind, |
78 const Script& script, | 60 const Script& script, |
79 TokenPosition token_pos, | 61 TokenPosition token_pos, |
80 bool report_after_token, | 62 bool report_after_token, |
81 const String& message); | 63 const String& message); |
82 | 64 |
83 private: | 65 private: |
84 // Emit a Javascript compatibility warning to the current trace buffer. | |
85 static void TraceJSWarning(const Script& script, | |
86 TokenPosition token_pos, | |
87 const String& message); | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(Report); | 66 DISALLOW_COPY_AND_ASSIGN(Report); |
90 }; | 67 }; |
91 | 68 |
92 } // namespace dart | 69 } // namespace dart |
93 | 70 |
94 #endif // VM_REPORT_H_ | 71 #endif // VM_REPORT_H_ |
95 | 72 |
OLD | NEW |