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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1468 | 1468 |
1469 // Helper routines to print out errors with imports. | 1469 // Helper routines to print out errors with imports. |
1470 void ReportLinkError(const char* error, uint32_t index, | 1470 void ReportLinkError(const char* error, uint32_t index, |
1471 Handle<String> module_name, Handle<String> import_name) { | 1471 Handle<String> module_name, Handle<String> import_name) { |
1472 thrower_->LinkError( | 1472 thrower_->LinkError( |
1473 "Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", index, | 1473 "Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", index, |
1474 module_name->length(), module_name->ToCString().get(), | 1474 module_name->length(), module_name->ToCString().get(), |
1475 import_name->length(), import_name->ToCString().get(), error); | 1475 import_name->length(), import_name->ToCString().get(), error); |
1476 } | 1476 } |
1477 | 1477 |
1478 MaybeHandle<Object> ReportTypeError(const char* error, uint32_t index, | 1478 MaybeHandle<Object> ReportLinkError(const char* error, uint32_t index, |
1479 Handle<String> module_name) { | 1479 Handle<String> module_name) { |
1480 thrower_->TypeError("Import #%d module=\"%.*s\" error: %s", index, | 1480 thrower_->LinkError("Import #%d module=\"%.*s\" error: %s", index, |
1481 module_name->length(), module_name->ToCString().get(), | 1481 module_name->length(), module_name->ToCString().get(), |
1482 error); | 1482 error); |
1483 return MaybeHandle<Object>(); | 1483 return MaybeHandle<Object>(); |
1484 } | 1484 } |
1485 | 1485 |
1486 // Look up an import value in the {ffi_} object. | 1486 // Look up an import value in the {ffi_} object. |
1487 MaybeHandle<Object> LookupImport(uint32_t index, Handle<String> module_name, | 1487 MaybeHandle<Object> LookupImport(uint32_t index, Handle<String> module_name, |
1488 Handle<String> import_name) { | 1488 Handle<String> import_name) { |
1489 if (ffi_.is_null()) { | 1489 if (ffi_.is_null()) { |
1490 return ReportTypeError("FFI is not an object", index, module_name); | 1490 return ReportLinkError("FFI is not an object", index, module_name); |
rossberg
2017/01/12 23:59:53
This one is not a linking error but a JS-level API
Mircea Trofin
2017/01/13 03:57:47
Oh, true.
I'll actually move that out and DCHECK
| |
1491 } | 1491 } |
1492 | 1492 |
1493 // Look up the module first. | 1493 // Look up the module first. |
1494 MaybeHandle<Object> result = | 1494 MaybeHandle<Object> result = |
1495 Object::GetPropertyOrElement(ffi_, module_name); | 1495 Object::GetPropertyOrElement(ffi_, module_name); |
1496 if (result.is_null()) { | 1496 if (result.is_null()) { |
1497 return ReportTypeError("module not found", index, module_name); | 1497 return ReportLinkError("module not found", index, module_name); |
1498 } | 1498 } |
1499 | 1499 |
1500 Handle<Object> module = result.ToHandleChecked(); | 1500 Handle<Object> module = result.ToHandleChecked(); |
1501 | 1501 |
1502 // Look up the value in the module. | 1502 // Look up the value in the module. |
1503 if (!module->IsJSReceiver()) { | 1503 if (!module->IsJSReceiver()) { |
1504 return ReportTypeError("module is not an object or function", index, | 1504 return ReportLinkError("module is not an object or function", index, |
1505 module_name); | 1505 module_name); |
1506 } | 1506 } |
1507 | 1507 |
1508 result = Object::GetPropertyOrElement(module, import_name); | 1508 result = Object::GetPropertyOrElement(module, import_name); |
1509 if (result.is_null()) { | 1509 if (result.is_null()) { |
1510 ReportLinkError("import not found", index, module_name, import_name); | 1510 ReportLinkError("import not found", index, module_name, import_name); |
1511 return MaybeHandle<JSFunction>(); | 1511 return MaybeHandle<JSFunction>(); |
1512 } | 1512 } |
1513 | 1513 |
1514 return result; | 1514 return result; |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2487 | 2487 |
2488 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(), | 2488 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(), |
2489 NONE); | 2489 NONE); |
2490 JSObject::AddProperty(entry, kind_string, export_kind, NONE); | 2490 JSObject::AddProperty(entry, kind_string, export_kind, NONE); |
2491 | 2491 |
2492 storage->set(index, *entry); | 2492 storage->set(index, *entry); |
2493 } | 2493 } |
2494 | 2494 |
2495 return array_object; | 2495 return array_object; |
2496 } | 2496 } |
OLD | NEW |