MCPcopy Create free account
hub / github.com/MikePopoloski/slang / eval

Method eval

source/ast/builtins/ArrayMethods.cpp:856–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854 }
855
856 ConstantValue eval(EvalContext& context, const Args& args, SourceRange,
857 const CallExpression::SystemCallInfo&) const final {
858 auto lval = args[0]->evalLValue(context);
859 auto ci = args[1]->eval(context);
860 auto cv = args[2]->eval(context);
861 if (!lval || !ci || !cv)
862 return nullptr;
863
864 auto target = lval.resolve();
865 SLANG_ASSERT(target && target->isQueue());
866
867 auto& q = *target->queue();
868 std::optional<int32_t> index = ci.integer().as<int32_t>();
869 if (!index || *index < 0 || size_t(*index) >= q.size() + 1) {
870 context.addDiag(diag::ConstEvalDynamicArrayIndex, args[1]->sourceRange)
871 << ci << *args[0]->type << q.size() + 1;
872 return NullConstant;
873 }
874
875 q.insert(q.begin() + *index, std::move(cv));
876 q.resizeToBound();
877
878 if (!context.checkMaxValue(*target, args[0]->sourceRange))
879 return nullptr;
880
881 return NullConstant;
882 }
883};
884
885class QueueDeleteMethod : public SystemSubroutine {

Callers

nothing calls this directly

Calls 7

evalLValueMethod · 0.80
checkMaxValueMethod · 0.80
evalMethod · 0.45
resolveMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected