* Cast to bool. */
| 2375 | * Cast to bool. |
| 2376 | */ |
| 2377 | static MatchVal matchCastToBool(MatchVal val) |
| 2378 | { |
| 2379 | switch (val.type) |
| 2380 | { |
| 2381 | case MATCH_TYPE_UNDEFINED: |
| 2382 | val.type = MATCH_TYPE_INTEGER; |
| 2383 | val.i = false; |
| 2384 | case MATCH_TYPE_INTEGER: |
| 2385 | val.i = (val.i != 0); |
| 2386 | return val; |
| 2387 | default: |
| 2388 | std::string str; |
| 2389 | dumpVal(val, str); |
| 2390 | error("type error; failed to cast value `%s' to type Boolean", |
| 2391 | str.c_str()); |
| 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | /* |
| 2396 | * Evaluate a matching. |
no test coverage detected