MCPcopy Create free account
hub / github.com/GJDuck/e9patch / matchCastToBool

Function matchCastToBool

src/e9tool/e9action.cpp:2377–2393  ·  view source on GitHub ↗

* Cast to bool. */

Source from the content-addressed store, hash-verified

2375 * Cast to bool.
2376 */
2377static 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.

Callers 2

matchDoEvalFunction · 0.85
matchEvalFunction · 0.85

Calls 2

dumpValFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected