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

Method eval

source/ast/builtins/ArrayMethods.cpp:599–621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597 }
598
599 ConstantValue eval(EvalContext& context, const Args& args, SourceRange,
600 const CallExpression::SystemCallInfo&) const final {
601 auto lval = args[0]->evalLValue(context);
602 if (!lval)
603 return nullptr;
604
605 if (args.size() > 1) {
606 auto index = args[1]->eval(context);
607 if (!index)
608 return nullptr;
609
610 auto target = lval.resolve();
611 if (target && target->isMap()) {
612 // Try to erase the element -- no warning if it doesn't exist.
613 target->map()->erase(index);
614 }
615 }
616 else {
617 // No argument means we should empty the array.
618 lval.store(args[0]->type->getDefaultValue());
619 }
620 return NullConstant;
621 }
622};
623
624class AssocArrayExistsMethod : public SystemSubroutine {

Callers

nothing calls this directly

Calls 7

evalLValueMethod · 0.80
storeMethod · 0.80
sizeMethod · 0.45
evalMethod · 0.45
resolveMethod · 0.45
eraseMethod · 0.45
getDefaultValueMethod · 0.45

Tested by

no test coverage detected