v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
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:
64 V8_DEPRECATE_SOON("Use constructor without the isolate.")
65 V8_INLINE ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
66 int resource_line_offset = 0,
67 int resource_column_offset = 0,
68 bool resource_is_shared_cross_origin = false,
69 int script_id = -1,
70 Local<Value> source_map_url = Local<Value>(),
71 bool resource_is_opaque = false, bool is_wasm = false,
72 bool is_module = false,
73 Local<Data> host_defined_options = Local<Data>())
74 : resource_name_(resource_name),
75 resource_line_offset_(resource_line_offset),
76 resource_column_offset_(resource_column_offset),
77 options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm,
78 is_module),
79 script_id_(script_id),
80 source_map_url_(source_map_url),
81 host_defined_options_(host_defined_options) {
82 VerifyHostDefinedOptions();
83 }
84
86 int resource_line_offset = 0,
87 int resource_column_offset = 0,
88 bool resource_is_shared_cross_origin = false,
89 int script_id = -1,
90 Local<Value> source_map_url = Local<Value>(),
91 bool resource_is_opaque = false, bool is_wasm = false,
92 bool is_module = false,
93 Local<Data> host_defined_options = Local<Data>())
94 : resource_name_(resource_name),
95 resource_line_offset_(resource_line_offset),
96 resource_column_offset_(resource_column_offset),
97 options_(resource_is_shared_cross_origin, resource_is_opaque, is_wasm,
98 is_module),
99 script_id_(script_id),
100 source_map_url_(source_map_url),
101 host_defined_options_(host_defined_options) {
102 VerifyHostDefinedOptions();
103 }
104
105 V8_INLINE Local<Value> ResourceName() const;
106 V8_INLINE int LineOffset() const;
107 V8_INLINE int ColumnOffset() const;
108 V8_INLINE int ScriptId() const;
109 V8_INLINE Local<Value> SourceMapUrl() const;
110 V8_INLINE Local<Data> GetHostDefinedOptions() const;
111 V8_INLINE ScriptOriginOptions Options() const { return options_; }
112
113 private:
114 void VerifyHostDefinedOptions() const;
115 Local<Value> resource_name_;
116 int resource_line_offset_;
117 int resource_column_offset_;
118 ScriptOriginOptions options_;
119 int script_id_;
120 Local<Value> source_map_url_;
121 Local<Data> host_defined_options_;
122};
123
128 public:
130
135
137 Local<Context> context) const;
139 Local<Context> context) const;
140
146
152
159
164
169 int GetStartPosition() const;
170
175 int GetEndPosition() const;
176
182
186 int ErrorLevel() const;
187
192 int GetStartColumn() const;
194
199 int GetEndColumn() const;
201
207 bool IsOpaque() const;
208
209 static void PrintCurrentStackTrace(Isolate* isolate, std::ostream& out);
210
211 static const int kNoLineNumberInfo = 0;
212 static const int kNoColumnInfo = 0;
213 static const int kNoScriptIdInfo = 0;
214 static const int kNoWasmFunctionIndexInfo = -1;
215};
216
217Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
218
220 return host_defined_options_;
221}
222
223int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
224
225int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
226
227int ScriptOrigin::ScriptId() const { return script_id_; }
228
229Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
230
231} // namespace v8
232
233#endif // INCLUDE_V8_MESSAGE_H_
Local< StackTrace > GetStackTrace() const
int GetEndPosition() const
Isolate * GetIsolate() const
V8_WARN_UNUSED_RESULT MaybeLocal< String > GetSourceLine(Local< Context > context) const
int GetEndColumn() const
int GetWasmFunctionIndex() const
V8_WARN_UNUSED_RESULT Maybe< int > GetStartColumn(Local< Context > context) const
int ErrorLevel() const
bool IsOpaque() const
V8_WARN_UNUSED_RESULT Maybe< int > GetLineNumber(Local< Context > context) const
ScriptOrigin GetScriptOrigin() const
int GetStartColumn() const
V8_WARN_UNUSED_RESULT MaybeLocal< String > GetSource(Local< Context > context) const
V8_WARN_UNUSED_RESULT Maybe< int > GetEndColumn(Local< Context > context) const
Local< Value > GetScriptResourceName() const
Local< String > Get() const
static void PrintCurrentStackTrace(Isolate *isolate, std::ostream &out)
bool IsSharedCrossOrigin() const
int GetStartPosition() const
V8_INLINE Local< Value > SourceMapUrl() const
Definition v8-message.h:229
V8_INLINE int ColumnOffset() const
Definition v8-message.h:225
V8_INLINE Local< Data > GetHostDefinedOptions() const
Definition v8-message.h:219
V8_INLINE int LineOffset() const
Definition v8-message.h:223
V8_INLINE ScriptOriginOptions Options() const
Definition v8-message.h:111
V8_INLINE 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:85
V8_INLINE Local< Value > ResourceName() const
Definition v8-message.h:217
V8_INLINE int ScriptId() const
Definition v8-message.h:227
bool IsModule() const
Definition v8-message.h:45
bool IsOpaque() const
Definition v8-message.h:43
V8_INLINE ScriptOriginOptions(int flags)
Definition v8-message.h:36
bool IsSharedCrossOrigin() const
Definition v8-message.h:40
V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin=false, bool is_opaque=false, bool is_wasm=false, bool is_module=false)
Definition v8-message.h:30
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477
#define V8_DEPRECATE_SOON(message)
Definition v8config.h:571
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:628