| 901 | } |
| 902 | |
| 903 | ConstantValue eval(EvalContext& context, const Args& args, SourceRange, |
| 904 | const CallExpression::SystemCallInfo&) const final { |
| 905 | auto lval = args[0]->evalLValue(context); |
| 906 | if (!lval) |
| 907 | return nullptr; |
| 908 | |
| 909 | auto target = lval.resolve(); |
| 910 | SLANG_ASSERT(target && target->isQueue()); |
| 911 | auto& q = *target->queue(); |
| 912 | |
| 913 | // If no arguments, clear the queue. |
| 914 | if (args.size() == 1) { |
| 915 | q.clear(); |
| 916 | return NullConstant; |
| 917 | } |
| 918 | |
| 919 | auto ci = args[1]->eval(context); |
| 920 | std::optional<int32_t> index = ci.integer().as<int32_t>(); |
| 921 | if (!index || *index < 0 || size_t(*index) >= q.size()) { |
| 922 | context.addDiag(diag::ConstEvalDynamicArrayIndex, args[1]->sourceRange) |
| 923 | << ci << *args[0]->type << q.size(); |
| 924 | return NullConstant; |
| 925 | } |
| 926 | |
| 927 | q.erase(q.begin() + *index); |
| 928 | return NullConstant; |
| 929 | } |
| 930 | }; |
| 931 | |
| 932 | class IteratorIndexMethod : public SystemSubroutine { |