assumption: either a or b is a list - static function, the caller validate types
| 448 | |
| 449 | // assumption: either a or b is a list - static function, the caller validate types |
| 450 | static SIValue SIValue_ConcatList(const SIValue a, const SIValue b) { |
| 451 | uint a_len = (a.type == T_ARRAY) ? SIArray_Length(a) : 1; |
| 452 | uint b_len = (b.type == T_ARRAY) ? SIArray_Length(b) : 1; |
| 453 | SIValue resultArray = SI_Array(a_len + b_len); |
| 454 | |
| 455 | // Append a to resultArray |
| 456 | if(a.type == T_ARRAY) { |
| 457 | // in thae case of a is an array |
| 458 | for(uint i = 0; i < a_len; i++) SIArray_Append(&resultArray, SIArray_Get(a, i)); |
| 459 | } else { |
| 460 | // in thae case of a is not an array |
| 461 | SIArray_Append(&resultArray, a); |
| 462 | } |
| 463 | |
| 464 | if(b.type == T_ARRAY) { |
| 465 | // b is an array |
| 466 | uint bArrayLen = SIArray_Length(b); |
| 467 | for(uint i = 0; i < bArrayLen; i++) { |
| 468 | SIArray_Append(&resultArray, SIArray_Get(b, i)); |
| 469 | } |
| 470 | } else { |
| 471 | // b is not an array |
| 472 | SIArray_Append(&resultArray, b); |
| 473 | } |
| 474 | return resultArray; |
| 475 | } |
| 476 | |
| 477 | SIValue SIValue_Add(const SIValue a, const SIValue b) { |
| 478 | if(a.type == T_NULL || b.type == T_NULL) return SI_NullVal(); |
no test coverage detected