[JSC] Introduce import.meta
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Oct 2017 03:57:38 +0000 (03:57 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Oct 2017 03:57:38 +0000 (03:57 +0000)
commit521c533c385135295a97ed6dc3fd9c317907e7bf
treed4eb405aa218ef5fdafd4ec73293651b7807a125
parentc42188a029adfab1648171a61ed1d88ca95c3905
[JSC] Introduce import.meta
https://bugs.webkit.org/show_bug.cgi?id=177703

Reviewed by Filip Pizlo.

JSTests:

* modules/import-meta-syntax.js: Added.
(shouldThrow):
(shouldNotThrow):
* modules/import-meta.js: Added.
* modules/import-meta/cocoa.js: Added.
* modules/resources/assert.js:
(export.shouldNotThrow):
* stress/import-syntax.js:

Source/JavaScriptCore:

This patch adds stage 3 `import.meta`[1].
We add a new hook function moduleLoaderCreateImportMetaProperties, which creates
import meta properties object to this module. And we set this object as @meta
private variable in module environments. So module code can access this by accessing
@meta private variable.

[1]: https://github.com/tc39/proposal-import-meta

* builtins/BuiltinNames.h:
* builtins/ModuleLoaderPrototype.js:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* jsc.cpp:
(GlobalObject::moduleLoaderCreateImportMetaProperties):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseModuleSourceElements):
(JSC::Parser<LexerType>::parseMemberExpression):
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::createImportMetaProperties):
* runtime/JSModuleLoader.h:
* runtime/JSModuleRecord.cpp:
(JSC::JSModuleRecord::link):
(JSC::JSModuleRecord::instantiateDeclarations):
* runtime/JSModuleRecord.h:
* runtime/ModuleLoaderPrototype.cpp:
(JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):

Source/WebCore:

* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSWorkerGlobalScopeBase.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222895 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
JSTests/ChangeLog
JSTests/modules/import-meta-syntax.js [new file with mode: 0644]
JSTests/modules/import-meta.js [new file with mode: 0644]
JSTests/modules/import-meta/cocoa.js [new file with mode: 0644]
JSTests/modules/resources/assert.js
JSTests/stress/import-syntax.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/BuiltinNames.h
Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/JSModuleLoader.cpp
Source/JavaScriptCore/runtime/JSModuleLoader.h
Source/JavaScriptCore/runtime/JSModuleRecord.cpp
Source/JavaScriptCore/runtime/JSModuleRecord.h
Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp