Fix assertion in print method.

ICE: Assertion 'args_number == 1' failed at Jerry/jerry-core/vm/opcodes-native-call.cpp(opfunc_native_call):55.
Error: ERR_FAILED_INTERNAL_ASSERTION

Test case:
  print('a', 'a');

Print all of the arguments separated by space.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2015-05-06 09:07:10 +02:00
parent 1f5a4f2690
commit 7c99170f54
+16 -5
View File
@@ -1,4 +1,5 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd. /* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* Copyright 2015 University of Szeged.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -67,10 +68,12 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
case OPCODE_NATIVE_CALL_PRINT: case OPCODE_NATIVE_CALL_PRINT:
{ {
JERRY_ASSERT (args_number == 1); for (ecma_length_t arg_index = 0;
arg_index < args_read;
arg_index++)
{
ECMA_TRY_CATCH (str_value, ECMA_TRY_CATCH (str_value,
ecma_op_to_string (arg_values[0]), ecma_op_to_string (arg_values[arg_index]),
ret_value); ret_value);
ecma_string_t *str_p = ecma_get_string_from_value (str_value); ecma_string_t *str_p = ecma_get_string_from_value (str_value);
@@ -89,7 +92,14 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
ecma_string_to_zt_string (str_p, zt_str_p, zt_str_size); ecma_string_to_zt_string (str_p, zt_str_p, zt_str_size);
#if CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII #if CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII
printf ("%s\n", (char*) zt_str_p); if (arg_index < args_read - 1)
{
printf ("%s ", (char*) zt_str_p);
}
else
{
printf ("%s", (char*) zt_str_p);
}
#elif CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 #elif CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16
JERRY_UNIMPLEMENTED ("UTF-16 support is not implemented."); JERRY_UNIMPLEMENTED ("UTF-16 support is not implemented.");
#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 */ #endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 */
@@ -99,7 +109,8 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
ret_value = ecma_make_empty_completion_value (); ret_value = ecma_make_empty_completion_value ();
ECMA_FINALIZE (str_value); ECMA_FINALIZE (str_value);
}
printf ("\n");
break; break;
} }