MCPcopy Create free account
hub / github.com/OpenMW/openmw / parseName

Method parseName

components/compiler/exprparser.cpp:282–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 11

lowerCaseFunction · 0.85
fetchLocalFunction · 0.85
fetchGlobalFunction · 0.85
warningMethod · 0.80
putbackNameMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
getTypeMethod · 0.45
getIndexMethod · 0.45
getGlobalTypeMethod · 0.45
isIdMethod · 0.45

Tested by

no test coverage detected