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

Side by Side Diff: include/v8.h

Issue 2611643002: [modules] Add an IsModule flag to ScriptOriginOptions. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 Data(); 955 Data();
956 }; 956 };
957 957
958 958
959 /** 959 /**
960 * The optional attributes of ScriptOrigin. 960 * The optional attributes of ScriptOrigin.
961 */ 961 */
962 class ScriptOriginOptions { 962 class ScriptOriginOptions {
963 public: 963 public:
964 V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false, 964 V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false,
965 bool is_opaque = false, bool is_wasm = false) 965 bool is_opaque = false, bool is_wasm = false,
966 bool is_module = false)
966 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) | 967 : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
967 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0)) {} 968 (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) |
969 (is_module ? kIsModule : 0)) {}
968 V8_INLINE ScriptOriginOptions(int flags) 970 V8_INLINE ScriptOriginOptions(int flags)
969 : flags_(flags & (kIsSharedCrossOrigin | kIsOpaque | kIsWasm)) {} 971 : flags_(flags &
972 (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {}
973
970 bool IsSharedCrossOrigin() const { 974 bool IsSharedCrossOrigin() const {
971 return (flags_ & kIsSharedCrossOrigin) != 0; 975 return (flags_ & kIsSharedCrossOrigin) != 0;
972 } 976 }
973 bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; } 977 bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; }
974 bool IsWasm() const { return (flags_ & kIsWasm) != 0; } 978 bool IsWasm() const { return (flags_ & kIsWasm) != 0; }
979 bool IsModule() const { return (flags_ & kIsModule) != 0; }
980
975 int Flags() const { return flags_; } 981 int Flags() const { return flags_; }
976 982
977 private: 983 private:
978 enum { kIsSharedCrossOrigin = 1, kIsOpaque = 1 << 1, kIsWasm = 1 << 2 }; 984 enum {
985 kIsSharedCrossOrigin = 1,
986 kIsOpaque = 1 << 1,
987 kIsWasm = 1 << 2,
988 kIsModule = 1 << 3
989 };
979 const int flags_; 990 const int flags_;
980 }; 991 };
981 992
982 /** 993 /**
983 * The origin, within a file, of a script. 994 * The origin, within a file, of a script.
984 */ 995 */
985 class ScriptOrigin { 996 class ScriptOrigin {
986 public: 997 public:
987 V8_INLINE ScriptOrigin( 998 V8_INLINE ScriptOrigin(
988 Local<Value> resource_name, 999 Local<Value> resource_name,
989 Local<Integer> resource_line_offset = Local<Integer>(), 1000 Local<Integer> resource_line_offset = Local<Integer>(),
990 Local<Integer> resource_column_offset = Local<Integer>(), 1001 Local<Integer> resource_column_offset = Local<Integer>(),
991 Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(), 1002 Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(),
992 Local<Integer> script_id = Local<Integer>(), 1003 Local<Integer> script_id = Local<Integer>(),
993 Local<Value> source_map_url = Local<Value>(), 1004 Local<Value> source_map_url = Local<Value>(),
994 Local<Boolean> resource_is_opaque = Local<Boolean>(), 1005 Local<Boolean> resource_is_opaque = Local<Boolean>(),
995 Local<Boolean> is_wasm = Local<Boolean>()); 1006 Local<Boolean> is_wasm = Local<Boolean>(),
1007 Local<Boolean> is_module = Local<Boolean>());
1008
1009 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
1010 Isolate* isolate);
996 1011
997 V8_INLINE Local<Value> ResourceName() const; 1012 V8_INLINE Local<Value> ResourceName() const;
998 V8_INLINE Local<Integer> ResourceLineOffset() const; 1013 V8_INLINE Local<Integer> ResourceLineOffset() const;
999 V8_INLINE Local<Integer> ResourceColumnOffset() const; 1014 V8_INLINE Local<Integer> ResourceColumnOffset() const;
1000 /** 1015 /**
1001 * Returns true for embedder's debugger scripts 1016 * Returns true for embedder's debugger scripts
1002 */ 1017 */
1003 V8_INLINE Local<Integer> ScriptID() const; 1018 V8_INLINE Local<Integer> ScriptID() const;
1004 V8_INLINE Local<Value> SourceMapUrl() const; 1019 V8_INLINE Local<Value> SourceMapUrl() const;
1005 V8_INLINE ScriptOriginOptions Options() const { return options_; } 1020 V8_INLINE ScriptOriginOptions Options() const { return options_; }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 CachedData* cached_data = NULL); 1191 CachedData* cached_data = NULL);
1177 V8_INLINE Source(Local<String> source_string, 1192 V8_INLINE Source(Local<String> source_string,
1178 CachedData* cached_data = NULL); 1193 CachedData* cached_data = NULL);
1179 V8_INLINE ~Source(); 1194 V8_INLINE ~Source();
1180 1195
1181 // Ownership of the CachedData or its buffers is *not* transferred to the 1196 // Ownership of the CachedData or its buffers is *not* transferred to the
1182 // caller. The CachedData object is alive as long as the Source object is 1197 // caller. The CachedData object is alive as long as the Source object is
1183 // alive. 1198 // alive.
1184 V8_INLINE const CachedData* GetCachedData() const; 1199 V8_INLINE const CachedData* GetCachedData() const;
1185 1200
1201 V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
1202
1186 // Prevent copying. 1203 // Prevent copying.
1187 Source(const Source&) = delete; 1204 Source(const Source&) = delete;
1188 Source& operator=(const Source&) = delete; 1205 Source& operator=(const Source&) = delete;
1189 1206
1190 private: 1207 private:
1191 friend class ScriptCompiler; 1208 friend class ScriptCompiler;
1192 1209
1193 Local<String> source_string; 1210 Local<String> source_string;
1194 1211
1195 // Origin information 1212 // Origin information
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 Local<String> arguments[], 1435 Local<String> arguments[],
1419 size_t context_extension_count, 1436 size_t context_extension_count,
1420 Local<Object> context_extensions[])); 1437 Local<Object> context_extensions[]));
1421 static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext( 1438 static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
1422 Local<Context> context, Source* source, size_t arguments_count, 1439 Local<Context> context, Source* source, size_t arguments_count,
1423 Local<String> arguments[], size_t context_extension_count, 1440 Local<String> arguments[], size_t context_extension_count,
1424 Local<Object> context_extensions[]); 1441 Local<Object> context_extensions[]);
1425 1442
1426 private: 1443 private:
1427 static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal( 1444 static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal(
1428 Isolate* isolate, Source* source, CompileOptions options, bool is_module); 1445 Isolate* isolate, Source* source, CompileOptions options);
1429 }; 1446 };
1430 1447
1431 1448
1432 /** 1449 /**
1433 * An error message. 1450 * An error message.
1434 */ 1451 */
1435 class V8_EXPORT Message { 1452 class V8_EXPORT Message {
1436 public: 1453 public:
1437 Local<String> Get() const; 1454 Local<String> Get() const;
1438 1455
(...skipping 7486 matching lines...) Expand 10 before | Expand all | Expand 10 after
8925 return length_; 8942 return length_;
8926 } 8943 }
8927 8944
8928 ScriptOrigin::ScriptOrigin(Local<Value> resource_name, 8945 ScriptOrigin::ScriptOrigin(Local<Value> resource_name,
8929 Local<Integer> resource_line_offset, 8946 Local<Integer> resource_line_offset,
8930 Local<Integer> resource_column_offset, 8947 Local<Integer> resource_column_offset,
8931 Local<Boolean> resource_is_shared_cross_origin, 8948 Local<Boolean> resource_is_shared_cross_origin,
8932 Local<Integer> script_id, 8949 Local<Integer> script_id,
8933 Local<Value> source_map_url, 8950 Local<Value> source_map_url,
8934 Local<Boolean> resource_is_opaque, 8951 Local<Boolean> resource_is_opaque,
8935 Local<Boolean> is_wasm) 8952 Local<Boolean> is_wasm, Local<Boolean> is_module)
8936 : resource_name_(resource_name), 8953 : resource_name_(resource_name),
8937 resource_line_offset_(resource_line_offset), 8954 resource_line_offset_(resource_line_offset),
8938 resource_column_offset_(resource_column_offset), 8955 resource_column_offset_(resource_column_offset),
8939 options_(!resource_is_shared_cross_origin.IsEmpty() && 8956 options_(!resource_is_shared_cross_origin.IsEmpty() &&
8940 resource_is_shared_cross_origin->IsTrue(), 8957 resource_is_shared_cross_origin->IsTrue(),
8941 !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(), 8958 !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(),
8942 !is_wasm.IsEmpty() && is_wasm->IsTrue()), 8959 !is_wasm.IsEmpty() && is_wasm->IsTrue(),
8960 !is_module.IsEmpty() && is_module->IsTrue()),
8943 script_id_(script_id), 8961 script_id_(script_id),
8944 source_map_url_(source_map_url) {} 8962 source_map_url_(source_map_url) {}
8945 8963
8964 ScriptOrigin ScriptOrigin::ModuleOrigin(Local<Value> resource_name,
8965 Isolate* isolate) {
8966 ScriptOrigin origin(resource_name, Local<Integer>(), Local<Integer>(),
8967 Local<Boolean>(), Local<Integer>(), Local<Value>(),
8968 Local<Boolean>(), Local<Boolean>(), True(isolate));
8969 return origin;
8970 }
8971
8946 Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; } 8972 Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; }
8947 8973
8948 8974
8949 Local<Integer> ScriptOrigin::ResourceLineOffset() const { 8975 Local<Integer> ScriptOrigin::ResourceLineOffset() const {
8950 return resource_line_offset_; 8976 return resource_line_offset_;
8951 } 8977 }
8952 8978
8953 8979
8954 Local<Integer> ScriptOrigin::ResourceColumnOffset() const { 8980 Local<Integer> ScriptOrigin::ResourceColumnOffset() const {
8955 return resource_column_offset_; 8981 return resource_column_offset_;
(...skipping 25 matching lines...) Expand all
8981 ScriptCompiler::Source::~Source() { 9007 ScriptCompiler::Source::~Source() {
8982 delete cached_data; 9008 delete cached_data;
8983 } 9009 }
8984 9010
8985 9011
8986 const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData() 9012 const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
8987 const { 9013 const {
8988 return cached_data; 9014 return cached_data;
8989 } 9015 }
8990 9016
9017 const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const {
9018 return resource_options;
9019 }
8991 9020
8992 Local<Boolean> Boolean::New(Isolate* isolate, bool value) { 9021 Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
8993 return value ? True(isolate) : False(isolate); 9022 return value ? True(isolate) : False(isolate);
8994 } 9023 }
8995 9024
8996 9025
8997 void Template::Set(Isolate* isolate, const char* name, v8::Local<Data> value) { 9026 void Template::Set(Isolate* isolate, const char* name, v8::Local<Data> value) {
8998 Set(v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal) 9027 Set(v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
8999 .ToLocalChecked(), 9028 .ToLocalChecked(),
9000 value); 9029 value);
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
9761 */ 9790 */
9762 9791
9763 9792
9764 } // namespace v8 9793 } // namespace v8
9765 9794
9766 9795
9767 #undef TYPE_CHECK 9796 #undef TYPE_CHECK
9768 9797
9769 9798
9770 #endif // INCLUDE_V8_H_ 9799 #endif // INCLUDE_V8_H_
OLDNEW
« 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