Loading...
Searching...
No Matches
v8-message.h
Go to the documentation of this file.
1// Copyright 2021 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#ifndef INCLUDE_V8_MESSAGE_H_
6#define INCLUDE_V8_MESSAGE_H_
7
8#include <stdio.h>
9
10#include <iosfwd>
11
12#include "v8-local-handle.h" // NOLINT(build/include_directory)
13#include "v8-maybe.h" // NOLINT(build/include_directory)
14#include "v8-primitive.h" // NOLINT(build/include_directory)
15#include "v8config.h" // NOLINT(build/include_directory)
16
17namespace v8 {
18
19class Integer;
20class PrimitiveArray;
21class StackTrace;
22class String;
23class Value;
24
29 public:
30 V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
31 bool is_opaque = false, bool is_wasm = false,
32 bool is_module = false)
33 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
34 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
35 (is_module ? kIsModule : 0)) {}
37 : flags_(flags &
38 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
39
40 bool IsSharedCrossOrigin() const {
41 return (flags_ & kIsSharedCrossOrigin) != 0;
42 }
43 bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
44 bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
45 bool IsModule() const { return (flags_ & kIsModule) != 0; }
46
47 int Flags() const { return flags_; }
48
49 private:
50 enum {
51 kIsSharedCrossOrigin = 1,
52 kIsOpaque = 1 << 1,
53 kIsWasm = 1 << 2,
54 kIsModule = 1 << 3
55 };
56 const int flags_;
57};
58
63 public:
65 int resource_line_offset = 0,
66 int resource_column_offset = 0,
67 bool resource_is_shared_cross_origin = false,
68 int script_id = -1,
69 Local<Value> source_map_url = Local<Value>(),
70 bool resource_is_opaque = false, bool is_wasm = false,
71 bool is_module = false,
72 Local<Data> host_defined_options = Local<Data>())
73 : resource_name_(resource_name),
74 resource_line_offset_(resource_line_offset),
75 resource_column_offset_(resource_column_offset),
76 options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm,
77 is_module),
78 script_id_(script_id),
79 source_map_url_(source_map_url),
80 host_defined_options_(host_defined_options) {
81 VerifyHostDefinedOptions();
82 }
83
84 V8_INLINE Local<Value> ResourceName() const;
85 V8_INLINE int LineOffset() const;
86 V8_INLINE int ColumnOffset() const;
87 V8_INLINE int ScriptId() const;
88 V8_INLINE Local<Value> SourceMapUrl() const;
89 V8_INLINE Local<Data> GetHostDefinedOptions() const;
90 V8_INLINE ScriptOriginOptions Options() const { return options_; }
91
92 private:
93 void VerifyHostDefinedOptions() const;
94 Local<Value> resource_name_;
95 int resource_line_offset_;
96 int resource_column_offset_;
97 ScriptOriginOptions options_;
98 int script_id_;
99 Local<Value> source_map_url_;
100 Local<Data> host_defined_options_;
101};
102
107 public:
109
114
116 Local<Context> context) const;
118 Local<Context> context) const;
119
125
131
138
143
148 int GetStartPosition() const;
149
154 int GetEndPosition() const;
155
161
165 int ErrorLevel() const;
166
171 int GetStartColumn() const;
173
178 int GetEndColumn() const;
180
186 bool IsOpaque() const;
187
188 static void PrintCurrentStackTrace(Isolate* isolate, std::ostream& out);
189
190 static const int kNoLineNumberInfo = 0;
191 static const int kNoColumnInfo = 0;
192 static const int kNoScriptIdInfo = 0;
193 static const int kNoWasmFunctionIndexInfo = -1;
194};
195
196Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
197
199 return host_defined_options_;
200}
201
202int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
203
204int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
205
206int ScriptOrigin::ScriptId() const { return script_id_; }
207
208Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
209
210} // namespace v8
211
212#endif // INCLUDE_V8_MESSAGE_H_
Definition: v8-isolate.h:212
Definition: v8-local-handle.h:266
Definition: v8-local-handle.h:632
Definition: v8-maybe.h:32
Definition: v8-message.h:106
ScriptOrigin GetScriptOrigin() const
int GetStartColumn() const
MaybeLocal< String > GetSourceLine(Local< Context > context) const
Local< String > Get() const
bool IsSharedCrossOrigin() const
Isolate * GetIsolate() const
Local< StackTrace > GetStackTrace() const
int GetWasmFunctionIndex() const
int GetStartPosition() const
int ErrorLevel() const
int GetEndPosition() const
Maybe< int > GetLineNumber(Local< Context > context) const
Maybe< int > GetEndColumn(Local< Context > context) const
static void PrintCurrentStackTrace(Isolate *isolate, std::ostream &out)
MaybeLocal< String > GetSource(Local< Context > context) const
bool IsOpaque() const
int GetEndColumn() const
Maybe< int > GetStartColumn(Local< Context > context) const
Local< Value > GetScriptResourceName() const
Definition: v8-message.h:28
bool IsModule() const
Definition: v8-message.h:45
bool IsWasm() const
Definition: v8-message.h:44
ScriptOriginOptions(bool is_shared_cross_origin=false, bool is_opaque=false, bool is_wasm=false, bool is_module=false)
Definition: v8-message.h:30
bool IsOpaque() const
Definition: v8-message.h:43
int Flags() const
Definition: v8-message.h:47
ScriptOriginOptions(int flags)
Definition: v8-message.h:36
bool IsSharedCrossOrigin() const
Definition: v8-message.h:40
Definition: v8-message.h:62
int LineOffset() const
Definition: v8-message.h:202
int ScriptId() const
Definition: v8-message.h:206
int ColumnOffset() const
Definition: v8-message.h:204
ScriptOriginOptions Options() const
Definition: v8-message.h:90
Local< Value > ResourceName() const
Definition: v8-message.h:196
Local< Value > SourceMapUrl() const
Definition: v8-message.h:208
ScriptOrigin(Local< Value > resource_name, int resource_line_offset=0, int resource_column_offset=0, bool resource_is_shared_cross_origin=false, int script_id=-1, Local< Value > source_map_url=Local< Value >(), bool resource_is_opaque=false, bool is_wasm=false, bool is_module=false, Local< Data > host_defined_options=Local< Data >())
Definition: v8-message.h:64
Local< Data > GetHostDefinedOptions() const
Definition: v8-message.h:198
Definition: libplatform.h:15
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:660