Skip to content

Jerry API update #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 107 additions & 173 deletions docs/03.API-EXAMPLE.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion jerry-core/ecma/base/ecma-gc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -502,7 +503,7 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
} /* ecma_gc_sweep */

/**
* Run garbage collecting
* Run garbage collection
*/
void
ecma_gc_run (void)
Expand Down
29 changes: 9 additions & 20 deletions jerry-core/ecma/operations/ecma-eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ecma_op_eval (ecma_string_t *code_p, /**< code string */
{
ECMA_STRING_TO_UTF8_STRING (code_p, code_utf8_buffer_p, code_utf8_buffer_size);

ret_value = ecma_op_eval_chars_buffer ((jerry_char_t *) code_utf8_buffer_p,
ret_value = ecma_op_eval_chars_buffer (code_utf8_buffer_p,
chars_num,
is_direct,
is_called_from_strict_mode_code);
Expand All @@ -77,39 +77,28 @@ ecma_op_eval (ecma_string_t *code_p, /**< code string */
* @return ecma value
*/
ecma_value_t
ecma_op_eval_chars_buffer (const jerry_char_t *code_p, /**< code characters buffer */
ecma_op_eval_chars_buffer (const lit_utf8_byte_t *code_p, /**< code characters buffer */
size_t code_buffer_size, /**< size of the buffer */
bool is_direct, /**< is eval called directly (ECMA-262 v5, 15.1.2.1.1) */
bool is_called_from_strict_mode_code) /**< is eval is called from strict mode code */
{
JERRY_ASSERT (code_p != NULL);

ecma_value_t ret_value;

ecma_compiled_code_t *bytecode_data_p;
jsp_status_t parse_status;

bool is_strict_call = (is_direct && is_called_from_strict_mode_code);
jerry_object_t *error_obj_p = NULL;

parse_status = parser_parse_eval (code_p,
code_buffer_size,
is_strict_call,
&bytecode_data_p,
&error_obj_p);
ecma_value_t parse_status = parser_parse_script (code_p,
code_buffer_size,
is_strict_call,
&bytecode_data_p);

if (parse_status == JSP_STATUS_OK)
if (ECMA_IS_VALUE_ERROR (parse_status))
{
ret_value = vm_run_eval (bytecode_data_p, is_direct);
return parse_status;
}
else
{
JERRY_ASSERT (parse_status == JSP_STATUS_SYNTAX_ERROR);

ret_value = ecma_make_error_obj_value (error_obj_p);
}

return ret_value;
return vm_run_eval (bytecode_data_p, is_direct);
} /* ecma_op_eval_chars_buffer */

/**
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/operations/ecma-eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern ecma_value_t
ecma_op_eval (ecma_string_t *, bool, bool);

extern ecma_value_t
ecma_op_eval_chars_buffer (const jerry_char_t *, size_t, bool, bool);
ecma_op_eval_chars_buffer (const lit_utf8_byte_t *, size_t, bool, bool);

/**
* @}
Expand Down
10 changes: 7 additions & 3 deletions jerry-core/ecma/operations/ecma-objects.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -277,8 +278,11 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
* See also:
* ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8
*
* @return ecma value
* Returned value must be freed with ecma_free_value
* Note:
* returned value must be freed with ecma_free_value
*
* @return true, if deleted successfully
* false or type error otherwise (based in 'is_throw')
*/
ecma_value_t
ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
Expand Down Expand Up @@ -315,7 +319,7 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
{
JERRY_ASSERT (false);
Copy link
Member

@dbatyai dbatyai Jul 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a valid code path, then this should probably be removed. Otherwise, it would be better to use JERRY_UNREACHABLE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several such asserts in legacy code, perhaps we could fix all of them in a separate patch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.


return ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
}
}
} /* ecma_op_object_delete */
Expand Down
Loading