| 280 | } |
| 281 | |
| 282 | bool ExprParser::parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner) |
| 283 | { |
| 284 | if (!mExplicit.empty()) |
| 285 | { |
| 286 | if (!mRefOp) |
| 287 | { |
| 288 | if (mMemberOp && handleMemberAccess(name)) |
| 289 | return true; |
| 290 | |
| 291 | return Parser::parseName(name, loc, scanner); |
| 292 | } |
| 293 | else |
| 294 | { |
| 295 | mExplicit.clear(); |
| 296 | getErrorHandler().warning("Stray explicit reference", loc); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | mFirst = false; |
| 301 | |
| 302 | if (mNextOperand) |
| 303 | { |
| 304 | start(); |
| 305 | |
| 306 | std::string name2 = Misc::StringUtils::lowerCase(name); |
| 307 | |
| 308 | char type = mLocals.getType(name2); |
| 309 | |
| 310 | if (type != ' ') |
| 311 | { |
| 312 | Generator::fetchLocal(mCode, type, mLocals.getIndex(name2)); |
| 313 | mNextOperand = false; |
| 314 | mOperands.push_back(type == 'f' ? 'f' : 'l'); |
| 315 | return true; |
| 316 | } |
| 317 | |
| 318 | type = getContext().getGlobalType(name2); |
| 319 | |
| 320 | if (type != ' ') |
| 321 | { |
| 322 | Generator::fetchGlobal(mCode, mLiterals, type, name2); |
| 323 | mNextOperand = false; |
| 324 | mOperands.push_back(type == 'f' ? 'f' : 'l'); |
| 325 | return true; |
| 326 | } |
| 327 | |
| 328 | if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name2))) |
| 329 | { |
| 330 | mExplicit = std::move(name2); |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | // This is terrible, but of course we must have this for legacy content. |
| 335 | // Convert the string to a number even if it's impossible and use it as a number literal. |
| 336 | // Can't use stof/atof or to_string out of locale concerns. |
| 337 | float number; |
| 338 | std::stringstream stream(name2); |
| 339 | stream >> number; |
nothing calls this directly
no test coverage detected