added new instructions - push_clsvar, store_into_clsvar, pop_into_clsvar
This commit is contained in:
parent
a61f6f5f47
commit
57bb1657b3
@ -499,6 +499,11 @@ static int emit_single_param_instruction (hcl_t* hcl, int cmd, hcl_oow_t param_1
|
||||
case HCL_CODE_JUMP2_BACKWARD_IF_TRUE:
|
||||
case HCL_CODE_JUMP2_BACKWARD_IF_FALSE:
|
||||
case HCL_CODE_JUMP2_BACKWARD:
|
||||
|
||||
case HCL_CODE_PUSH_CLSVAR_X:
|
||||
case HCL_CODE_STORE_INTO_CLSVAR_X:
|
||||
case HCL_CODE_POP_INTO_CLSVAR_X:
|
||||
|
||||
case HCL_CODE_TRY_ENTER:
|
||||
case HCL_CODE_TRY_ENTER2:
|
||||
case HCL_CODE_PUSH_INTLIT:
|
||||
|
17
lib/decode.c
17
lib/decode.c
@ -501,6 +501,23 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end)
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
case HCL_CODE_PUSH_CLSVAR_X:
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "push_clsvar %zu", b1);
|
||||
break;
|
||||
|
||||
case HCL_CODE_STORE_INTO_CLSVAR_X:
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "store_into_clsvar %zu", b1);
|
||||
break;
|
||||
|
||||
case HCL_CODE_POP_INTO_CLSVAR_X:
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "pop_into_clsvar %zu", b1);
|
||||
break;
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
case HCL_CODE_PUSH_RECEIVER:
|
||||
LOG_INST_0 (hcl, "push_receiver");
|
||||
break;
|
||||
|
44
lib/exec.c
44
lib/exec.c
@ -218,6 +218,14 @@ static void terminate_all_processes (hcl_t* hcl);
|
||||
ap->clsp = HCL_SMOOI_TO_OOP(clsp_); \
|
||||
} while (0)
|
||||
|
||||
#define HCL_CLSTACK_FETCH_TOP_TO(hcl, v) \
|
||||
do { \
|
||||
hcl_oop_process_t ap = (hcl)->processor->active; \
|
||||
hcl_ooi_t clsp_ = HCL_OOP_TO_SMOOI(ap->clsp); \
|
||||
v = ap->slot[clsp_]; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define HCL_CLSTACK_CHOP(hcl, clsp_) ((hcl)->processor->active->clsp = HCL_SMOOI_TO_OOP(clsp_))
|
||||
|
||||
#define HCL_CLSTACK_GET_ST(hcl) HCL_OOP_TO_SMOOI(((hcl)->processor->active)->clst)
|
||||
@ -3538,7 +3546,7 @@ if (do_throw(hcl, hcl->_nil, fetched_instruction_pointer) <= -1)
|
||||
{
|
||||
hcl_oop_oop_t t;
|
||||
|
||||
/* b1 -> variable index to the object indicated by b2.
|
||||
/* b1 -> variable index in the object indicated by b2.
|
||||
* b2 -> object index stored in the literal frame. */
|
||||
b1 = bcode & 0x3; /* low 2 bits */
|
||||
FETCH_BYTE_CODE_TO (hcl, b2);
|
||||
@ -3558,8 +3566,8 @@ if (do_throw(hcl, hcl->_nil, fetched_instruction_pointer) <= -1)
|
||||
if ((bcode >> 2) & 1)
|
||||
{
|
||||
/* pop */
|
||||
HCL_STACK_POP (hcl);
|
||||
LOG_INST_2 (hcl, "pop_into_objvar %zu %zu", b1, b2);
|
||||
HCL_STACK_POP (hcl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3609,6 +3617,38 @@ if (do_throw(hcl, hcl->_nil, fetched_instruction_pointer) <= -1)
|
||||
break; /* CMD_SEND_MESSAGE */
|
||||
}
|
||||
#endif
|
||||
/* -------------------------------------------------------- */
|
||||
case HCL_CODE_PUSH_CLSVAR_X:
|
||||
{
|
||||
hcl_oop_class_t t;
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "push_clsvar %zu", b1);
|
||||
HCL_CLSTACK_FETCH_TOP_TO(hcl, t);
|
||||
HCL_STACK_PUSH (hcl, t->cvar[b1]); /* TODO: consider the base size... */
|
||||
break;
|
||||
}
|
||||
|
||||
case HCL_CODE_STORE_INTO_CLSVAR_X:
|
||||
{
|
||||
hcl_oop_class_t t;
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "store_into_clsvar %zu", b1);
|
||||
HCL_CLSTACK_FETCH_TOP_TO(hcl, t);
|
||||
t->cvar[b1] = HCL_STACK_GETTOP(hcl);
|
||||
break;
|
||||
}
|
||||
|
||||
case HCL_CODE_POP_INTO_CLSVAR_X:
|
||||
{
|
||||
hcl_oop_class_t t;
|
||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||
LOG_INST_1 (hcl, "pop_into_clsvar %zu", b1);
|
||||
HCL_CLSTACK_FETCH_TOP_TO(hcl, t);
|
||||
t->cvar[b1] = HCL_STACK_GETTOP(hcl);
|
||||
HCL_STACK_POP (hcl);
|
||||
break;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
case HCL_CODE_PUSH_RECEIVER: /* push self or super */
|
||||
|
@ -532,6 +532,13 @@ struct hcl_compiler_t
|
||||
hcl_oow_t wcount; /* word count */
|
||||
} tv; /* temporary variables including arguments */
|
||||
|
||||
struct
|
||||
{
|
||||
hcl_oocs_t s; /* buffer */
|
||||
hcl_oow_t capa; /* bufer capacity */
|
||||
hcl_oow_t wcount; /* word count */
|
||||
} cv; /* class variables */
|
||||
|
||||
struct
|
||||
{
|
||||
hcl_ooi_t depth; /* signed because it starts with -1 */
|
||||
@ -672,7 +679,11 @@ SHORT INSTRUCTION CODE LONG INSTRUCTION C
|
||||
116-119 0111 01XX YYYYYYYY SEND_MESSAGE_TO_SUPER 244 1111 0100 XXXXXXXX YYYYYYYY SEND_MESSAGE_TO_SUPER_X (bit 2 on)
|
||||
# XXX args, YYYYYYYY message
|
||||
|
||||
120-123 0111 10XX UNUSED
|
||||
120 0111 1000 YYYYYYYY PUSH_CLSVAR_X
|
||||
121 0111 1001 YYYYYYYY STORE_INTO_CLSVAR_X
|
||||
122 0111 1010 YYYYYYYY POP_INTO_CLSVAR_X
|
||||
|
||||
123 0111 1011 UNUSED
|
||||
124-127 0111 11XX UNUSED
|
||||
|
||||
##
|
||||
@ -817,17 +828,21 @@ enum hcl_bcode_t
|
||||
HCL_CODE_POP_INTO_OBJVAR_2 = 0x6E,
|
||||
HCL_CODE_POP_INTO_OBJVAR_3 = 0x6F,
|
||||
|
||||
HCL_CODE_SEND_MESSAGE_0 = 0x70,
|
||||
HCL_CODE_SEND_MESSAGE_1 = 0x71,
|
||||
HCL_CODE_SEND_MESSAGE_2 = 0x72,
|
||||
HCL_CODE_SEND_MESSAGE_3 = 0x73,
|
||||
HCL_CODE_SEND_MESSAGE_0 = 0x70, /* 112 */
|
||||
HCL_CODE_SEND_MESSAGE_1 = 0x71, /* 113 */
|
||||
HCL_CODE_SEND_MESSAGE_2 = 0x72, /* 114 */
|
||||
HCL_CODE_SEND_MESSAGE_3 = 0x73, /* 115 */
|
||||
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_0 = 0x74,
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_1 = 0x75,
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_2 = 0x76,
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_3 = 0x77,
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_0 = 0x74, /* 116 */
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_1 = 0x75, /* 117 */
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_2 = 0x76, /* 118 */
|
||||
HCL_CODE_SEND_MESSAGE_TO_SUPER_3 = 0x77, /* 119 */
|
||||
|
||||
/* UNUSED 0x78 - 0x7F */
|
||||
HCL_CODE_PUSH_CLSVAR_X = 0x78, /* 120 */
|
||||
HCL_CODE_STORE_INTO_CLSVAR_X = 0x79, /* 121 */
|
||||
HCL_CODE_POP_INTO_CLSVAR_X = 0x7A, /* 122 */
|
||||
/* UNUSED 0x7B */
|
||||
/* UNUSED 0x7C - 0x7F */
|
||||
|
||||
HCL_CODE_STORE_INTO_INSTVAR_X = 0x80, /* 128 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user