implement comparisons and not for pointers

This commit is contained in:
Bill Currie 2002-01-30 21:20:12 +00:00
parent e1abe4c44b
commit 6d63d1d55b
3 changed files with 36 additions and 12 deletions

View file

@ -84,10 +84,10 @@ typedef enum {
OP_NE_E,
OP_NE_FNC,
OP_LE,
OP_GE,
OP_LT,
OP_GT,
OP_LE_F,
OP_GE_F,
OP_LT_F,
OP_GT_F,
OP_LOAD_F,
OP_LOAD_V,
@ -243,6 +243,13 @@ typedef enum {
OP_LOAD_P,
OP_STORE_P,
OP_STOREP_P,
OP_NOT_P,
OP_EQ_P,
OP_NE_P,
OP_LE_P,
OP_GE_P,
OP_LT_P,
OP_GT_P,
} pr_opcode_e;
typedef struct

View file

@ -363,16 +363,16 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
case OP_SHR_I:
OPC.integer_var = OPA.integer_var >> OPB.integer_var;
break;
case OP_GE:
case OP_GE_F:
OPC.float_var = OPA.float_var >= OPB.float_var;
break;
case OP_LE:
case OP_LE_F:
OPC.float_var = OPA.float_var <= OPB.float_var;
break;
case OP_GT:
case OP_GT_F:
OPC.float_var = OPA.float_var > OPB.float_var;
break;
case OP_LT:
case OP_LT_F:
OPC.float_var = OPA.float_var < OPB.float_var;
break;
case OP_AND: // OPA and OPB have to be float for -0.0
@ -785,15 +785,19 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
break;
case OP_GE_I:
case OP_GE_P:
OPC.integer_var = OPA.integer_var >= OPB.integer_var;
break;
case OP_LE_I:
case OP_LE_P:
OPC.integer_var = OPA.integer_var <= OPB.integer_var;
break;
case OP_GT_I:
case OP_GT_P:
OPC.integer_var = OPA.integer_var > OPB.integer_var;
break;
case OP_LT_I:
case OP_LT_P:
OPC.integer_var = OPA.uinteger_var < OPB.uinteger_var;
break;
case OP_GE_UI:
@ -816,12 +820,15 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
OPC.integer_var = OPA.integer_var || OPB.integer_var;
break;
case OP_NOT_I:
case OP_NOT_P:
OPC.integer_var = !OPA.integer_var;
break;
case OP_EQ_I:
case OP_EQ_P:
OPC.integer_var = OPA.integer_var == OPB.integer_var;
break;
case OP_NE_I:
case OP_NE_P:
OPC.integer_var = OPA.integer_var != OPB.integer_var;
break;

View file

@ -76,12 +76,12 @@ opcode_t pr_opcodes[] = {
{"!=", "ne.e", OP_NE_E, false, ev_entity, ev_entity, ev_integer, PROG_ID_VERSION},
{"!=", "ne.fnc", OP_NE_FNC, false, ev_func, ev_func, ev_integer, PROG_ID_VERSION},
{"<=", "le.f", OP_LE, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{">=", "ge.f", OP_GE, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{"<=", "le.f", OP_LE_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{">=", "ge.f", OP_GE_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{"<=", "le.s", OP_LE_S, false, ev_string, ev_string, ev_integer, PROG_VERSION},
{">=", "ge.s", OP_GE_S, false, ev_string, ev_string, ev_integer, PROG_VERSION},
{"<", "lt.f", OP_LT, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{">", "gt.f", OP_GT, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{"<", "lt.f", OP_LT_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{">", "gt.f", OP_GT_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
{"<", "lt.s", OP_LT_S, false, ev_string, ev_string, ev_integer, PROG_VERSION},
{">", "gt.s", OP_GT_S, false, ev_string, ev_string, ev_integer, PROG_VERSION},
@ -173,6 +173,7 @@ opcode_t pr_opcodes[] = {
{"!", "not.s", OP_NOT_S, false, ev_string, ev_void, ev_integer, PROG_ID_VERSION},
{"!", "not.ent", OP_NOT_ENT, false, ev_entity, ev_void, ev_integer, PROG_ID_VERSION},
{"!", "not.fnc", OP_NOT_FNC, false, ev_func, ev_void, ev_integer, PROG_ID_VERSION},
{"!", "not.p", OP_NOT_P, false, ev_pointer, ev_void, ev_integer, PROG_VERSION},
{"<IF>", "if", OP_IF, false, ev_integer, ev_void, ev_void, PROG_ID_VERSION},
{"<IFNOT>", "ifnot", OP_IFNOT, false, ev_integer, ev_void, ev_void, PROG_ID_VERSION},
@ -238,6 +239,15 @@ opcode_t pr_opcodes[] = {
{"~", "bitnot.f", OP_BITNOT_F, false, ev_float, ev_void, ev_float, PROG_VERSION},
{"^", "bitxor.i", OP_BITXOR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
{"~", "bitnot.i", OP_BITNOT_I, false, ev_integer, ev_void, ev_integer, PROG_VERSION},
{">=", "ge.p", OP_GE_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
{"<=", "le.p", OP_LE_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
{">", "gt.p", OP_GT_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
{"<", "lt.p", OP_LT_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
{"==", "eq.p", OP_EQ_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
{"!=", "ne.p", OP_NE_P, false, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
// end of table
{0},
};