The ternary operator.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2037 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-02-28 22:55:07 +00:00
parent 8b960915b5
commit 7d09a3efdc
1 changed files with 20 additions and 0 deletions

View File

@ -4196,6 +4196,26 @@ QCC_def_t *QCC_PR_Expression (int priority)
qcc_usefulstatement=true;
return QCC_PR_ParseFunctionCall (e);
}
if (priority == 1 && QCC_PR_CheckToken ("?"))
{
QCC_dstatement32_t *fromj, *elsej;
QCC_PR_Statement(&pr_opcodes[OP_IFNOT], e, NULL, fromj);
e = QCC_PR_Expression(TOP_PRIORITY);
e2 = QCC_GetTemp(e->type);
QCC_PR_Statement(&pr_opcodes[(e2->size>=3)?OP_STORE_V:OP_STORE_F], e, e2);
QCC_PR_Expect(":");
QCC_PR_Statement(&pr_opcodes[OP_GOTO], NULL, NULL, elsej);
fromj->b = &statements[numstatements] - fromj;
e = QCC_PR_Expression(TOP_PRIORITY);
if (typecmp(e, e2) != 0)
QCC_PR_ParseError(0, "Ternary operator with mismatching types\n")
QCC_PR_Statement(&pr_opcodes[(e2->size>=3)?OP_STORE_V:OP_STORE_F], e, e2);
elsej->a = &statements[numstatements] - elsej;
return e2;
}
opnum=0;