Correctly propagate errors when parsing modules (#2907)

Fixes #2896.

Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2019-06-14 09:29:26 +02:00
committed by Robert Fancsik
parent 351acdf545
commit 3953fee035
3 changed files with 36 additions and 16 deletions
+13 -9
View File
@@ -545,7 +545,7 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
ecma_value_t ret_value;
ret_value = vm_run_module (ecma_op_function_get_compiled_code ((ecma_extended_object_t *) module_p->compiled_code_p),
ret_value = vm_run_module (module_p->compiled_code_p,
module_p->scope_p);
if (!ECMA_IS_VALUE_ERROR (ret_value))
@@ -556,7 +556,7 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
ecma_deref_object (module_p->compiled_code_p);
ecma_bytecode_deref (module_p->compiled_code_p);
module_p->state = ECMA_MODULE_STATE_EVALUATED;
return ret_value;
@@ -695,11 +695,13 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
module_p->context_p->parent_p = JERRY_CONTEXT (module_top_context_p);
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
ecma_value_t ret_value = jerry_parse ((jerry_char_t *) script_path_p,
script_path_size,
(jerry_char_t *) source_p,
source_size,
JERRY_PARSE_NO_OPTS);
ecma_compiled_code_t *bytecode_data_p;
ecma_value_t ret_value = parser_parse_script (NULL,
0,
(jerry_char_t *) source_p,
source_size,
JERRY_PARSE_NO_OPTS,
&bytecode_data_p);
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
@@ -710,7 +712,9 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
return ret_value;
}
module_p->compiled_code_p = ecma_get_object_from_value (ret_value);
ecma_free_value (ret_value);
module_p->compiled_code_p = bytecode_data_p;
module_p->state = ECMA_MODULE_STATE_PARSED;
return ECMA_VALUE_EMPTY;
@@ -851,7 +855,7 @@ ecma_module_release_module (ecma_module_t *module_p) /**< module */
if (module_p->state >= ECMA_MODULE_STATE_PARSED
&& module_p->state < ECMA_MODULE_STATE_EVALUATED)
{
ecma_deref_object (module_p->compiled_code_p);
ecma_bytecode_deref (module_p->compiled_code_p);
}
if (module_p->namespace_object_p != NULL)
+7 -7
View File
@@ -77,13 +77,13 @@ typedef enum
*/
struct ecma_module
{
struct ecma_module *next_p; /**< next linked list node */
ecma_module_state_t state; /**< state of the mode */
ecma_string_t *path_p; /**< path of the module */
ecma_module_context_t *context_p; /**< module context of the module */
ecma_object_t *compiled_code_p; /**< compiled code of the module */
ecma_object_t *scope_p; /**< lexica lenvironment of the module */
ecma_object_t *namespace_object_p; /**< namespace import object of the module */
struct ecma_module *next_p; /**< next linked list node */
ecma_module_state_t state; /**< state of the mode */
ecma_string_t *path_p; /**< path of the module */
ecma_module_context_t *context_p; /**< module context of the module */
ecma_compiled_code_t *compiled_code_p; /**< compiled code of the module */
ecma_object_t *scope_p; /**< lexica lenvironment of the module */
ecma_object_t *namespace_object_p; /**< namespace import object of the module */
};
/**
@@ -0,0 +1,16 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export {} from "dummy.js";
export {} from "tests/jerry/es2015/module-export-04.js";