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

Side by Side Diff: src/objects.cc

Issue 2827733002: [modules] Allow resolve-callback to signal failure. (Closed)
Patch Set: Cleanup. Created 3 years, 8 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 | « src/objects.h ('k') | test/cctest/test-modules.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 20316 matching lines...) Expand 10 before | Expand all | Expand 10 after
20327 if (module->status() == kPrepared) return true; 20327 if (module->status() == kPrepared) return true;
20328 20328
20329 // Obtain requested modules. 20329 // Obtain requested modules.
20330 Isolate* isolate = module->GetIsolate(); 20330 Isolate* isolate = module->GetIsolate();
20331 Handle<ModuleInfo> module_info(module->info(), isolate); 20331 Handle<ModuleInfo> module_info(module->info(), isolate);
20332 Handle<FixedArray> module_requests(module_info->module_requests(), isolate); 20332 Handle<FixedArray> module_requests(module_info->module_requests(), isolate);
20333 Handle<FixedArray> requested_modules(module->requested_modules(), isolate); 20333 Handle<FixedArray> requested_modules(module->requested_modules(), isolate);
20334 for (int i = 0, length = module_requests->length(); i < length; ++i) { 20334 for (int i = 0, length = module_requests->length(); i < length; ++i) {
20335 Handle<String> specifier(String::cast(module_requests->get(i)), isolate); 20335 Handle<String> specifier(String::cast(module_requests->get(i)), isolate);
20336 v8::Local<v8::Module> api_requested_module; 20336 v8::Local<v8::Module> api_requested_module;
20337 // TODO(adamk): Revisit these failure cases once d8 knows how to
20338 // persist a module_map across multiple top-level module loads, as
20339 // the current module is left in a "half-instantiated" state.
20340 if (!callback(context, v8::Utils::ToLocal(specifier), 20337 if (!callback(context, v8::Utils::ToLocal(specifier),
20341 v8::Utils::ToLocal(module)) 20338 v8::Utils::ToLocal(module))
20342 .ToLocal(&api_requested_module)) { 20339 .ToLocal(&api_requested_module)) {
20343 // TODO(adamk): Give this a better error message. But this is a 20340 isolate->PromoteScheduledException();
20344 // misuse of the API anyway.
20345 isolate->ThrowIllegalOperation();
20346 return false; 20341 return false;
20347 } 20342 }
20348 Handle<Module> requested_module = Utils::OpenHandle(*api_requested_module); 20343 Handle<Module> requested_module = Utils::OpenHandle(*api_requested_module);
20349 requested_modules->set(i, *requested_module); 20344 requested_modules->set(i, *requested_module);
20350 } 20345 }
20351 20346
20352 // Recurse. 20347 // Recurse.
20353 module->set_status(kPrepared); 20348 module->set_status(kPrepared);
20354 for (int i = 0, length = requested_modules->length(); i < length; ++i) { 20349 for (int i = 0, length = requested_modules->length(); i < length; ++i) {
20355 Handle<Module> requested_module(Module::cast(requested_modules->get(i)), 20350 Handle<Module> requested_module(Module::cast(requested_modules->get(i)),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
20679 // depend on this. 20674 // depend on this.
20680 return DICTIONARY_ELEMENTS; 20675 return DICTIONARY_ELEMENTS;
20681 } 20676 }
20682 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20677 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20683 return kind; 20678 return kind;
20684 } 20679 }
20685 } 20680 }
20686 20681
20687 } // namespace internal 20682 } // namespace internal
20688 } // namespace v8 20683 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-modules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698