OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium 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 #include "bindings/core/v8/ScriptModule.h" | 5 #include "bindings/core/v8/ScriptModule.h" |
6 | 6 |
7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module) | 11 ScriptModule::ScriptModule(v8::Isolate* isolate, v8::Local<v8::Module> module) |
12 : m_module(SharedPersistent<v8::Module>::create(module, isolate)) {} | 12 : m_module(SharedPersistent<v8::Module>::create(module, isolate)), |
| 13 m_identityHash(static_cast<unsigned>(module->GetIdentityHash())) { |
| 14 DCHECK(!m_module.isEmpty()); |
| 15 } |
13 | 16 |
14 ScriptModule::~ScriptModule() {} | 17 ScriptModule::~ScriptModule() {} |
15 | 18 |
16 ScriptModule ScriptModule::compile(v8::Isolate* isolate, | 19 ScriptModule ScriptModule::compile(v8::Isolate* isolate, |
17 const String& source, | 20 const String& source, |
18 const String& fileName) { | 21 const String& fileName) { |
19 v8::TryCatch tryCatch(isolate); | 22 v8::TryCatch tryCatch(isolate); |
20 tryCatch.SetVerbose(true); | 23 tryCatch.SetVerbose(true); |
21 v8::Local<v8::Module> module; | 24 v8::Local<v8::Module> module; |
22 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module, | 25 if (!v8Call(V8ScriptRunner::compileModule(isolate, source, fileName), module, |
(...skipping 24 matching lines...) Expand all Loading... |
47 tryCatch.SetVerbose(true); | 50 tryCatch.SetVerbose(true); |
48 v8::Local<v8::Value> result; | 51 v8::Local<v8::Value> result; |
49 if (!v8Call(V8ScriptRunner::evaluateModule(m_module->newLocal(isolate), | 52 if (!v8Call(V8ScriptRunner::evaluateModule(m_module->newLocal(isolate), |
50 scriptState->context(), isolate), | 53 scriptState->context(), isolate), |
51 result, tryCatch)) { | 54 result, tryCatch)) { |
52 // TODO(adamk): report error | 55 // TODO(adamk): report error |
53 } | 56 } |
54 } | 57 } |
55 | 58 |
56 } // namespace blink | 59 } // namespace blink |
OLD | NEW |