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
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_REPORT_H_
6#define RUNTIME_VM_REPORT_H_
7
8#include "vm/allocation.h"
9#include "vm/tagged_pointer.h"
10#include "vm/token_position.h"
11
12namespace dart {
13
14// Forward declarations.
15class Error;
16class ICData;
17class Script;
18class StackFrame;
19class String;
20
21class Report : AllStatic {
22 public:
23 enum Kind {
24 kWarning,
25 kError,
26 kBailout,
27 };
28
29 static const bool AtLocation = false;
30 static const bool AfterLocation = true;
31
32 // Report an already formatted error via a long jump.
33 DART_NORETURN static void LongJump(const Error& error);
34
35 // Concatenate and report an already formatted error and a new error message.
36 DART_NORETURN static void LongJumpF(const Error& prev_error,
37 const Script& script,
38 TokenPosition token_pos,
39 const char* format,
40 ...) PRINTF_ATTRIBUTE(4, 5);
41 DART_NORETURN static void LongJumpV(const Error& prev_error,
42 const Script& script,
43 TokenPosition token_pos,
44 const char* format,
45 va_list args);
46
47 // Report a warning/jswarning/error/bailout message.
48 static void MessageF(Kind kind,
49 const Script& script,
50 TokenPosition token_pos,
51 bool report_after_token,
52 const char* format,
53 ...) PRINTF_ATTRIBUTE(5, 6);
54 static void MessageV(Kind kind,
55 const Script& script,
56 TokenPosition token_pos,
57 bool report_after_token,
58 const char* format,
59 va_list args);
60
61 // Prepend a source snippet to the message.
62 // A null script means no source and a negative token_pos means no position.
63 static StringPtr PrependSnippet(Kind kind,
64 const Script& script,
65 TokenPosition token_pos,
66 bool report_after_token,
67 const String& message);
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(Report);
71};
72
73} // namespace dart
74
75#endif // RUNTIME_VM_REPORT_H_
76