Return a list/string/map/path size. "RETURN size([1, 2, 3])" will return 3 TODO: when map and path are implemented, add their functionality */
| 374 | "RETURN size([1, 2, 3])" will return 3 |
| 375 | TODO: when map and path are implemented, add their functionality */ |
| 376 | SIValue AR_SIZE(SIValue *argv, int argc, void *private_data) { |
| 377 | ASSERT(argc == 1); |
| 378 | SIValue value = argv[0]; |
| 379 | switch(SI_TYPE(value)) { |
| 380 | case T_ARRAY: |
| 381 | return SI_LongVal(SIArray_Length(value)); |
| 382 | case T_STRING: |
| 383 | return SI_LongVal(str_length(value.stringval)); |
| 384 | case T_NULL: |
| 385 | return SI_NullVal(); |
| 386 | default: |
| 387 | ASSERT(false); |
| 388 | return SI_NullVal(); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /* Return the first member of a list. |
| 393 | "RETURN head([1, 2, 3])" will return 1 */ |
nothing calls this directly
no test coverage detected