[JSC] Support import assertion syntax
https://bugs.webkit.org/show_bug.cgi?id=235312
Reviewed by Ross Kirsling.
JSTests:
- modules/import-meta-syntax.js:
(shouldThrow):
- stress/import-syntax.js:
- stress/modules-syntax-error.js:
- stress/modules-syntax-import-assertion-error.js: Added.
(shouldThrow):
- stress/modules-syntax-import-assertion.js: Added.
LayoutTests/imported/w3c:
- web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
- web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
- web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt:
- web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt:
- web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt:
Source/JavaScriptCore:
This patch adds syntax support for import assertion[1].
This does not add the actual feature propagating import assertion
to the module request yet.
[1]: https://github.com/tc39/proposal-import-assertions
- bytecompiler/NodesCodegen.cpp:
(JSC::ImportNode::emitBytecode):
(JSC::ASTBuilder::createImportExpr):
(JSC::ASTBuilder::createImportAssertionList):
(JSC::ASTBuilder::appendImportAssertion):
(JSC::ASTBuilder::createImportDeclaration):
(JSC::ASTBuilder::createExportAllDeclaration):
(JSC::ASTBuilder::createExportNamedDeclaration):
- parser/NodeConstructors.h:
(JSC::ImportNode::ImportNode):
(JSC::ImportDeclarationNode::ImportDeclarationNode):
(JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
(JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):
- parser/Nodes.h:
- parser/Parser.cpp:
(JSC::Parser<LexerType>::parseImportAssertions):
(JSC::Parser<LexerType>::parseImportDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseMemberExpression):
- parser/Parser.h:
- parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createImportExpr):
(JSC::SyntaxChecker::createImportAssertionList):
(JSC::SyntaxChecker::appendImportAssertion):
(JSC::SyntaxChecker::createImportDeclaration):
(JSC::SyntaxChecker::createExportAllDeclaration):
(JSC::SyntaxChecker::createExportNamedDeclaration):
- runtime/JSGlobalObjectFunctions.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):