1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The infrastructure used for (localized) message reporting in V8.
7 // Note: there's a big unresolved issue about ownership of the data
8 // structures used by this framework.
10 #ifndef V8_MESSAGES_H_
11 #define V8_MESSAGES_H_
13 #include "handles-inl.h"
15 // Forward declaration of MessageLocation.
18 class MessageLocation;
19 } } // namespace v8::internal
25 v8::internal::Handle<v8::internal::JSArray> args,
26 const v8::internal::MessageLocation* loc) :
27 type_(type), args_(args), loc_(loc) { }
28 char* type() const { return type_; }
29 v8::internal::Handle<v8::internal::JSArray> args() const { return args_; }
30 const v8::internal::MessageLocation* loc() const { return loc_; }
33 v8::internal::Handle<v8::internal::JSArray> const args_;
34 const v8::internal::MessageLocation* loc_;
44 class MessageLocation {
46 MessageLocation(Handle<Script> script,
50 start_pos_(start_pos),
52 MessageLocation() : start_pos_(-1), end_pos_(-1) { }
54 Handle<Script> script() const { return script_; }
55 int start_pos() const { return start_pos_; }
56 int end_pos() const { return end_pos_; }
59 Handle<Script> script_;
65 // A message handler is a convenience interface for accessing the list
66 // of message listeners registered in an environment
67 class MessageHandler {
69 // Returns a message object for the API to use.
70 static Handle<JSMessageObject> MakeMessageObject(
74 Vector< Handle<Object> > args,
75 Handle<JSArray> stack_frames);
77 // Report a formatted message (needs JS allocation).
78 static void ReportMessage(Isolate* isolate,
80 Handle<Object> message);
82 static void DefaultMessageReport(Isolate* isolate,
83 const MessageLocation* loc,
84 Handle<Object> message_obj);
85 static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data);
86 static SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate,
90 } } // namespace v8::internal
92 #endif // V8_MESSAGES_H_