if statements

Changed:
if check on vals now return true if the value has a string value
%val = "test me" if(%val) will now return true since %val is not null

Script side:
string checks for "true" and "false" will now be parsed as integer values of 1 and 0.

TEST VIGOUROUSLY
This commit is contained in:
marauder2k7 2024-06-16 15:04:20 +01:00
parent 760c153232
commit e56f4cb6a6
5 changed files with 39 additions and 4 deletions

View file

@ -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)
{
ip = testExpr->compile(codeStream, ip, TypeReqString);
codeStream.emit(OP_JMPIFNOT);
}
else
{
ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat);
codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT);
}
if (elseBlock)
{