1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibJS: Follow the spec with storing im- and export entries

Because we can have arbitrary in- and export names with strings we can
have '*' and '' which means using '*' as an indicating namespace imports
failed / behaved incorrectly for string imports '*'.
We now use more specific types to indicate these special states instead
of these 'magic' string values.

Do note that 'default' is not actually a magic string value but one
specified by the spec. And you can in fact export the default value by
doing: `export { 1 as default }`.
This commit is contained in:
davidot 2022-01-27 01:54:47 +01:00 committed by Linus Groh
parent 8473f6caee
commit e0e4ead2c8
11 changed files with 190 additions and 96 deletions

View file

@ -4231,12 +4231,17 @@ void ExportStatement::dump(int indent) const
for (auto& entry : m_entries) {
print_indent(indent + 2);
out("ModuleRequest: {}", entry.module_request.module_specifier);
dump_assert_clauses(entry.module_request);
outln(", ImportName: {}, LocalName: {}, ExportName: {}",
entry.kind == ExportEntry::Kind::ModuleRequest ? string_or_null(entry.local_or_import_name) : "null",
entry.kind != ExportEntry::Kind::ModuleRequest ? string_or_null(entry.local_or_import_name) : "null",
string_or_null(entry.export_name));
out("ExportName: {}, ImportName: {}, LocalName: {}, ModuleRequest: ",
string_or_null(entry.export_name),
entry.is_module_request() ? string_or_null(entry.local_or_import_name) : "null",
entry.is_module_request() ? "null" : string_or_null(entry.local_or_import_name));
if (entry.is_module_request()) {
out("{}", entry.m_module_request->module_specifier);
dump_assert_clauses(*entry.m_module_request);
outln();
} else {
outln("null");
}
}
if (m_statement) {