mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Implementing opfunc_addition with a string-operand.
This commit is contained in:
parent
c72555d25f
commit
38fdcba69c
@ -128,7 +128,20 @@ opfunc_addition (opcode_t opdata, /**< operation data */
|
||||
if (prim_left_value.value.value_type == ECMA_TYPE_STRING
|
||||
|| prim_right_value.value.value_type == ECMA_TYPE_STRING)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED ();
|
||||
ECMA_TRY_CATCH (str_left_value, ecma_op_to_string (prim_left_value.value), ret_value);
|
||||
ECMA_TRY_CATCH (str_right_value, ecma_op_to_string (prim_right_value.value), ret_value);
|
||||
|
||||
ecma_string_t *string1_p = ECMA_GET_POINTER (str_left_value.value.value);
|
||||
ecma_string_t *string2_p = ECMA_GET_POINTER (str_right_value.value.value);
|
||||
|
||||
ecma_string_t *concat_str_p = ecma_concat_ecma_strings (string1_p, string2_p);
|
||||
|
||||
ret_value = set_variable_value (int_data, dst_var_idx, ecma_make_string_value (concat_str_p));
|
||||
|
||||
ecma_deref_ecma_string (concat_str_p);
|
||||
|
||||
ECMA_FINALIZE (str_right_value);
|
||||
ECMA_FINALIZE (str_left_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
18
tests/jerry/string.js
Normal file
18
tests/jerry/string.js
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
//
|
||||
// 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.
|
||||
|
||||
var a = 'abcd';
|
||||
var b = 'dfgh';
|
||||
|
||||
c = a + b;
|
||||
Loading…
x
Reference in New Issue
Block a user