| 153 | {&builtins.intType, &builtins.intType}, builtins.stringType, true) {} |
| 154 | |
| 155 | ConstantValue eval(EvalContext& context, const Args& args, SourceRange, |
| 156 | const CallExpression::SystemCallInfo&) const final { |
| 157 | auto strCv = args[0]->eval(context); |
| 158 | auto leftCv = args[1]->eval(context); |
| 159 | auto rightCv = args[2]->eval(context); |
| 160 | if (!strCv || !leftCv || !rightCv) |
| 161 | return nullptr; |
| 162 | |
| 163 | const std::string& str = strCv.str(); |
| 164 | int32_t left = leftCv.integer().as<int32_t>().value(); |
| 165 | int32_t right = rightCv.integer().as<int32_t>().value(); |
| 166 | if (left < 0 || right < left || size_t(right) >= str.length()) |
| 167 | return ""s; |
| 168 | |
| 169 | int32_t count = right - left + 1; |
| 170 | return str.substr(size_t(left), size_t(count)); |
| 171 | } |
| 172 | }; |
| 173 | |
| 174 | class StringAtoIMethod : public SimpleSystemSubroutine { |