mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
Clean out some unnecessary types from the progs engine and clean up the mess.
This is a nasty commit, sorry, but 99% of the commit is interdependent.
This commit is contained in:
parent
c69ac1f56f
commit
75ec6bf244
116 changed files with 1538 additions and 1812 deletions
|
@ -42,14 +42,9 @@ typedef enum {
|
|||
ev_pointer, // end of v6 types
|
||||
ev_quat,
|
||||
ev_integer,
|
||||
ev_uinteger,
|
||||
ev_short, // value is embedded in the opcode
|
||||
ev_struct,
|
||||
ev_object,
|
||||
ev_class,
|
||||
ev_sel,
|
||||
ev_array,
|
||||
|
||||
|
||||
ev_invalid, // invalid type. used for instruction checking
|
||||
ev_type_count // not a type, gives number of types
|
||||
} etype_t;
|
||||
|
||||
|
@ -263,33 +258,8 @@ typedef enum {
|
|||
OP_MOVE,
|
||||
OP_MOVEP,
|
||||
|
||||
OP_ADD_U,
|
||||
OP_SUB_U,
|
||||
OP_MUL_U,
|
||||
OP_DIV_U,
|
||||
OP_BITAND_U,
|
||||
OP_BITOR_U,
|
||||
OP_BITXOR_U,
|
||||
OP_BITNOT_U,
|
||||
OP_AND_U,
|
||||
OP_OR_U,
|
||||
OP_NOT_U,
|
||||
OP_EQ_U,
|
||||
OP_NE_U,
|
||||
OP_MOD_U,
|
||||
OP_SHL_U,
|
||||
OP_SHR_U,
|
||||
OP_STORE_U,
|
||||
OP_STOREB_U,
|
||||
OP_STOREBI_U,
|
||||
OP_STOREP_U,
|
||||
OP_LOAD_U,
|
||||
OP_LOADB_U,
|
||||
OP_LOADBI_U,
|
||||
OP_ADDRESS_U,
|
||||
|
||||
OP_CONV_IU,
|
||||
OP_CONV_UI,
|
||||
|
||||
OP_STATE_F,
|
||||
|
||||
|
@ -383,8 +353,12 @@ typedef struct pr_va_list_s {
|
|||
pointer_t list; // pr_type_t
|
||||
} pr_va_list_t;
|
||||
|
||||
#define PROG_VERSION_ENCODE(a,b,c) \
|
||||
( (((0x##a) & 0x0ff) << 24) \
|
||||
|(((0x##b) & 0xfff) << 12) \
|
||||
|(((0x##c) & 0xfff) << 0) )
|
||||
#define PROG_ID_VERSION 6
|
||||
#define PROG_VERSION 0x00fff005 // MMmmmRRR 0.fff.005 (hex)
|
||||
#define PROG_VERSION PROG_VERSION_ENCODE(0,fff,006)
|
||||
|
||||
typedef struct dprograms_s {
|
||||
pr_uint_t version;
|
||||
|
|
|
@ -645,12 +645,6 @@ value_string (progs_t *pr, etype_t type, pr_type_t *val)
|
|||
case ev_integer:
|
||||
dsprintf (line, "%d", val->integer_var);
|
||||
break;
|
||||
case ev_uinteger:
|
||||
dsprintf (line, "$%08x", val->uinteger_var);
|
||||
break;
|
||||
case ev_sel:
|
||||
dsprintf (line, "(SEL) %s", PR_GetString (pr, val->string_var));
|
||||
break;
|
||||
default:
|
||||
dsprintf (line, "bad type %i", type);
|
||||
break;
|
||||
|
@ -1041,18 +1035,12 @@ ED_Print (progs_t *pr, edict_t *ed)
|
|||
switch (type) {
|
||||
case ev_entity:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_pointer:
|
||||
case ev_func:
|
||||
case ev_field:
|
||||
if (!v->integer_var)
|
||||
continue;
|
||||
break;
|
||||
case ev_sel:
|
||||
if (!v[0].integer_var
|
||||
&& !PR_GetString (pr, v[1].string_var)[0])
|
||||
continue;
|
||||
break;
|
||||
case ev_string:
|
||||
if (PR_StringValid (pr, v->string_var))
|
||||
if (!PR_GetString (pr, v->string_var)[0])
|
||||
|
|
|
@ -312,7 +312,6 @@ signal_hook (int sig, void *data)
|
|||
OPC.integer_var = 0x7fffffff;
|
||||
return 1;
|
||||
case OP_MOD_I:
|
||||
case OP_MOD_U:
|
||||
case OP_MOD_F:
|
||||
OPC.integer_var = 0x00000000;
|
||||
return 1;
|
||||
|
@ -572,7 +571,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_STORE_S:
|
||||
case OP_STORE_FN: // pointers
|
||||
case OP_STORE_I:
|
||||
case OP_STORE_U:
|
||||
case OP_STORE_P:
|
||||
OPB.integer_var = OPA.integer_var;
|
||||
break;
|
||||
|
@ -589,7 +587,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_STOREP_S:
|
||||
case OP_STOREP_FN: // pointers
|
||||
case OP_STOREP_I:
|
||||
case OP_STOREP_U:
|
||||
case OP_STOREP_P:
|
||||
pointer = OPB.integer_var;
|
||||
if (pr_boundscheck->int_val) {
|
||||
|
@ -638,7 +635,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_ADDRESS_FLD:
|
||||
case OP_ADDRESS_FN:
|
||||
case OP_ADDRESS_I:
|
||||
case OP_ADDRESS_U:
|
||||
case OP_ADDRESS_P:
|
||||
OPC.integer_var = st->a;
|
||||
break;
|
||||
|
@ -649,7 +645,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_LOAD_S:
|
||||
case OP_LOAD_FN:
|
||||
case OP_LOAD_I:
|
||||
case OP_LOAD_U:
|
||||
case OP_LOAD_P:
|
||||
if (pr_boundscheck->int_val) {
|
||||
if (OPA.entity_var < 0
|
||||
|
@ -696,7 +691,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_LOADB_FLD:
|
||||
case OP_LOADB_FN:
|
||||
case OP_LOADB_I:
|
||||
case OP_LOADB_U:
|
||||
case OP_LOADB_P:
|
||||
pointer = OPA.integer_var + OPB.integer_var;
|
||||
if (pr_boundscheck->int_val) {
|
||||
|
@ -728,7 +722,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_LOADBI_FLD:
|
||||
case OP_LOADBI_FN:
|
||||
case OP_LOADBI_I:
|
||||
case OP_LOADBI_U:
|
||||
case OP_LOADBI_P:
|
||||
pointer = OPA.integer_var + (short) st->b;
|
||||
if (pr_boundscheck->int_val) {
|
||||
|
@ -770,7 +763,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_STOREB_FLD:
|
||||
case OP_STOREB_FN:
|
||||
case OP_STOREB_I:
|
||||
case OP_STOREB_U:
|
||||
case OP_STOREB_P:
|
||||
pointer = OPB.integer_var + OPC.integer_var;
|
||||
if (pr_boundscheck->int_val) {
|
||||
|
@ -802,7 +794,6 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
|
|||
case OP_STOREBI_FLD:
|
||||
case OP_STOREBI_FN:
|
||||
case OP_STOREBI_I:
|
||||
case OP_STOREBI_U:
|
||||
case OP_STOREBI_P:
|
||||
pointer = OPB.integer_var + (short) st->c;
|
||||
if (pr_boundscheck->int_val) {
|
||||
|
@ -990,44 +981,18 @@ op_call:
|
|||
OPC.integer_var = OPA.float_var;
|
||||
break;
|
||||
case OP_BITAND_I:
|
||||
case OP_BITAND_U:
|
||||
OPC.integer_var = OPA.integer_var & OPB.integer_var;
|
||||
break;
|
||||
case OP_BITOR_I:
|
||||
case OP_BITOR_U:
|
||||
OPC.integer_var = OPA.integer_var | OPB.integer_var;
|
||||
break;
|
||||
case OP_BITXOR_I:
|
||||
case OP_BITXOR_U:
|
||||
OPC.integer_var = OPA.integer_var ^ OPB.integer_var;
|
||||
break;
|
||||
case OP_BITNOT_I:
|
||||
case OP_BITNOT_U:
|
||||
OPC.integer_var = ~OPA.integer_var;
|
||||
break;
|
||||
|
||||
case OP_ADD_U:
|
||||
OPC.uinteger_var = OPA.uinteger_var + OPB.uinteger_var;
|
||||
break;
|
||||
case OP_SUB_U:
|
||||
OPC.uinteger_var = OPA.uinteger_var - OPB.uinteger_var;
|
||||
break;
|
||||
case OP_MUL_U:
|
||||
OPC.uinteger_var = OPA.uinteger_var * OPB.uinteger_var;
|
||||
break;
|
||||
case OP_DIV_U:
|
||||
OPC.uinteger_var = OPA.uinteger_var / OPB.uinteger_var;
|
||||
break;
|
||||
case OP_MOD_U:
|
||||
OPC.uinteger_var = OPA.uinteger_var % OPB.uinteger_var;
|
||||
break;
|
||||
case OP_CONV_IU:
|
||||
OPC.uinteger_var = OPA.integer_var;
|
||||
break;
|
||||
case OP_CONV_UI:
|
||||
OPC.integer_var = OPA.uinteger_var;
|
||||
break;
|
||||
|
||||
case OP_GE_I:
|
||||
case OP_GE_P:
|
||||
OPC.integer_var = OPA.integer_var >= OPB.integer_var;
|
||||
|
@ -1058,25 +1023,20 @@ op_call:
|
|||
break;
|
||||
|
||||
case OP_AND_I:
|
||||
case OP_AND_U:
|
||||
OPC.integer_var = OPA.integer_var && OPB.integer_var;
|
||||
break;
|
||||
case OP_OR_I:
|
||||
case OP_OR_U:
|
||||
OPC.integer_var = OPA.integer_var || OPB.integer_var;
|
||||
break;
|
||||
case OP_NOT_I:
|
||||
case OP_NOT_U:
|
||||
case OP_NOT_P:
|
||||
OPC.integer_var = !OPA.integer_var;
|
||||
break;
|
||||
case OP_EQ_I:
|
||||
case OP_EQ_U:
|
||||
case OP_EQ_P:
|
||||
OPC.integer_var = OPA.integer_var == OPB.integer_var;
|
||||
break;
|
||||
case OP_NE_I:
|
||||
case OP_NE_U:
|
||||
case OP_NE_P:
|
||||
OPC.integer_var = OPA.integer_var != OPB.integer_var;
|
||||
break;
|
||||
|
|
|
@ -60,13 +60,7 @@ VISIBLE int pr_type_size[ev_type_count] = {
|
|||
1, // ev_pointer
|
||||
4, // ev_quat
|
||||
1, // ev_integer
|
||||
1, // ev_uinteger
|
||||
0, // ev_short value in opcode
|
||||
0, // ev_struct variable
|
||||
0, // ev_object variable
|
||||
0, // ev_class variable
|
||||
2, // ev_sel
|
||||
0, // ev_array variable
|
||||
};
|
||||
|
||||
VISIBLE const char *pr_type_name[ev_type_count] = {
|
||||
|
@ -80,13 +74,8 @@ VISIBLE const char *pr_type_name[ev_type_count] = {
|
|||
"pointer",
|
||||
"quaternion",
|
||||
"integer",
|
||||
"uinteger",
|
||||
"short",
|
||||
"struct",
|
||||
"object",
|
||||
"Class",
|
||||
"SEL",
|
||||
"array",
|
||||
"invalid",
|
||||
};
|
||||
|
||||
// default format is "%Ga, %Gb, %gc"
|
||||
|
@ -106,8 +95,8 @@ VISIBLE const char *pr_type_name[ev_type_count] = {
|
|||
// x place holder for P (padding)
|
||||
// 0-7 parameter index (for P)
|
||||
VISIBLE opcode_t pr_opcodes[] = {
|
||||
{"<DONE>", "done", OP_DONE, false,
|
||||
ev_entity, ev_field, ev_void,
|
||||
{"<DONE>", "done", OP_DONE, false, // OP_DONE is actually the same as
|
||||
ev_entity, ev_field, ev_void, // OP_RETURN, the types are bogus
|
||||
PROG_ID_VERSION,
|
||||
"%Va",
|
||||
},
|
||||
|
@ -142,7 +131,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"~", "conj.q", OP_CONJ_Q, false,
|
||||
ev_quat, ev_void, ev_quat,
|
||||
ev_quat, ev_invalid, ev_quat,
|
||||
PROG_ID_VERSION,
|
||||
},
|
||||
|
||||
|
@ -304,11 +293,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
"%Ga.%Gb(%Ec), %gc",
|
||||
},
|
||||
{".", "load.u", OP_LOAD_U, false,
|
||||
ev_entity, ev_field, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
"%Ga.%Gb(%Ec), %gc",
|
||||
},
|
||||
{".", "load.p", OP_LOAD_P, false,
|
||||
ev_entity, ev_field, ev_pointer,
|
||||
PROG_VERSION,
|
||||
|
@ -355,11 +339,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
"*(%Ga + %Gb), %gc",
|
||||
},
|
||||
{".", "loadb.u", OP_LOADB_U, false,
|
||||
ev_pointer, ev_integer, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
"*(%Ga + %Gb), %gc",
|
||||
},
|
||||
{".", "loadb.p", OP_LOADB_P, false,
|
||||
ev_pointer, ev_integer, ev_pointer,
|
||||
PROG_VERSION,
|
||||
|
@ -406,11 +385,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
"*(%Ga + %sb), %gc",
|
||||
},
|
||||
{".", "loadbi.u", OP_LOADBI_U, false,
|
||||
ev_pointer, ev_short, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
"*(%Ga + %sb), %gc",
|
||||
},
|
||||
{".", "loadbi.p", OP_LOADBI_P, false,
|
||||
ev_pointer, ev_short, ev_pointer,
|
||||
PROG_VERSION,
|
||||
|
@ -424,52 +398,47 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"&", "address.f", OP_ADDRESS_F, false,
|
||||
ev_float, ev_void, ev_pointer,
|
||||
ev_float, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.v", OP_ADDRESS_V, false,
|
||||
ev_vector, ev_void, ev_pointer,
|
||||
ev_vector, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.q", OP_ADDRESS_Q, false,
|
||||
ev_quat, ev_void, ev_pointer,
|
||||
ev_quat, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.s", OP_ADDRESS_S, false,
|
||||
ev_string, ev_void, ev_pointer,
|
||||
ev_string, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.ent", OP_ADDRESS_ENT, false,
|
||||
ev_entity, ev_void, ev_pointer,
|
||||
ev_entity, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.fld", OP_ADDRESS_FLD, false,
|
||||
ev_field, ev_void, ev_pointer,
|
||||
ev_field, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.fn", OP_ADDRESS_FN, false,
|
||||
ev_func, ev_void, ev_pointer,
|
||||
ev_func, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.i", OP_ADDRESS_I, false,
|
||||
ev_integer, ev_void, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.u", OP_ADDRESS_U, false,
|
||||
ev_uinteger, ev_void, ev_pointer,
|
||||
ev_integer, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"&", "address.p", OP_ADDRESS_P, false,
|
||||
ev_pointer, ev_void, ev_pointer,
|
||||
ev_pointer, ev_invalid, ev_pointer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
@ -486,125 +455,104 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"=", "conv.if", OP_CONV_IF, false,
|
||||
ev_integer, ev_void, ev_float,
|
||||
ev_integer, ev_invalid, ev_float,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"=", "conv.fi", OP_CONV_FI, false,
|
||||
ev_float, ev_void, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
||||
{"=", "conv.iu", OP_CONV_IU, false,
|
||||
ev_integer, ev_void, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"=", "conv.ui", OP_CONV_UI, false,
|
||||
ev_uinteger, ev_void, ev_integer,
|
||||
ev_float, ev_invalid, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
||||
{"=", "store.f", OP_STORE_F, true,
|
||||
ev_float, ev_float, ev_void,
|
||||
ev_float, ev_float, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.v", OP_STORE_V, true,
|
||||
ev_vector, ev_vector, ev_void,
|
||||
ev_vector, ev_vector, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.q", OP_STORE_Q, true,
|
||||
ev_quat, ev_quat, ev_void,
|
||||
ev_quat, ev_quat, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.s", OP_STORE_S, true,
|
||||
ev_string, ev_string, ev_void,
|
||||
ev_string, ev_string, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.ent", OP_STORE_ENT, true,
|
||||
ev_entity, ev_entity, ev_void,
|
||||
ev_entity, ev_entity, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.fld", OP_STORE_FLD, true,
|
||||
ev_field, ev_field, ev_void,
|
||||
ev_field, ev_field, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.fn", OP_STORE_FN, true,
|
||||
ev_func, ev_func, ev_void,
|
||||
ev_func, ev_func, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.i", OP_STORE_I, true,
|
||||
ev_integer, ev_integer, ev_void,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.u", OP_STORE_U, true,
|
||||
ev_uinteger, ev_uinteger, ev_void,
|
||||
ev_integer, ev_integer, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
{"=", "store.p", OP_STORE_P, true,
|
||||
ev_pointer, ev_pointer, ev_void,
|
||||
ev_pointer, ev_pointer, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gb",
|
||||
},
|
||||
|
||||
{".=", "storep.f", OP_STOREP_F, true,
|
||||
ev_float, ev_pointer, ev_void,
|
||||
ev_float, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.v", OP_STOREP_V, true,
|
||||
ev_vector, ev_pointer, ev_void,
|
||||
ev_vector, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.q", OP_STOREP_Q, true,
|
||||
ev_quat, ev_pointer, ev_void,
|
||||
ev_quat, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.s", OP_STOREP_S, true,
|
||||
ev_string, ev_pointer, ev_void,
|
||||
ev_string, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.ent", OP_STOREP_ENT, true,
|
||||
ev_entity, ev_pointer, ev_void,
|
||||
ev_entity, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.fld", OP_STOREP_FLD, true,
|
||||
ev_field, ev_pointer, ev_void,
|
||||
ev_field, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.fn", OP_STOREP_FN, true,
|
||||
ev_func, ev_pointer, ev_void,
|
||||
ev_func, ev_pointer, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.i", OP_STOREP_I, true,
|
||||
ev_integer, ev_pointer, ev_void,
|
||||
PROG_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.u", OP_STOREP_U, true,
|
||||
ev_uinteger, ev_pointer, ev_void,
|
||||
ev_integer, ev_pointer, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
{".=", "storep.p", OP_STOREP_P, true,
|
||||
ev_pointer, ev_pointer, ev_void,
|
||||
ev_pointer, ev_pointer, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga, *%Gb",
|
||||
},
|
||||
|
@ -649,11 +597,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
"%Ga, *(%Gb + %Gc)",
|
||||
},
|
||||
{".=", "storeb.u", OP_STOREB_U, true,
|
||||
ev_uinteger, ev_pointer, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, *(%Gb + %Gc)",
|
||||
},
|
||||
{".=", "storeb.p", OP_STOREB_P, true,
|
||||
ev_pointer, ev_pointer, ev_integer,
|
||||
PROG_VERSION,
|
||||
|
@ -700,11 +643,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
"%Ga, *(%Gb + %sc)",
|
||||
},
|
||||
{".=", "storebi.u", OP_STOREBI_U, true,
|
||||
ev_uinteger, ev_pointer, ev_short,
|
||||
PROG_VERSION,
|
||||
"%Ga, *(%Gb + %sc)",
|
||||
},
|
||||
{".=", "storebi.p", OP_STOREBI_P, true,
|
||||
ev_pointer, ev_pointer, ev_short,
|
||||
PROG_VERSION,
|
||||
|
@ -712,126 +650,126 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"<RETURN>", "return", OP_RETURN, false,
|
||||
ev_void, ev_void, ev_void,
|
||||
ev_void, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ra",
|
||||
},
|
||||
|
||||
{"!", "not.f", OP_NOT_F, false,
|
||||
ev_float, ev_void, ev_integer,
|
||||
ev_float, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.v", OP_NOT_V, false,
|
||||
ev_vector, ev_void, ev_integer,
|
||||
ev_vector, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.q", OP_NOT_Q, false,
|
||||
ev_quat, ev_void, ev_integer,
|
||||
ev_quat, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.s", OP_NOT_S, false,
|
||||
ev_string, ev_void, ev_integer,
|
||||
ev_string, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.ent", OP_NOT_ENT, false,
|
||||
ev_entity, ev_void, ev_integer,
|
||||
ev_entity, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.fn", OP_NOT_FN, false,
|
||||
ev_func, ev_void, ev_integer,
|
||||
ev_func, ev_invalid, ev_integer,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"!", "not.p", OP_NOT_P, false,
|
||||
ev_pointer, ev_void, ev_integer,
|
||||
ev_pointer, ev_invalid, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
||||
{"<IF>", "if", OP_IF, false,
|
||||
ev_integer, ev_void, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
{"<IFNOT>", "ifnot", OP_IFNOT, false,
|
||||
ev_integer, ev_void, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
{"<IFBE>", "ifbe", OP_IFBE, true,
|
||||
ev_integer, ev_integer, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
{"<IFB>", "ifb", OP_IFB, true,
|
||||
ev_integer, ev_integer, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
{"<IFAE>", "ifae", OP_IFAE, true,
|
||||
ev_integer, ev_integer, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
{"<IFA>", "ifa", OP_IFA, true,
|
||||
ev_integer, ev_integer, ev_void,
|
||||
ev_integer, ev_short, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga branch %sb (%Ob)",
|
||||
},
|
||||
|
||||
// calls returns REG_RETURN
|
||||
{"<CALL0>", "call0", OP_CALL0, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa ()",
|
||||
},
|
||||
{"<CALL1>", "call1", OP_CALL1, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x)",
|
||||
},
|
||||
{"<CALL2>", "call2", OP_CALL2, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x)",
|
||||
},
|
||||
{"<CALL3>", "call3", OP_CALL3, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x)",
|
||||
},
|
||||
{"<CALL4>", "call4", OP_CALL4, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x, %P3x)",
|
||||
},
|
||||
{"<CALL5>", "call5", OP_CALL5, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x, %P3x, %P4x)",
|
||||
},
|
||||
{"<CALL6>", "call6", OP_CALL6, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x, %P3x, %P4x, %P5x)",
|
||||
},
|
||||
{"<CALL7>", "call7", OP_CALL7, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x, %P3x, %P4x, %P5x, %P6x)",
|
||||
},
|
||||
{"<CALL8>", "call8", OP_CALL8, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Fa (%P0x, %P1x, %P2x, %P3x, %P4x, %P5x, %P6x, %P7x)",
|
||||
},
|
||||
{"<RCALL1>", "rcall1", OP_RCALL1, false,
|
||||
ev_func, ev_void, ev_void,
|
||||
ev_func, ev_void, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Fa (%P0b)",
|
||||
},
|
||||
|
@ -872,7 +810,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"<STATE>", "state", OP_STATE, false,
|
||||
ev_float, ev_func, ev_void,
|
||||
ev_float, ev_func, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"%Ga, %Gb",
|
||||
},
|
||||
|
@ -884,19 +822,19 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"<GOTO>", "goto", OP_GOTO, false,
|
||||
ev_integer, ev_void, ev_void,
|
||||
ev_short, ev_invalid, ev_invalid,
|
||||
PROG_ID_VERSION,
|
||||
"branch %sa (%Oa)",
|
||||
},
|
||||
{"<JUMP>", "jump", OP_JUMP, false,
|
||||
ev_integer, ev_void, ev_void,
|
||||
ev_integer, ev_invalid, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga",
|
||||
},
|
||||
{"<JUMPB>", "jumpb", OP_JUMPB, false,
|
||||
ev_pointer, ev_integer, ev_void,
|
||||
ev_pointer, ev_integer, ev_invalid,
|
||||
PROG_VERSION,
|
||||
"%Ga, %Gb",
|
||||
"%Ga[%Gb]",
|
||||
},
|
||||
|
||||
{"&&", "and.f", OP_AND, false,
|
||||
|
@ -925,11 +863,11 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
{"<<", "shl.u", OP_SHL_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{">>", "shr.u", OP_SHR_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
|
||||
|
@ -971,35 +909,6 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
|
||||
{"+", "add.u", OP_ADD_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"-", "sub.u", OP_SUB_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"*", "mul.u", OP_MUL_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"/", "div.u", OP_DIV_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"%", "mod_u", OP_MOD_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"&", "bitand.u", OP_BITAND_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"|", "bitor.u", OP_BITOR_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
|
||||
{"%", "mod.f", OP_MOD_F, false,
|
||||
ev_float, ev_float, ev_float,
|
||||
PROG_VERSION,
|
||||
|
@ -1031,7 +940,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
{"!", "not.i", OP_NOT_I, false,
|
||||
ev_integer, ev_void, ev_integer,
|
||||
ev_integer, ev_invalid, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
@ -1044,42 +953,20 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
|
||||
{"&&", "and.u", OP_AND_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"||", "or.u", OP_OR_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"!", "not.u", OP_NOT_U, false,
|
||||
ev_uinteger, ev_void, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"==", "eq.u", OP_EQ_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"!=", "ne.u", OP_NE_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
|
||||
{">=", "ge.u", OP_GE_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"<=", "le.u", OP_LE_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{">", "gt.u", OP_GT_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"<", "lt.u", OP_LT_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_integer,
|
||||
ev_integer, ev_integer, ev_integer,
|
||||
PROG_VERSION,
|
||||
},
|
||||
|
||||
|
@ -1088,7 +975,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
{"~", "bitnot.f", OP_BITNOT_F, false,
|
||||
ev_float, ev_void, ev_float,
|
||||
ev_float, ev_invalid, ev_float,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
@ -1097,16 +984,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
PROG_VERSION,
|
||||
},
|
||||
{"~", "bitnot.i", OP_BITNOT_I, false,
|
||||
ev_integer, ev_void, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
{"^", "bitxor.u", OP_BITXOR_U, false,
|
||||
ev_uinteger, ev_uinteger, ev_uinteger,
|
||||
PROG_VERSION,
|
||||
},
|
||||
{"~", "bitnot.u", OP_BITNOT_U, false,
|
||||
ev_uinteger, ev_void, ev_uinteger,
|
||||
ev_integer, ev_invalid, ev_integer,
|
||||
PROG_VERSION,
|
||||
"%Ga, %gc",
|
||||
},
|
||||
|
@ -1137,7 +1015,7 @@ VISIBLE opcode_t pr_opcodes[] = {
|
|||
},
|
||||
|
||||
{"<MOVE>", "move", OP_MOVE, true,
|
||||
ev_struct, ev_short, ev_struct,
|
||||
ev_void, ev_short, ev_void,
|
||||
PROG_VERSION,
|
||||
"%Ga, %sb, %gc",
|
||||
},
|
||||
|
@ -1212,9 +1090,9 @@ check_global (progs_t *pr, dstatement_t *st, opcode_t *op, etype_t type,
|
|||
switch (type) {
|
||||
case ev_short:
|
||||
break;
|
||||
case ev_void:
|
||||
case ev_invalid:
|
||||
if (operand) {
|
||||
msg = "non-zero global index in void operand";
|
||||
msg = "non-zero global index in invalid operand";
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -356,6 +356,7 @@ set_address (sv_def_t *def, void *address)
|
|||
switch (def->type) {
|
||||
case ev_void:
|
||||
case ev_short:
|
||||
case ev_invalid:
|
||||
case ev_type_count:
|
||||
break;
|
||||
case ev_float:
|
||||
|
@ -369,12 +370,6 @@ set_address (sv_def_t *def, void *address)
|
|||
case ev_func:
|
||||
case ev_pointer:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_object:
|
||||
case ev_class:
|
||||
case ev_sel:
|
||||
case ev_array:
|
||||
case ev_struct:
|
||||
*(int **)def->field = (int *) address;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -357,6 +357,7 @@ set_address (sv_def_t *def, void *address)
|
|||
switch (def->type) {
|
||||
case ev_void:
|
||||
case ev_short:
|
||||
case ev_invalid:
|
||||
case ev_type_count:
|
||||
break;
|
||||
case ev_float:
|
||||
|
@ -370,12 +371,6 @@ set_address (sv_def_t *def, void *address)
|
|||
case ev_func:
|
||||
case ev_pointer:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_object:
|
||||
case ev_class:
|
||||
case ev_sel:
|
||||
case ev_array:
|
||||
case ev_struct:
|
||||
*(int **)def->field = (int *) address;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
@interface CrosshairView : View
|
||||
{
|
||||
CrosshairCvar crosshair;
|
||||
CrosshairCvar []crosshair;
|
||||
}
|
||||
-(id)initWithBounds:(Rect)aRect :(CrosshairCvar)_crosshair;
|
||||
-(id)initWithBounds:(Rect)aRect :(CrosshairCvar[])_crosshair;
|
||||
-(void) next;
|
||||
@end
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
@implementation CrosshairView
|
||||
{
|
||||
CrosshairCvar crosshair;
|
||||
CrosshairCvar []crosshair;
|
||||
}
|
||||
|
||||
-(id)initWithBounds:(Rect)aRect :(CrosshairCvar)_crosshair
|
||||
-(id)initWithBounds:(Rect)aRect :(CrosshairCvar[])_crosshair
|
||||
{
|
||||
self = [self initWithBounds:aRect];
|
||||
crosshair = _crosshair;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
@interface CvarColorView : View
|
||||
{
|
||||
CvarColor color;
|
||||
CvarColor []color;
|
||||
}
|
||||
-(id)initWithBounds:(Rect)aRect :(CvarColor)_color;
|
||||
-(id)initWithBounds:(Rect)aRect :(CvarColor [])_color;
|
||||
-(void)next;
|
||||
-(void)prev;
|
||||
@end
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "CvarColor.h"
|
||||
|
||||
@implementation CvarColorView
|
||||
-(id)initWithBounds:(Rect)aRect :(CvarColor)_color
|
||||
-(id)initWithBounds:(Rect)aRect :(CvarColor [])_color
|
||||
{
|
||||
self = [self initWithBounds:aRect];
|
||||
color = _color;
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
@interface CvarRangeView : Group
|
||||
{
|
||||
Text title;
|
||||
Text value;
|
||||
Slider slider;
|
||||
CvarRange range;
|
||||
Text []title;
|
||||
Text []value;
|
||||
Slider []slider;
|
||||
CvarRange []range;
|
||||
}
|
||||
-(void)update;
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange)_range;
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange [])_range;
|
||||
-(void)inc;
|
||||
-(void)dec;
|
||||
@end
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[value setText:ftos ([range value])];
|
||||
}
|
||||
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange)_range
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title sliderWidth:(integer)width :(CvarRange [])_range
|
||||
{
|
||||
local Rect rect;
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
@interface CvarToggleView : Group
|
||||
{
|
||||
Text title;
|
||||
Text value;
|
||||
CvarToggle toggle;
|
||||
Text []title;
|
||||
Text []value;
|
||||
CvarToggle []toggle;
|
||||
}
|
||||
-(void)update;
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title :(CvarToggle)_toggle;
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title :(CvarToggle [])_toggle;
|
||||
-(void)toggle;
|
||||
@end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
[value setText:[toggle value] ? "On" : "Off"];
|
||||
}
|
||||
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title :(CvarToggle)_toggle
|
||||
-(id)initWithBounds:(Rect)aRect title:(string)_title :(CvarToggle [])_toggle
|
||||
{
|
||||
local Rect rect;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@interface Frame : Object
|
||||
{
|
||||
QPic picture;
|
||||
QPic []picture;
|
||||
float duration;
|
||||
}
|
||||
- (id) initWithFile: (string) file duration: (float) time;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
@interface HUDGraphic : HUDObject
|
||||
{
|
||||
QPic picture;
|
||||
QPic []picture;
|
||||
}
|
||||
|
||||
- (id) initWithComponents: (integer)x :(integer)y :(string) _file;
|
||||
|
@ -52,7 +52,7 @@
|
|||
|
||||
@interface HUDAnimation : HUDObject
|
||||
{
|
||||
Array frames;
|
||||
Array []frames;
|
||||
integer currentFrame;
|
||||
float nextFrameTime;
|
||||
BOOL looping;
|
||||
|
@ -60,7 +60,7 @@
|
|||
- (id) initWithComponents: (integer) x :(integer) y;
|
||||
- (void) dealloc;
|
||||
- (Size) size;
|
||||
- (void) addFrame: (Frame) frame;
|
||||
- (void) addFrame: (Frame []) frame;
|
||||
- (void) changeFrame;
|
||||
- (void) display;
|
||||
- (void) start;
|
||||
|
|
|
@ -147,13 +147,13 @@ integer HUDHandleClass;
|
|||
|
||||
- (Size) size
|
||||
{
|
||||
local Frame frame;
|
||||
local Frame []frame;
|
||||
|
||||
frame = [frames objectAtIndex: currentFrame];
|
||||
return [frame size];
|
||||
}
|
||||
|
||||
- (void) addFrame: (Frame) frame
|
||||
- (void) addFrame: (Frame[]) frame
|
||||
{
|
||||
[frames addObject: frame];
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ integer HUDHandleClass;
|
|||
- (void) changeFrame
|
||||
{
|
||||
while (time >= nextFrameTime) {
|
||||
local Frame f;
|
||||
local Frame []f;
|
||||
if (++currentFrame == [frames count]) {
|
||||
if (looping)
|
||||
currentFrame = 0;
|
||||
|
@ -178,7 +178,7 @@ integer HUDHandleClass;
|
|||
|
||||
- (void) display
|
||||
{
|
||||
local Frame f;
|
||||
local Frame []f;
|
||||
|
||||
if (!visible)
|
||||
return;
|
||||
|
@ -192,7 +192,7 @@ integer HUDHandleClass;
|
|||
|
||||
- (void) start
|
||||
{
|
||||
local Frame f;
|
||||
local Frame []f;
|
||||
|
||||
currentFrame = 0;
|
||||
f = [frames objectAtIndex: 0];
|
||||
|
|
|
@ -57,10 +57,10 @@
|
|||
|
||||
- (void) draw
|
||||
{
|
||||
local View cur;
|
||||
local View []cur;
|
||||
|
||||
[super draw];
|
||||
cur = (View) [views objectAtIndex:current];
|
||||
cur = [views objectAtIndex:current];
|
||||
opt_cursor (cur.xabs - 8, cur.yabs);
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
@interface ProxyView : View
|
||||
{
|
||||
View title;
|
||||
View view;
|
||||
View []title;
|
||||
View []view;
|
||||
}
|
||||
-(id)initWithBounds:(Rect)aRect title:(View)aTitle view:(View)aView;
|
||||
-(id)initWithBounds:(Rect)aRect title:(View[])aTitle view:(View[])aView;
|
||||
@end
|
||||
|
||||
#endif//__ProxyView_h
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
@implementation ProxyView
|
||||
|
||||
-(id)initWithBounds:(Rect)aRect title:(View)aTitle view:(View)aView
|
||||
-(id)initWithBounds:(Rect)aRect title:(View [])aTitle view:(View [])aView
|
||||
{
|
||||
self = [super initWithBounds:aRect];
|
||||
if (!self)
|
||||
|
@ -24,7 +24,7 @@
|
|||
[view draw];
|
||||
}
|
||||
|
||||
- (void) setBasePosFromView: (View) aview
|
||||
- (void) setBasePosFromView: (View []) aview
|
||||
{
|
||||
[super setBasePosFromView:aview];
|
||||
[title setBasePosFromView:self];
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
#define __client_menu_h
|
||||
|
||||
@class InputLine;
|
||||
@extern InputLine input_active;
|
||||
@extern InputLine []input_active;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -123,10 +123,10 @@ integer save_cursor;
|
|||
string (QFile f) get_comment =
|
||||
{
|
||||
local string line;
|
||||
local PLItem plist;
|
||||
local PLItem []plist;
|
||||
|
||||
plist = [PLItem fromFile:f];
|
||||
line = [(PLString) [(PLDictionary) plist getObjectForKey:"comment"] string];
|
||||
line = [(PLString[]) [(PLDictionary[]) plist getObjectForKey:"comment"] string];
|
||||
return line;
|
||||
}
|
||||
|
||||
|
@ -368,9 +368,9 @@ string lanConfig_portname;
|
|||
string lanConfig_joinname;
|
||||
#define NUM_LANCONFIG_CMDS 3
|
||||
integer [NUM_LANCONFIG_CMDS] lanConfig_cursor_table = { 72, 92, 124 };
|
||||
InputLine lanConfig_port_il;
|
||||
InputLine lanConfig_join_il;
|
||||
InputLine input_active;
|
||||
InputLine []lanConfig_port_il;
|
||||
InputLine []lanConfig_join_il;
|
||||
InputLine []input_active;
|
||||
|
||||
integer (integer x, integer y) join_draw =
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
integer set_key_flag; // holds flag for the key-setting
|
||||
|
||||
// three global hashes for the main binding groups
|
||||
Array movement_bindings;
|
||||
Array misc_bindings;
|
||||
Array weapon_bindings;
|
||||
Array []movement_bindings;
|
||||
Array []misc_bindings;
|
||||
Array []weapon_bindings;
|
||||
|
||||
struct binding_s {
|
||||
string text;
|
||||
|
@ -110,7 +110,7 @@ binding_t [10] weapon_binding_list = {
|
|||
{"Thunderbolt", "impulse 8"},
|
||||
};
|
||||
|
||||
Binding (binding_t binding)
|
||||
Binding [](binding_t binding)
|
||||
new_binding =
|
||||
{
|
||||
return [[Binding alloc] initWithBinding:binding];
|
||||
|
@ -168,11 +168,11 @@ get_keyname =
|
|||
|
||||
gets the keys for a keybinding-hash
|
||||
*/
|
||||
void (Array list)
|
||||
void (Array []list)
|
||||
get_hash_keys =
|
||||
{
|
||||
local integer i,hlen;
|
||||
local Binding binding;
|
||||
local Binding []binding;
|
||||
local string desc1 = "", desc2 = "";
|
||||
|
||||
hlen = [list count];
|
||||
|
@ -229,7 +229,7 @@ load_keybindings =
|
|||
It takes the binding as argument.
|
||||
This function is called by the real callbacks.
|
||||
*/
|
||||
integer (Binding binding, integer key)
|
||||
integer (Binding []binding, integer key)
|
||||
CB_MAIN_control_binding =
|
||||
{
|
||||
local integer retval = 0, bindcnt = 0;
|
||||
|
@ -270,7 +270,7 @@ CB_MAIN_control_binding =
|
|||
integer (string text, integer key)
|
||||
CB_basic_control_binding =
|
||||
{
|
||||
local Binding binding = [movement_bindings objectAtIndex: stoi (text)];
|
||||
local Binding []binding = [movement_bindings objectAtIndex: stoi (text)];
|
||||
local integer ret = CB_MAIN_control_binding (binding, key);
|
||||
|
||||
// fetch all keynames (possible to optimize.. but not very neccessary)
|
||||
|
@ -307,7 +307,7 @@ DRAW_basic_control_binding =
|
|||
|
||||
hl = [movement_bindings count];
|
||||
for(i = 0; i < hl; i++) {
|
||||
local Binding binding = [movement_bindings objectAtIndex: i];
|
||||
local Binding []binding = [movement_bindings objectAtIndex: i];
|
||||
draw_val_item (x + 20, y + 40 + ( i * 10), bind_desc_pad,
|
||||
binding.text, binding.keys);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ MENU_basic_control_binding =
|
|||
integer (string text, integer key)
|
||||
CB_misc_control_binding =
|
||||
{
|
||||
local Binding binding = [misc_bindings objectAtIndex: stoi (text)];
|
||||
local Binding []binding = [misc_bindings objectAtIndex: stoi (text)];
|
||||
local integer ret = CB_MAIN_control_binding (binding, key);
|
||||
|
||||
// fetch all keynames (possible to optimize.. but not very neccessary)
|
||||
|
@ -384,7 +384,7 @@ DRAW_misc_control_binding =
|
|||
|
||||
hl = [misc_bindings count];
|
||||
for(i=0;i < hl; i++) {
|
||||
local Binding binding = [misc_bindings objectAtIndex: i];
|
||||
local Binding []binding = [misc_bindings objectAtIndex: i];
|
||||
draw_val_item (x + 20, y + 40+(i*10), bind_desc_pad,
|
||||
binding.text, binding.keys);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ MENU_misc_control_binding =
|
|||
integer (string text, integer key)
|
||||
CB_weapon_control_binding =
|
||||
{
|
||||
local Binding binding = [weapon_bindings objectAtIndex: stoi (text)];
|
||||
local Binding []binding = [weapon_bindings objectAtIndex: stoi (text)];
|
||||
local integer ret = CB_MAIN_control_binding (binding, key);
|
||||
|
||||
// fetch all keynames (possible to optimize.. but not very neccessary)
|
||||
|
@ -460,7 +460,7 @@ DRAW_weapon_control_binding =
|
|||
|
||||
hl = [weapon_bindings count];
|
||||
for(i = 0; i < hl; i++) {
|
||||
local Binding binding = [weapon_bindings objectAtIndex: i];
|
||||
local Binding []binding = [weapon_bindings objectAtIndex: i];
|
||||
draw_val_item (x + 20, y + 40 + (i * 10), bind_desc_pad,
|
||||
binding.text, binding.keys);
|
||||
}
|
||||
|
|
|
@ -53,32 +53,32 @@
|
|||
#include "CvarColor.h"
|
||||
#include "CvarToggle.h"
|
||||
|
||||
Group video_options;
|
||||
Group audio_options;
|
||||
Group []video_options;
|
||||
Group []audio_options;
|
||||
|
||||
Group control_options;
|
||||
CvarToggleView grab_mouse_view;
|
||||
CvarToggleView invert_mouse_view;
|
||||
CvarToggleView autorun_view;
|
||||
CvarToggleView freelook_view;
|
||||
CvarToggleView lookspring_view;
|
||||
CvarToggleView lookstrafe_view;
|
||||
CvarRangeView mouse_amp_view;
|
||||
Group []control_options;
|
||||
CvarToggleView []grab_mouse_view;
|
||||
CvarToggleView []invert_mouse_view;
|
||||
CvarToggleView []autorun_view;
|
||||
CvarToggleView []freelook_view;
|
||||
CvarToggleView []lookspring_view;
|
||||
CvarToggleView []lookstrafe_view;
|
||||
CvarRangeView []mouse_amp_view;
|
||||
|
||||
Group feature_options;
|
||||
CvarToggleView fraglog_view;
|
||||
CvarToggleView autorecord_view;
|
||||
Group []feature_options;
|
||||
CvarToggleView []fraglog_view;
|
||||
CvarToggleView []autorecord_view;
|
||||
|
||||
Group player_options;
|
||||
InputLine player_config_plname_il;
|
||||
InputLine player_config_tname_il;
|
||||
InputLine player_config_iactive;
|
||||
CvarColorView topcolor_view;
|
||||
CvarColorView bottomcolor_view;
|
||||
Group []player_options;
|
||||
InputLine []player_config_plname_il;
|
||||
InputLine []player_config_tname_il;
|
||||
InputLine []player_config_iactive;
|
||||
CvarColorView []topcolor_view;
|
||||
CvarColorView []bottomcolor_view;
|
||||
|
||||
Group network_options;
|
||||
InputLine network_config_rate_il;
|
||||
InputLine network_config_iactive;
|
||||
Group []network_options;
|
||||
InputLine []network_config_rate_il;
|
||||
InputLine []network_config_iactive;
|
||||
|
||||
/*
|
||||
some definitions of border values for different things
|
||||
|
@ -133,7 +133,7 @@ KEY_video_options =
|
|||
|
||||
Menu function for the video options menu.
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_video_options =
|
||||
{
|
||||
local @param ret;
|
||||
|
@ -143,7 +143,7 @@ MENU_video_options =
|
|||
Menu_KeyEvent (KEY_video_options);
|
||||
|
||||
if (plist) {
|
||||
ret = object_from_plist ([(PLDictionary) plist getObjectForKey:"video_options"]);
|
||||
ret = object_from_plist ([(PLDictionary[]) plist getObjectForKey:"video_options"]);
|
||||
video_options = ret.pointer_val;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ KEY_audio_options =
|
|||
|
||||
Makes the audio menu
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_audio_options =
|
||||
{
|
||||
local @param ret;
|
||||
|
@ -190,7 +190,7 @@ MENU_audio_options =
|
|||
Menu_KeyEvent (KEY_audio_options);
|
||||
|
||||
if (plist) {
|
||||
ret = object_from_plist ([(PLDictionary) plist getObjectForKey:"audio_options"]);
|
||||
ret = object_from_plist ([(PLDictionary[]) plist getObjectForKey:"audio_options"]);
|
||||
audio_options = ret.pointer_val;
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ KEY_control_options =
|
|||
|
||||
Menu make function for control options
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_control_options =
|
||||
{
|
||||
local @param ret;
|
||||
|
@ -274,7 +274,7 @@ MENU_control_options =
|
|||
Menu_KeyEvent (KEY_control_options);
|
||||
|
||||
if (plist) {
|
||||
ret = object_from_plist ([(PLDictionary) plist getObjectForKey:"control_options"]);
|
||||
ret = object_from_plist ([(PLDictionary[]) plist getObjectForKey:"control_options"]);
|
||||
control_options = ret.pointer_val;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ DRAW_feature_options =
|
|||
|
||||
Makes the feature option menu
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_feature_options =
|
||||
{
|
||||
local Rect rect;
|
||||
|
@ -512,7 +512,7 @@ CB_ME_player_options =
|
|||
|
||||
Makes the player option menu
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_player_options =
|
||||
{
|
||||
local Rect rect;
|
||||
|
@ -682,7 +682,7 @@ CB_ME_network_options =
|
|||
|
||||
Makes the network option menu
|
||||
*/
|
||||
void (PLItem plist)
|
||||
void (PLItem []plist)
|
||||
MENU_network_options =
|
||||
{
|
||||
local id view;
|
||||
|
@ -743,7 +743,7 @@ void ()
|
|||
MENU_options =
|
||||
{
|
||||
local integer spacing = 120;
|
||||
local PLItem plist;
|
||||
local PLItem []plist;
|
||||
|
||||
plist = read_plist ("menu.plist");
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "PropertyList.h"
|
||||
|
||||
@extern @param object_from_plist (PLItem plist);
|
||||
@extern PLItem read_plist (string fname);
|
||||
@extern @param object_from_plist (PLItem []plist);
|
||||
@extern PLItem []read_plist (string fname);
|
||||
|
||||
#endif//__plistmenu_r
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "plistmenu.h"
|
||||
|
||||
@static @param
|
||||
class_from_plist (PLDictionary pldict)
|
||||
class_from_plist (PLDictionary []pldict)
|
||||
{
|
||||
local @param [8]params;
|
||||
local @param ret;
|
||||
|
@ -41,12 +41,12 @@ class_from_plist (PLDictionary pldict)
|
|||
local string classname, selname, paramstr;
|
||||
local id class;
|
||||
local id obj;
|
||||
local PLArray messages, msg;
|
||||
local PLArray []messages, msg;
|
||||
local integer message_count, i, j;
|
||||
local SEL sel;
|
||||
local PLItem item;
|
||||
local PLItem []item;
|
||||
|
||||
classname = [(PLString) [pldict getObjectForKey:"Class"] string];
|
||||
classname = [(PLString[]) [pldict getObjectForKey:"Class"] string];
|
||||
class = obj_lookup_class (classname);
|
||||
if (!class) {
|
||||
dprint ("could not find " + classname + "\n");
|
||||
|
@ -55,15 +55,15 @@ class_from_plist (PLDictionary pldict)
|
|||
}
|
||||
obj = [class alloc];
|
||||
|
||||
messages = (PLArray) [pldict getObjectForKey:"Messages"];
|
||||
messages = (PLArray[]) [pldict getObjectForKey:"Messages"];
|
||||
message_count = [messages count];
|
||||
for (i = 0; i < message_count; i++) {
|
||||
msg = (PLArray) [messages getObjectAtIndex:i];
|
||||
selname = [(PLString) [msg getObjectAtIndex:0] string];
|
||||
msg = (PLArray[]) [messages getObjectAtIndex:i];
|
||||
selname = [(PLString[]) [msg getObjectAtIndex:0] string];
|
||||
sel = sel_get_uid (selname);
|
||||
va_list.count = [msg count] - 1;
|
||||
for (j = 0; j < va_list.count; j++) {
|
||||
paramstr = [(PLString) [msg getObjectAtIndex:j + 1] string];
|
||||
paramstr = [(PLString[]) [msg getObjectAtIndex:j + 1] string];
|
||||
switch (str_mid (paramstr, 0, 1)) {
|
||||
case "\"":
|
||||
va_list.list[j].string_val = str_mid (paramstr, 1, -1);
|
||||
|
@ -88,9 +88,9 @@ class_from_plist (PLDictionary pldict)
|
|||
}
|
||||
|
||||
@static @param
|
||||
array_from_plist (PLArray plarray)
|
||||
array_from_plist (PLArray []plarray)
|
||||
{
|
||||
local Array array;
|
||||
local Array []array;
|
||||
local integer i, count;
|
||||
local @param ret;
|
||||
|
||||
|
@ -110,29 +110,29 @@ union ParamRect {
|
|||
};
|
||||
|
||||
@static @param
|
||||
rect_from_plist (PLString plstring)
|
||||
rect_from_plist (PLString []plstring)
|
||||
{
|
||||
local string str = [plstring string];
|
||||
local string tmp;
|
||||
local integer xp, yp, xl, yl;
|
||||
local PLItem item;
|
||||
local PLItem []item;
|
||||
local union ParamRect pr;
|
||||
|
||||
pr.r = makeRect (0, 0, 0, 0);
|
||||
if (str_mid (str, 0, 1) == "[") {
|
||||
tmp = "(" + str_mid (str, 1, -1) + ")";
|
||||
item = [PLItem fromString:tmp];
|
||||
xp = stoi ([(PLString) [(PLArray) item getObjectAtIndex:0] string]);
|
||||
yp = stoi ([(PLString) [(PLArray) item getObjectAtIndex:1] string]);
|
||||
xl = stoi ([(PLString) [(PLArray) item getObjectAtIndex:2] string]);
|
||||
yl = stoi ([(PLString) [(PLArray) item getObjectAtIndex:3] string]);
|
||||
xp = stoi ([(PLString[]) [(PLArray[]) item getObjectAtIndex:0] string]);
|
||||
yp = stoi ([(PLString[]) [(PLArray[]) item getObjectAtIndex:1] string]);
|
||||
xl = stoi ([(PLString[]) [(PLArray[]) item getObjectAtIndex:2] string]);
|
||||
yl = stoi ([(PLString[]) [(PLArray[]) item getObjectAtIndex:3] string]);
|
||||
pr.r = makeRect (xp, yp, xl, yl);
|
||||
}
|
||||
return pr.p;
|
||||
}
|
||||
|
||||
@static @param
|
||||
string_from_plist (PLString plstring)
|
||||
string_from_plist (PLString []plstring)
|
||||
{
|
||||
local @param ret;
|
||||
local string str = [plstring string];
|
||||
|
@ -145,28 +145,28 @@ string_from_plist (PLString plstring)
|
|||
}
|
||||
|
||||
@param
|
||||
object_from_plist (PLItem plist)
|
||||
object_from_plist (PLItem []plist)
|
||||
{
|
||||
local @param ret;
|
||||
|
||||
switch ([plist type]) {
|
||||
case QFDictionary:
|
||||
return class_from_plist ((PLDictionary) plist);
|
||||
return class_from_plist ((PLDictionary []) plist);
|
||||
case QFArray:
|
||||
return array_from_plist ((PLArray) plist);
|
||||
return array_from_plist ((PLArray []) plist);
|
||||
case QFBinary:
|
||||
ret.pointer_val = NIL;
|
||||
return ret;
|
||||
case QFString:
|
||||
return string_from_plist ((PLString) plist);
|
||||
return string_from_plist ((PLString []) plist);
|
||||
}
|
||||
}
|
||||
|
||||
PLItem
|
||||
PLItem []
|
||||
read_plist (string fname)
|
||||
{
|
||||
local QFile file;
|
||||
local PLItem plist;
|
||||
local PLItem []plist;
|
||||
|
||||
file = QFS_OpenFile (fname);
|
||||
if (!file) {
|
||||
|
|
|
@ -25,8 +25,8 @@ integer (integer x, integer y) servlist_all_draw =
|
|||
|
||||
integer serv_nfull;
|
||||
integer serv_nempty;
|
||||
InputLine serv_maxping;
|
||||
InputLine serv_game;
|
||||
InputLine []serv_maxping;
|
||||
InputLine []serv_game;
|
||||
|
||||
integer (integer x, integer y) servlist_filter_draw =
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
@interface Axe: Object <Weapon>
|
||||
{
|
||||
Entity owner;
|
||||
Entity[] owner;
|
||||
float damage;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) setOwner: (Entity) o
|
||||
- (void) setOwner: (Entity []) o
|
||||
{
|
||||
owner = o;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@protocol Weapon
|
||||
|
||||
- (void) setOwner: (Entity)o;
|
||||
- (void) setOwner: (Entity [])o;
|
||||
- (void) fire;
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,12 +8,12 @@ integer deathmatch;
|
|||
|
||||
@interface BodyQueue: Object
|
||||
{
|
||||
entity [MAX_BODIES] bodies;
|
||||
entity[MAX_BODIES] bodies;
|
||||
integer head;
|
||||
}
|
||||
|
||||
- (id) init;
|
||||
- (void) addEntity: (GameEntity)ent;
|
||||
- (void) addEntity: (GameEntity [])ent;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -27,7 +27,7 @@ integer deathmatch;
|
|||
head = NIL;
|
||||
|
||||
for (i = 0; i < MAX_BODIES; i++) {
|
||||
local GameEntity ent = NIL;
|
||||
local GameEntity[] ent = NIL;
|
||||
ent = [[GameEntity alloc] init];
|
||||
bodies[i] = ent.ent;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ integer deathmatch;
|
|||
#endif
|
||||
}
|
||||
|
||||
- (void) addEntity: (GameEntity)ent
|
||||
- (void) addEntity: (GameEntity[])ent
|
||||
{
|
||||
local entity be = bodies[head++];
|
||||
local entity e = [ent ent];
|
||||
|
@ -63,7 +63,7 @@ integer deathmatch;
|
|||
}
|
||||
|
||||
- (void) spawn: (entity)ent;
|
||||
- (void) copyToBodyQueue: (GameEntity)ent;
|
||||
- (void) copyToBodyQueue: (GameEntity [])ent;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -75,7 +75,7 @@ integer deathmatch;
|
|||
bodyque = [[BodyQueue alloc] init];
|
||||
}
|
||||
|
||||
- (void) copyToBodyQueue: (GameEntity)ent
|
||||
- (void) copyToBodyQueue: (GameEntity [])ent
|
||||
{
|
||||
[bodyque addEntity: ent];
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (View) addView: (View)aView
|
||||
- (View []) addView: (View [])aView
|
||||
{
|
||||
[views addObject:aView];
|
||||
return aView;
|
||||
}
|
||||
|
||||
- (id) addViews: (Array)viewlist
|
||||
- (id) addViews: (Array [])viewlist
|
||||
{
|
||||
while ([viewlist count]) {
|
||||
[self addView: [viewlist objectAtIndex: 0]];
|
||||
|
@ -44,7 +44,7 @@
|
|||
[views makeObjectsPerformSelector:sel withObject:self];
|
||||
}
|
||||
|
||||
- (void) setBasePosFromView: (View) view
|
||||
- (void) setBasePosFromView: (View []) view
|
||||
{
|
||||
[super setBasePosFromView:view];
|
||||
local SEL sel = @selector (setBasePosFromView:);
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
yabs = ypos + y;
|
||||
}
|
||||
|
||||
- (void) setBasePosFromView: (View) view
|
||||
- (void) setBasePosFromView: (View []) view
|
||||
{
|
||||
Point pos = [view basePos];
|
||||
xabs = xpos + pos.x;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
/**
|
||||
Returns a copy of \a array, retaining its contents.
|
||||
*/
|
||||
+ (id) arrayWithArray: (Array)array;
|
||||
+ (id) arrayWithArray: (Array [])array;
|
||||
|
||||
/**
|
||||
Create an array containing only \a anObject .
|
||||
|
@ -79,7 +79,7 @@
|
|||
/**
|
||||
Initialize the receiver with objects from \a array.
|
||||
*/
|
||||
- (id) initWithArray: (Array)array;
|
||||
- (id) initWithArray: (Array [])array;
|
||||
|
||||
/**
|
||||
Initialize the receiver with objects from \a array.
|
||||
|
@ -87,7 +87,7 @@
|
|||
\param array The array to duplicate
|
||||
\param flag if #YES, copies the contents instead of retaining them.
|
||||
*/
|
||||
- (id) initWithArray: (Array)array
|
||||
- (id) initWithArray: (Array [])array
|
||||
copyItems: (BOOL)flag;
|
||||
|
||||
/**
|
||||
|
@ -193,7 +193,7 @@
|
|||
/**
|
||||
Adds each object in \a array to the receiver, retaining it.
|
||||
*/
|
||||
- (void) addObjectsFromArray: (Array)array;
|
||||
- (void) addObjectsFromArray: (Array [])array;
|
||||
|
||||
/**
|
||||
Adds a single object to an array
|
||||
|
@ -218,7 +218,7 @@
|
|||
|
||||
\note If \a array and self are the same object, this method has no effect.
|
||||
*/
|
||||
- (void) setArray: (Array)array;
|
||||
- (void) setArray: (Array [])array;
|
||||
//\}
|
||||
|
||||
///\name Removing Objects
|
||||
|
@ -245,7 +245,7 @@
|
|||
Finds and removes all objects from the receiver that are equal to any
|
||||
objects in array \a anArray.
|
||||
*/
|
||||
- (void) removeObjectsInArray: (Array)anArray;
|
||||
- (void) removeObjectsInArray: (Array [])anArray;
|
||||
|
||||
/**
|
||||
Finds and removes all objects from the receiver that are \b exactly equal
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
@interface AutoreleasePool: Object
|
||||
{
|
||||
Array array; ///< a list of objects awaiting release
|
||||
Array[] array; ///< a list of objects awaiting release
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
@interface ListNode: Object
|
||||
{
|
||||
ListNode nextNode;
|
||||
ListNode[] nextNode;
|
||||
id data;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
withObject: (id)anObject
|
||||
withObject: (id)anotherObject;
|
||||
- (BOOL) respondsToSelector: (SEL)aSelector;
|
||||
- (BOOL) conformsToProtocol: (Protocol)aProtocol;
|
||||
- (BOOL) conformsToProtocol: (Protocol [])aProtocol;
|
||||
|
||||
- (id) retain;
|
||||
- (id) autorelease;
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
plitem_t item;
|
||||
integer own;
|
||||
}
|
||||
+ (PLItem) newDictionary;
|
||||
+ (PLItem) newArray;
|
||||
+ (PLItem) newData:(void[]) data size:(integer) len;
|
||||
+ (PLItem) newString:(string) str;
|
||||
+ (PLItem) fromString:(string) str;
|
||||
+ (PLItem) fromFile:(QFile) file;
|
||||
+ (PLItem []) newDictionary;
|
||||
+ (PLItem []) newArray;
|
||||
+ (PLItem []) newData:(void[]) data size:(integer) len;
|
||||
+ (PLItem []) newString:(string) str;
|
||||
+ (PLItem []) fromString:(string) str;
|
||||
+ (PLItem []) fromFile:(QFile) file;
|
||||
|
||||
- initWithItem:(plitem_t) item;
|
||||
- initWithOwnItem:(plitem_t) item;
|
||||
|
@ -23,31 +23,31 @@
|
|||
@end
|
||||
|
||||
@interface PLDictionary: PLItem
|
||||
+ (PLDictionary) new;
|
||||
+ (PLDictionary []) new;
|
||||
|
||||
- (integer) count;
|
||||
- (integer) numKeys;
|
||||
- (PLItem) getObjectForKey:(string) key;
|
||||
- (PLItem) allKeys;
|
||||
- addKey:(string) key value:(PLItem) value;
|
||||
- (PLItem []) getObjectForKey:(string) key;
|
||||
- (PLItem []) allKeys;
|
||||
- addKey:(string) key value:(PLItem []) value;
|
||||
@end
|
||||
|
||||
@interface PLArray: PLItem
|
||||
+ (PLArray) new;
|
||||
+ (PLArray []) new;
|
||||
|
||||
- (integer) count;
|
||||
- (integer) numObjects;
|
||||
- (PLItem) getObjectAtIndex:(integer) index;
|
||||
- addObject:(PLItem) object;
|
||||
- insertObject:(PLItem) object atIndex:(integer) index;
|
||||
- (PLItem []) getObjectAtIndex:(integer) index;
|
||||
- addObject:(PLItem []) object;
|
||||
- insertObject:(PLItem []) object atIndex:(integer) index;
|
||||
@end
|
||||
|
||||
@interface PLData: PLItem
|
||||
+ (PLData) new:(void[]) data size:(integer) len;
|
||||
+ (PLData []) new:(void[]) data size:(integer) len;
|
||||
@end
|
||||
|
||||
@interface PLString: PLItem
|
||||
+ (PLString) new:(string) str;
|
||||
+ (PLString []) new:(string) str;
|
||||
|
||||
- (string) string;
|
||||
@end
|
||||
|
|
|
@ -17,7 +17,7 @@ struct obj_method_description {
|
|||
}
|
||||
|
||||
- (string) name;
|
||||
- (BOOL) conformsTo: (Protocol)aProtocolObject;
|
||||
- (BOOL) conformsTo: (Protocol [])aProtocolObject;
|
||||
- (struct obj_method_description []) descriptionForInstanceMethod: (SEL)aSel;
|
||||
- (struct obj_method_description []) descriptionForClassMethod: (SEL)aSel;
|
||||
@end
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
@interface Group : View
|
||||
{
|
||||
Array views;
|
||||
Array []views;
|
||||
}
|
||||
- (void) dealloc;
|
||||
- (View) addView: (View)aView;
|
||||
- (id) addViews: (Array)viewlist;
|
||||
- (View[]) addView: (View[])aView;
|
||||
- (id) addViews: (Array[])viewlist;
|
||||
- (void) moveTo: (integer)x y:(integer)y;
|
||||
- (void) draw;
|
||||
@end
|
||||
|
|
|
@ -44,7 +44,7 @@ struct il_data_t {
|
|||
|
||||
@interface InputLineBox: View
|
||||
{
|
||||
InputLine input_line;
|
||||
InputLine []input_line;
|
||||
}
|
||||
- (id) initWithBounds: (Rect)aRect promptCharacter: (integer)char;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
integer xpos, ypos;
|
||||
integer xlen, ylen;
|
||||
integer xabs, yabs;
|
||||
View parent;
|
||||
View []parent;
|
||||
integer flags;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
- (id) canFocus: (integer)cf;
|
||||
- (integer) canFocus;
|
||||
- (void) setBasePos: (integer)x y: (integer)y;
|
||||
- (void) setBasePosFromView: (View)view;
|
||||
- (void) setBasePosFromView: (View[])view;
|
||||
- (void) draw;
|
||||
|
||||
- (integer) keyEvent:(integer)key unicode:(integer)unicode down:(integer)down;
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
return [[[self alloc] initWithCapacity: cap] autorelease];
|
||||
}
|
||||
|
||||
+ (id) arrayWithArray: (Array)array
|
||||
+ (id) arrayWithArray: (Array [])array
|
||||
{
|
||||
return [[array copy] autorelease];
|
||||
}
|
||||
|
||||
+ (id) arrayWithObject: (id)anObject
|
||||
{
|
||||
Array newArray = (Array)[self arrayWithCapacity: STANDARD_CAPACITY];
|
||||
Array [] newArray = (Array [])[self arrayWithCapacity: STANDARD_CAPACITY];
|
||||
|
||||
[newArray addObject: anObject];
|
||||
return newArray;
|
||||
|
@ -86,7 +86,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithArray: (Array)array
|
||||
- (id) initWithArray: (Array [])array
|
||||
{
|
||||
#if 0
|
||||
local unsigned i;
|
||||
|
@ -104,7 +104,7 @@
|
|||
#endif
|
||||
}
|
||||
|
||||
- (id) initWithArray: (Array)array
|
||||
- (id) initWithArray: (Array [])array
|
||||
copyItems: (BOOL)copy
|
||||
{
|
||||
local unsigned i;
|
||||
|
@ -241,7 +241,7 @@
|
|||
count++;
|
||||
}
|
||||
|
||||
- (void) addObjectsFromArray: (Array)array
|
||||
- (void) addObjectsFromArray: (Array [])array
|
||||
{
|
||||
local unsigned i;
|
||||
|
||||
|
@ -299,7 +299,7 @@
|
|||
[tmp release];
|
||||
}
|
||||
|
||||
- (void) setArray: (Array)array
|
||||
- (void) setArray: (Array [])array
|
||||
{
|
||||
if (self == array)
|
||||
return;
|
||||
|
@ -381,7 +381,7 @@
|
|||
} while (i);
|
||||
}
|
||||
|
||||
- (void) removeObjectsInArray: (Array)array
|
||||
- (void) removeObjectsInArray: (Array [])array
|
||||
{
|
||||
local unsigned i = [array count];
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Array.h"
|
||||
#include "Array+Private.h"
|
||||
|
||||
@static Array poolStack;
|
||||
@static Array[] poolStack;
|
||||
|
||||
@implementation AutoreleasePool
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ function PR_FindFunction (string func) = #0;
|
|||
local string field, value;
|
||||
local plitem_t keys;
|
||||
local function func;
|
||||
local Entity e;
|
||||
local Entity [] e;
|
||||
|
||||
classname = PL_String (PL_ObjectForKey (dict, "classname"));
|
||||
if (classname == "worldspawn")
|
||||
|
|
|
@ -8,7 +8,7 @@ void (id object, integer code, string fmt, @va_list args) obj_verror = #0;
|
|||
IMP (id receiver, SEL op) obj_msg_lookup = #0;
|
||||
IMP (Super class, SEL op) obj_msg_lookup_super = #0;
|
||||
id (id receiver, SEL op, ...) obj_msgSend = #0;
|
||||
id (Super class, SEL op, ...) obj_msgSend_super = #0;
|
||||
id (Super[] class, SEL op, ...) obj_msgSend_super = #0;
|
||||
@param (id receiver, SEL op, @va_list args) obj_msg_sendv = #0;
|
||||
(void []) (integer size) obj_malloc = #0;
|
||||
(void []) (integer size) obj_atomic_malloc = #0;
|
||||
|
@ -206,7 +206,7 @@ BOOL (id object) object_is_meta_class = #0;
|
|||
return (class_get_instance_method ([self class], aSelector) != NIL);
|
||||
}
|
||||
|
||||
- (BOOL) conformsToProtocol: (Protocol)aProtocol
|
||||
- (BOOL) conformsToProtocol: (Protocol [])aProtocol
|
||||
{
|
||||
return [[self class] conformsToProtocol: aProtocol];
|
||||
}
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
@implementation PLItem
|
||||
|
||||
+ (PLItem) newDictionary
|
||||
+ (PLItem []) newDictionary
|
||||
{
|
||||
return [PLDictionary new];
|
||||
}
|
||||
|
||||
+ (PLItem) newArray
|
||||
+ (PLItem []) newArray
|
||||
{
|
||||
return [PLArray new];
|
||||
}
|
||||
|
||||
+ (PLItem) newData:(void[]) data size:(integer) len
|
||||
+ (PLItem []) newData:(void[]) data size:(integer) len
|
||||
{
|
||||
return [PLData new:data size:len];
|
||||
}
|
||||
|
||||
+ (PLItem) newString:(string) str
|
||||
+ (PLItem []) newString:(string) str
|
||||
{
|
||||
return [PLString new:str];
|
||||
}
|
||||
|
@ -49,12 +49,12 @@
|
|||
return [[class alloc] initWithItem: item];
|
||||
}
|
||||
|
||||
+ (PLItem) fromString:(string) str
|
||||
+ (PLItem []) fromString:(string) str
|
||||
{
|
||||
return [[PLItem itemClass: PL_GetPropertyList (str)] autorelease];
|
||||
}
|
||||
|
||||
+ (PLItem) fromFile:(QFile) file
|
||||
+ (PLItem []) fromFile:(QFile) file
|
||||
{
|
||||
return [[PLItem itemClass: PL_GetFromFile (file)] autorelease];
|
||||
}
|
||||
|
@ -99,7 +99,7 @@
|
|||
|
||||
@implementation PLDictionary
|
||||
|
||||
+ (PLDictionary) new
|
||||
+ (PLDictionary []) new
|
||||
{
|
||||
return [[PLDictionary alloc] initWithOwnItem: PL_NewDictionary ()];
|
||||
}
|
||||
|
@ -114,17 +114,17 @@
|
|||
return PL_D_NumKeys (item);
|
||||
}
|
||||
|
||||
- (PLItem) getObjectForKey:(string) key
|
||||
- (PLItem []) getObjectForKey:(string) key
|
||||
{
|
||||
return [[PLItem itemClass: PL_ObjectForKey (item, key)] autorelease];
|
||||
}
|
||||
|
||||
- (PLItem) allKeys
|
||||
- (PLItem []) allKeys
|
||||
{
|
||||
return [[PLItem itemClass: PL_D_AllKeys (item)] autorelease];
|
||||
}
|
||||
|
||||
- addKey:(string) key value:(PLItem) value
|
||||
- addKey:(string) key value:(PLItem []) value
|
||||
{
|
||||
if (!value.own) {
|
||||
obj_error (self, 0, "add of unowned key/value to PLDictionary");
|
||||
|
@ -140,7 +140,7 @@
|
|||
|
||||
@implementation PLArray
|
||||
|
||||
+ (PLArray) new
|
||||
+ (PLArray []) new
|
||||
{
|
||||
return [[PLArray alloc] initWithOwnItem: PL_NewArray ()];
|
||||
}
|
||||
|
@ -155,12 +155,12 @@
|
|||
return PL_A_NumObjects (item);
|
||||
}
|
||||
|
||||
- (PLItem) getObjectAtIndex:(integer) index
|
||||
- (PLItem []) getObjectAtIndex:(integer) index
|
||||
{
|
||||
return [[PLItem itemClass: PL_ObjectAtIndex (item, index)] autorelease];
|
||||
}
|
||||
|
||||
- addObject:(PLItem) object
|
||||
- addObject:(PLItem []) object
|
||||
{
|
||||
if (!object.own) {
|
||||
obj_error (self, 0, "add of unowned object to PLArray");
|
||||
|
@ -172,7 +172,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- insertObject:(PLItem) object atIndex:(integer) index
|
||||
- insertObject:(PLItem []) object atIndex:(integer) index
|
||||
{
|
||||
if (!object.own) {
|
||||
obj_error (self, 0, "add of unowned object to PLArray");
|
||||
|
@ -188,7 +188,7 @@
|
|||
|
||||
@implementation PLData
|
||||
|
||||
+ (PLData) new:(void[]) data size:(integer) len
|
||||
+ (PLData []) new:(void[]) data size:(integer) len
|
||||
{
|
||||
return [[PLData alloc] initWithOwnItem: PL_NewData (data, len)];
|
||||
}
|
||||
|
@ -197,7 +197,7 @@
|
|||
|
||||
@implementation PLString
|
||||
|
||||
+ (PLString) new: (string) str
|
||||
+ (PLString []) new: (string) str
|
||||
{
|
||||
return [[PLString alloc] initWithOwnItem: PL_NewString (str)];
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ struct obj_method_description_list {
|
|||
return protocol_name;
|
||||
}
|
||||
|
||||
- (BOOL) conformsTo: (Protocol)aProtocolObject
|
||||
- (BOOL) conformsTo: (Protocol [])aProtocolObject
|
||||
{
|
||||
local integer i;
|
||||
local struct obj_protocol_list [] proto_list;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "Cons.h"
|
||||
|
||||
instruction_t returninst;
|
||||
BaseContinuation base;
|
||||
BaseContinuation []base;
|
||||
|
||||
@implementation BaseContinuation
|
||||
+ (void) initialize
|
||||
|
@ -15,14 +15,14 @@ BaseContinuation base;
|
|||
return base;
|
||||
}
|
||||
|
||||
- (void) restoreOnMachine: (Machine) m
|
||||
- (void) restoreOnMachine: (Machine []) m
|
||||
{
|
||||
[m state].program = &returninst;
|
||||
}
|
||||
|
||||
- (void) invokeOnMachine: (Machine) m
|
||||
- (void) invokeOnMachine: (Machine []) m
|
||||
{
|
||||
[m value: [(Cons) [m stack] car]];
|
||||
[m value: [(Cons []) [m stack] car]];
|
||||
[m state].program = &returninst;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Boolean.h"
|
||||
|
||||
Boolean trueConstant;
|
||||
Boolean falseConstant;
|
||||
Boolean []trueConstant;
|
||||
Boolean []falseConstant;
|
||||
|
||||
@implementation Boolean
|
||||
|
||||
|
|
|
@ -8,26 +8,26 @@
|
|||
|
||||
struct lineinfo_s {
|
||||
integer linenumber;
|
||||
String sourcefile;
|
||||
String []sourcefile;
|
||||
};
|
||||
|
||||
typedef struct lineinfo_s lineinfo_t;
|
||||
|
||||
@interface CompiledCode: SchemeObject
|
||||
{
|
||||
Frame literals;
|
||||
Array instructions;
|
||||
Array constants;
|
||||
Frame []literals;
|
||||
Array []instructions;
|
||||
Array []constants;
|
||||
instruction_t [] code;
|
||||
lineinfo_t [] lineinfo;
|
||||
integer minargs, size;
|
||||
}
|
||||
- (void) addInstruction: (Instruction) inst;
|
||||
- (integer) addConstant: (SchemeObject) c;
|
||||
- (void) addInstruction: (Instruction []) inst;
|
||||
- (integer) addConstant: (SchemeObject []) c;
|
||||
- (void) compile;
|
||||
- (instruction_t []) code;
|
||||
- (lineinfo_t []) lineinfo;
|
||||
- (Frame) literals;
|
||||
- (Frame []) literals;
|
||||
- (integer) minimumArguments;
|
||||
- (void) minimumArguments: (integer) min;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
[instructions makeObjectsPerformSelector: @selector(mark)];
|
||||
}
|
||||
|
||||
- (void) addInstruction: (Instruction) inst
|
||||
- (void) addInstruction: (Instruction []) inst
|
||||
{
|
||||
[inst line: [self line]];
|
||||
[inst source: [self source]];
|
||||
|
@ -32,7 +32,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (integer) addConstant: (SchemeObject) c
|
||||
- (integer) addConstant: (SchemeObject []) c
|
||||
{
|
||||
local integer number = [constants count];
|
||||
[constants addObject: c];
|
||||
|
@ -42,12 +42,12 @@
|
|||
- (void) compile
|
||||
{
|
||||
local integer index;
|
||||
local Instruction inst;
|
||||
local Instruction []inst;
|
||||
literals = [Frame newWithSize: [constants count] link: NIL];
|
||||
code = obj_malloc (@sizeof(instruction_t) * [instructions count]);
|
||||
lineinfo = obj_malloc(@sizeof(lineinfo_t) * [instructions count]);
|
||||
for (index = 0; index < [constants count]; index++) {
|
||||
[literals set: index to: (SchemeObject) [constants objectAtIndex: index]];
|
||||
[literals set: index to: (SchemeObject[]) [constants objectAtIndex: index]];
|
||||
}
|
||||
for (index = 0; index < [instructions count]; index++) {
|
||||
inst = [instructions objectAtIndex: index];
|
||||
|
@ -72,14 +72,14 @@
|
|||
return lineinfo;
|
||||
}
|
||||
|
||||
- (Frame) literals
|
||||
- (Frame[]) literals
|
||||
{
|
||||
return literals;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
local Array temp;
|
||||
local Array []temp;
|
||||
|
||||
if (instructions) {
|
||||
temp = instructions;
|
||||
|
|
|
@ -10,20 +10,20 @@
|
|||
|
||||
@interface Compiler: SchemeObject
|
||||
{
|
||||
CompiledCode code;
|
||||
SchemeObject sexpr;
|
||||
Scope scope;
|
||||
Error err;
|
||||
CompiledCode []code;
|
||||
SchemeObject []sexpr;
|
||||
Scope []scope;
|
||||
Error []err;
|
||||
}
|
||||
|
||||
+ (id) newWithLambda: (SchemeObject) xp scope: (Scope) sc;
|
||||
- (id) initWithLambda: (SchemeObject) xp scope: (Scope) sc;
|
||||
- (SchemeObject) compile;
|
||||
+ (id) newWithLambda: (SchemeObject []) xp scope: (Scope []) sc;
|
||||
- (id) initWithLambda: (SchemeObject []) xp scope: (Scope []) sc;
|
||||
- (SchemeObject[]) compile;
|
||||
|
||||
- (void) emitExpression: (SchemeObject) expression flags: (integer) fl;
|
||||
- (void) emitLambda: (SchemeObject) expression;
|
||||
- (void) emitConstant: (SchemeObject) expression;
|
||||
- (void) emitApply: (SchemeObject) expression flags: (integer) fl;
|
||||
- (void) emitExpression: (SchemeObject []) expression flags: (integer) fl;
|
||||
- (void) emitLambda: (SchemeObject []) expression;
|
||||
- (void) emitConstant: (SchemeObject []) expression;
|
||||
- (void) emitApply: (SchemeObject []) expression flags: (integer) fl;
|
||||
@end
|
||||
|
||||
#endif //__Compiler_h
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#include "Cons.h"
|
||||
#include "defs.h"
|
||||
|
||||
Symbol lambdaSym;
|
||||
Symbol quoteSym;
|
||||
Symbol defineSym;
|
||||
Symbol ifSym;
|
||||
Symbol letrecSym;
|
||||
Symbol beginSym;
|
||||
Symbol []lambdaSym;
|
||||
Symbol []quoteSym;
|
||||
Symbol []defineSym;
|
||||
Symbol []ifSym;
|
||||
Symbol []letrecSym;
|
||||
Symbol []beginSym;
|
||||
|
||||
@implementation Compiler
|
||||
+ (void) initialize
|
||||
|
@ -30,12 +30,12 @@ Symbol beginSym;
|
|||
[beginSym retain];
|
||||
}
|
||||
|
||||
+ (id) newWithLambda: (SchemeObject) xp scope: (Scope) sc
|
||||
+ (id) newWithLambda: (SchemeObject[]) xp scope: (Scope[]) sc
|
||||
{
|
||||
return [[self alloc] initWithLambda: xp scope: sc];
|
||||
}
|
||||
|
||||
- (id) initWithLambda: (SchemeObject) xp scope: (Scope) sc
|
||||
- (id) initWithLambda: (SchemeObject[]) xp scope: (Scope[]) sc
|
||||
{
|
||||
self = [super init];
|
||||
sexpr = xp;
|
||||
|
@ -45,14 +45,14 @@ Symbol beginSym;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) emitBuildEnvironment: (SchemeObject) arguments
|
||||
- (void) emitBuildEnvironment: (SchemeObject []) arguments
|
||||
{
|
||||
local integer count, index;
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
scope = [Scope newWithOuter: scope];
|
||||
count = 0;
|
||||
for (cur = arguments; [cur isKindOfClass: [Cons class]]; cur = [(Cons) cur cdr]) {
|
||||
for (cur = arguments; [cur isKindOfClass: [Cons class]]; cur = [(Cons[]) cur cdr]) {
|
||||
count++;
|
||||
}
|
||||
[code minimumArguments: count];
|
||||
|
@ -62,12 +62,12 @@ Symbol beginSym;
|
|||
[code addInstruction: [Instruction opcode: MAKEENV operand: count]];
|
||||
[code addInstruction: [Instruction opcode: LOADENV]];
|
||||
cur = arguments;
|
||||
for (index = 0; index < count; cur = [(Cons) cur cdr]) {
|
||||
for (index = 0; index < count; cur = [(Cons[]) cur cdr]) {
|
||||
if ([cur isKindOfClass: [Cons class]]) {
|
||||
[scope addName: (Symbol) [(Cons) cur car]];
|
||||
[scope addName: (Symbol[]) [(Cons[]) cur car]];
|
||||
[code addInstruction: [Instruction opcode: SET operand: index]];
|
||||
} else if ([cur isKindOfClass: [Symbol class]]) {
|
||||
[scope addName: (Symbol) cur];
|
||||
[scope addName: (Symbol[]) cur];
|
||||
[code addInstruction:
|
||||
[Instruction opcode: SETREST operand: index]];
|
||||
break;
|
||||
|
@ -81,21 +81,21 @@ Symbol beginSym;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) emitSequence: (SchemeObject) expressions flags: (integer) fl
|
||||
- (void) emitSequence: (SchemeObject[]) expressions flags: (integer) fl
|
||||
{
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
for (cur = expressions; cur != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
if ([(Cons) cur cdr] == [Nil nil] && (fl & TAIL)) {
|
||||
[self emitExpression: [(Cons) cur car] flags: fl];
|
||||
for (cur = expressions; cur != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
if ([(Cons[]) cur cdr] == [Nil nil] && (fl & TAIL)) {
|
||||
[self emitExpression: [(Cons[]) cur car] flags: fl];
|
||||
} else {
|
||||
[self emitExpression: [(Cons) cur car] flags: fl & ~TAIL];
|
||||
[self emitExpression: [(Cons[]) cur car] flags: fl & ~TAIL];
|
||||
}
|
||||
if (err) return;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) emitVariable: (Symbol) sym
|
||||
- (void) emitVariable: (Symbol[]) sym
|
||||
{
|
||||
local integer depth = [scope depthOf: sym];
|
||||
local integer index = [scope indexOf: sym];
|
||||
|
@ -114,27 +114,27 @@ Symbol beginSym;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) emitDefine: (SchemeObject) expression
|
||||
- (void) emitDefine: (SchemeObject[]) expression
|
||||
{
|
||||
local integer index = 0;
|
||||
|
||||
if (![expression isKindOfClass: [Cons class]] ||
|
||||
![[(Cons) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
![[(Cons[]) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
err = [Error type: "syntax"
|
||||
message: "Malformed define statement"
|
||||
by: expression];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([[(Cons) expression car] isKindOfClass: [Cons class]]) {
|
||||
index = [code addConstant: [(Cons) [(Cons) expression car] car]];
|
||||
if ([[(Cons[]) expression car] isKindOfClass: [Cons class]]) {
|
||||
index = [code addConstant: [(Cons[]) [(Cons[]) expression car] car]];
|
||||
[self emitLambda: cons(lambdaSym,
|
||||
cons([(Cons) [(Cons) expression car] cdr],
|
||||
[(Cons) expression cdr]))];
|
||||
cons([(Cons[]) [(Cons[]) expression car] cdr],
|
||||
[(Cons[]) expression cdr]))];
|
||||
if (err) return;
|
||||
} else if ([[(Cons) expression car] isKindOfClass: [Symbol class]]) {
|
||||
index = [code addConstant: [(Cons) expression car]];
|
||||
[self emitExpression: [(Cons) [(Cons) expression cdr] car] flags: 0];
|
||||
} else if ([[(Cons[]) expression car] isKindOfClass: [Symbol class]]) {
|
||||
index = [code addConstant: [(Cons[]) expression car]];
|
||||
[self emitExpression: [(Cons[]) [(Cons[]) expression cdr] car] flags: 0];
|
||||
if (err) return;
|
||||
} else {
|
||||
err = [Error type: "syntax"
|
||||
|
@ -148,12 +148,12 @@ Symbol beginSym;
|
|||
[code addInstruction: [Instruction opcode: SETGLOBAL]];
|
||||
}
|
||||
|
||||
- (void) emitIf: (SchemeObject) expression flags: (integer) fl
|
||||
- (void) emitIf: (SchemeObject[]) expression flags: (integer) fl
|
||||
{
|
||||
local Instruction falseLabel, endLabel;
|
||||
local Instruction []falseLabel, endLabel;
|
||||
local integer index;
|
||||
if (![expression isKindOfClass: [Cons class]] ||
|
||||
![[(Cons) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
![[(Cons[]) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
err = [Error type: "syntax"
|
||||
message: "Malformed if expression"
|
||||
by: expression];
|
||||
|
@ -162,19 +162,19 @@ Symbol beginSym;
|
|||
falseLabel = [Instruction opcode: LABEL];
|
||||
endLabel = [Instruction opcode: LABEL];
|
||||
|
||||
[self emitExpression: [(Cons) expression car] flags: fl & ~TAIL];
|
||||
[self emitExpression: [(Cons[]) expression car] flags: fl & ~TAIL];
|
||||
if (err) return;
|
||||
[code addInstruction: [Instruction opcode: IFFALSE label: falseLabel]];
|
||||
[self emitExpression: [(Cons) [(Cons) expression cdr] car] flags: fl];
|
||||
[self emitExpression: [(Cons[]) [(Cons[]) expression cdr] car] flags: fl];
|
||||
if (err) return;
|
||||
[code addInstruction: [Instruction opcode: GOTO label: endLabel]];
|
||||
[code addInstruction: falseLabel];
|
||||
if ([(Cons) [(Cons) expression cdr] cdr] == [Nil nil]) {
|
||||
if ([(Cons[]) [(Cons[]) expression cdr] cdr] == [Nil nil]) {
|
||||
index = [code addConstant: [Void voidConstant]];
|
||||
[code addInstruction: [Instruction opcode: LOADLITS]];
|
||||
[code addInstruction: [Instruction opcode: GET operand: index]];
|
||||
} else {
|
||||
[self emitExpression: [(Cons) [(Cons) [(Cons) expression cdr] cdr] car] flags: fl];
|
||||
[self emitExpression: [(Cons[]) [(Cons[]) [(Cons[]) expression cdr] cdr] car] flags: fl];
|
||||
if (err) return;
|
||||
}
|
||||
[code addInstruction: endLabel];
|
||||
|
@ -184,14 +184,14 @@ Symbol beginSym;
|
|||
|
||||
|
||||
|
||||
- (void) emitLetrec: (SchemeObject) expression flags: (integer) fl
|
||||
- (void) emitLetrec: (SchemeObject[]) expression flags: (integer) fl
|
||||
{
|
||||
local SchemeObject bindings;
|
||||
local SchemeObject []bindings;
|
||||
local integer count;
|
||||
|
||||
if (!isList(expression) ||
|
||||
!isList([(Cons) expression car]) ||
|
||||
![[(Cons) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
!isList([(Cons[]) expression car]) ||
|
||||
![[(Cons[]) expression cdr] isKindOfClass: [Cons class]]) {
|
||||
err = [Error type: "syntax"
|
||||
message: "Malformed letrec expression"
|
||||
by: expression];
|
||||
|
@ -201,8 +201,8 @@ Symbol beginSym;
|
|||
|
||||
count = 0;
|
||||
|
||||
for (bindings = [(Cons) expression car]; bindings != [Nil nil]; bindings = [(Cons) bindings cdr]) {
|
||||
[scope addName: (Symbol) [(Cons) [(Cons) bindings car] car]];
|
||||
for (bindings = [(Cons[]) expression car]; bindings != [Nil nil]; bindings = [(Cons[]) bindings cdr]) {
|
||||
[scope addName: (Symbol[]) [(Cons[]) [(Cons[]) bindings car] car]];
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -210,84 +210,84 @@ Symbol beginSym;
|
|||
|
||||
count = 0;
|
||||
|
||||
for (bindings = [(Cons) expression car]; bindings != [Nil nil]; bindings = [(Cons) bindings cdr]) {
|
||||
[self emitSequence: [(Cons) [(Cons) bindings car] cdr] flags: fl & ~TAIL];
|
||||
for (bindings = [(Cons[]) expression car]; bindings != [Nil nil]; bindings = [(Cons[]) bindings cdr]) {
|
||||
[self emitSequence: [(Cons[]) [(Cons[]) bindings car] cdr] flags: fl & ~TAIL];
|
||||
[code addInstruction: [Instruction opcode: PUSH]];
|
||||
[code addInstruction: [Instruction opcode: LOADENV]];
|
||||
[code addInstruction: [Instruction opcode: SET operand: count]];
|
||||
count++;
|
||||
}
|
||||
|
||||
[self emitSequence: [(Cons) expression cdr] flags: fl];
|
||||
[self emitSequence: [(Cons[]) expression cdr] flags: fl];
|
||||
[code addInstruction: [Instruction opcode: POPENV]];
|
||||
scope = [scope outer];
|
||||
}
|
||||
|
||||
- (void) emitExpression: (SchemeObject) expression flags: (integer) fl
|
||||
- (void) emitExpression: (SchemeObject[]) expression flags: (integer) fl
|
||||
{
|
||||
if ([expression isKindOfClass: [Cons class]]) {
|
||||
[code source: [expression source]];
|
||||
[code line: [expression line]];
|
||||
|
||||
if ([(Cons) expression car] == lambdaSym) {
|
||||
if ([(Cons[]) expression car] == lambdaSym) {
|
||||
[self emitLambda: expression];
|
||||
} else if ([(Cons) expression car] == quoteSym) {
|
||||
[self emitConstant: [(Cons) [(Cons) expression cdr] car]];
|
||||
} else if ([(Cons) expression car] == defineSym) {
|
||||
[self emitDefine: [(Cons) expression cdr]];
|
||||
} else if ([(Cons) expression car] == ifSym) {
|
||||
[self emitIf: [(Cons) expression cdr] flags: fl];
|
||||
} else if ([(Cons) expression car] == letrecSym) {
|
||||
[self emitLetrec: [(Cons) expression cdr] flags: fl];
|
||||
} else if ([(Cons) expression car] == beginSym) {
|
||||
[self emitSequence: [(Cons) expression cdr] flags: fl];
|
||||
} else if ([(Cons[]) expression car] == quoteSym) {
|
||||
[self emitConstant: [(Cons[]) [(Cons[]) expression cdr] car]];
|
||||
} else if ([(Cons[]) expression car] == defineSym) {
|
||||
[self emitDefine: [(Cons[]) expression cdr]];
|
||||
} else if ([(Cons[]) expression car] == ifSym) {
|
||||
[self emitIf: [(Cons[]) expression cdr] flags: fl];
|
||||
} else if ([(Cons[]) expression car] == letrecSym) {
|
||||
[self emitLetrec: [(Cons[]) expression cdr] flags: fl];
|
||||
} else if ([(Cons[]) expression car] == beginSym) {
|
||||
[self emitSequence: [(Cons[]) expression cdr] flags: fl];
|
||||
} else {
|
||||
[self emitApply: expression flags: fl];
|
||||
}
|
||||
} else if ([expression isKindOfClass: [Symbol class]]) {
|
||||
[self emitVariable: (Symbol) expression];
|
||||
[self emitVariable: (Symbol[]) expression];
|
||||
} else {
|
||||
[self emitConstant: expression];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) emitArguments: (SchemeObject) expression
|
||||
- (void) emitArguments: (SchemeObject[]) expression
|
||||
{
|
||||
if (expression == [Nil nil]) {
|
||||
return;
|
||||
} else {
|
||||
[self emitArguments: [(Cons) expression cdr]];
|
||||
[self emitArguments: [(Cons[]) expression cdr]];
|
||||
if (err) return;
|
||||
[self emitExpression: [(Cons) expression car] flags: 0];
|
||||
[self emitExpression: [(Cons[]) expression car] flags: 0];
|
||||
if (err) return;
|
||||
[code addInstruction: [Instruction opcode: PUSH]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) emitApply: (SchemeObject) expression flags: (integer) fl
|
||||
- (void) emitApply: (SchemeObject[]) expression flags: (integer) fl
|
||||
{
|
||||
local Instruction label = [Instruction opcode: LABEL];
|
||||
local Instruction []label = [Instruction opcode: LABEL];
|
||||
if (!(fl & TAIL)) {
|
||||
[code addInstruction: [Instruction opcode: MAKECONT label: label]];
|
||||
}
|
||||
[self emitArguments: [(Cons) expression cdr]];
|
||||
[self emitArguments: [(Cons[]) expression cdr]];
|
||||
if (err) return;
|
||||
[self emitExpression: [(Cons) expression car] flags: fl & ~TAIL];
|
||||
[self emitExpression: [(Cons[]) expression car] flags: fl & ~TAIL];
|
||||
if (err) return;
|
||||
[code addInstruction: [Instruction opcode: CALL]];
|
||||
[code addInstruction: label];
|
||||
}
|
||||
|
||||
- (void) emitLambda: (SchemeObject) expression
|
||||
- (void) emitLambda: (SchemeObject[]) expression
|
||||
{
|
||||
local Compiler compiler = [Compiler newWithLambda: expression
|
||||
local Compiler []compiler = [Compiler newWithLambda: expression
|
||||
scope: scope];
|
||||
local SchemeObject res;
|
||||
local SchemeObject []res;
|
||||
local integer index;
|
||||
|
||||
res = [compiler compile];
|
||||
if ([res isError]) {
|
||||
err = (Error) res;
|
||||
err = (Error []) res;
|
||||
return;
|
||||
}
|
||||
index = [code addConstant: res];
|
||||
|
@ -296,7 +296,7 @@ Symbol beginSym;
|
|||
[code addInstruction: [Instruction opcode: MAKECLOSURE]];
|
||||
}
|
||||
|
||||
- (void) emitConstant: (SchemeObject) expression
|
||||
- (void) emitConstant: (SchemeObject[]) expression
|
||||
{
|
||||
local integer index;
|
||||
index = [code addConstant: expression];
|
||||
|
@ -304,29 +304,29 @@ Symbol beginSym;
|
|||
[code addInstruction: [Instruction opcode: GET operand: index]];
|
||||
}
|
||||
|
||||
- (void) checkLambdaSyntax: (SchemeObject) expression
|
||||
- (void) checkLambdaSyntax: (SchemeObject[]) expression
|
||||
{
|
||||
if (![expression isKindOfClass: [Cons class]] ||
|
||||
[(Cons) expression car] != lambdaSym ||
|
||||
[(Cons) expression cdr] == [Nil nil] ||
|
||||
[(Cons) [(Cons) expression cdr] cdr] == [Nil nil]) {
|
||||
[(Cons[]) expression car] != lambdaSym ||
|
||||
[(Cons[]) expression cdr] == [Nil nil] ||
|
||||
[(Cons[]) [(Cons[]) expression cdr] cdr] == [Nil nil]) {
|
||||
err = [Error type: "syntax"
|
||||
message: "malformed lambda expression"
|
||||
by: expression];
|
||||
}
|
||||
}
|
||||
|
||||
- (SchemeObject) compile
|
||||
- (SchemeObject[]) compile
|
||||
{
|
||||
[self checkLambdaSyntax: sexpr];
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
[self emitBuildEnvironment: [(Cons) [(Cons) sexpr cdr] car]];
|
||||
[self emitBuildEnvironment: [(Cons[]) [(Cons[]) sexpr cdr] car]];
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
[self emitSequence: [(Cons) [(Cons) sexpr cdr] cdr] flags: TAIL];
|
||||
[self emitSequence: [(Cons[]) [(Cons[]) sexpr cdr] cdr] flags: TAIL];
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
|
||||
@interface Cons: SchemeObject
|
||||
{
|
||||
SchemeObject car, cdr;
|
||||
SchemeObject []car, cdr;
|
||||
}
|
||||
+ (id) newWithCar: (SchemeObject) a cdr: (SchemeObject) d;
|
||||
- (id) initWithCar: (SchemeObject) a cdr: (SchemeObject) d;
|
||||
- (SchemeObject) car;
|
||||
- (void) car: (SchemeObject) a;
|
||||
- (SchemeObject) cdr;
|
||||
- (void) cdr: (SchemeObject) d;
|
||||
+ (id) newWithCar: (SchemeObject []) a cdr: (SchemeObject []) d;
|
||||
- (id) initWithCar: (SchemeObject []) a cdr: (SchemeObject []) d;
|
||||
- (SchemeObject []) car;
|
||||
- (void) car: (SchemeObject []) a;
|
||||
- (SchemeObject []) cdr;
|
||||
- (void) cdr: (SchemeObject []) d;
|
||||
@end
|
||||
|
||||
@extern Cons cons (SchemeObject car, SchemeObject cdr);
|
||||
@extern BOOL isList (SchemeObject ls);
|
||||
@extern integer length (SchemeObject foo);
|
||||
@extern Cons []cons (SchemeObject []car, SchemeObject []cdr);
|
||||
@extern BOOL isList (SchemeObject []ls);
|
||||
@extern integer length (SchemeObject []foo);
|
||||
|
||||
#endif //__Cons_h
|
||||
|
|
|
@ -4,37 +4,37 @@
|
|||
#include "defs.h"
|
||||
#include "SchemeString.h"
|
||||
|
||||
Cons cons (SchemeObject car, SchemeObject cdr)
|
||||
Cons []cons (SchemeObject []car, SchemeObject []cdr)
|
||||
{
|
||||
return [Cons newWithCar: car cdr: cdr];
|
||||
}
|
||||
|
||||
integer length (SchemeObject foo)
|
||||
integer length (SchemeObject []foo)
|
||||
{
|
||||
local integer len;
|
||||
|
||||
for (len = 0; [foo isKindOfClass: [Cons class]]; foo = [(Cons) foo cdr]) {
|
||||
for (len = 0; [foo isKindOfClass: [Cons class]]; foo = [(Cons []) foo cdr]) {
|
||||
len++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
BOOL isList (SchemeObject ls)
|
||||
BOOL isList (SchemeObject []ls)
|
||||
{
|
||||
return ls == [Nil nil] ||
|
||||
([ls isKindOfClass: [Cons class]] &&
|
||||
isList([(Cons) ls cdr]));
|
||||
isList([(Cons[]) ls cdr]));
|
||||
}
|
||||
|
||||
@implementation Cons
|
||||
|
||||
+ (id) newWithCar: (SchemeObject) a cdr: (SchemeObject) d
|
||||
+ (id) newWithCar: (SchemeObject []) a cdr: (SchemeObject []) d
|
||||
{
|
||||
return [[self alloc] initWithCar: a cdr: d];
|
||||
}
|
||||
|
||||
- (id) initWithCar: (SchemeObject) a cdr: (SchemeObject) d
|
||||
- (id) initWithCar: (SchemeObject []) a cdr: (SchemeObject []) d
|
||||
{
|
||||
car = a;
|
||||
cdr = d;
|
||||
|
@ -48,22 +48,22 @@ BOOL isList (SchemeObject ls)
|
|||
return [super init];
|
||||
}
|
||||
|
||||
- (SchemeObject) car
|
||||
- (SchemeObject []) car
|
||||
{
|
||||
return car;
|
||||
}
|
||||
|
||||
- (void) car: (SchemeObject) a
|
||||
- (void) car: (SchemeObject []) a
|
||||
{
|
||||
car = a;
|
||||
}
|
||||
|
||||
- (SchemeObject) cdr
|
||||
- (SchemeObject []) cdr
|
||||
{
|
||||
return cdr;
|
||||
}
|
||||
|
||||
- (void) cdr: (SchemeObject) d
|
||||
- (void) cdr: (SchemeObject []) d
|
||||
{
|
||||
cdr = d;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
}
|
||||
+ (id) newWithState: (state_t []) st pc: (integer) p;
|
||||
- (id) initWithState: (state_t []) st pc: (integer) p;
|
||||
- (void) restoreOnMachine: (Machine) m;
|
||||
- (void) restoreOnMachine: (Machine []) m;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) restoreOnMachine: (Machine) m
|
||||
- (void) restoreOnMachine: (Machine []) m
|
||||
{
|
||||
[m state: &state];
|
||||
return;
|
||||
}
|
||||
|
||||
- (void) invokeOnMachine: (Machine) m
|
||||
- (void) invokeOnMachine: (Machine []) m
|
||||
{
|
||||
[m value: [(Cons) [m stack] car]];
|
||||
[m value: [(Cons []) [m stack] car]];
|
||||
[m state: &state];
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
{
|
||||
string type, message;
|
||||
}
|
||||
+ (id) type: (string) t message: (string) m by: (SchemeObject) o;
|
||||
+ (id) type: (string) t message: (string) m by: (SchemeObject []) o;
|
||||
+ (id) type: (string) t message: (string) m;
|
||||
- (id) initWithType: (string) t message: (string) m by: (SchemeObject) o;
|
||||
- (id) initWithType: (string) t message: (string) m by: (SchemeObject []) o;
|
||||
- (string) type;
|
||||
- (string) message;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "string.h"
|
||||
|
||||
@implementation Error
|
||||
+ (id) type: (string) t message: (string) m by: (SchemeObject) o
|
||||
+ (id) type: (string) t message: (string) m by: (SchemeObject []) o
|
||||
{
|
||||
return [[self alloc] initWithType: t message: m by: o];
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
|||
return [[self alloc] initWithType: t message: m by: NIL];
|
||||
}
|
||||
|
||||
- (id) initWithType: (string) t message: (string) m by: (SchemeObject) o
|
||||
- (id) initWithType: (string) t message: (string) m by: (SchemeObject []) o
|
||||
{
|
||||
self = [super init];
|
||||
type = str_new();
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
|
||||
@interface Frame: SchemeObject
|
||||
{
|
||||
SchemeObject[] array;
|
||||
SchemeObject[][] array;
|
||||
integer size;
|
||||
Frame link;
|
||||
Frame []link;
|
||||
}
|
||||
+ (id) newWithSize: (integer) sz link: (Frame) l;
|
||||
- (id) initWithSize: (integer) sz link: (Frame) l;
|
||||
- (void) set: (integer) index to: (SchemeObject) o;
|
||||
- (SchemeObject) get: (integer) index;
|
||||
- (Frame) getLink;
|
||||
+ (id) newWithSize: (integer) sz link: (Frame []) l;
|
||||
- (id) initWithSize: (integer) sz link: (Frame []) l;
|
||||
- (void) set: (integer) index to: (SchemeObject []) o;
|
||||
- (SchemeObject []) get: (integer) index;
|
||||
- (Frame []) getLink;
|
||||
@end
|
||||
|
||||
#endif //__FOO_h
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "Frame.h"
|
||||
|
||||
@implementation Frame
|
||||
+ (id) newWithSize: (integer) sz link: (Frame) l
|
||||
+ (id) newWithSize: (integer) sz link: (Frame []) l
|
||||
{
|
||||
return [[self alloc] initWithSize: sz link: l];
|
||||
}
|
||||
|
||||
- (id) initWithSize: (integer) sz link: (Frame) l
|
||||
- (id) initWithSize: (integer) sz link: (Frame []) l
|
||||
{
|
||||
self = [super init];
|
||||
size = sz;
|
||||
|
@ -15,17 +15,17 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) set: (integer) index to: (SchemeObject) o
|
||||
- (void) set: (integer) index to: (SchemeObject []) o
|
||||
{
|
||||
array[index] = o;
|
||||
}
|
||||
|
||||
- (SchemeObject) get: (integer) index
|
||||
- (SchemeObject []) get: (integer) index
|
||||
{
|
||||
return array[index];
|
||||
}
|
||||
|
||||
- (Frame) getLink
|
||||
- (Frame []) getLink
|
||||
{
|
||||
return link;
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ typedef struct instruction_s instruction_t;
|
|||
{
|
||||
opcode_e opcode;
|
||||
integer operand, offset;
|
||||
Instruction label;
|
||||
Instruction []label;
|
||||
}
|
||||
+ (id) opcode: (opcode_e) oc;
|
||||
+ (id) opcode: (opcode_e) oc operand: (integer) op;
|
||||
+ (id) opcode: (opcode_e) oc label: (Instruction) l;
|
||||
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction) l;
|
||||
+ (id) opcode: (opcode_e) oc label: (Instruction []) l;
|
||||
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction []) l;
|
||||
- (void) offset: (integer) ofs;
|
||||
- (integer) offset;
|
||||
- (opcode_e) opcode;
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
return [[self alloc] initWithOpcode: oc operand: op label: NIL];
|
||||
}
|
||||
|
||||
+ (id) opcode: (opcode_e) oc label: (Instruction) l
|
||||
+ (id) opcode: (opcode_e) oc label: (Instruction []) l
|
||||
{
|
||||
return [[self alloc] initWithOpcode: oc operand: 0 label: l];
|
||||
}
|
||||
|
||||
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction) l
|
||||
- (id) initWithOpcode: (opcode_e) oc operand: (integer) op label: (Instruction []) l
|
||||
{
|
||||
self = [super init];
|
||||
opcode = oc;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
@interface Lambda: Procedure
|
||||
{
|
||||
Frame env;
|
||||
CompiledCode code;
|
||||
Frame []env;
|
||||
CompiledCode []code;
|
||||
}
|
||||
+ (id) newWithCode: (CompiledCode) c environment: (Frame) e;
|
||||
- (id) initWithCode: (CompiledCode) c environment: (Frame) e;
|
||||
+ (id) newWithCode: (CompiledCode []) c environment: (Frame []) e;
|
||||
- (id) initWithCode: (CompiledCode []) c environment: (Frame []) e;
|
||||
@end
|
||||
|
||||
#endif //__Lambda_h
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
#include "Machine.h"
|
||||
|
||||
@implementation Lambda
|
||||
+ (id) newWithCode: (CompiledCode) c environment: (Frame) e
|
||||
+ (id) newWithCode: (CompiledCode []) c environment: (Frame []) e
|
||||
{
|
||||
return [[self alloc] initWithCode: c environment: e];
|
||||
}
|
||||
|
||||
- (id) initWithCode: (CompiledCode) c environment: (Frame) e
|
||||
- (id) initWithCode: (CompiledCode []) c environment: (Frame []) e
|
||||
{
|
||||
self = [super init];
|
||||
code = c;
|
||||
|
@ -21,7 +21,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) invokeOnMachine: (Machine) m
|
||||
- (void) invokeOnMachine: (Machine []) m
|
||||
{
|
||||
[super invokeOnMachine: m];
|
||||
if (length([m stack]) < [code minimumArguments]) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
+ (id) newFromSource: (string) s file: (string) f;
|
||||
- (id) initWithSource: (string) s file: (string) f;
|
||||
- (SchemeObject) nextToken;
|
||||
- (SchemeObject []) nextToken;
|
||||
- (integer) lineNumber;
|
||||
@end
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ BOOL issymbol (string x)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (SchemeObject) nextToken
|
||||
- (SchemeObject[]) nextToken
|
||||
{
|
||||
local integer len;
|
||||
local Number num;
|
||||
local Symbol sym;
|
||||
local String str;
|
||||
local Boolean bl;
|
||||
local Number []num;
|
||||
local Symbol []sym;
|
||||
local String []str;
|
||||
local Boolean []bl;
|
||||
|
||||
for (len = 0; isjunk(str_mid(source, len, len+1)); len++) {
|
||||
if (str_mid(source, len, len+1) == ";") {
|
||||
|
|
|
@ -10,23 +10,23 @@
|
|||
@interface Machine: SchemeObject
|
||||
{
|
||||
state_t state;
|
||||
SchemeObject value;
|
||||
SchemeObject []value;
|
||||
hashtab_t globals;
|
||||
SchemeObject all_globals;
|
||||
SchemeObject []all_globals;
|
||||
}
|
||||
- (void) loadCode: (CompiledCode) code;
|
||||
- (SchemeObject) run;
|
||||
- (void) addGlobal: (Symbol) sym value: (SchemeObject) val;
|
||||
- (void) environment: (Frame) e;
|
||||
- (void) continuation: (Continuation) c;
|
||||
- (Continuation) continuation;
|
||||
- (void) value: (SchemeObject) o;
|
||||
- (SchemeObject) stack;
|
||||
- (void) stack: (SchemeObject) o;
|
||||
- (void) loadCode: (CompiledCode []) code;
|
||||
- (SchemeObject []) run;
|
||||
- (void) addGlobal: (Symbol []) sym value: (SchemeObject []) val;
|
||||
- (void) environment: (Frame []) e;
|
||||
- (void) continuation: (Continuation []) c;
|
||||
- (Continuation []) continuation;
|
||||
- (void) value: (SchemeObject []) o;
|
||||
- (SchemeObject []) stack;
|
||||
- (void) stack: (SchemeObject []) o;
|
||||
- (state_t []) state;
|
||||
- (void) state: (state_t []) st;
|
||||
- (void) reset;
|
||||
- (void) procedure: (Procedure) pr;
|
||||
- (void) procedure: (Procedure []) pr;
|
||||
@end
|
||||
|
||||
#endif //__Machine_h
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
string GlobalGetKey (void []ele, void []data)
|
||||
{
|
||||
return [[((Cons) ele) car] printForm];
|
||||
return [[((Cons[]) ele) car] printForm];
|
||||
}
|
||||
|
||||
void GlobalFree (void []ele, void []data)
|
||||
|
@ -37,14 +37,14 @@ void GlobalFree (void []ele, void []data)
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) addGlobal: (Symbol) sym value: (SchemeObject) val
|
||||
- (void) addGlobal: (Symbol[]) sym value: (SchemeObject[]) val
|
||||
{
|
||||
local Cons c = cons(sym, val);
|
||||
local Cons []c = cons(sym, val);
|
||||
Hash_Add(globals, c);
|
||||
all_globals = cons(c, all_globals);
|
||||
}
|
||||
|
||||
- (void) loadCode: (CompiledCode) code
|
||||
- (void) loadCode: (CompiledCode[]) code
|
||||
{
|
||||
state.program = [code code];
|
||||
state.literals = [code literals];
|
||||
|
@ -52,37 +52,37 @@ void GlobalFree (void []ele, void []data)
|
|||
state.pc = 0;
|
||||
}
|
||||
|
||||
- (void) environment: (Frame) e
|
||||
- (void) environment: (Frame[]) e
|
||||
{
|
||||
state.env = e;
|
||||
}
|
||||
|
||||
- (void) continuation: (Continuation) c
|
||||
- (void) continuation: (Continuation[]) c
|
||||
{
|
||||
state.cont = c;
|
||||
}
|
||||
|
||||
- (void) value: (SchemeObject) v
|
||||
- (void) value: (SchemeObject[]) v
|
||||
{
|
||||
value = v;
|
||||
}
|
||||
|
||||
- (SchemeObject) value
|
||||
- (SchemeObject[]) value
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
- (Continuation) continuation
|
||||
- (Continuation[]) continuation
|
||||
{
|
||||
return state.cont;
|
||||
}
|
||||
|
||||
- (SchemeObject) stack
|
||||
- (SchemeObject[]) stack
|
||||
{
|
||||
return state.stack;
|
||||
}
|
||||
|
||||
- (void) stack: (SchemeObject) o
|
||||
- (void) stack: (SchemeObject[]) o
|
||||
{
|
||||
state.stack = o;
|
||||
}
|
||||
|
@ -94,26 +94,26 @@ void GlobalFree (void []ele, void []data)
|
|||
|
||||
- (void) state: (state_t []) st
|
||||
{
|
||||
state.program = st[0].program;
|
||||
state.pc = st[0].pc;
|
||||
state.literals = st[0].literals;
|
||||
state.stack = st[0].stack;
|
||||
state.cont = st[0].cont;
|
||||
state.env = st[0].env;
|
||||
state.proc = st[0].proc;
|
||||
state.lineinfo = st[0].lineinfo;
|
||||
state.program = st.program;
|
||||
state.pc = st.pc;
|
||||
state.literals = st.literals;
|
||||
state.stack = st.stack;
|
||||
state.cont = st.cont;
|
||||
state.env = st.env;
|
||||
state.proc = st.proc;
|
||||
state.lineinfo = st.lineinfo;
|
||||
}
|
||||
|
||||
- (void) procedure: (Procedure) pr
|
||||
- (void) procedure: (Procedure[]) pr
|
||||
{
|
||||
state.proc = pr;
|
||||
}
|
||||
|
||||
- (SchemeObject) run
|
||||
- (SchemeObject[]) run
|
||||
{
|
||||
local integer opcode;
|
||||
local integer operand;
|
||||
local SchemeObject res;
|
||||
local SchemeObject []res;
|
||||
while (1) {
|
||||
if (value && [value isError]) {
|
||||
dprintf("Error: %s[%s]\n", [value description], [value printForm]);
|
||||
|
@ -134,17 +134,17 @@ void GlobalFree (void []ele, void []data)
|
|||
state.stack = cons(value, state.stack);
|
||||
break;
|
||||
case POP:
|
||||
value = [(Cons) state.stack car];
|
||||
value = [(Cons[]) state.stack car];
|
||||
if (value) {
|
||||
dprintf("Pop: %s\n", [value printForm]);
|
||||
} else {
|
||||
dprintf("Pop: NULL!!!!\n");
|
||||
}
|
||||
state.stack = [(Cons) state.stack cdr];
|
||||
state.stack = [(Cons[]) state.stack cdr];
|
||||
break;
|
||||
case MAKECLOSURE:
|
||||
dprintf("Makeclosure\n");
|
||||
value = [Lambda newWithCode: (CompiledCode) value
|
||||
value = [Lambda newWithCode: (CompiledCode[]) value
|
||||
environment: state.env];
|
||||
break;
|
||||
case MAKECONT:
|
||||
|
@ -169,16 +169,16 @@ void GlobalFree (void []ele, void []data)
|
|||
dprintf("Popenv\n");
|
||||
state.env = [state.env getLink];
|
||||
case GET:
|
||||
value = [(Frame) value get: operand];
|
||||
value = [(Frame[]) value get: operand];
|
||||
dprintf("Get: %i --> %s\n", operand, [value printForm]);
|
||||
break;
|
||||
case SET:
|
||||
[(Frame) value set: operand to: [(Cons) state.stack car]];
|
||||
dprintf("Set: %i --> %s\n", operand, [[(Cons) state.stack car] printForm]);
|
||||
state.stack = [(Cons) state.stack cdr];
|
||||
[(Frame[]) value set: operand to: [(Cons[]) state.stack car]];
|
||||
dprintf("Set: %i --> %s\n", operand, [[(Cons[]) state.stack car] printForm]);
|
||||
state.stack = [(Cons[]) state.stack cdr];
|
||||
break;
|
||||
case SETREST:
|
||||
[(Frame) value set: operand to: state.stack];
|
||||
[(Frame[]) value set: operand to: state.stack];
|
||||
dprintf("Setrest: %i --> %s\n", operand, [state.stack printForm]);
|
||||
state.stack = [Nil nil];
|
||||
break;
|
||||
|
@ -188,11 +188,11 @@ void GlobalFree (void []ele, void []data)
|
|||
break;
|
||||
case GETLINK:
|
||||
dprintf("Getlink\n");
|
||||
value = [(Frame) value getLink];
|
||||
value = [(Frame[]) value getLink];
|
||||
break;
|
||||
case GETGLOBAL:
|
||||
dprintf("Getglobal: %s\n", [value printForm]);
|
||||
res = [((Cons) Hash_Find(globals, [value printForm])) cdr];
|
||||
res = [((Cons[]) Hash_Find(globals, [value printForm])) cdr];
|
||||
if (!res) {
|
||||
return [Error type: "binding"
|
||||
message: sprintf("Undefined binding: %s",
|
||||
|
@ -204,8 +204,8 @@ void GlobalFree (void []ele, void []data)
|
|||
break;
|
||||
case SETGLOBAL:
|
||||
dprintf("Setglobal: %s\n", [value printForm]);
|
||||
[self addGlobal: (Symbol) value value: [(Cons) state.stack car]];
|
||||
state.stack = [(Cons) state.stack cdr];
|
||||
[self addGlobal: (Symbol[]) value value: [(Cons[]) state.stack car]];
|
||||
state.stack = [(Cons[]) state.stack cdr];
|
||||
break;
|
||||
case CALL:
|
||||
dprintf("Call\n");
|
||||
|
@ -217,7 +217,7 @@ void GlobalFree (void []ele, void []data)
|
|||
[value printForm], [state.stack printForm])
|
||||
by: self];
|
||||
}
|
||||
[(Procedure) value invokeOnMachine: self];
|
||||
[(Procedure[]) value invokeOnMachine: self];
|
||||
break;
|
||||
case RETURN:
|
||||
dprintf("Return: %s\n", [value printForm]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "Nil.h"
|
||||
#include "defs.h"
|
||||
|
||||
Nil one_nil_to_rule_them_all;
|
||||
Nil []one_nil_to_rule_them_all;
|
||||
|
||||
@implementation Nil
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
@interface Parser: SchemeObject
|
||||
{
|
||||
Lexer lexer;
|
||||
Lexer []lexer;
|
||||
string file;
|
||||
}
|
||||
+ (id) newFromSource: (string) s file: (string) f;
|
||||
- (id) initWithSource: (string) s file: (string) f;
|
||||
- (SchemeObject) readAtomic;
|
||||
- (SchemeObject) read;
|
||||
- (SchemeObject []) readAtomic;
|
||||
- (SchemeObject []) read;
|
||||
@end
|
||||
|
||||
#endif //__Parser_h
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (SchemeObject) readList
|
||||
- (SchemeObject[]) readList
|
||||
{
|
||||
local SchemeObject token, res;
|
||||
local SchemeObject []token, res;
|
||||
local integer line;
|
||||
local Error err;
|
||||
local Error []err;
|
||||
|
||||
line = [lexer lineNumber];
|
||||
token = [self readAtomic];
|
||||
|
@ -60,9 +60,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (SchemeObject) readAtomic
|
||||
- (SchemeObject[]) readAtomic
|
||||
{
|
||||
local SchemeObject token, list, res;
|
||||
local SchemeObject []token, list, res;
|
||||
local integer line;
|
||||
|
||||
line = [lexer lineNumber];
|
||||
|
@ -93,10 +93,10 @@
|
|||
} else return token;
|
||||
}
|
||||
|
||||
- (SchemeObject) read
|
||||
- (SchemeObject[]) read
|
||||
{
|
||||
local SchemeObject token;
|
||||
local Error err;
|
||||
local SchemeObject []token;
|
||||
local Error []err;
|
||||
|
||||
token = [self readAtomic];
|
||||
if (token == [Symbol rightParen]) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Procedure.h"
|
||||
#include "Machine.h"
|
||||
|
||||
typedef SchemeObject (SchemeObject args, Machine m) primfunc_t;
|
||||
typedef SchemeObject [](SchemeObject []args, Machine []m) primfunc_t;
|
||||
|
||||
@interface Primitive: Procedure
|
||||
{
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
func = f;
|
||||
return self;
|
||||
}
|
||||
- (SchemeObject) invokeOnMachine: (Machine) m
|
||||
- (SchemeObject[]) invokeOnMachine: (Machine[]) m
|
||||
{
|
||||
local SchemeObject value = func ([m stack], m);
|
||||
local SchemeObject []value = func ([m stack], m);
|
||||
[super invokeOnMachine: m];
|
||||
if (value) {
|
||||
[m value: value];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@class Machine;
|
||||
|
||||
@interface Procedure: SchemeObject
|
||||
- (void) invokeOnMachine: (Machine) m;
|
||||
- (void) invokeOnMachine: (Machine []) m;
|
||||
@end
|
||||
|
||||
#endif //__Procedure_h
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "Machine.h"
|
||||
|
||||
@implementation Procedure
|
||||
- (void) invokeOnMachine: (Machine) m
|
||||
- (void) invokeOnMachine: (Machine []) m
|
||||
{
|
||||
[m procedure: self];
|
||||
return;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
@interface SchemeObject: Object
|
||||
{
|
||||
@public SchemeObject prev, next;
|
||||
@public SchemeObject []prev, next;
|
||||
BOOL marked, root;
|
||||
integer line;
|
||||
string source;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "defs.h"
|
||||
//#include "debug.h"
|
||||
|
||||
SchemeObject maybe_garbage, not_garbage, not_garbage_end, wait_list, roots, queue_pos;
|
||||
SchemeObject []maybe_garbage, not_garbage, not_garbage_end, wait_list, roots, queue_pos;
|
||||
BOOL markstate;
|
||||
|
||||
typedef enum {
|
||||
|
@ -42,7 +42,7 @@ integer checkpoint;
|
|||
|
||||
+ (void) collect
|
||||
{
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
local integer amount;
|
||||
|
||||
switch (gc_state) {
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
|
||||
@interface Scope: SchemeObject
|
||||
{
|
||||
Scope outerScope;
|
||||
Array names;
|
||||
Scope []outerScope;
|
||||
Array []names;
|
||||
}
|
||||
+ (id) newWithOuter: (Scope) o;
|
||||
- (id) initWithOuter: (Scope) o;
|
||||
- (integer) depthOf: (Symbol) sym;
|
||||
- (integer) indexOf: (Symbol) sym;
|
||||
- (void) addName: (Symbol) sym;
|
||||
- (Scope) outer;
|
||||
+ (id) newWithOuter: (Scope []) o;
|
||||
- (id) initWithOuter: (Scope []) o;
|
||||
- (integer) depthOf: (Symbol []) sym;
|
||||
- (integer) indexOf: (Symbol []) sym;
|
||||
- (void) addName: (Symbol []) sym;
|
||||
- (Scope []) outer;
|
||||
@end
|
||||
|
||||
#endif //__Scope_h
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
@implementation Scope
|
||||
|
||||
+ (id) newWithOuter: (Scope) o
|
||||
+ (id) newWithOuter: (Scope []) o
|
||||
{
|
||||
return [[self alloc] initWithOuter: o];
|
||||
}
|
||||
|
||||
- (id) initWithOuter: (Scope) o
|
||||
- (id) initWithOuter: (Scope []) o
|
||||
{
|
||||
self = [super init];
|
||||
outerScope = o;
|
||||
|
@ -16,7 +16,7 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (integer) indexLocal: (Symbol) sym
|
||||
- (integer) indexLocal: (Symbol []) sym
|
||||
{
|
||||
local integer index;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
return -1;
|
||||
}
|
||||
|
||||
- (integer) indexOf: (Symbol) sym
|
||||
- (integer) indexOf: (Symbol []) sym
|
||||
{
|
||||
local integer index;
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (integer) depthOf: (Symbol) sym
|
||||
- (integer) depthOf: (Symbol []) sym
|
||||
{
|
||||
local integer index;
|
||||
local integer res;
|
||||
|
@ -64,7 +64,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) addName: (Symbol) sym
|
||||
- (void) addName: (Symbol []) sym
|
||||
{
|
||||
[names addObject: sym];
|
||||
}
|
||||
|
@ -84,7 +84,7 @@
|
|||
[outerScope mark];
|
||||
}
|
||||
|
||||
- (Scope) outer
|
||||
- (Scope []) outer
|
||||
{
|
||||
return outerScope;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
{
|
||||
}
|
||||
+ (void) initialize;
|
||||
+ (Symbol) leftParen;
|
||||
+ (Symbol) rightParen;
|
||||
+ (Symbol) dot;
|
||||
+ (Symbol) forString: (string) s;
|
||||
+ (Symbol) quote;
|
||||
+ (Symbol []) leftParen;
|
||||
+ (Symbol []) rightParen;
|
||||
+ (Symbol []) dot;
|
||||
+ (Symbol []) forString: (string) s;
|
||||
+ (Symbol []) quote;
|
||||
@end
|
||||
|
||||
@extern Symbol symbol (string str);
|
||||
@extern Symbol []symbol (string str);
|
||||
|
||||
#endif //__Symbol_h
|
||||
|
|
|
@ -4,25 +4,25 @@
|
|||
|
||||
string SymbolGetKey (void [] ele, void [] data)
|
||||
{
|
||||
local Symbol s = (Symbol) ele;
|
||||
local Symbol []s = (Symbol[]) ele;
|
||||
|
||||
return [s stringValue];
|
||||
}
|
||||
|
||||
void SymbolFree (void [] ele, void [] data)
|
||||
{
|
||||
local Symbol s = (Symbol) ele;
|
||||
local Symbol []s = (Symbol[]) ele;
|
||||
|
||||
[s release];
|
||||
}
|
||||
|
||||
hashtab_t symbols;
|
||||
Symbol lparen;
|
||||
Symbol rparen;
|
||||
Symbol quote;
|
||||
Symbol dot;
|
||||
Symbol []lparen;
|
||||
Symbol []rparen;
|
||||
Symbol []quote;
|
||||
Symbol []dot;
|
||||
|
||||
Symbol symbol (string str)
|
||||
Symbol []symbol (string str)
|
||||
{
|
||||
return [Symbol forString: str];
|
||||
}
|
||||
|
@ -41,35 +41,35 @@ Symbol symbol (string str)
|
|||
[dot retain];
|
||||
}
|
||||
|
||||
+ (Symbol) forString: (string) s
|
||||
+ (Symbol[]) forString: (string) s
|
||||
{
|
||||
local Symbol res;
|
||||
local Symbol []res;
|
||||
|
||||
if ((res = Hash_Find (symbols, s))) {
|
||||
return res;
|
||||
} else {
|
||||
res = (Symbol) [self newFromString: s];
|
||||
res = (Symbol[]) [self newFromString: s];
|
||||
Hash_Add (symbols, res);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
+ (Symbol) leftParen
|
||||
+ (Symbol[]) leftParen
|
||||
{
|
||||
return lparen;
|
||||
}
|
||||
|
||||
+ (Symbol) rightParen
|
||||
+ (Symbol[]) rightParen
|
||||
{
|
||||
return rparen;
|
||||
}
|
||||
|
||||
+ (Symbol) quote
|
||||
+ (Symbol[]) quote
|
||||
{
|
||||
return quote;
|
||||
}
|
||||
|
||||
+ (Symbol) dot
|
||||
+ (Symbol[]) dot
|
||||
{
|
||||
return dot;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
+ (id) voidConstant;
|
||||
@end
|
||||
|
||||
@extern Void voidConstant;
|
||||
@extern Void []voidConstant;
|
||||
|
||||
#endif //__Void_h
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "Void.h"
|
||||
|
||||
Void voidConstant;
|
||||
Void []voidConstant;
|
||||
|
||||
@implementation Void
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#include "Primitive.h"
|
||||
|
||||
@extern void builtin_addtomachine (Machine m);
|
||||
@extern void builtin_addtomachine (Machine []m);
|
||||
|
|
|
@ -10,26 +10,26 @@
|
|||
#include "Boolean.h"
|
||||
#include "Error.h"
|
||||
|
||||
BOOL num_args (SchemeObject list, integer num)
|
||||
BOOL num_args (SchemeObject []list, integer num)
|
||||
{
|
||||
for (; [list isKindOfClass: [Cons class]]; list = [(Cons) list cdr]) {
|
||||
for (; [list isKindOfClass: [Cons class]]; list = [(Cons[]) list cdr]) {
|
||||
num--;
|
||||
}
|
||||
return num == 0;
|
||||
}
|
||||
|
||||
SchemeObject bi_display (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_display (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "display"
|
||||
message: "expected 1 argument"
|
||||
by: m];
|
||||
}
|
||||
print([[(Cons) args car] printForm]);
|
||||
print([[(Cons[]) args car] printForm]);
|
||||
return [Void voidConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_newline (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_newline (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 0)) {
|
||||
return [Error type: "newline"
|
||||
|
@ -40,28 +40,28 @@ SchemeObject bi_newline (SchemeObject args, Machine m)
|
|||
return [Void voidConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_add (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_add (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local integer sum = 0;
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
for (cur = args; cur != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
if (![[(Cons) cur car] isKindOfClass: [Number class]]) {
|
||||
for (cur = args; cur != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
if (![[(Cons[]) cur car] isKindOfClass: [Number class]]) {
|
||||
return [Error type: "+"
|
||||
message: sprintf("non-number argument: %s\n",
|
||||
[[(Cons) cur car] printForm])
|
||||
[[(Cons[]) cur car] printForm])
|
||||
by: m];
|
||||
}
|
||||
sum += [(Number) [(Cons) cur car] intValue];
|
||||
sum += [(Number[]) [(Cons[]) cur car] intValue];
|
||||
}
|
||||
|
||||
return [Number newFromInt: sum];
|
||||
}
|
||||
|
||||
SchemeObject bi_sub (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_sub (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local integer diff = 0;
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
if (args == [Nil nil]) {
|
||||
return [Error type: "-"
|
||||
|
@ -69,7 +69,7 @@ SchemeObject bi_sub (SchemeObject args, Machine m)
|
|||
by: m];
|
||||
}
|
||||
|
||||
cur = [(Cons) args car];
|
||||
cur = [(Cons[]) args car];
|
||||
|
||||
if (![cur isKindOfClass: [Number class]]) {
|
||||
return [Error type: "-"
|
||||
|
@ -78,47 +78,47 @@ SchemeObject bi_sub (SchemeObject args, Machine m)
|
|||
by: m];
|
||||
}
|
||||
|
||||
diff = [(Number) cur intValue];
|
||||
diff = [(Number[]) cur intValue];
|
||||
|
||||
if ([(Cons) args cdr] == [Nil nil]) {
|
||||
if ([(Cons[]) args cdr] == [Nil nil]) {
|
||||
return [Number newFromInt: -diff];
|
||||
}
|
||||
|
||||
for (cur = [(Cons) args cdr]; cur != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
if (![[(Cons) cur car] isKindOfClass: [Number class]]) {
|
||||
for (cur = [(Cons[]) args cdr]; cur != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
if (![[(Cons[]) cur car] isKindOfClass: [Number class]]) {
|
||||
return [Error type: "-"
|
||||
message: sprintf("non-number argument: %s\n",
|
||||
[[(Cons) cur car] printForm])
|
||||
[[(Cons[]) cur car] printForm])
|
||||
by: m];
|
||||
}
|
||||
diff -= [(Number) [(Cons) cur car] intValue];
|
||||
diff -= [(Number[]) [(Cons[]) cur car] intValue];
|
||||
}
|
||||
|
||||
return [Number newFromInt: diff];
|
||||
}
|
||||
|
||||
SchemeObject bi_mult (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_mult (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local integer prod = 1;
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
for (cur = args; cur != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
if (![[(Cons) cur car] isKindOfClass: [Number class]]) {
|
||||
for (cur = args; cur != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
if (![[(Cons[]) cur car] isKindOfClass: [Number class]]) {
|
||||
return [Error type: "*"
|
||||
message: sprintf("non-number argument: %s\n",
|
||||
[[(Cons) cur car] printForm])
|
||||
[[(Cons[]) cur car] printForm])
|
||||
by: m];
|
||||
}
|
||||
prod *= [(Number) [(Cons) cur car] intValue];
|
||||
prod *= [(Number[]) [(Cons[]) cur car] intValue];
|
||||
}
|
||||
|
||||
return [Number newFromInt: prod];
|
||||
}
|
||||
|
||||
SchemeObject bi_div (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_div (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local integer frac = 0;
|
||||
local SchemeObject cur;
|
||||
local SchemeObject []cur;
|
||||
|
||||
if (args == [Nil nil]) {
|
||||
return [Error type: "/"
|
||||
|
@ -126,7 +126,7 @@ SchemeObject bi_div (SchemeObject args, Machine m)
|
|||
by: m];
|
||||
}
|
||||
|
||||
cur = [(Cons) args car];
|
||||
cur = [(Cons[]) args car];
|
||||
|
||||
if (![cur isKindOfClass: [Number class]]) {
|
||||
return [Error type: "/"
|
||||
|
@ -135,123 +135,123 @@ SchemeObject bi_div (SchemeObject args, Machine m)
|
|||
by: m];
|
||||
}
|
||||
|
||||
frac = [(Number) cur intValue];
|
||||
frac = [(Number[]) cur intValue];
|
||||
|
||||
if ([(Cons) args cdr] == [Nil nil]) {
|
||||
if ([(Cons[]) args cdr] == [Nil nil]) {
|
||||
return [Number newFromInt: 1/frac];
|
||||
}
|
||||
|
||||
for (cur = [(Cons) args cdr]; cur != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
if (![[(Cons) cur car] isKindOfClass: [Number class]]) {
|
||||
for (cur = [(Cons[]) args cdr]; cur != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
if (![[(Cons[]) cur car] isKindOfClass: [Number class]]) {
|
||||
return [Error type: "/"
|
||||
message: sprintf("non-number argument: %s\n",
|
||||
[[(Cons) cur car] printForm])
|
||||
[[(Cons[]) cur car] printForm])
|
||||
by: m];
|
||||
}
|
||||
frac /= [(Number) [(Cons) cur car] intValue];
|
||||
frac /= [(Number[]) [(Cons[]) cur car] intValue];
|
||||
}
|
||||
|
||||
return [Number newFromInt: frac];
|
||||
}
|
||||
|
||||
SchemeObject bi_cons (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_cons (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 2)) {
|
||||
return [Error type: "cons"
|
||||
message: "expected 2 arguments"
|
||||
by: m];
|
||||
}
|
||||
[(Cons) args cdr: [(Cons) [(Cons) args cdr] car]];
|
||||
[(Cons[]) args cdr: [(Cons[]) [(Cons[]) args cdr] car]];
|
||||
return args;
|
||||
}
|
||||
|
||||
SchemeObject bi_null (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_null (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "null?"
|
||||
message: "expected 1 argument"
|
||||
by: m];
|
||||
}
|
||||
return [(Cons) args car] == [Nil nil]
|
||||
return [(Cons[]) args car] == [Nil nil]
|
||||
?
|
||||
[Boolean trueConstant] :
|
||||
[Boolean falseConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_car (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_car (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "car"
|
||||
message: "expected 1 argument"
|
||||
by: m];
|
||||
}
|
||||
if (![[(Cons) args car] isKindOfClass: [Cons class]]) {
|
||||
if (![[(Cons[]) args car] isKindOfClass: [Cons class]]) {
|
||||
return [Error type: "car"
|
||||
message: sprintf("expected pair, got: %s",
|
||||
[[(Cons) args car] printForm])
|
||||
[[(Cons[]) args car] printForm])
|
||||
by: m];
|
||||
}
|
||||
|
||||
return [(Cons) [(Cons) args car] car];
|
||||
return [(Cons[]) [(Cons[]) args car] car];
|
||||
}
|
||||
|
||||
SchemeObject bi_cdr (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_cdr (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "cdr"
|
||||
message: "expected 1 argument"
|
||||
by: m];
|
||||
}
|
||||
if (![[(Cons) args car] isKindOfClass: [Cons class]]) {
|
||||
if (![[(Cons[]) args car] isKindOfClass: [Cons class]]) {
|
||||
return [Error type: "cdr"
|
||||
message: sprintf("expected pair, got: %s",
|
||||
[[(Cons) args car] printForm])
|
||||
[[(Cons[]) args car] printForm])
|
||||
by: m];
|
||||
}
|
||||
return [(Cons) [(Cons) args car] cdr];
|
||||
return [(Cons[]) [(Cons[]) args car] cdr];
|
||||
}
|
||||
|
||||
SchemeObject bi_apply (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_apply (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local SchemeObject cur, prev;
|
||||
local SchemeObject []cur, prev;
|
||||
if (args == [Nil nil]) {
|
||||
return [Error type: "apply"
|
||||
message: "expected at least 1 argument"
|
||||
by: m];
|
||||
} else if (![[(Cons) args car] isKindOfClass: [Procedure class]]) {
|
||||
} else if (![[(Cons[]) args car] isKindOfClass: [Procedure class]]) {
|
||||
return [Error type: "apply"
|
||||
message:
|
||||
sprintf("expected procedure as 1st argument, got: %s",
|
||||
[[(Cons) args car] printForm])
|
||||
[[(Cons[]) args car] printForm])
|
||||
by: m];
|
||||
}
|
||||
|
||||
prev = NIL;
|
||||
|
||||
for (cur = args; [(Cons) cur cdr] != [Nil nil]; cur = [(Cons) cur cdr]) {
|
||||
for (cur = args; [(Cons[]) cur cdr] != [Nil nil]; cur = [(Cons[]) cur cdr]) {
|
||||
prev = cur;
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
[(Cons) prev cdr: [(Cons) cur car]];
|
||||
[(Cons[]) prev cdr: [(Cons[]) cur car]];
|
||||
}
|
||||
|
||||
[m stack: [(Cons) args cdr]];
|
||||
[(Procedure) [(Cons) args car] invokeOnMachine: m];
|
||||
[m stack: [(Cons[]) args cdr]];
|
||||
[(Procedure[]) [(Cons[]) args car] invokeOnMachine: m];
|
||||
return NIL;
|
||||
}
|
||||
|
||||
SchemeObject bi_callcc (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_callcc (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (args == [Nil nil]) {
|
||||
return [Error type: "call-with-current-continuation"
|
||||
message: "expected at least 1 argument"
|
||||
by: m];
|
||||
} else if (![[(Cons) args car] isKindOfClass: [Procedure class]]) {
|
||||
} else if (![[(Cons[]) args car] isKindOfClass: [Procedure class]]) {
|
||||
return [Error type: "call-with-current-continuation"
|
||||
message:
|
||||
sprintf("expected procedure as 1st argument, got: %s",
|
||||
[[(Cons) args car] printForm])
|
||||
[[(Cons[]) args car] printForm])
|
||||
by: m];
|
||||
}
|
||||
if ([m continuation]) {
|
||||
|
@ -260,11 +260,11 @@ SchemeObject bi_callcc (SchemeObject args, Machine m)
|
|||
[m stack: cons([BaseContinuation baseContinuation],
|
||||
[Nil nil])];
|
||||
}
|
||||
[(Procedure) [(Cons) args car] invokeOnMachine: m];
|
||||
[(Procedure[]) [(Cons[]) args car] invokeOnMachine: m];
|
||||
return NIL;
|
||||
}
|
||||
|
||||
SchemeObject bi_eq (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_eq (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 2)) {
|
||||
return [Error type: "eq?"
|
||||
|
@ -272,21 +272,21 @@ SchemeObject bi_eq (SchemeObject args, Machine m)
|
|||
by: m];
|
||||
}
|
||||
return
|
||||
[(Cons) args car] == [(Cons) [(Cons) args cdr] car] ?
|
||||
[(Cons[]) args car] == [(Cons[]) [(Cons[]) args cdr] car] ?
|
||||
[Boolean trueConstant] :
|
||||
[Boolean falseConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_numeq (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_numeq (SchemeObject []args, Machine []m)
|
||||
{
|
||||
local SchemeObject num1, num2;
|
||||
local SchemeObject []num1, num2;
|
||||
if (!num_args(args, 2)) {
|
||||
return [Error type: "="
|
||||
message: "expected 2 arguments"
|
||||
by: m];
|
||||
}
|
||||
num1 = [(Cons) args car];
|
||||
num2 = [(Cons) [(Cons) args cdr] car];
|
||||
num1 = [(Cons[]) args car];
|
||||
num2 = [(Cons[]) [(Cons[]) args cdr] car];
|
||||
if (![num1 isKindOfClass: [Number class]]) {
|
||||
return [Error type: "="
|
||||
message: sprintf("expected number argument, got: %s",
|
||||
|
@ -300,12 +300,12 @@ SchemeObject bi_numeq (SchemeObject args, Machine m)
|
|||
}
|
||||
|
||||
return
|
||||
[(Number) num1 intValue] == [(Number) num2 intValue] ?
|
||||
[(Number[]) num1 intValue] == [(Number[]) num2 intValue] ?
|
||||
[Boolean trueConstant] :
|
||||
[Boolean falseConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_islist (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_islist (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "list?"
|
||||
|
@ -319,7 +319,7 @@ SchemeObject bi_islist (SchemeObject args, Machine m)
|
|||
[Boolean falseConstant];
|
||||
}
|
||||
|
||||
SchemeObject bi_ispair (SchemeObject args, Machine m)
|
||||
SchemeObject []bi_ispair (SchemeObject []args, Machine []m)
|
||||
{
|
||||
if (!num_args(args, 1)) {
|
||||
return [Error type: "pair?"
|
||||
|
@ -328,14 +328,14 @@ SchemeObject bi_ispair (SchemeObject args, Machine m)
|
|||
}
|
||||
|
||||
return
|
||||
[[(Cons) args car] isKindOfClass: [Cons class]] ?
|
||||
[[(Cons[]) args car] isKindOfClass: [Cons class]] ?
|
||||
[Boolean trueConstant] :
|
||||
[Boolean falseConstant];
|
||||
}
|
||||
|
||||
#define builtin(name, func) [m addGlobal: symbol(#name) value: [Primitive newFromFunc: (func)]]
|
||||
|
||||
void builtin_addtomachine (Machine m)
|
||||
void builtin_addtomachine (Machine []m)
|
||||
{
|
||||
builtin(display, bi_display);
|
||||
builtin(newline, bi_newline);
|
||||
|
|
|
@ -11,10 +11,10 @@ struct state_s {
|
|||
instruction_t [] program;
|
||||
lineinfo_t [] lineinfo;
|
||||
integer pc;
|
||||
Frame literals, env;
|
||||
SchemeObject stack;
|
||||
Continuation cont;
|
||||
Procedure proc;
|
||||
Frame []literals, env;
|
||||
SchemeObject []stack;
|
||||
Continuation []cont;
|
||||
Procedure []proc;
|
||||
};
|
||||
|
||||
typedef struct state_s state_t;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
AUTOMAKE_OPTIONS= foreign
|
||||
|
||||
EXTRA_DIST= class.h cpp.h debug.h def.h emit.h expr.h function.h \
|
||||
idstuff.h immediate.h linker.h method.h obj_file.h opcodes.h \
|
||||
options.h qfcc.h qfprogs.h reloc.h strpool.h struct.h switch.h \
|
||||
symtab.h type.h
|
||||
EXTRA_DIST= class.h codespace.h cpp.h debug.h def.h emit.h expr.h \
|
||||
function.h grab.h idstuff.h immediate.h linker.h method.h \
|
||||
obj_file.h opcodes.h options.h qfcc.h qfprogs.h reloc.h strpool.h \
|
||||
struct.h switch.h symtab.h type.h
|
||||
|
|
47
tools/qfcc/include/codespace.h
Normal file
47
tools/qfcc/include/codespace.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
codespace.h
|
||||
|
||||
management of code segement
|
||||
|
||||
Copyright (C) 2011 Bill Currie <bill@taniwha.org>
|
||||
|
||||
Author: Bill Currie <bill@taniwha.org>
|
||||
Date: 2011/01/07
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef __codespace_h
|
||||
#define __codespace_h
|
||||
|
||||
typedef struct codespace_s {
|
||||
struct statement_s *code;
|
||||
int size;
|
||||
int max_size;
|
||||
} codespace_t;
|
||||
|
||||
codespace_t *codespace_new (void);
|
||||
void codespace_delete (codespace_t *codespace);
|
||||
void codespace_addcode (codespace_t *codespace, struct statement_s *code,
|
||||
int size);
|
||||
struct statement_s *codespace_newstatement (codespace_t *codespace);
|
||||
|
||||
#endif//__codespace_h
|
|
@ -110,6 +110,7 @@ typedef enum {
|
|||
} storage_class_t;
|
||||
|
||||
extern def_t def_void;
|
||||
extern def_t def_invalid;
|
||||
extern def_t def_function;
|
||||
|
||||
scope_t *new_scope (scope_type type, defspace_t *space, scope_t *parent);
|
||||
|
|
|
@ -32,18 +32,6 @@
|
|||
#ifndef __emit_h
|
||||
#define __emit_h
|
||||
|
||||
typedef struct codespace_s {
|
||||
struct statement_s *code;
|
||||
int size;
|
||||
int max_size;
|
||||
} codespace_t;
|
||||
|
||||
codespace_t *codespace_new (void);
|
||||
void codespace_delete (codespace_t *codespace);
|
||||
void codespace_addcode (codespace_t *codespace, struct statement_s *code,
|
||||
int size);
|
||||
struct statement_s *codespace_newstatement (codespace_t *codespace);
|
||||
|
||||
struct expr_s;
|
||||
struct def_s *emit_statement (struct expr_s *e, opcode_t *op, struct def_s *var_a, struct def_s *var_b, struct def_s *var_c);
|
||||
struct def_s *emit_sub_expr (struct expr_s*e, struct def_s *dest);
|
||||
|
|
|
@ -209,6 +209,11 @@ extern expr_type expr_types[];
|
|||
*/
|
||||
expr_t *type_mismatch (expr_t *e1, expr_t *e2, int op);
|
||||
|
||||
expr_t *param_mismatch (expr_t *e, int param, const char *fn,
|
||||
struct type_s *t1, struct type_s *t2);
|
||||
expr_t *cast_error (expr_t *e, struct type_s *t1, struct type_s *t2);
|
||||
expr_t *test_error (expr_t *e, struct type_s *t);
|
||||
|
||||
extern expr_t *local_expr;
|
||||
|
||||
/** Get the type descriptor of the expression result.
|
||||
|
|
|
@ -34,19 +34,42 @@
|
|||
|
||||
#include "QF/pr_comp.h"
|
||||
|
||||
typedef struct ty_func_s {
|
||||
struct type_s *type;
|
||||
int num_params;
|
||||
struct type_s *param_types[MAX_PARMS];
|
||||
} ty_func_t;
|
||||
|
||||
typedef struct ty_fldptr_s {
|
||||
struct type_s *type;
|
||||
} ty_fldptr_t;
|
||||
|
||||
typedef struct ty_array_s {
|
||||
struct type_s *type;
|
||||
int base;
|
||||
int size;
|
||||
} ty_array_t;
|
||||
|
||||
typedef enum {
|
||||
ty_none, ///< func/field/pointer or not used
|
||||
ty_struct,
|
||||
ty_array,
|
||||
ty_class,
|
||||
} ty_type_e;
|
||||
|
||||
typedef struct type_s {
|
||||
etype_t type;
|
||||
const char *name;
|
||||
struct type_s *next;
|
||||
// function/pointer/struct types are more complex
|
||||
struct type_s *aux_type; // return type or field type
|
||||
int num_parms; // -1 = variable args
|
||||
struct type_s *parm_types[MAX_PARMS]; // only [num_parms] allocated
|
||||
etype_t type; ///< ev_invalid means structure/array etc
|
||||
const char *name;
|
||||
/// function/pointer/array/struct types are more complex
|
||||
ty_type_e ty;
|
||||
union {
|
||||
struct class_s *class; // for ev_class
|
||||
struct struct_s *strct; // for ev_struct
|
||||
int base; // for arrays
|
||||
} s;
|
||||
ty_func_t func;
|
||||
ty_fldptr_t fldptr;
|
||||
ty_array_t array;
|
||||
struct struct_s *strct;
|
||||
struct class_s *class;
|
||||
} t;
|
||||
struct type_s *next;
|
||||
} type_t;
|
||||
|
||||
typedef struct typedef_s {
|
||||
|
@ -55,6 +78,7 @@ typedef struct typedef_s {
|
|||
type_t *type;
|
||||
} typedef_t;
|
||||
|
||||
extern type_t type_invalid;
|
||||
extern type_t type_void;
|
||||
extern type_t type_string;
|
||||
extern type_t type_float;
|
||||
|
@ -66,9 +90,8 @@ extern type_t type_pointer;
|
|||
extern type_t type_floatfield;
|
||||
extern type_t type_quaternion;
|
||||
extern type_t type_integer;
|
||||
extern type_t type_uinteger;
|
||||
extern type_t type_short;
|
||||
extern type_t type_struct;
|
||||
|
||||
extern type_t type_id;
|
||||
extern type_t type_Class;
|
||||
extern type_t type_Protocol;
|
||||
|
@ -99,10 +122,15 @@ type_t *field_type (type_t *aux);
|
|||
type_t *pointer_type (type_t *aux);
|
||||
type_t *array_type (type_t *aux, int size);
|
||||
type_t *based_array_type (type_t *aux, int base, int top);
|
||||
void print_type_str (struct dstring_s *str, type_t *type);
|
||||
void print_type (type_t *type);
|
||||
const char *encode_params (type_t *type);
|
||||
void encode_type (struct dstring_s *encoding, type_t *type);
|
||||
type_t *parse_type (const char *str);
|
||||
int is_scalar (type_t *type);
|
||||
int is_struct (type_t *type);
|
||||
int is_class (type_t *type);
|
||||
int is_array (type_t *type);
|
||||
int type_assignable (type_t *dst, type_t *src);
|
||||
int type_size (type_t *type);
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ bin_SCRIPTS= $(qfpreqcc)
|
|||
EXTRA_PROGRAMS= qfcc qfpc qfprogs
|
||||
|
||||
common_src=\
|
||||
class.c constfold.c cpp.c debug.c def.c emit.c expr.c function.c grab.c \
|
||||
idstuff.c immediate.c linker.c method.c obj_file.c opcodes.c options.c \
|
||||
qfcc.c reloc.c strpool.c struct.c switch.c symtab.c \
|
||||
class.c codespace.c constfold.c cpp.c debug.c def.c emit.c expr.c \
|
||||
function.c grab.c idstuff.c immediate.c linker.c method.c obj_file.c \
|
||||
opcodes.c options.c qfcc.c reloc.c strpool.c struct.c switch.c symtab.c \
|
||||
type.c
|
||||
|
||||
qfcc_SOURCES= qc-lex.l qc-parse.y $(common_src)
|
||||
|
|
|
@ -49,6 +49,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
|
||||
#include "qfcc.h"
|
||||
|
||||
#include "codespace.h"
|
||||
#include "class.h"
|
||||
#include "def.h"
|
||||
#include "emit.h"
|
||||
|
@ -126,7 +127,7 @@ class_def (class_type_t *class_type, int external)
|
|||
break;
|
||||
case ct_class:
|
||||
name = va ("_OBJ_CLASS_%s", class_type->c.class->name);
|
||||
type = type_Class.aux_type;
|
||||
type = type_Class.t.fldptr.type;
|
||||
break;
|
||||
case ct_protocol:
|
||||
return 0; // probably in error recovery
|
||||
|
@ -156,9 +157,9 @@ get_class (const char *name, int create)
|
|||
|
||||
c = calloc (sizeof (class_t), 1);
|
||||
c->name = name;
|
||||
new = *type_Class.aux_type;
|
||||
new.s.class = c;
|
||||
c->type = pointer_type (find_type (&new));
|
||||
new = *type_Class.t.fldptr.type;
|
||||
new.t.class = c;
|
||||
c->type = find_type (&new);
|
||||
c->methods = new_methodlist ();
|
||||
c->class_type.type = ct_class;
|
||||
c->class_type.c.class = c;
|
||||
|
@ -171,7 +172,7 @@ static void
|
|||
set_self_type (class_t *class, method_t *method)
|
||||
{
|
||||
if (method->instance)
|
||||
method->params->type = class->type;
|
||||
method->params->type = pointer_type (class->type);
|
||||
else
|
||||
method->params->type = &type_Class;
|
||||
}
|
||||
|
@ -246,7 +247,7 @@ begin_class (class_t *class)
|
|||
|
||||
current_class = &class->class_type;
|
||||
class->def = class_def (current_class, 0);
|
||||
meta_def = get_def (type_Class.aux_type,
|
||||
meta_def = get_def (type_Class.t.fldptr.type,
|
||||
va ("_OBJ_METACLASS_%s", class->name),
|
||||
pr.scope, st_static);
|
||||
meta_def->initialized = meta_def->constant = 1;
|
||||
|
@ -257,9 +258,9 @@ begin_class (class_t *class)
|
|||
EMIT_STRING (meta->super_class, class->super_class->name);
|
||||
EMIT_STRING (meta->name, class->name);
|
||||
meta->info = _PR_CLS_META;
|
||||
meta->instance_size = type_size (type_Class.aux_type);
|
||||
meta->instance_size = type_size (type_Class.t.fldptr.type);
|
||||
EMIT_DEF (meta->ivars,
|
||||
emit_struct (type_Class.aux_type->s.class->ivars,
|
||||
emit_struct (type_Class.t.fldptr.type->t.class->ivars,
|
||||
"Class"));
|
||||
|
||||
class->def->initialized = class->def->constant = 1;
|
||||
|
@ -558,7 +559,8 @@ class_message_response (class_t *class, int class_msg, expr_t *sel)
|
|||
class_t *c = class;
|
||||
category_t *cat;
|
||||
|
||||
if (sel->type != ex_pointer && sel->e.pointer.type != type_SEL.aux_type) {
|
||||
if (sel->type != ex_pointer
|
||||
&& sel->e.pointer.type != type_SEL.t.fldptr.type) {
|
||||
error (sel, "not a selector");
|
||||
return 0;
|
||||
}
|
||||
|
@ -790,7 +792,7 @@ class_finish_module (void)
|
|||
symtab_def->nosave = 1;
|
||||
symtab = &G_STRUCT (pr_symtab_t, symtab_def->ofs);
|
||||
if (selector_table_def) {
|
||||
symtab->sel_ref_cnt = selector_table_def->type->num_parms;
|
||||
symtab->sel_ref_cnt = selector_table_def->type->t.func.num_params;
|
||||
EMIT_DEF (symtab->refs, selector_table_def);
|
||||
}
|
||||
symtab->cls_def_cnt = num_classes;
|
||||
|
@ -920,14 +922,14 @@ emit_protocol (protocol_t *protocol)
|
|||
def_t *proto_def;
|
||||
pr_protocol_t *proto;
|
||||
|
||||
proto_def = get_def (type_Protocol.aux_type,
|
||||
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
||||
pr.scope, st_none);
|
||||
proto_def = get_def (&type_Protocol,
|
||||
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
||||
pr.scope, st_none);
|
||||
if (proto_def)
|
||||
return proto_def;
|
||||
proto_def = get_def (type_Protocol.aux_type,
|
||||
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
||||
pr.scope, st_static);
|
||||
proto_def = get_def (&type_Protocol,
|
||||
va ("_OBJ_PROTOCOL_%s", protocol->name),
|
||||
pr.scope, st_static);
|
||||
proto_def->initialized = proto_def->constant = 1;
|
||||
proto_def->nosave = 1;
|
||||
proto = &G_STRUCT (pr_protocol_t, proto_def->ofs);
|
||||
|
@ -960,9 +962,9 @@ emit_protocol_list (protocollist_t *protocols, const char *name)
|
|||
new_struct_field (protocol_list, &type_integer, "count", vis_public);
|
||||
for (i = 0; i < protocols->count; i++)
|
||||
new_struct_field (protocol_list, &type_pointer, 0, vis_public);
|
||||
proto_list_def = get_def (type_Protocol.aux_type,
|
||||
va ("_OBJ_PROTOCOLS_%s", name),
|
||||
pr.scope, st_static);
|
||||
proto_list_def = get_def (&type_Protocol,
|
||||
va ("_OBJ_PROTOCOLS_%s", name),
|
||||
pr.scope, st_static);
|
||||
proto_list_def->initialized = proto_list_def->constant = 1;
|
||||
proto_list_def->nosave = 1;
|
||||
proto_list = &G_STRUCT (pr_protocol_list_t, proto_list_def->ofs);
|
||||
|
|
83
tools/qfcc/source/codespace.c
Normal file
83
tools/qfcc/source/codespace.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
codespace.c
|
||||
|
||||
management of code segement
|
||||
|
||||
Copyright (C) 2011 Bill Currie <bill@taniwha.org>
|
||||
|
||||
Author: Bill Currie <bill@taniwha.org>
|
||||
Date: 2011/01/07
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/pr_comp.h"
|
||||
|
||||
#include "codespace.h"
|
||||
|
||||
codespace_t *
|
||||
codespace_new (void)
|
||||
{
|
||||
return calloc (1, sizeof (codespace_t));
|
||||
}
|
||||
|
||||
void
|
||||
codespace_delete (codespace_t *codespace)
|
||||
{
|
||||
free (codespace->code);
|
||||
free (codespace);
|
||||
}
|
||||
|
||||
void
|
||||
codespace_addcode (codespace_t *codespace, dstatement_t *code, int size)
|
||||
{
|
||||
if (codespace->size + size > codespace->max_size) {
|
||||
codespace->max_size = (codespace->size + size + 16383) & ~16383;
|
||||
codespace->code = realloc (codespace->code,
|
||||
codespace->max_size * sizeof (dstatement_t));
|
||||
}
|
||||
memcpy (codespace->code + codespace->size, code,
|
||||
size * sizeof (dstatement_t));
|
||||
codespace->size += size;
|
||||
}
|
||||
|
||||
dstatement_t *
|
||||
codespace_newstatement (codespace_t *codespace)
|
||||
{
|
||||
if (codespace->size >= codespace->max_size) {
|
||||
codespace->max_size += 16384;
|
||||
codespace->code = realloc (codespace->code,
|
||||
codespace->max_size * sizeof (dstatement_t));
|
||||
}
|
||||
return codespace->code + codespace->size++;
|
||||
}
|
|
@ -402,7 +402,7 @@ static expr_t *
|
|||
do_op_func (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
if (op == 'c') {
|
||||
e->e.expr.type = get_type (e1)->aux_type;
|
||||
e->e.expr.type = get_type (e1)->t.func.type;
|
||||
return e;
|
||||
}
|
||||
if (op == EQ || op == NE) {
|
||||
|
@ -427,7 +427,7 @@ do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
|||
if (!valid_op (op, valid))
|
||||
return error (e1, "invalid operand for pointer");
|
||||
|
||||
if (op == PAS && (type = get_type (e1)->aux_type) != get_type (e2)) {
|
||||
if (op == PAS && (type = get_type (e1)->t.fldptr.type) != get_type (e2)) {
|
||||
// make sure auto-convertions happen
|
||||
expr_t *tmp = new_temp_def_expr (type);
|
||||
expr_t *ass = new_binary_expr ('=', tmp, e2);
|
||||
|
@ -449,10 +449,10 @@ do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
|||
if (op != PAS && op != '.' && op != '&' && op != 'M'
|
||||
&& extract_type (e1) != extract_type (e2))
|
||||
return type_mismatch (e1, e2, op);
|
||||
if ((op == '.' || op == '&') && get_type (e2) == &type_uinteger) {
|
||||
//FIXME should implement unsigned addressing
|
||||
e->e.expr.e2 = cf_cast_expr (&type_integer, e2);
|
||||
}
|
||||
//if ((op == '.' || op == '&') && get_type (e2) == &type_uinteger) {
|
||||
// //FIXME should implement unsigned addressing
|
||||
// e->e.expr.e2 = cf_cast_expr (&type_integer, e2);
|
||||
//}
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -632,161 +632,6 @@ do_op_integer (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
|||
return e1;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
convert_to_uinteger (expr_t *e)
|
||||
{
|
||||
if (get_type (e) == &type_uinteger)
|
||||
return e;
|
||||
|
||||
switch (e->type) {
|
||||
case ex_integer:
|
||||
convert_int_uint (e);
|
||||
return e;
|
||||
case ex_short:
|
||||
convert_short_uint (e);
|
||||
return e;
|
||||
case ex_def:
|
||||
case ex_expr:
|
||||
case ex_uexpr:
|
||||
case ex_temp:
|
||||
case ex_block:
|
||||
return cf_cast_expr (&type_uinteger, e);
|
||||
default:
|
||||
internal_error (e);
|
||||
}
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_uinteger (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
expr_t *conv;
|
||||
type_t *type;
|
||||
unsigned i1, i2;
|
||||
static int valid[] = {
|
||||
'=', 'b', '+', '-', '*', '/', '&', '|', '^', '%',
|
||||
SHL, SHR, AND, OR, LT, GT, LE, GE, EQ, NE, 0
|
||||
};
|
||||
|
||||
if (!valid_op (op, valid))
|
||||
return error (e1, "invalid operand for uinteger");
|
||||
|
||||
if (e1->type == ex_short)
|
||||
convert_short_uint (e1);
|
||||
if (e1->type == ex_integer)
|
||||
convert_int_uint (e1);
|
||||
if (op == 'b') {
|
||||
// bind is backwards to assign (why did I do that? :P)
|
||||
if ((type = get_type (e2)) != &type_uinteger) {
|
||||
e->e.expr.e1 = e1 = cf_cast_expr (type, e1);
|
||||
} else if ((conv = convert_to_uinteger (e1)) != e1) {
|
||||
e->e.expr.e1 = e1 = conv;
|
||||
}
|
||||
} else if (op == '=' || op == PAS) {
|
||||
if ((type = get_type (e1)) != &type_uinteger) {
|
||||
e->e.expr.e2 = e2 = cf_cast_expr (type, e2);
|
||||
} else if ((conv = convert_to_uinteger (e2)) != e2) {
|
||||
e->e.expr.e2 = e2 = conv;
|
||||
}
|
||||
} else {
|
||||
if (get_type (e1) != &type_uinteger) {
|
||||
e->e.expr.e1 = e1 = cf_cast_expr (&type_uinteger, e1);
|
||||
}
|
||||
if (e2->type == ex_short)
|
||||
convert_short_uint (e2);
|
||||
if (e2->type == ex_integer)
|
||||
convert_int_uint (e2);
|
||||
if (get_type (e2) != &type_uinteger) {
|
||||
e->e.expr.e2 = e2 = cf_cast_expr (&type_uinteger, e2);
|
||||
}
|
||||
if ((conv = convert_to_uinteger (e2)) != e2) {
|
||||
e->e.expr.e2 = e2 = conv;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_compare (op) || is_logic (op)) {
|
||||
if (options.code.progsversion > PROG_ID_VERSION)
|
||||
e->e.expr.type = &type_integer;
|
||||
else
|
||||
e->e.expr.type = &type_float;
|
||||
} else {
|
||||
e->e.expr.type = &type_uinteger;
|
||||
}
|
||||
|
||||
if (op == '=' || op == 'b' || !is_constant (e1) || !is_constant (e2))
|
||||
return e;
|
||||
|
||||
i1 = e1->e.uinteger_val;
|
||||
i2 = e2->e.uinteger_val;
|
||||
|
||||
switch (op) {
|
||||
case '+':
|
||||
e1->e.uinteger_val += i2;
|
||||
break;
|
||||
case '-':
|
||||
e1->e.uinteger_val -= i2;
|
||||
break;
|
||||
case '*':
|
||||
e1->e.uinteger_val *= i2;
|
||||
break;
|
||||
case '/':
|
||||
if (options.warnings.integer_divide)
|
||||
warning (e2, "%d / %d == %d", i1, i2, i1 / i2);
|
||||
e1->e.uinteger_val /= i2;
|
||||
break;
|
||||
case '&':
|
||||
e1->e.uinteger_val = i1 & i2;
|
||||
break;
|
||||
case '|':
|
||||
e1->e.uinteger_val = i1 | i2;
|
||||
break;
|
||||
case '^':
|
||||
e1->e.uinteger_val = i1 ^ i2;
|
||||
break;
|
||||
case '%':
|
||||
e1->e.uinteger_val = i1 % i2;
|
||||
break;
|
||||
case SHL:
|
||||
e1->e.uinteger_val = i1 << i2;
|
||||
break;
|
||||
case SHR:
|
||||
e1->e.uinteger_val = i1 >> i2;
|
||||
break;
|
||||
case AND:
|
||||
e1->e.uinteger_val = i1 && i2;
|
||||
break;
|
||||
case OR:
|
||||
e1->e.uinteger_val = i1 || i2;
|
||||
break;
|
||||
case LT:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 < i2;
|
||||
break;
|
||||
case GT:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 > i2;
|
||||
break;
|
||||
case LE:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 <= i2;
|
||||
break;
|
||||
case GE:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 >= i2;
|
||||
break;
|
||||
case EQ:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 == i2;
|
||||
break;
|
||||
case NE:
|
||||
e1->type = ex_integer;
|
||||
e1->e.integer_val = i1 != i2;
|
||||
break;
|
||||
default:
|
||||
return error (e1, "invalid operand for uinteger");
|
||||
}
|
||||
return e1;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_short (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
|
@ -896,19 +741,21 @@ do_op_struct (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
|||
return e;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_array (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_invalid (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
print_expr (e),puts("");
|
||||
return error (e1, "invalid operands for binary %s: %s %s",
|
||||
get_op_string (op), pr_type_name[extract_type (e1)],
|
||||
pr_type_name[extract_type (e2)]);
|
||||
dstring_t *t1 = dstring_newstr ();
|
||||
dstring_t *t2 = dstring_newstr ();
|
||||
|
||||
print_type_str (t1, get_type (e1));
|
||||
print_type_str (t2, get_type (e2));
|
||||
|
||||
//print_expr (e),puts("");
|
||||
e1 = error (e1, "invalid operands for binary %s: %s %s",
|
||||
get_op_string (op), t1->str, t2->str);
|
||||
dstring_delete (t1);
|
||||
dstring_delete (t2);
|
||||
return e1;
|
||||
}
|
||||
|
||||
typedef expr_t *(*operation_t) (int op, expr_t *e, expr_t *e1, expr_t *e2);
|
||||
|
@ -924,13 +771,8 @@ static operation_t op_void[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_string[ev_type_count] = {
|
||||
|
@ -944,13 +786,8 @@ static operation_t op_string[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_float[ev_type_count] = {
|
||||
|
@ -964,13 +801,8 @@ static operation_t op_float[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_quaternion, // ev_quaternion
|
||||
do_op_float, // ev_integer
|
||||
do_op_float, // ev_uinteger
|
||||
do_op_float, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_vector[ev_type_count] = {
|
||||
|
@ -984,13 +816,8 @@ static operation_t op_vector[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_vector, // ev_integer
|
||||
do_op_vector, // ev_uinteger
|
||||
do_op_vector, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_entity[ev_type_count] = {
|
||||
|
@ -1004,13 +831,8 @@ static operation_t op_entity[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_field[ev_type_count] = {
|
||||
|
@ -1024,13 +846,8 @@ static operation_t op_field[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_func[ev_type_count] = {
|
||||
|
@ -1044,13 +861,8 @@ static operation_t op_func[ev_type_count] = {
|
|||
do_op_func, // ev_pointer
|
||||
do_op_func, // ev_quaternion
|
||||
do_op_func, // ev_integer
|
||||
do_op_func, // ev_uinteger
|
||||
do_op_func, // ev_short
|
||||
do_op_func, // ev_struct
|
||||
do_op_func, // ev_object
|
||||
do_op_func, // ev_class
|
||||
do_op_func, // ev_sel
|
||||
do_op_func, // ev_array
|
||||
do_op_func, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_pointer[ev_type_count] = {
|
||||
|
@ -1064,13 +876,8 @@ static operation_t op_pointer[ev_type_count] = {
|
|||
do_op_pointer, // ev_pointer
|
||||
do_op_pointer, // ev_quaternion
|
||||
do_op_pointer, // ev_integer
|
||||
do_op_pointer, // ev_uinteger
|
||||
do_op_pointer, // ev_short
|
||||
do_op_pointer, // ev_struct
|
||||
do_op_pointer, // ev_object
|
||||
do_op_pointer, // ev_class
|
||||
do_op_pointer, // ev_sel
|
||||
do_op_pointer, // ev_array
|
||||
do_op_pointer, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_quaternion[ev_type_count] = {
|
||||
|
@ -1084,13 +891,8 @@ static operation_t op_quaternion[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_quaternion, // ev_quaternion
|
||||
do_op_quaternion, // ev_integer
|
||||
do_op_quaternion, // ev_uinteger
|
||||
do_op_quaternion, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_integer[ev_type_count] = {
|
||||
|
@ -1104,33 +906,8 @@ static operation_t op_integer[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_quaternion, // ev_quaternion
|
||||
do_op_integer, // ev_integer
|
||||
do_op_uinteger, // ev_uinteger
|
||||
do_op_integer, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_uinteger[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_float, // ev_float
|
||||
do_op_vector, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_invalid, // ev_pointer
|
||||
do_op_quaternion, // ev_quaternion
|
||||
do_op_uinteger, // ev_integer
|
||||
do_op_uinteger, // ev_uinteger
|
||||
do_op_uinteger, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t op_short[ev_type_count] = {
|
||||
|
@ -1144,113 +921,8 @@ static operation_t op_short[ev_type_count] = {
|
|||
do_op_invalid, // ev_pointer
|
||||
do_op_quaternion, // ev_quaternion
|
||||
do_op_integer, // ev_integer
|
||||
do_op_uinteger, // ev_uinteger
|
||||
do_op_short, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_struct[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_invalid, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_pointer, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_struct, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_object[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_invalid, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_class[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_invalid, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_sel[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_invalid, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_invalid, // ev_integer
|
||||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
};
|
||||
|
||||
static operation_t op_array[ev_type_count] = {
|
||||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_invalid, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
do_op_invalid, // ev_pointer
|
||||
do_op_invalid, // ev_quaternion
|
||||
do_op_array, // ev_integer
|
||||
do_op_array, // ev_uinteger
|
||||
do_op_array, // ev_short
|
||||
do_op_invalid, // ev_struct
|
||||
do_op_invalid, // ev_object
|
||||
do_op_invalid, // ev_class
|
||||
do_op_invalid, // ev_sel
|
||||
do_op_invalid, // ev_array
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
static operation_t *do_op[ev_type_count] = {
|
||||
|
@ -1264,13 +936,8 @@ static operation_t *do_op[ev_type_count] = {
|
|||
op_pointer, // ev_pointer
|
||||
op_quaternion, // ev_quaternion
|
||||
op_integer, // ev_integer
|
||||
op_uinteger, // ev_uinteger
|
||||
op_short, // ev_short
|
||||
op_struct, // ev_struct
|
||||
op_object, // ev_object
|
||||
op_class, // ev_class
|
||||
op_sel, // ev_sel
|
||||
op_array, // ev_array
|
||||
op_void, // ev_invalid
|
||||
};
|
||||
|
||||
expr_t *
|
||||
|
@ -1332,7 +999,10 @@ fold_constants (expr_t *e)
|
|||
if (op == 's')
|
||||
return e;
|
||||
|
||||
if (!do_op[t1][t2])
|
||||
if (is_struct (get_type (e1)) && is_struct (get_type (e2)))
|
||||
return do_op_struct (op, e, e1, e2);
|
||||
|
||||
if (!do_op[t1] || !do_op[t1][t2])
|
||||
internal_error (e);
|
||||
return do_op[t1][t2] (op, e, e1, e2);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ typedef struct locref_s {
|
|||
} locref_t;
|
||||
|
||||
def_t def_void = { &type_void, "def void" };
|
||||
def_t def_invalid = { &type_invalid, "def invalid" };
|
||||
def_t def_function = { &type_function, "def function" };
|
||||
|
||||
static def_t *free_temps[4]; // indexted by type size
|
||||
|
@ -280,8 +281,8 @@ get_def (type_t *type, const char *name, scope_t *scope,
|
|||
// not valid for st_static or st_extern
|
||||
def->space = space;
|
||||
if (space) {
|
||||
if (type->type == ev_field && type->aux_type == &type_vector)
|
||||
def->ofs = new_location (type->aux_type, space);
|
||||
if (type->type == ev_field && type->t.fldptr.type == &type_vector)
|
||||
def->ofs = new_location (type->t.fldptr.type, space);
|
||||
else
|
||||
def->ofs = new_location (type, space);
|
||||
}
|
||||
|
@ -299,14 +300,14 @@ get_def (type_t *type, const char *name, scope_t *scope,
|
|||
|
||||
if (type->type == ev_field) {
|
||||
if (storage == st_global || storage == st_static) {
|
||||
G_INT (def->ofs) = new_location (type->aux_type,
|
||||
G_INT (def->ofs) = new_location (type->t.fldptr.type,
|
||||
pr.entity_data);
|
||||
reloc_def_field (def, def->ofs);
|
||||
def->constant = 1;
|
||||
def->nosave = 1;
|
||||
}
|
||||
|
||||
if (type->aux_type->type == ev_vector) {
|
||||
if (type->t.fldptr.type->type == ev_vector) {
|
||||
vector_component (1, def, 0, scope, storage);
|
||||
vector_component (1, def, 1, scope, storage);
|
||||
vector_component (1, def, 2, scope, storage);
|
||||
|
@ -524,7 +525,8 @@ def_initialized (def_t *d)
|
|||
{
|
||||
d->initialized = 1;
|
||||
if (d->type == &type_vector
|
||||
|| (d->type->type == ev_field && d->type->aux_type == &type_vector)) {
|
||||
|| (d->type->type == ev_field
|
||||
&& d->type->t.fldptr.type == &type_vector)) {
|
||||
d = d->def_next;
|
||||
d->initialized = 1;
|
||||
d = d->def_next;
|
||||
|
@ -557,7 +559,7 @@ def_to_ddef (def_t *def, ddef_t *ddef, int aux)
|
|||
type_t *type = def->type;
|
||||
|
||||
if (aux)
|
||||
type = type->aux_type;
|
||||
type = type->t.fldptr.type; // aux is true only for fields
|
||||
ddef->type = type->type;
|
||||
ddef->ofs = def->ofs;
|
||||
ddef->s_name = ReuseString (def->name);
|
||||
|
|
|
@ -45,6 +45,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#include <QF/mathlib.h>
|
||||
#include <QF/va.h>
|
||||
|
||||
#include "codespace.h"
|
||||
#include "def.h"
|
||||
#include "debug.h"
|
||||
#include "emit.h"
|
||||
|
@ -60,43 +61,6 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
|
||||
static expr_t zero;
|
||||
|
||||
codespace_t *
|
||||
codespace_new (void)
|
||||
{
|
||||
return calloc (1, sizeof (codespace_t));
|
||||
}
|
||||
|
||||
void
|
||||
codespace_delete (codespace_t *codespace)
|
||||
{
|
||||
free (codespace->code);
|
||||
free (codespace);
|
||||
}
|
||||
|
||||
void
|
||||
codespace_addcode (codespace_t *codespace, dstatement_t *code, int size)
|
||||
{
|
||||
if (codespace->size + size > codespace->max_size) {
|
||||
codespace->max_size = (codespace->size + size + 16383) & ~16383;
|
||||
codespace->code = realloc (codespace->code,
|
||||
codespace->max_size * sizeof (dstatement_t));
|
||||
}
|
||||
memcpy (codespace->code + codespace->size, code,
|
||||
size * sizeof (dstatement_t));
|
||||
codespace->size += size;
|
||||
}
|
||||
|
||||
dstatement_t *
|
||||
codespace_newstatement (codespace_t *codespace)
|
||||
{
|
||||
if (codespace->size >= codespace->max_size) {
|
||||
codespace->max_size += 16384;
|
||||
codespace->code = realloc (codespace->code,
|
||||
codespace->max_size * sizeof (dstatement_t));
|
||||
}
|
||||
return codespace->code + codespace->size++;
|
||||
}
|
||||
|
||||
static void
|
||||
add_statement_ref (def_t *def, dstatement_t *st, int field)
|
||||
{
|
||||
|
@ -146,7 +110,7 @@ emit_statement (expr_t *e, opcode_t *op, def_t *var_a, def_t *var_b,
|
|||
statement->a = var_a ? var_a->ofs : 0;
|
||||
statement->b = var_b ? var_b->ofs : 0;
|
||||
statement->c = 0;
|
||||
if (op->type_c == ev_void || op->right_associative) {
|
||||
if (op->type_c == ev_invalid || op->right_associative) {
|
||||
// ifs, gotos, and assignments don't need vars allocated
|
||||
if (var_c)
|
||||
statement->c = var_c->ofs;
|
||||
|
@ -230,6 +194,8 @@ emit_function_call (expr_t *e, def_t *dest)
|
|||
expr_t *earg;
|
||||
expr_t *parm;
|
||||
opcode_t *op;
|
||||
type_t *t1 = &type_invalid;
|
||||
type_t *t2 = &type_invalid;
|
||||
int count = 0, ind;
|
||||
const char *pref = "";
|
||||
|
||||
|
@ -241,6 +207,10 @@ emit_function_call (expr_t *e, def_t *dest)
|
|||
parm = new_param_expr (get_type (earg), ind);
|
||||
if (options.code.progsversion != PROG_ID_VERSION && ind < 2) {
|
||||
pref = "R";
|
||||
if (ind == 1)
|
||||
t2 = &type_void;
|
||||
if (ind == 0)
|
||||
t1 = &type_void;
|
||||
if (options.code.vector_calls && earg->type == ex_vector) {
|
||||
a[ind] = vector_call (earg, parm, ind);
|
||||
} else {
|
||||
|
@ -248,7 +218,7 @@ emit_function_call (expr_t *e, def_t *dest)
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if (extract_type (parm) == ev_struct) {
|
||||
if (is_struct (get_type (parm))) {
|
||||
expr_t *a = assign_expr (parm, earg);
|
||||
a->line = e->line;
|
||||
a->file = e->file;
|
||||
|
@ -260,19 +230,18 @@ emit_function_call (expr_t *e, def_t *dest)
|
|||
p = emit_sub_expr (parm, 0);
|
||||
arg = emit_sub_expr (earg, p);
|
||||
if (arg != p) {
|
||||
op = opcode_find ("=", arg->type, arg->type, &type_void);
|
||||
op = opcode_find ("=", arg->type, arg->type, &type_invalid);
|
||||
emit_statement (e, op, arg, p, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
op = opcode_find (va ("<%sCALL%d>", pref, count),
|
||||
&type_function, &type_void, &type_void);
|
||||
op = opcode_find (va ("<%sCALL%d>", pref, count), &type_function, t1, t2);
|
||||
emit_statement (e, op, func, a[0], a[1]);
|
||||
|
||||
ret = emit_sub_expr (new_ret_expr (func->type->aux_type), 0);
|
||||
ret = emit_sub_expr (new_ret_expr (func->type->t.func.type), 0);
|
||||
if (dest) {
|
||||
op = opcode_find ("=", dest->type, ret->type, &type_void);
|
||||
op = opcode_find ("=", dest->type, ret->type, &type_invalid);
|
||||
emit_statement (e, op, ret, dest, 0);
|
||||
return dest;
|
||||
} else {
|
||||
|
@ -319,7 +288,8 @@ emit_assign_expr (int oper, expr_t *e)
|
|||
}
|
||||
def_b = emit_sub_expr (e2, def_a);
|
||||
if (def_b != def_a) {
|
||||
op = opcode_find (operator, def_b->type, def_a->type, &type_void);
|
||||
op = opcode_find (operator, def_b->type, def_a->type,
|
||||
&type_invalid);
|
||||
emit_statement (e, op, def_b, def_a, 0);
|
||||
}
|
||||
return def_a;
|
||||
|
@ -335,7 +305,7 @@ emit_assign_expr (int oper, expr_t *e)
|
|||
} else {
|
||||
def_a = emit_sub_expr (e1, 0);
|
||||
def_c = 0;
|
||||
op = opcode_find (operator, def_b->type, def_a->type, &type_void);
|
||||
op = opcode_find (operator, def_b->type, def_a->type, &type_invalid);
|
||||
}
|
||||
emit_statement (e, op, def_b, def_a, def_c);
|
||||
return def_b;
|
||||
|
@ -382,24 +352,27 @@ emit_move_expr (expr_t *e)
|
|||
src = emit_sub_expr (e2, 0);
|
||||
dst = emit_sub_expr (e1, 0);
|
||||
|
||||
if (dst_type->type == ev_struct && src_type->type == ev_struct) {
|
||||
if (is_struct (dst_type) && is_struct (src_type)) {
|
||||
size_expr = new_short_expr (type_size (dst->type));
|
||||
} else if (dst_type->type == ev_struct) {
|
||||
dst_type = src_type = &type_void;
|
||||
} else if (is_struct (dst_type)) {
|
||||
if (dst->alias)
|
||||
dst = dst->alias;
|
||||
dst = emit_sub_expr (address_expr (new_def_expr (dst), 0, 0), 0);
|
||||
dst_type = dst->type;
|
||||
size_expr = new_integer_expr (type_size (dst_type));
|
||||
} else if (src_type->type == ev_struct) {
|
||||
} else if (is_struct (src_type)) {
|
||||
if (src->alias)
|
||||
src = src->alias;
|
||||
src = emit_sub_expr (address_expr (new_def_expr (src), 0, 0), 0);
|
||||
size_expr = new_integer_expr (type_size (dst_type->aux_type));
|
||||
src_type = src->type;
|
||||
size_expr = new_integer_expr (type_size (dst_type->t.fldptr.type));
|
||||
} else {
|
||||
size_expr = new_integer_expr (type_size (dst_type->aux_type));
|
||||
size_expr = new_integer_expr (type_size (dst_type->t.fldptr.type));
|
||||
}
|
||||
size = emit_sub_expr (size_expr, 0);
|
||||
|
||||
op = opcode_find ("<MOVE>", src->type, size->type, dst->type);
|
||||
op = opcode_find ("<MOVE>", src_type, size->type, dst_type);
|
||||
return emit_statement (e, op, src, size, dst);
|
||||
}
|
||||
|
||||
|
@ -445,7 +418,7 @@ emit_deref_expr (expr_t *e, def_t *dest)
|
|||
}
|
||||
if (e->type == ex_uexpr && e->e.expr.op == '&'
|
||||
&& e->e.expr.e1->type == ex_def) {
|
||||
d = new_def (e->e.expr.type->aux_type, 0, current_scope);
|
||||
d = new_def (e->e.expr.type->t.fldptr.type, 0, current_scope);
|
||||
d->alias = e->e.expr.e1->e.def;
|
||||
d->local = d->alias->local;
|
||||
d->ofs = d->alias->ofs;
|
||||
|
@ -457,7 +430,7 @@ emit_deref_expr (expr_t *e, def_t *dest)
|
|||
dest->file = e->file;
|
||||
dest->users += 2;
|
||||
}
|
||||
if (dest->type->type == ev_struct) {
|
||||
if (is_struct (dest->type)) {
|
||||
expr_t *d = new_def_expr (dest);
|
||||
expr_t *m = new_move_expr (d, e, dest->type);
|
||||
d->line = dest->line;
|
||||
|
@ -685,12 +658,12 @@ emit_sub_expr (expr_t *e, def_t *dest)
|
|||
case '!':
|
||||
operator = "!";
|
||||
def_a = emit_sub_expr (e->e.expr.e1, 0);
|
||||
def_b = &def_void;
|
||||
def_b = &def_invalid;
|
||||
break;
|
||||
case '~':
|
||||
operator = "~";
|
||||
def_a = emit_sub_expr (e->e.expr.e1, 0);
|
||||
def_b = &def_void;
|
||||
def_b = &def_invalid;
|
||||
break;
|
||||
case '-':
|
||||
zero.type = expr_types[extract_type (e->e.expr.e1)];
|
||||
|
@ -738,15 +711,9 @@ emit_sub_expr (expr_t *e, def_t *dest)
|
|||
return def_a;
|
||||
}
|
||||
if ((def_a->type->type == ev_pointer
|
||||
&& (e->e.expr.type->type == ev_integer
|
||||
|| e->e.expr.type->type == ev_uinteger))
|
||||
|| ((def_a->type->type == ev_integer
|
||||
|| def_a->type->type == ev_uinteger)
|
||||
&& e->e.expr.type->type == ev_pointer)
|
||||
&& e->e.expr.type->type == ev_integer)
|
||||
|| (def_a->type->type == ev_integer
|
||||
&& e->e.expr.type->type == ev_uinteger)
|
||||
|| (def_a->type->type == ev_uinteger
|
||||
&& e->e.expr.type->type == ev_integer)) {
|
||||
&& e->e.expr.type->type == ev_pointer)) {
|
||||
def_t *tmp;
|
||||
tmp = new_def (e->e.expr.type, 0, def_a->scope);
|
||||
tmp->ofs = 0;
|
||||
|
@ -755,7 +722,7 @@ emit_sub_expr (expr_t *e, def_t *dest)
|
|||
tmp->freed = 1;
|
||||
return tmp;
|
||||
}
|
||||
def_b = &def_void;
|
||||
def_b = &def_invalid;
|
||||
if (!dest) {
|
||||
dest = get_tempdef (e->e.expr.type, current_scope);
|
||||
dest->file = e->file;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue