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

Method eval

source/ast/builtins/StringMethods.cpp:39–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 /* isFirstArgLValue */ true) {}
38
39 ConstantValue eval(EvalContext& context, const Args& args, SourceRange,
40 const CallExpression::SystemCallInfo&) const final {
41 auto strCv = args[0]->evalLValue(context);
42 auto indexCv = args[1]->eval(context);
43 auto charCv = args[2]->eval(context);
44 if (!strCv || !indexCv || !charCv)
45 return nullptr;
46
47 const std::string& str = strCv.load().str();
48 int32_t index = indexCv.integer().as<int32_t>().value();
49 uint8_t c = charCv.integer().as<uint8_t>().value();
50
51 if (c == 0 || index < 0 || size_t(index) >= str.length())
52 return NullConstant;
53
54 strCv.addIndex(index, nullptr);
55 strCv.store(SVInt(8, c, false));
56 return NullConstant;
57 }
58};
59
60class StringGetcMethod : public SimpleSystemSubroutine {

Callers

nothing calls this directly

Calls 8

SVIntFunction · 0.85
evalLValueMethod · 0.80
strMethod · 0.80
addIndexMethod · 0.80
storeMethod · 0.80
evalMethod · 0.45
loadMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected