mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #1289 from marauder2k9-torque/script-bug-ifstatmt-
if statements
This commit is contained in:
commit
62f3b93ff9
|
|
@ -246,6 +246,7 @@ public:
|
|||
return s == StringTable->EmptyString() ? 0 : dAtoi(s);
|
||||
if (type == ConsoleValueType::cvString)
|
||||
return dStrcmp(s, "") == 0 ? 0 : dAtoi(s);
|
||||
|
||||
return dAtoi(getConsoleData());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,9 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
|
|||
U32 endifIp, elseIp;
|
||||
addBreakLine(codeStream);
|
||||
|
||||
if (testExpr->getPreferredType() == TypeReqUInt)
|
||||
TypeReq testType = testExpr->getPreferredType();
|
||||
|
||||
if (testType == TypeReqUInt)
|
||||
{
|
||||
integer = true;
|
||||
}
|
||||
|
|
@ -209,8 +211,16 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
|
|||
integer = false;
|
||||
}
|
||||
|
||||
ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat);
|
||||
codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT);
|
||||
if (testType == TypeReqString || testType == TypeReqNone)
|
||||
{
|
||||
ip = testExpr->compile(codeStream, ip, TypeReqString);
|
||||
codeStream.emit(OP_JMPNOTSTRING);
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat);
|
||||
codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT);
|
||||
}
|
||||
|
||||
if (elseBlock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1144,6 +1144,15 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
|
|||
ip++;
|
||||
break;
|
||||
}
|
||||
|
||||
ip = code[ip];
|
||||
break;
|
||||
case OP_JMPNOTSTRING:
|
||||
if (stack[_STK--].getBool())
|
||||
{
|
||||
ip++;
|
||||
break;
|
||||
}
|
||||
ip = code[ip];
|
||||
break;
|
||||
case OP_JMPIFF:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ namespace Compiler
|
|||
|
||||
OP_JMPIFFNOT,
|
||||
OP_JMPIFNOT,
|
||||
OP_JMPNOTSTRING,
|
||||
OP_JMPIFF,
|
||||
OP_JMPIF,
|
||||
OP_JMPIFNOT_NP,
|
||||
|
|
|
|||
|
|
@ -259,9 +259,23 @@ extern S32 dStrcmp(const UTF16 *str1, const UTF16 *str2);
|
|||
extern S32 dStrnatcmp( const char* str1, const char* str2 );
|
||||
extern S32 dStrnatcasecmp( const char* str1, const char* str2 );
|
||||
|
||||
inline bool dAtob(const char *str)
|
||||
inline bool dAtob(const char* str)
|
||||
{
|
||||
return !dStricmp(str, "true") || dAtof(str);
|
||||
if (str && str[0] != '\0')
|
||||
{
|
||||
if (dStricmp(str, "0") == 0)
|
||||
return false;
|
||||
if (dStricmp(str, "0.0") == 0)
|
||||
return false;
|
||||
if (dStricmp(str, "0.0f") == 0)
|
||||
return false;
|
||||
if (dStricmp(str, "null") == 0)
|
||||
return false;
|
||||
if (dStricmp(str, "false") == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dStrEqual(const char* str1, const char* str2);
|
||||
|
|
|
|||
Loading…
Reference in a new issue