V8 Project
messages.h
Go to the documentation of this file.
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.
4 
5 // The infrastructure used for (localized) message reporting in V8.
6 //
7 // Note: there's a big unresolved issue about ownership of the data
8 // structures used by this framework.
9 
10 #ifndef V8_MESSAGES_H_
11 #define V8_MESSAGES_H_
12 
13 #include "src/handles-inl.h"
14 
15 // Forward declaration of MessageLocation.
16 namespace v8 {
17 namespace internal {
18 class MessageLocation;
19 } } // namespace v8::internal
20 
21 
22 class V8Message {
23  public:
24  V8Message(char* type,
27  type_(type), args_(args), loc_(loc) { }
28  char* type() const { return type_; }
30  const v8::internal::MessageLocation* loc() const { return loc_; }
31  private:
32  char* type_;
35 };
36 
37 
38 namespace v8 {
39 namespace internal {
40 
41 struct Language;
42 class SourceInfo;
43 
45  public:
47  int start_pos,
48  int end_pos)
49  : script_(script),
51  end_pos_(end_pos) { }
53 
54  Handle<Script> script() const { return script_; }
55  int start_pos() const { return start_pos_; }
56  int end_pos() const { return end_pos_; }
57 
58  private:
61  int end_pos_;
62 };
63 
64 
65 // A message handler is a convenience interface for accessing the list
66 // of message listeners registered in an environment
68  public:
69  // Returns a message object for the API to use.
71  Isolate* isolate,
72  const char* type,
73  MessageLocation* loc,
74  Vector< Handle<Object> > args,
75  Handle<JSArray> stack_frames);
76 
77  // Report a formatted message (needs JS allocation).
78  static void ReportMessage(Isolate* isolate,
79  MessageLocation* loc,
80  Handle<Object> message);
81 
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);
87  Handle<Object> data);
88 };
89 
90 } } // namespace v8::internal
91 
92 #endif // V8_MESSAGES_H_
v8::internal::Handle< v8::internal::JSArray > args() const
Definition: messages.h:29
V8Message(char *type, v8::internal::Handle< v8::internal::JSArray > args, const v8::internal::MessageLocation *loc)
Definition: messages.h:24
char * type_
Definition: messages.h:32
char * type() const
Definition: messages.h:28
v8::internal::Handle< v8::internal::JSArray > const args_
Definition: messages.h:33
const v8::internal::MessageLocation * loc() const
Definition: messages.h:30
const v8::internal::MessageLocation * loc_
Definition: messages.h:34
static void ReportMessage(Isolate *isolate, MessageLocation *loc, Handle< Object > message)
Definition: messages.cc:77
static Handle< String > GetMessage(Isolate *isolate, Handle< Object > data)
Definition: messages.cc:129
static SmartArrayPointer< char > GetLocalizedMessage(Isolate *isolate, Handle< Object > data)
Definition: messages.cc:157
static void DefaultMessageReport(Isolate *isolate, const MessageLocation *loc, Handle< Object > message_obj)
Definition: messages.cc:18
static Handle< JSMessageObject > MakeMessageObject(Isolate *isolate, const char *type, MessageLocation *loc, Vector< Handle< Object > > args, Handle< JSArray > stack_frames)
Definition: messages.cc:36
Handle< Script > script_
Definition: messages.h:59
MessageLocation(Handle< Script > script, int start_pos, int end_pos)
Definition: messages.h:46
Handle< Script > script() const
Definition: messages.h:54
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20