Rework module parsing and execution (#4462)

This patch disables automatic detection of module code, and instead
requires the user to explicitly specify whether to parse a source
as a module or as a script.

To achieve this the jerry_parse API function now takes a new option
which signals that the source should be parsed as a module.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
Dániel Bátyai
2021-01-18 15:33:43 +01:00
committed by GitHub
parent ef8a6a9f39
commit 0fec9135ec
85 changed files with 575 additions and 492 deletions
@@ -14,4 +14,4 @@
*/
// File does not exist.
import b from "module-exports.js"
import b from "module-exports.mjs"
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import { , as b } from "../es.next/module-export-01.js";
import { , as b } from "../es.next/module-export-01.mjs";
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import , as b from "../es.next/module-export-01.js";
import , as b from "../es.next/module-export-01.mjs";
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import { b as , } from "../es.next/module-export-01.js";
import { b as , } from "../es.next/module-export-01.mjs";
@@ -14,4 +14,4 @@
*/
/* Named imports must be in a NamedImports block. */
import b as , from "../es.next/module-export-01.js";
import b as , from "../es.next/module-export-01.mjs";
@@ -14,4 +14,4 @@
*/
/* Module requests must always be evaluated. */
import "./module-sideeffect.js"
import "./module-sideeffect.mjs"
@@ -14,4 +14,4 @@
*/
/* Can't have duplicate local bindings */
import { c as a, d as a } from "../es.next/module-export-01.js";
import { c as a, d as a } from "../es.next/module-export-01.mjs";
@@ -15,5 +15,5 @@
/* Import/export statements must be in the global scope. */
if (true) {
import { c } from "../es.next/module-export-01.js";
import { c } from "../es.next/module-export-01.mjs";
}
@@ -15,5 +15,5 @@
/* Import/export statements must be in the global scope. */
function someFunction() {
import { c } from "../es.next/module-export-01.js";
import { c } from "../es.next/module-export-01.mjs";
}
@@ -14,4 +14,4 @@
*/
/* Import/export statements must be in the global scope. */
eval ('import { c } from "../es.next/module-export-01.js";');
eval ('import { c } from "../es.next/module-export-01.mjs";');
@@ -14,4 +14,4 @@
*/
/* NamedImports must always be followed by a FromClause. */
import { b }, from "../es.next/module-export-01.js"
import { b }, from "../es.next/module-export-01.mjs"
@@ -14,4 +14,4 @@
*/
/* An import statement can have either a NameSpaceImport or NamedIpmorts */
import * as mod, { b } from "../es.next/module-export-01.js"
import * as mod, { b } from "../es.next/module-export-01.mjs"
@@ -14,4 +14,4 @@
*/
/* '*' is not valid inside NamedImports. */
import { *, d } from "../es.next/module-imported-01.js"
import { *, d } from "../es.next/module-imported-01.mjs"
@@ -14,5 +14,5 @@
*/
/* Can't have duplicated local bindings. */
import { b } from "../es.next/module-export-01.js"
import { b } from "../es.next/module-export-02.js"
import { b } from "../es.next/module-export-01.mjs"
import { b } from "../es.next/module-export-02.mjs"
@@ -14,4 +14,4 @@
*/
/* FromClause must follow an ImportClause. */
import from "../es.next/module-export-02.js"
import from "../es.next/module-export-02.mjs"
@@ -14,4 +14,4 @@
*/
/* Namespace imports must have a local name. */
import * from "../es.next/module-export-01.js"
import * from "../es.next/module-export-01.mjs"
@@ -14,4 +14,4 @@
*/
/* Star exports can't have an export name. */
export * as star from "../es.next/module-export-01.js"
export * as star from "../es.next/module-export-01.mjs"
@@ -14,4 +14,4 @@
*/
/* Indirect exports must be checked if they are resolvable. */
export { l } from "../es.next/module-export-01.js"
export { l } from "../es.next/module-export-01.mjs"
@@ -14,4 +14,4 @@
*/
/* Can't have circular imports/exports. */
export { b } from "./module-027.js"
export { b } from "./module-027.mjs"
@@ -14,4 +14,4 @@
*/
/* Can't have circular imports/exports. */
export { b } from "./module-026.js"
export { b } from "./module-026.mjs"
@@ -14,4 +14,4 @@
*/
/* Ambiguous import */
import { x } from "../es.next/module-export-05.js"
import { x } from "../es.next/module-export-05.mjs"
@@ -14,4 +14,4 @@
*/
/* Import/export statements must be in the global scope. */
Function('','import { c } from "../es.next/module-export-01.js";')
Function('','import { c } from "../es.next/module-export-01.mjs";')
@@ -14,4 +14,4 @@
*/
/* No default export found. */
import def from "../es.next/module-export-06.js"
import def from "../es.next/module-export-06.mjs"
@@ -14,4 +14,4 @@
*/
let a;
import { a } from "../es.next/module-export-fail-test.js";
import { a } from "../es.next/module-export-fail-test.mjs";
@@ -14,4 +14,4 @@
*/
var a;
import { a } from "../es.next/module-export-fail-test.js";
import { a } from "../es.next/module-export-fail-test.mjs";
@@ -13,5 +13,5 @@
* limitations under the License.
*/
import { a } from "../es.next/module-export-fail-test.js";
import { a } from "../es.next/module-export-fail-test.mjs";
class a {};
@@ -13,5 +13,5 @@
* limitations under the License.
*/
import { a } from "../es.next/module-export-fail-test.js";
import { a } from "../es.next/module-export-fail-test.mjs";
function a() {}
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import "./module-export-001.js"
import "./module-await-001.mjs"
@@ -13,4 +13,4 @@
* limitations under the License.
*/
import "./module-await-001.js"
import "./module-await-001.mjs"
@@ -12,5 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.
export {} from "dummy.js";
export {} from "../es.next/module-export-04.js";
export {} from "dummy.mjs";
export {} from "../es.next/module-export-04.mjs";