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

Method eval

source/ast/builtins/ArrayMethods.cpp:738–760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736 }
737
738 ConstantValue eval(EvalContext& context, const Args& args, SourceRange,
739 const CallExpression::SystemCallInfo&) const final {
740 auto lval = args[0]->evalLValue(context);
741 if (!lval)
742 return nullptr;
743
744 auto target = lval.resolve();
745 SLANG_ASSERT(target && target->isQueue());
746
747 auto& q = *target->queue();
748 if (q.empty()) {
749 context.addDiag(diag::ConstEvalEmptyQueue, args[0]->sourceRange);
750 return args[0]->type->getArrayElementType()->getDefaultValue();
751 }
752
753 ConstantValue result = front ? std::move(q.front()) : std::move(q.back());
754 if (front)
755 q.pop_front();
756 else
757 q.pop_back();
758
759 return result;
760 }
761
762private:
763 bool front;

Callers 12

evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45
evalMethod · 0.45

Calls 8

evalLValueMethod · 0.80
getArrayElementTypeMethod · 0.80
frontMethod · 0.80
resolveMethod · 0.45
emptyMethod · 0.45
getDefaultValueMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected