mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
string comparison operators
This commit is contained in:
parent
7178824ee6
commit
275e74161b
5 changed files with 39 additions and 8 deletions
|
@ -129,6 +129,10 @@ typedef enum {
|
|||
OP_BITOR,
|
||||
|
||||
OP_ADD_S,
|
||||
OP_LE_S,
|
||||
OP_GE_S,
|
||||
OP_LT_S,
|
||||
OP_GT_S,
|
||||
} pr_opcode_e;
|
||||
|
||||
|
||||
|
|
|
@ -1159,6 +1159,10 @@ PR_LoadProgs (progs_t * pr, char *progsname)
|
|||
case OP_BITAND:
|
||||
case OP_BITOR:
|
||||
case OP_ADD_S:
|
||||
case OP_GE_S:
|
||||
case OP_LE_S:
|
||||
case OP_GT_S:
|
||||
case OP_LT_S:
|
||||
case OP_GE:
|
||||
case OP_LE:
|
||||
case OP_GT:
|
||||
|
|
|
@ -134,6 +134,10 @@ char *pr_opnames[] = {
|
|||
"BITOR",
|
||||
|
||||
"ADD_S",
|
||||
"LE_S",
|
||||
"GE_S",
|
||||
"LT_S",
|
||||
"GT_S",
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -485,11 +489,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
&& (E_OPA->vector[1] == E_OPB->vector[1])
|
||||
&& (E_OPA->vector[2] == E_OPB->vector[2]);
|
||||
break;
|
||||
case OP_EQ_S:
|
||||
E_OPC->_float =
|
||||
!strcmp (PR_GetString (pr, E_OPA->string),
|
||||
PR_GetString (pr, E_OPB->string));
|
||||
break;
|
||||
case OP_EQ_E:
|
||||
E_OPC->_float = E_OPA->_int == E_OPB->_int;
|
||||
break;
|
||||
|
@ -504,10 +503,25 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
|| (E_OPA->vector[1] != E_OPB->vector[1])
|
||||
|| (E_OPA->vector[2] != E_OPB->vector[2]);
|
||||
break;
|
||||
case OP_LE_S:
|
||||
case OP_GE_S:
|
||||
case OP_LT_S:
|
||||
case OP_GT_S:
|
||||
case OP_NE_S:
|
||||
E_OPC->_float =
|
||||
strcmp (PR_GetString (pr, E_OPA->string),
|
||||
PR_GetString (pr, E_OPB->string));
|
||||
case OP_EQ_S:
|
||||
{
|
||||
int cmp = strcmp (PR_GetString (pr, E_OPA->string),
|
||||
PR_GetString (pr, E_OPB->string));
|
||||
switch (st->op) {
|
||||
case OP_LE_S: cmp = (cmp <= 0); break;
|
||||
case OP_GE_S: cmp = (cmp >= 0); break;
|
||||
case OP_LT_S: cmp = (cmp < 0); break;
|
||||
case OP_GT_S: cmp = (cmp > 0); break;
|
||||
case OP_NE_S: break;
|
||||
case OP_EQ_S: cmp = !cmp; break;
|
||||
}
|
||||
E_OPC->_float = cmp;
|
||||
}
|
||||
break;
|
||||
case OP_NE_E:
|
||||
E_OPC->_float = E_OPA->_int != E_OPB->_int;
|
||||
|
|
|
@ -68,8 +68,12 @@ opcode_t pr_opcodes[] = {
|
|||
|
||||
{"<=", "LE", OP_LE, 4, false, &def_float, &def_float, &def_float},
|
||||
{">=", "GE", OP_GE, 4, false, &def_float, &def_float, &def_float},
|
||||
{"<=", "LE_S", OP_LE_S, 4, false, &def_string, &def_string, &def_float},
|
||||
{">=", "GE_S", OP_GE_S, 4, false, &def_string, &def_string, &def_float},
|
||||
{"<", "LT", OP_LT, 4, false, &def_float, &def_float, &def_float},
|
||||
{">", "GT", OP_GT, 4, false, &def_float, &def_float, &def_float},
|
||||
{"<", "LT_S", OP_LT_S, 4, false, &def_string, &def_string, &def_float},
|
||||
{">", "GT_S", OP_GT_S, 4, false, &def_string, &def_string, &def_float},
|
||||
|
||||
{".", "INDIRECT", OP_LOAD_F, 1, false, &def_entity, &def_field, &def_float},
|
||||
{".", "INDIRECT", OP_LOAD_V, 1, false, &def_entity, &def_field, &def_vector},
|
||||
|
|
|
@ -3,4 +3,9 @@ string world = "world";
|
|||
float () main =
|
||||
{
|
||||
print (hello + " " + world + "\n");
|
||||
if (hello < world)
|
||||
print (hello);
|
||||
if (world > hello)
|
||||
print (world);
|
||||
print ("\n");
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue