|
1 | 1 | /* Copyright 2014-2015 Samsung Electronics Co., Ltd. |
| 2 | + * Copyright 2015 University of Szeged. |
2 | 3 | * |
3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 5 | * you may not use this file except in compliance with the License. |
@@ -67,39 +68,49 @@ opfunc_native_call (opcode_t opdata, /**< operation data */ |
67 | 68 |
|
68 | 69 | case OPCODE_NATIVE_CALL_PRINT: |
69 | 70 | { |
70 | | - JERRY_ASSERT (args_number == 1); |
71 | | - |
72 | | - ECMA_TRY_CATCH (str_value, |
73 | | - ecma_op_to_string (arg_values[0]), |
74 | | - ret_value); |
| 71 | + for (ecma_length_t arg_index = 0; |
| 72 | + arg_index < args_read; |
| 73 | + arg_index++) |
| 74 | + { |
| 75 | + ECMA_TRY_CATCH (str_value, |
| 76 | + ecma_op_to_string (arg_values[arg_index]), |
| 77 | + ret_value); |
75 | 78 |
|
76 | | - ecma_string_t *str_p = ecma_get_string_from_value (str_value); |
| 79 | + ecma_string_t *str_p = ecma_get_string_from_value (str_value); |
77 | 80 |
|
78 | | - int32_t chars = ecma_string_get_length (str_p); |
79 | | - JERRY_ASSERT (chars >= 0); |
| 81 | + int32_t chars = ecma_string_get_length (str_p); |
| 82 | + JERRY_ASSERT (chars >= 0); |
80 | 83 |
|
81 | | - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (chars + 1); |
82 | | - ecma_char_t *zt_str_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) zt_str_size, |
83 | | - MEM_HEAP_ALLOC_SHORT_TERM); |
84 | | - if (zt_str_p == NULL) |
85 | | - { |
86 | | - jerry_fatal (ERR_OUT_OF_MEMORY); |
87 | | - } |
| 84 | + ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (chars + 1); |
| 85 | + ecma_char_t *zt_str_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) zt_str_size, |
| 86 | + MEM_HEAP_ALLOC_SHORT_TERM); |
| 87 | + if (zt_str_p == NULL) |
| 88 | + { |
| 89 | + jerry_fatal (ERR_OUT_OF_MEMORY); |
| 90 | + } |
88 | 91 |
|
89 | | - ecma_string_to_zt_string (str_p, zt_str_p, zt_str_size); |
| 92 | + ecma_string_to_zt_string (str_p, zt_str_p, zt_str_size); |
90 | 93 |
|
91 | 94 | #if CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII |
92 | | - printf ("%s\n", (char*) zt_str_p); |
| 95 | + if (arg_index < args_read - 1) |
| 96 | + { |
| 97 | + printf ("%s ", (char*) zt_str_p); |
| 98 | + } |
| 99 | + else |
| 100 | + { |
| 101 | + printf ("%s", (char*) zt_str_p); |
| 102 | + } |
93 | 103 | #elif CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 |
94 | | - JERRY_UNIMPLEMENTED ("UTF-16 support is not implemented."); |
| 104 | + JERRY_UNIMPLEMENTED ("UTF-16 support is not implemented."); |
95 | 105 | #endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 */ |
96 | 106 |
|
97 | | - mem_heap_free_block (zt_str_p); |
98 | | - |
99 | | - ret_value = ecma_make_empty_completion_value (); |
| 107 | + mem_heap_free_block (zt_str_p); |
100 | 108 |
|
101 | | - ECMA_FINALIZE (str_value); |
| 109 | + ret_value = ecma_make_empty_completion_value (); |
102 | 110 |
|
| 111 | + ECMA_FINALIZE (str_value); |
| 112 | + } |
| 113 | + printf ("\n"); |
103 | 114 | break; |
104 | 115 | } |
105 | 116 |
|
|
0 commit comments