MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / eval

Method eval

src/common/StateDatabase.cpp:300–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298
299
300float StateDatabase::eval(const std::string& name) {
301 static StringSet evalStack;
302
303 // avoid recursive evaluation
304 if (evalStack.find(name) != evalStack.end()) {
305 return getNaN();
306 }
307
308 EvalMap::const_iterator cit = evalCache.find(name);
309 if (cit != evalCache.end()) {
310 if (!evalStack.empty()) {
311 // add this item to its dependents' sets
312 ItemMap::iterator it = lookup(name);
313 addDependents(it, evalStack);
314 }
315 return cit->second;
316 }
317
318 StringSet::iterator myStackIt = evalStack.insert(name).first;
319
320 DEBUG_LOOKUPS(name);
321 ItemMap::iterator it = items.find(name);
322 if ((it == items.end()) ||
323 !it->second.isSet || it->second.value.empty()) {
324 evalStack.erase(myStackIt);
325 return getNaN();
326 }
327
328 Expression infix;
329 std::string input = it->second.value;
330 input >> infix;
331
332 Expression prefix = infixToPrefix(infix);
333 const float value = evaluate(prefix);
334 if (value != getNaN()) {
335 evalCache[name] = value;
336 }
337
338 evalStack.erase(myStackIt);
339
340 // add this item to its dependents' sets
341 addDependents(it, evalStack);
342
343 return value;
344}
345
346
347int StateDatabase::evalInt(const std::string& name) {

Callers 15

angularCallbackMethod · 0.80
radialCallbackMethod · 0.80
slideCallbackMethod · 0.80
computeMaxAngleVelocityFunction · 0.80
computeMaxLinVelocityFunction · 0.80
computeJumpVelocityFunction · 0.80
computeGroundLimitFunction · 0.80
evalFunction · 0.80
getGoodPosValueFunction · 0.80
getGoodNonZeroValueFunction · 0.80
getGameFPSFunction · 0.80

Calls 5

getNaNFunction · 0.85
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected