Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: include/v8.h

Issue 2611643002: [modules] Add an IsModule flag to ScriptOriginOptions. (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 3d8082ee1415f7a5ff41f4b059cce528bf22c381..1d6ac5ab7ad9eb4573745c6b0360902f2b2eacc9 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -962,20 +962,31 @@ class V8_EXPORT Data {
class ScriptOriginOptions {
public:
V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
- bool is_opaque = false, bool is_wasm = false)
+ bool is_opaque = false, bool is_wasm = false,
+ bool is_module = false)
: flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
- (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0)) {}
+ (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
+ (is_module ? kIsModule : 0)) {}
V8_INLINE ScriptOriginOptions(int flags)
- : flags_(flags & (kIsSharedCrossOrigin | kIsOpaque | kIsWasm)) {}
+ : flags_(flags &
+ (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
+
bool IsSharedCrossOrigin() const {
return (flags_ & kIsSharedCrossOrigin) != 0;
}
bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
+ bool IsModule() const { return (flags_ & kIsModule) != 0; }
+
int Flags() const { return flags_; }
private:
- enum { kIsSharedCrossOrigin = 1, kIsOpaque = 1 << 1, kIsWasm = 1 << 2 };
+ enum {
+ kIsSharedCrossOrigin = 1,
+ kIsOpaque = 1 << 1,
+ kIsWasm = 1 << 2,
+ kIsModule = 1 << 3
+ };
const int flags_;
};
@@ -992,7 +1003,11 @@ class ScriptOrigin {
Local<Integer> script_id = Local<Integer>(),
Local<Value> source_map_url = Local<Value>(),
Local<Boolean> resource_is_opaque = Local<Boolean>(),
- Local<Boolean> is_wasm = Local<Boolean>());
+ Local<Boolean> is_wasm = Local<Boolean>(),
+ Local<Boolean> is_module = Local<Boolean>());
+
+ V8_INLINE static ScriptOrigin ModuleOrigin(Local<Value> resource_name,
adamk 2017/01/03 18:41:32 If we're going to expose this API we probably want
+ Isolate* isolate);
V8_INLINE Local<Value> ResourceName() const;
V8_INLINE Local<Integer> ResourceLineOffset() const;
@@ -1183,6 +1198,8 @@ class V8_EXPORT ScriptCompiler {
// alive.
V8_INLINE const CachedData* GetCachedData() const;
+ V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
+
// Prevent copying.
Source(const Source&) = delete;
Source& operator=(const Source&) = delete;
@@ -1425,7 +1442,7 @@ class V8_EXPORT ScriptCompiler {
private:
static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
- Isolate* isolate, Source* source, CompileOptions options, bool is_module);
+ Isolate* isolate, Source* source, CompileOptions options);
};
@@ -8932,17 +8949,26 @@ ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
Local<Integer> script_id,
Local<Value> source_map_url,
Local<Boolean> resource_is_opaque,
- Local<Boolean> is_wasm)
+ Local<Boolean> is_wasm, Local<Boolean> is_module)
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
options_(!resource_is_shared_cross_origin.IsEmpty() &&
resource_is_shared_cross_origin->IsTrue(),
!resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
- !is_wasm.IsEmpty() && is_wasm->IsTrue()),
+ !is_wasm.IsEmpty() && is_wasm->IsTrue(),
+ !is_module.IsEmpty() && is_module->IsTrue()),
script_id_(script_id),
source_map_url_(source_map_url) {}
+ScriptOrigin ScriptOrigin::ModuleOrigin(Local<Value> resource_name,
+ Isolate* isolate) {
+ ScriptOrigin origin(resource_name, Local<Integer>(), Local<Integer>(),
+ Local<Boolean>(), Local<Integer>(), Local<Value>(),
+ Local<Boolean>(), Local<Boolean>(), True(isolate));
+ return origin;
+}
+
Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
@@ -8988,6 +9014,9 @@ const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
return cached_data;
}
+const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const {
+ return resource_options;
+}
Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
return value ? True(isolate) : False(isolate);
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698