From: <rly...@us...> - 2010-11-26 19:13:17
|
Revision: 6452 http://planeshift.svn.sourceforge.net/planeshift/?rev=6452&view=rev Author: rlydontknow Date: 2010-11-26 19:13:10 +0000 (Fri, 26 Nov 2010) Log Message: ----------- removed MathExpression's UID member as it's only needed for parsing instead used size_t stringCount in MathExpression's Parse function disabled fparser's optimization if constant string literals are used to work around wrong optimizations if multiple NaNs are encountered and can be recognized as such by fparser Modified Paths: -------------- trunk/src/common/util/mathscript.cpp trunk/src/common/util/mathscript.h Modified: trunk/src/common/util/mathscript.cpp =================================================================== --- trunk/src/common/util/mathscript.cpp 2010-11-26 14:35:44 UTC (rev 6451) +++ trunk/src/common/util/mathscript.cpp 2010-11-26 19:13:10 UTC (rev 6452) @@ -749,7 +749,7 @@ //---------------------------------------------------------------------------- -MathExpression::MathExpression() : opcode(MATH_EXP),UID(0) +MathExpression::MathExpression() : opcode(MATH_EXP) { fp.AddFunction("rnd", MathScriptEngine::RandomGen, 1); @@ -859,6 +859,11 @@ //for (size_t i = 0; i < tokens.GetSize(); i++) // printf("Token[%d] = %s\n", int(i), tokens[i].GetDataSafe()); + // used to assign UIDs to string literals and to disable optimizations + // if string literals are used to prevent them from being optimized out + // due to their NaN value + size_t stringCount = 0; + // PARSER: (kind of) for (size_t i = 0; i < tokens.GetSize(); i++) { @@ -939,7 +944,7 @@ // build placeholder token csString placeholder("string"); - placeholder.Append(++UID); + placeholder.Append(++stringCount); // add the placeholder token as constant so we can have an exact value // (i.e. different NaNs/Infs) @@ -1004,7 +1009,8 @@ return false; } - fp.Optimize(); + if(!stringCount) + fp.Optimize(); return true; } Modified: trunk/src/common/util/mathscript.h =================================================================== --- trunk/src/common/util/mathscript.h 2010-11-26 14:35:44 UTC (rev 6451) +++ trunk/src/common/util/mathscript.h 2010-11-26 19:13:10 UTC (rev 6452) @@ -345,7 +345,6 @@ csSet<csString> requiredObjs; ///< a subset of requiredVars which are known to be objects; for type checking csSet<PropertyRef> propertyRefs; ///< properties that have to be resolved prior to evaluation FunctionParser fp; - uint UID; const char *name; // used for debugging This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |