| 387 | } |
| 388 | |
| 389 | ConstantValue eval(EvalContext& context, const Args& args, SourceRange, |
| 390 | const CallExpression::SystemCallInfo& callInfo) const final { |
| 391 | ConstantValue arr = args[0]->eval(context); |
| 392 | if (!arr) |
| 393 | return nullptr; |
| 394 | |
| 395 | SVQueue result; |
| 396 | if (arr.empty()) |
| 397 | return result; |
| 398 | |
| 399 | auto [iterExpr, iterVar] = callInfo.getIteratorInfo(); |
| 400 | if (iterExpr) { |
| 401 | SLANG_ASSERT(iterVar); |
| 402 | |
| 403 | auto it = begin(arr); |
| 404 | auto guard = context.disableCaching(); |
| 405 | auto iterVal = context.createLocal(iterVar, *it); |
| 406 | ConstantValue elem = *it; |
| 407 | ConstantValue val = iterExpr->eval(context); |
| 408 | |
| 409 | for (++it; it != end(arr); ++it) { |
| 410 | *iterVal = *it; |
| 411 | auto cv = iterExpr->eval(context); |
| 412 | |
| 413 | if (isMin) { |
| 414 | if (cv < val) { |
| 415 | val = cv; |
| 416 | elem = *it; |
| 417 | } |
| 418 | } |
| 419 | else { |
| 420 | if (val < cv) { |
| 421 | val = cv; |
| 422 | elem = *it; |
| 423 | } |
| 424 | } |
| 425 | } |
| 426 | result.emplace_back(std::move(elem)); |
| 427 | } |
| 428 | else { |
| 429 | auto it = begin(arr); |
| 430 | ConstantValue elem = *it; |
| 431 | for (++it; it != end(arr); ++it) { |
| 432 | if (isMin) { |
| 433 | if (*it < elem) |
| 434 | elem = *it; |
| 435 | } |
| 436 | else { |
| 437 | if (elem < *it) |
| 438 | elem = *it; |
| 439 | } |
| 440 | } |
| 441 | result.emplace_back(std::move(elem)); |
| 442 | } |
| 443 | |
| 444 | return result; |
| 445 | } |
| 446 |
nothing calls this directly
no test coverage detected