mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
immidiate indexed pointer access and some whitespace + reorg
This commit is contained in:
parent
d222f25f0b
commit
028f8a116d
4 changed files with 163 additions and 72 deletions
|
@ -38,12 +38,13 @@ typedef enum {
|
|||
ev_quaternion,
|
||||
ev_integer,
|
||||
ev_uinteger,
|
||||
ev_short, // value is embedded in the opcode
|
||||
|
||||
ev_type_count // not a type, gives number of types
|
||||
} etype_t;
|
||||
|
||||
extern int pr_type_size[ev_type_count];
|
||||
|
||||
extern const char *type_name[ev_type_count];
|
||||
|
||||
#define OFS_NULL 0
|
||||
#define OFS_RETURN 1
|
||||
|
@ -217,6 +218,24 @@ typedef enum {
|
|||
OP_GT_UI,
|
||||
OP_LE_UI,
|
||||
OP_GE_UI,
|
||||
|
||||
OP_LOADBI_F,
|
||||
OP_LOADBI_V,
|
||||
OP_LOADBI_S,
|
||||
OP_LOADBI_ENT,
|
||||
OP_LOADBI_FLD,
|
||||
OP_LOADBI_FNC,
|
||||
OP_LOADBI_I,
|
||||
OP_LOADBI_P,
|
||||
|
||||
OP_STOREBI_F,
|
||||
OP_STOREBI_V,
|
||||
OP_STOREBI_S,
|
||||
OP_STOREBI_ENT,
|
||||
OP_STOREBI_FLD,
|
||||
OP_STOREBI_FNC,
|
||||
OP_STOREBI_I,
|
||||
OP_STOREBI_P,
|
||||
} pr_opcode_e;
|
||||
|
||||
typedef struct
|
||||
|
@ -230,7 +249,6 @@ typedef struct
|
|||
} opcode_t;
|
||||
|
||||
extern opcode_t pr_opcodes[];
|
||||
extern const char *type_name[ev_type_count];
|
||||
opcode_t *PR_Opcode (short opcode);
|
||||
void PR_Opcode_Init (void);
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ int pr_type_size[ev_type_count] = {
|
|||
4,
|
||||
1,
|
||||
1,
|
||||
0, // value in opcode
|
||||
};
|
||||
|
||||
const char *type_name[ev_type_count] = {
|
||||
|
@ -82,6 +83,7 @@ const char *type_name[ev_type_count] = {
|
|||
"quaternion",
|
||||
"integer",
|
||||
"uinteger",
|
||||
"short",
|
||||
};
|
||||
|
||||
ddef_t *ED_FieldAtOfs (progs_t * pr, int ofs);
|
||||
|
@ -476,6 +478,10 @@ PR_GlobalString (progs_t * pr, int ofs, etype_t type)
|
|||
void *val;
|
||||
static char line[128];
|
||||
|
||||
if (type == ev_short) {
|
||||
snprintf (line, sizeof (line), "%-20d", (short) ofs);
|
||||
return line;
|
||||
}
|
||||
if (pr_debug->int_val && pr->debug)
|
||||
def = PR_Get_Local_Def (pr, ofs);
|
||||
val = (void *) &pr->pr_globals[ofs];
|
||||
|
|
|
@ -574,6 +574,25 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
VectorCopy (ptr->vector_var, OPC.vector_var);
|
||||
break;
|
||||
|
||||
case OP_LOADBI_F:
|
||||
case OP_LOADBI_S:
|
||||
case OP_LOADBI_ENT:
|
||||
case OP_LOADBI_FLD:
|
||||
case OP_LOADBI_FNC:
|
||||
case OP_LOADBI_I:
|
||||
case OP_LOADBI_P:
|
||||
//FIXME put bounds checking in
|
||||
pointer = OPA.integer_var + (short) st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
OPC.integer_var = ptr->integer_var;
|
||||
break;
|
||||
case OP_LOADBI_V:
|
||||
//FIXME put bounds checking in
|
||||
pointer = OPA.integer_var + (short) st->b;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (ptr->vector_var, OPC.vector_var);
|
||||
break;
|
||||
|
||||
case OP_LEA:
|
||||
pointer = OPA.integer_var + OPB.integer_var;
|
||||
OPC.integer_var = pointer;
|
||||
|
@ -598,6 +617,25 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
VectorCopy (OPA.vector_var, ptr->vector_var);
|
||||
break;
|
||||
|
||||
case OP_STOREBI_F:
|
||||
case OP_STOREBI_S:
|
||||
case OP_STOREBI_ENT:
|
||||
case OP_STOREBI_FLD:
|
||||
case OP_STOREBI_FNC:
|
||||
case OP_STOREBI_I:
|
||||
case OP_STOREBI_P:
|
||||
//FIXME put bounds checking in
|
||||
pointer = OPB.integer_var + (short) st->c;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
ptr->integer_var = OPA.integer_var;
|
||||
break;
|
||||
case OP_STOREBI_V:
|
||||
//FIXME put bounds checking in
|
||||
pointer = OPB.integer_var + (short) st->c;
|
||||
ptr = pr->pr_globals + pointer;
|
||||
VectorCopy (OPA.vector_var, ptr->vector_var);
|
||||
break;
|
||||
|
||||
// ==================
|
||||
case OP_IFNOT:
|
||||
if (!OPA.integer_var)
|
||||
|
|
|
@ -49,8 +49,8 @@ hashtab_t *opcode_table;
|
|||
opcode_t pr_opcodes[] = {
|
||||
{"<DONE>", "done", OP_DONE, false, ev_entity, ev_field, ev_void, PROG_ID_VERSION},
|
||||
|
||||
{"*", "mul.f", OP_MUL_F, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
{"*", "mul.v", OP_MUL_V, false, ev_vector, ev_vector, ev_float, PROG_ID_VERSION},
|
||||
{"*", "mul.f", OP_MUL_F, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
{"*", "mul.v", OP_MUL_V, false, ev_vector, ev_vector, ev_float, PROG_ID_VERSION},
|
||||
{"*", "mul.fv", OP_MUL_FV, false, ev_float, ev_vector, ev_vector, PROG_ID_VERSION},
|
||||
{"*", "mul.vf", OP_MUL_VF, false, ev_vector, ev_float, ev_vector, PROG_ID_VERSION},
|
||||
|
||||
|
@ -63,93 +63,114 @@ opcode_t pr_opcodes[] = {
|
|||
{"-", "sub.f", OP_SUB_F, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
{"-", "sub.v", OP_SUB_V, false, ev_vector, ev_vector, ev_vector, PROG_ID_VERSION},
|
||||
|
||||
{"==", "eq.f", OP_EQ_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.v", OP_EQ_V, false, ev_vector, ev_vector, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.s", OP_EQ_S, false, ev_string, ev_string, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.e", OP_EQ_E, false, ev_entity, ev_entity, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.f", OP_EQ_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.v", OP_EQ_V, false, ev_vector, ev_vector, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.s", OP_EQ_S, false, ev_string, ev_string, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.e", OP_EQ_E, false, ev_entity, ev_entity, ev_integer, PROG_ID_VERSION},
|
||||
{"==", "eq.fnc", OP_EQ_FNC, false, ev_func, ev_func, ev_integer, PROG_ID_VERSION},
|
||||
|
||||
{"!=", "ne.f", OP_NE_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.v", OP_NE_V, false, ev_vector, ev_vector, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.s", OP_NE_S, false, ev_string, ev_string, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.e", OP_NE_E, false, ev_entity, ev_entity, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.f", OP_NE_F, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.v", OP_NE_V, false, ev_vector, ev_vector, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "ne.s", OP_NE_S, false, ev_string, ev_string, ev_integer, PROG_ID_VERSION},
|
||||
{"!=", "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, 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.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.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},
|
||||
{"<", "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.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},
|
||||
|
||||
{".", "load.f", OP_LOAD_F, false, ev_entity, ev_field, ev_float, PROG_ID_VERSION},
|
||||
{".", "load.v", OP_LOAD_V, false, ev_entity, ev_field, ev_vector, PROG_ID_VERSION},
|
||||
{".", "load.s", OP_LOAD_S, false, ev_entity, ev_field, ev_string, PROG_ID_VERSION},
|
||||
{".", "load.f", OP_LOAD_F, false, ev_entity, ev_field, ev_float, PROG_ID_VERSION},
|
||||
{".", "load.v", OP_LOAD_V, false, ev_entity, ev_field, ev_vector, PROG_ID_VERSION},
|
||||
{".", "load.s", OP_LOAD_S, false, ev_entity, ev_field, ev_string, PROG_ID_VERSION},
|
||||
{".", "load.ent", OP_LOAD_ENT, false, ev_entity, ev_field, ev_entity, PROG_ID_VERSION},
|
||||
{".", "load.fld", OP_LOAD_FLD, false, ev_entity, ev_field, ev_field, PROG_ID_VERSION},
|
||||
{".", "load.fnc", OP_LOAD_FNC, false, ev_entity, ev_field, ev_func, PROG_ID_VERSION},
|
||||
{".", "load.i", OP_LOAD_I, false, ev_entity, ev_field, ev_integer, PROG_VERSION},
|
||||
|
||||
{".", "loadb.f", OP_LOADB_F, false, ev_pointer, ev_integer, ev_float, PROG_VERSION},
|
||||
{".", "loadb.v", OP_LOADB_V, false, ev_pointer, ev_integer, ev_vector, PROG_VERSION},
|
||||
{".", "loadb.s", OP_LOADB_S, false, ev_pointer, ev_integer, ev_string, PROG_VERSION},
|
||||
{".", "loadb.f", OP_LOADB_F, false, ev_pointer, ev_integer, ev_float, PROG_VERSION},
|
||||
{".", "loadb.v", OP_LOADB_V, false, ev_pointer, ev_integer, ev_vector, PROG_VERSION},
|
||||
{".", "loadb.s", OP_LOADB_S, false, ev_pointer, ev_integer, ev_string, PROG_VERSION},
|
||||
{".", "loadb.ent", OP_LOADB_ENT, false, ev_pointer, ev_integer, ev_entity, PROG_VERSION},
|
||||
{".", "loadb.fld", OP_LOADB_FLD, false, ev_pointer, ev_integer, ev_field, PROG_VERSION},
|
||||
{".", "loadb.fnc", OP_LOADB_FNC, false, ev_pointer, ev_integer, ev_func, PROG_VERSION},
|
||||
{".", "loadb.i", OP_LOADB_I, false, ev_pointer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{".", "loadb.p", OP_LOADB_P, false, ev_pointer, ev_integer, ev_pointer, PROG_VERSION},
|
||||
{".", "loadb.i", OP_LOADB_I, false, ev_pointer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{".", "loadb.p", OP_LOADB_P, false, ev_pointer, ev_integer, ev_pointer, PROG_VERSION},
|
||||
|
||||
{".", "loadbi.f", OP_LOADBI_F, false, ev_pointer, ev_short, ev_float, PROG_VERSION},
|
||||
{".", "loadbi.v", OP_LOADBI_V, false, ev_pointer, ev_short, ev_vector, PROG_VERSION},
|
||||
{".", "loadbi.s", OP_LOADBI_S, false, ev_pointer, ev_short, ev_string, PROG_VERSION},
|
||||
{".", "loadbi.ent", OP_LOADBI_ENT, false, ev_pointer, ev_short, ev_entity, PROG_VERSION},
|
||||
{".", "loadbi.fld", OP_LOADBI_FLD, false, ev_pointer, ev_short, ev_field, PROG_VERSION},
|
||||
{".", "loadbi.fnc", OP_LOADBI_FNC, false, ev_pointer, ev_short, ev_func, PROG_VERSION},
|
||||
{".", "loadbi.i", OP_LOADBI_I, false, ev_pointer, ev_short, ev_integer, PROG_VERSION},
|
||||
{".", "loadbi.p", OP_LOADBI_P, false, ev_pointer, ev_short, ev_pointer, PROG_VERSION},
|
||||
|
||||
{".", "address", OP_ADDRESS, false, ev_entity, ev_field, ev_pointer, PROG_ID_VERSION},
|
||||
|
||||
{"&", "address.f", OP_ADDRESS_F, false, ev_float, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.v", OP_ADDRESS_V, false, ev_vector, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.s", OP_ADDRESS_S, false, ev_string, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.f", OP_ADDRESS_F, false, ev_float, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.v", OP_ADDRESS_V, false, ev_vector, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.s", OP_ADDRESS_S, false, ev_string, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.ent", OP_ADDRESS_ENT, false, ev_entity, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.fld", OP_ADDRESS_FLD, false, ev_field, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.fnc", OP_ADDRESS_FNC, false, ev_func, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.i", OP_ADDRESS_I, false, ev_integer, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.p", OP_ADDRESS_P, false, ev_pointer, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.i", OP_ADDRESS_I, false, ev_integer, ev_void, ev_pointer, PROG_VERSION},
|
||||
{"&", "address.p", OP_ADDRESS_P, false, ev_pointer, ev_void, ev_pointer, PROG_VERSION},
|
||||
|
||||
{"&", "lea", OP_LEA, false, ev_pointer, ev_integer, ev_pointer, PROG_VERSION},
|
||||
|
||||
{"=", "store.f", OP_STORE_F, true, ev_float, ev_float, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.v", OP_STORE_V, true, ev_vector, ev_vector, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.s", OP_STORE_S, true, ev_string, ev_string, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.f", OP_STORE_F, true, ev_float, ev_float, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.v", OP_STORE_V, true, ev_vector, ev_vector, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.s", OP_STORE_S, true, ev_string, ev_string, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.ent", OP_STORE_ENT, true, ev_entity, ev_entity, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.fld", OP_STORE_FLD, true, ev_field, ev_field, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.fnc", OP_STORE_FNC, true, ev_func, ev_func, ev_void, PROG_ID_VERSION},
|
||||
{"=", "store.i", OP_STORE_I, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
|
||||
{"=", "storep.f", OP_STOREP_F, true, ev_float, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.v", OP_STOREP_V, true, ev_vector, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.s", OP_STOREP_S, true, ev_string, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.f", OP_STOREP_F, true, ev_float, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.v", OP_STOREP_V, true, ev_vector, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.s", OP_STOREP_S, true, ev_string, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.ent", OP_STOREP_ENT, true, ev_entity, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.fld", OP_STOREP_FLD, true, ev_field, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.fnc", OP_STOREP_FNC, true, ev_func, ev_pointer, ev_void, PROG_ID_VERSION},
|
||||
{"=", "storep.i", OP_STOREP_I, true, ev_integer, ev_pointer, ev_void, PROG_VERSION},
|
||||
|
||||
{"=", "storeb.f", OP_STOREB_F, true, ev_float, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.v", OP_STOREB_V, true, ev_vector, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.s", OP_STOREB_S, true, ev_string, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.f", OP_STOREB_F, true, ev_float, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.v", OP_STOREB_V, true, ev_vector, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.s", OP_STOREB_S, true, ev_string, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.ent", OP_STOREB_ENT, true, ev_entity, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.fld", OP_STOREB_FLD, true, ev_field, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.fnc", OP_STOREB_FNC, true, ev_func, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.i", OP_STOREB_I, true, ev_integer, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.p", OP_STOREB_P, true, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.i", OP_STOREB_I, true, ev_integer, ev_pointer, ev_integer, PROG_VERSION},
|
||||
{"=", "storeb.p", OP_STOREB_P, true, ev_pointer, ev_pointer, ev_integer, PROG_VERSION},
|
||||
|
||||
{"=", "storebi.f", OP_STOREBI_F, true, ev_float, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.v", OP_STOREBI_V, true, ev_vector, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.s", OP_STOREBI_S, true, ev_string, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.ent", OP_STOREBI_ENT, true, ev_entity, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.fld", OP_STOREBI_FLD, true, ev_field, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.fnc", OP_STOREBI_FNC, true, ev_func, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.i", OP_STOREBI_I, true, ev_integer, ev_pointer, ev_short, PROG_VERSION},
|
||||
{"=", "storebi.p", OP_STOREBI_P, true, ev_pointer, ev_pointer, ev_short, PROG_VERSION},
|
||||
|
||||
{"<RETURN>", "return", OP_RETURN, false, ev_void, ev_void, ev_void, PROG_ID_VERSION},
|
||||
|
||||
{"!", "not.f", OP_NOT_F, false, ev_float, ev_void, ev_integer, PROG_ID_VERSION},
|
||||
{"!", "not.v", OP_NOT_V, false, ev_vector, ev_void, ev_integer, PROG_ID_VERSION},
|
||||
{"!", "not.s", OP_NOT_S, false, ev_string, ev_void, ev_integer, PROG_ID_VERSION},
|
||||
{"!", "not.f", OP_NOT_F, false, ev_float, ev_void, ev_integer, PROG_ID_VERSION},
|
||||
{"!", "not.v", OP_NOT_V, false, ev_vector, ev_void, ev_integer, PROG_ID_VERSION},
|
||||
{"!", "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},
|
||||
|
||||
{"<IF>", "if", OP_IF, false, ev_integer, ev_void, ev_void, PROG_ID_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},
|
||||
{"<IFBE>", "ifbe", OP_IFBE, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFB>", "ifb", OP_IFB, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFAE>", "ifae", OP_IFAE, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFA>", "ifa", OP_IFA, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFBE>", "ifbe", OP_IFBE, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFB>", "ifb", OP_IFB, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFAE>", "ifae", OP_IFAE, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"<IFA>", "ifa", OP_IFA, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
|
||||
// calls returns REG_RETURN
|
||||
{"<CALL0>", "call0", OP_CALL0, false, ev_func, ev_void, ev_void, PROG_ID_VERSION},
|
||||
|
@ -164,12 +185,12 @@ opcode_t pr_opcodes[] = {
|
|||
|
||||
{"<STATE>", "state", OP_STATE, false, ev_float, ev_float, ev_void, PROG_ID_VERSION},
|
||||
|
||||
{"<GOTO>", "goto", OP_GOTO, false, ev_integer, ev_void, ev_void, PROG_ID_VERSION},
|
||||
{"<JUMP>", "jump", OP_JUMP, false, ev_integer, ev_void, ev_void, PROG_VERSION},
|
||||
{"<GOTO>", "goto", OP_GOTO, false, ev_integer, ev_void, ev_void, PROG_ID_VERSION},
|
||||
{"<JUMP>", "jump", OP_JUMP, false, ev_integer, ev_void, ev_void, PROG_VERSION},
|
||||
{"<JUMPB>", "jumpb", OP_JUMPB, false, ev_pointer, ev_integer, ev_void, PROG_VERSION},
|
||||
|
||||
{"&&", "and", OP_AND, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"||", "or", OP_OR, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
{"||", "or", OP_OR, false, ev_float, ev_float, ev_integer, PROG_ID_VERSION},
|
||||
|
||||
{"<<", "shl.f", OP_SHL_F, false, ev_float, ev_float, ev_float, PROG_VERSION},
|
||||
{">>", "shr.f", OP_SHR_F, false, ev_float, ev_float, ev_float, PROG_VERSION},
|
||||
|
@ -177,7 +198,7 @@ opcode_t pr_opcodes[] = {
|
|||
{">>", "shr.i", OP_SHR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
|
||||
{"&", "bitand", OP_BITAND, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
{"|", "bitor", OP_BITOR, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
{"|", "bitor", OP_BITOR, false, ev_float, ev_float, ev_float, PROG_ID_VERSION},
|
||||
|
||||
{"+", "add.i", OP_ADD_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"-", "sub.i", OP_SUB_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
|
@ -186,30 +207,27 @@ opcode_t pr_opcodes[] = {
|
|||
{"%", "mod_i", OP_MOD_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"%", "mod.f", OP_MOD_F, false, ev_float, ev_float, ev_float, PROG_VERSION},
|
||||
{"&", "bitand.i", OP_BITAND_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"|", "bitor.i", OP_BITOR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"|", "bitor.i", OP_BITOR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
|
||||
{">=", "ge.i", OP_GE_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"<=", "le.i", OP_LE_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{">", "gt.i", OP_GT_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"<", "lt.i", OP_LT_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{">", "gt.i", OP_GT_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"<", "lt.i", OP_LT_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
|
||||
{">=", "ge.ui", OP_GE_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
{"<=", "le.ui", OP_LE_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
{">", "gt.ui", OP_GT_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
{"<", "lt.ui", OP_LT_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
{">", "gt.ui", OP_GT_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
{"<", "lt.ui", OP_LT_UI, false, ev_uinteger, ev_uinteger, ev_integer, PROG_VERSION},
|
||||
|
||||
{"&&", "and.i", OP_AND_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"||", "or.i", OP_OR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"!", "not.i", OP_NOT_I, false, ev_integer, ev_void, ev_integer, PROG_VERSION},
|
||||
{"==", "eq.i", OP_EQ_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"!=", "ne.i", OP_NE_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"=", "store.i", OP_STORE_I, true, ev_integer, ev_integer, ev_void, PROG_VERSION},
|
||||
{"=", "storep.i", OP_STOREP_I, true, ev_integer, ev_pointer, ev_void, PROG_VERSION},
|
||||
{".", "load.i", OP_LOAD_I, false, ev_entity, ev_field, ev_integer, PROG_VERSION},
|
||||
{"||", "or.i", OP_OR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"!", "not.i", OP_NOT_I, false, ev_integer, ev_void, ev_integer, PROG_VERSION},
|
||||
{"==", "eq.i", OP_EQ_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"!=", "ne.i", OP_NE_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
|
||||
{"^", "bitxor.f", OP_BITXOR_F, false, ev_float, ev_float, ev_float, PROG_VERSION},
|
||||
{"^", "bitxor.i", OP_BITXOR_I, false, ev_integer, ev_integer, ev_integer, PROG_VERSION},
|
||||
{"~", "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},
|
||||
{0},
|
||||
};
|
||||
|
@ -267,11 +285,22 @@ static inline void
|
|||
check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
|
||||
unsigned short operand)
|
||||
{
|
||||
if (type == ev_void && operand) {
|
||||
if (st->op != OP_RETURN && st->op != OP_DONE) //FIXME need better "not used flags"
|
||||
PR_Error (pr, "PR_Check_Opcodes: non-zero global index in void operand (statement %ld: %s)\n", (long)(st - pr->pr_statements), op->opname);
|
||||
} else if (operand >= pr->progs->numglobals) {
|
||||
PR_Error (pr, "PR_Check_Opcodes: out of bounds global index (statement %ld: %s)\n", (long)(st - pr->pr_statements), op->opname);
|
||||
switch (type) {
|
||||
case ev_short:
|
||||
break;
|
||||
case ev_void:
|
||||
//FIXME need better "not used flags"
|
||||
if (operand && st->op != OP_RETURN && st->op != OP_DONE)
|
||||
PR_Error (pr, "PR_Check_Opcodes: non-zero global index in "
|
||||
"void operand (statement %ld: %s)\n",
|
||||
(long)(st - pr->pr_statements), op->opname);
|
||||
break;
|
||||
default:
|
||||
if (operand >= pr->progs->numglobals)
|
||||
PR_Error (pr, "PR_Check_Opcodes: out of bounds global index "
|
||||
"(statement %ld: %s)\n",
|
||||
(long)(st - pr->pr_statements), op->opname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue