| OLD | NEW |
| 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 19882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19893 ResolveSet resolve_set(&zone); | 19893 ResolveSet resolve_set(&zone); |
| 19894 if (ResolveExport(module, Handle<String>::cast(name), true, &resolve_set) | 19894 if (ResolveExport(module, Handle<String>::cast(name), true, &resolve_set) |
| 19895 .is_null()) { | 19895 .is_null()) { |
| 19896 return false; | 19896 return false; |
| 19897 } | 19897 } |
| 19898 } | 19898 } |
| 19899 | 19899 |
| 19900 return true; | 19900 return true; |
| 19901 } | 19901 } |
| 19902 | 19902 |
| 19903 MaybeHandle<Object> Module::Evaluate(Handle<Module> module) { |
| 19904 DCHECK(module->code()->IsJSFunction()); |
| 19905 |
| 19906 Isolate* isolate = module->GetIsolate(); |
| 19907 |
| 19908 // Each module can only be evaluated once. |
| 19909 if (module->evaluated()) return isolate->factory()->undefined_value(); |
| 19910 module->set_evaluated(true); |
| 19911 |
| 19912 Handle<FixedArray> requested_modules(module->requested_modules(), isolate); |
| 19913 for (int i = 0, length = requested_modules->length(); i < length; ++i) { |
| 19914 Handle<Module> import(Module::cast(requested_modules->get(i)), isolate); |
| 19915 RETURN_ON_EXCEPTION(isolate, Evaluate(import), Object); |
| 19916 } |
| 19917 |
| 19918 Handle<JSFunction> function(JSFunction::cast(module->code()), isolate); |
| 19919 DCHECK_EQ(MODULE_SCOPE, function->shared()->scope_info()->scope_type()); |
| 19920 Handle<Object> receiver = isolate->factory()->undefined_value(); |
| 19921 Handle<Object> argv[] = {module}; |
| 19922 return Execution::Call(isolate, function, receiver, arraysize(argv), argv); |
| 19923 } |
| 19924 |
| 19903 } // namespace internal | 19925 } // namespace internal |
| 19904 } // namespace v8 | 19926 } // namespace v8 |
| OLD | NEW |