v8 10.2.154 (node 18.16.0)
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_INLINE ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
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 : isolate_(isolate),
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
85 V8_INLINE Local<Value> ResourceName() const;
86 V8_INLINE int LineOffset() const;
87 V8_INLINE int ColumnOffset() const;
88 V8_INLINE int ScriptId() const;
89 V8_INLINE Local<Value> SourceMapUrl() const;
90 V8_DEPRECATE_SOON("Use GetHostDefinedOptions")
91 Local<PrimitiveArray> HostDefinedOptions() const;
92 V8_INLINE Local<Data> GetHostDefinedOptions() const;
93 V8_INLINE ScriptOriginOptions Options() const { return options_; }
94
95 private:
96 void VerifyHostDefinedOptions() const;
97 Isolate* isolate_;
98 Local<Value> resource_name_;
99 int resource_line_offset_;
100 int resource_column_offset_;
101 ScriptOriginOptions options_;
102 int script_id_;
103 Local<Value> source_map_url_;
104 Local<Data> host_defined_options_;
105};
106
111 public:
113
118
120 Local<Context> context) const;
122 Local<Context> context) const;
123
129
135
142
147
152 int GetStartPosition() const;
153
158 int GetEndPosition() const;
159
165
169 int ErrorLevel() const;
170
175 int GetStartColumn() const;
177
182 int GetEndColumn() const;
184
190 bool IsOpaque() const;
191
192 static void PrintCurrentStackTrace(Isolate* isolate, std::ostream& out);
193
194 static const int kNoLineNumberInfo = 0;
195 static const int kNoColumnInfo = 0;
196 static const int kNoScriptIdInfo = 0;
197 static const int kNoWasmFunctionIndexInfo = -1;
198};
199
200Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
201
203 return host_defined_options_;
204}
205
206int ScriptOrigin::LineOffset() const { return resource_line_offset_; }
207
208int ScriptOrigin::ColumnOffset() const { return resource_column_offset_; }
209
210int ScriptOrigin::ScriptId() const { return script_id_; }
211
212Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; }
213
214} // namespace v8
215
216#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 ScriptOrigin(Isolate *isolate, 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
V8_INLINE Local< Value > SourceMapUrl() const
Definition v8-message.h:212
V8_INLINE int ColumnOffset() const
Definition v8-message.h:208
V8_INLINE Local< Data > GetHostDefinedOptions() const
Definition v8-message.h:202
V8_INLINE int LineOffset() const
Definition v8-message.h:206
V8_INLINE Local< Value > ResourceName() const
Definition v8-message.h:200
V8_INLINE int ScriptId() const
Definition v8-message.h:210
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:578
#define V8_INLINE
Definition v8config.h:425
#define V8_DEPRECATE_SOON(message)
Definition v8config.h:470
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:499