2016-09-28 14:40:37 +00:00
|
|
|
/*
|
2018-02-07 14:13:13 +00:00
|
|
|
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
2023-11-21 15:24:57 +00:00
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
2016-09-28 14:40:37 +00:00
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hcl-prv.h"
|
|
|
|
|
2018-02-05 15:59:32 +00:00
|
|
|
#define DECODE_LOG_MASK (HCL_LOG_MNEMONIC | HCL_LOG_INFO)
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2021-11-21 16:02:39 +00:00
|
|
|
#define LOG_INST_0(hcl,fmt) HCL_LOG1(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer)
|
|
|
|
#define LOG_INST_1(hcl,fmt,a1) HCL_LOG2(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1)
|
|
|
|
#define LOG_INST_2(hcl,fmt,a1,a2) HCL_LOG3(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2)
|
|
|
|
#define LOG_INST_3(hcl,fmt,a1,a2,a3) HCL_LOG4(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3)
|
|
|
|
#define LOG_INST_4(hcl,fmt,a1,a2,a3,a4) HCL_LOG5(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3, a4)
|
|
|
|
#define LOG_INST_5(hcl,fmt,a1,a2,a3,a4,a5) HCL_LOG6(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3, a4, a5)
|
|
|
|
#define LOG_INST_6(hcl,fmt,a1,a2,a3,a4,a5,a6) HCL_LOG7(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3, a4, a5, a6)
|
2022-03-17 13:22:17 +00:00
|
|
|
#define LOG_INST_7(hcl,fmt,a1,a2,a3,a4,a5,a6,a7) HCL_LOG8(hcl, DECODE_LOG_MASK, " %06zd " fmt "\n", fetched_instruction_pointer, a1, a2, a3, a4, a5, a6, a7)
|
2021-11-21 16:02:39 +00:00
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
#define FETCH_BYTE_CODE(hcl) (cdptr[ip++])
|
|
|
|
#define FETCH_BYTE_CODE_TO(hcl,v_ooi) (v_ooi = FETCH_BYTE_CODE(hcl))
|
2021-01-29 12:39:31 +00:00
|
|
|
#if (HCL_CODE_LONG_PARAM_SIZE == 2)
|
2016-09-28 14:40:37 +00:00
|
|
|
# define FETCH_PARAM_CODE_TO(hcl,v_ooi) \
|
|
|
|
do { \
|
|
|
|
v_ooi = FETCH_BYTE_CODE(hcl); \
|
|
|
|
v_ooi = (v_ooi << 8) | FETCH_BYTE_CODE(hcl); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
# define FETCH_PARAM_CODE_TO(hcl,v_ooi) (v_ooi = FETCH_BYTE_CODE(hcl))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* TODO: check if ip shoots beyond the maximum length in fetching code and parameters */
|
2023-12-27 00:09:40 +00:00
|
|
|
int hcl_decode (hcl_t* hcl, const hcl_code_t* code, hcl_oow_t start, hcl_oow_t end)
|
2016-09-28 14:40:37 +00:00
|
|
|
{
|
|
|
|
hcl_oob_t bcode, * cdptr;
|
2016-10-06 17:49:47 +00:00
|
|
|
hcl_ooi_t ip = start, fetched_instruction_pointer;
|
2021-05-05 17:37:26 +00:00
|
|
|
hcl_oow_t b1, b2;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* the instruction at the offset 'end' is not decoded.
|
|
|
|
* decoding offset range is from start to end - 1. */
|
2016-10-04 17:56:28 +00:00
|
|
|
|
2023-12-27 15:27:27 +00:00
|
|
|
if (!code) code = &hcl->code;
|
2023-12-27 00:09:40 +00:00
|
|
|
|
2018-02-05 10:43:25 +00:00
|
|
|
HCL_ASSERT (hcl, start >= 0 && end >= 0);
|
2023-12-27 00:09:40 +00:00
|
|
|
HCL_ASSERT (hcl, code->bc.len < HCL_SMOOI_MAX); /* asserted by the compiler */
|
|
|
|
HCL_ASSERT (hcl, end <= code->bc.len); /* not harmful though this fails */
|
|
|
|
if (start >= code->bc.len)
|
2018-03-11 11:16:28 +00:00
|
|
|
{
|
|
|
|
hcl_seterrnum (hcl, HCL_EINVAL);
|
|
|
|
return -1;
|
|
|
|
}
|
2023-12-27 00:09:40 +00:00
|
|
|
if (end > code->bc.len) end = code->bc.len;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
ip = start;
|
2023-12-27 00:09:40 +00:00
|
|
|
cdptr = code->bc.ptr;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* TODO: check if ip increases beyond bcode when fetching parameters too */
|
|
|
|
while (ip < end)
|
|
|
|
{
|
2016-10-06 17:49:47 +00:00
|
|
|
fetched_instruction_pointer = ip;
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_BYTE_CODE_TO(hcl, bcode);
|
|
|
|
|
|
|
|
switch (bcode)
|
|
|
|
{
|
2022-03-21 15:38:31 +00:00
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
case HCL_CODE_PLUS:
|
|
|
|
LOG_INST_0 (hcl, "plus");
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_PUSH_IVAR_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto push_ivar;
|
|
|
|
case HCL_CODE_PUSH_IVAR_0:
|
|
|
|
case HCL_CODE_PUSH_IVAR_1:
|
|
|
|
case HCL_CODE_PUSH_IVAR_2:
|
|
|
|
case HCL_CODE_PUSH_IVAR_3:
|
|
|
|
case HCL_CODE_PUSH_IVAR_4:
|
|
|
|
case HCL_CODE_PUSH_IVAR_5:
|
|
|
|
case HCL_CODE_PUSH_IVAR_6:
|
|
|
|
case HCL_CODE_PUSH_IVAR_7:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x7; /* low 3 bits */
|
2022-02-17 12:40:22 +00:00
|
|
|
push_ivar:
|
|
|
|
LOG_INST_1 (hcl, "push_ivar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_STORE_INTO_IVAR_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto store_into_ivar;
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_0:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_1:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_2:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_3:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_4:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_5:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_6:
|
|
|
|
case HCL_CODE_STORE_INTO_IVAR_7:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x7; /* low 3 bits */
|
2022-02-17 12:40:22 +00:00
|
|
|
store_into_ivar:
|
|
|
|
LOG_INST_1 (hcl, "store_into_ivar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_POP_INTO_IVAR_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
goto pop_into_ivar;
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_0:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_1:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_2:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_3:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_4:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_5:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_6:
|
|
|
|
case HCL_CODE_POP_INTO_IVAR_7:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x7; /* low 3 bits */
|
2022-02-17 12:40:22 +00:00
|
|
|
pop_into_ivar:
|
|
|
|
LOG_INST_1 (hcl, "pop_into_ivar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_X:
|
2016-09-29 13:20:09 +00:00
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_X:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto handle_tempvar;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_0:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_1:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_2:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_3:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_4:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_5:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_6:
|
|
|
|
case HCL_CODE_PUSH_TEMPVAR_7:
|
2016-09-29 13:20:09 +00:00
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_0:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_1:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_2:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_3:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_4:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_5:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_6:
|
|
|
|
case HCL_CODE_STORE_INTO_TEMPVAR_7:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_0:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_1:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_2:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_3:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_4:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_5:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_6:
|
|
|
|
case HCL_CODE_POP_INTO_TEMPVAR_7:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x7; /* low 3 bits */
|
|
|
|
handle_tempvar:
|
|
|
|
|
|
|
|
if ((bcode >> 4) & 1)
|
|
|
|
{
|
|
|
|
/* push - bit 4 on */
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_tempvar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* store or pop - bit 5 off */
|
|
|
|
if ((bcode >> 3) & 1)
|
|
|
|
{
|
|
|
|
/* pop - bit 3 on */
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "pop_into_tempvar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "store_into_tempvar %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
case HCL_CODE_PUSH_LITERAL_X2:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
2021-05-05 17:37:26 +00:00
|
|
|
b1 = (b1 << (8 * HCL_CODE_LONG_PARAM_SIZE)) | b2;
|
2016-09-28 14:40:37 +00:00
|
|
|
goto push_literal;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_LITERAL_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto push_literal;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_LITERAL_0:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_1:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_2:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_3:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_4:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_5:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_6:
|
|
|
|
case HCL_CODE_PUSH_LITERAL_7:
|
|
|
|
b1 = bcode & 0x7; /* low 3 bits */
|
|
|
|
push_literal:
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_literal @%zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* ------------------------------------------------- */
|
|
|
|
case HCL_CODE_PUSH_OBJECT_X:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJECT_X:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_OBJECT_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto handle_object;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_OBJECT_0:
|
|
|
|
case HCL_CODE_PUSH_OBJECT_1:
|
|
|
|
case HCL_CODE_PUSH_OBJECT_2:
|
|
|
|
case HCL_CODE_PUSH_OBJECT_3:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJECT_0:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJECT_1:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJECT_2:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJECT_3:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_OBJECT_0:
|
|
|
|
case HCL_CODE_POP_INTO_OBJECT_1:
|
|
|
|
case HCL_CODE_POP_INTO_OBJECT_2:
|
|
|
|
case HCL_CODE_POP_INTO_OBJECT_3:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x3; /* low 2 bits */
|
|
|
|
handle_object:
|
|
|
|
if ((bcode >> 3) & 1)
|
|
|
|
{
|
|
|
|
if ((bcode >> 2) & 1)
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "pop_into_object @%zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "store_into_object @%zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_object @%zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP_FORWARD_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump_forward %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP_FORWARD_0:
|
|
|
|
case HCL_CODE_JUMP_FORWARD_1:
|
|
|
|
case HCL_CODE_JUMP_FORWARD_2:
|
|
|
|
case HCL_CODE_JUMP_FORWARD_3:
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump_forward %zu", (hcl_oow_t)(bcode & 0x3)); /* low 2 bits */
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump_backward %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
hcl->ip += b1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_0:
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_1:
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_2:
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_3:
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump_backward %zu", (hcl_oow_t)(bcode & 0x3)); /* low 2 bits */
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
2016-10-12 07:30:54 +00:00
|
|
|
case HCL_CODE_JUMP_FORWARD_IF_TRUE:
|
2016-10-10 11:36:24 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-12 07:30:54 +00:00
|
|
|
LOG_INST_1 (hcl, "jump_forward_if_true %zu", b1);
|
2016-10-10 11:36:24 +00:00
|
|
|
break;
|
|
|
|
|
2016-10-12 07:30:54 +00:00
|
|
|
case HCL_CODE_JUMP2_FORWARD_IF_TRUE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump2_forward_if_true %zu", b1);
|
2016-10-10 11:36:24 +00:00
|
|
|
break;
|
|
|
|
|
2016-10-12 07:30:54 +00:00
|
|
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE:
|
2016-10-10 11:36:24 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump_forward_if_false %zu", b1);
|
|
|
|
break;
|
|
|
|
|
2016-10-12 07:30:54 +00:00
|
|
|
case HCL_CODE_JUMP2_FORWARD_IF_FALSE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump2_forward_if_false %zu", b1);
|
2016-10-10 11:36:24 +00:00
|
|
|
break;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
case HCL_CODE_JUMP2_FORWARD:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump2_forward %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
case HCL_CODE_JUMP_BACKWARD_IF_TRUE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump_backward_if_true %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP2_BACKWARD_IF_TRUE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump2_backward_if_true %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP_BACKWARD_IF_FALSE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump_backward_if_false %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_JUMP2_BACKWARD_IF_FALSE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "jump2_backward_if_false %zu", b1);
|
|
|
|
break;
|
|
|
|
|
2016-09-28 14:40:37 +00:00
|
|
|
case HCL_CODE_JUMP2_BACKWARD:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "jump2_backward %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
2021-05-13 14:43:40 +00:00
|
|
|
case HCL_CODE_PUSH_RETURN_R:
|
|
|
|
LOG_INST_0 (hcl, "push_return_r");
|
|
|
|
break;
|
|
|
|
|
2021-05-11 15:04:53 +00:00
|
|
|
case HCL_CODE_CALL_R:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1); /* nargs */
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2); /* nrvars */
|
|
|
|
LOG_INST_2 (hcl, "call %zu %zu", b1, b2);
|
|
|
|
break;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
case HCL_CODE_CALL_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
goto handle_call;
|
|
|
|
|
|
|
|
case HCL_CODE_CALL_0:
|
|
|
|
case HCL_CODE_CALL_1:
|
|
|
|
case HCL_CODE_CALL_2:
|
|
|
|
case HCL_CODE_CALL_3:
|
|
|
|
b1 = bcode & 0x3; /* low 2 bits */
|
|
|
|
handle_call:
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "call %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
2021-02-28 17:00:28 +00:00
|
|
|
|
2021-02-22 14:56:27 +00:00
|
|
|
/* -------------------------------------------------------- */
|
2021-04-09 08:22:40 +00:00
|
|
|
case HCL_CODE_TRY_ENTER:
|
2021-04-11 15:08:27 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "try_enter %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_TRY_ENTER2:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "try_enter2 %zu", b1);
|
2021-04-09 08:22:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_TRY_EXIT:
|
|
|
|
LOG_INST_0 (hcl, "try_exit");
|
2021-02-22 14:56:27 +00:00
|
|
|
break;
|
2021-02-28 17:00:28 +00:00
|
|
|
|
|
|
|
case HCL_CODE_THROW:
|
|
|
|
LOG_INST_0 (hcl, "throw");
|
|
|
|
break;
|
2016-09-28 14:40:37 +00:00
|
|
|
/* -------------------------------------------------------- */
|
2024-03-16 08:00:34 +00:00
|
|
|
case HCL_CODE_CLASS_LOAD_X2:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
b1 = (b1 << (8 * HCL_CODE_LONG_PARAM_SIZE)) | b2;
|
|
|
|
goto class_load;
|
|
|
|
|
|
|
|
case HCL_CODE_CLASS_LOAD_X:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
class_load:
|
|
|
|
LOG_INST_1 (hcl, "class_load @%zu", b1);
|
|
|
|
break;
|
|
|
|
|
2021-06-19 17:19:24 +00:00
|
|
|
case HCL_CODE_CLASS_ENTER:
|
2021-06-25 16:07:29 +00:00
|
|
|
{
|
|
|
|
hcl_oow_t b3;
|
2023-11-09 15:03:03 +00:00
|
|
|
|
2021-06-25 16:07:29 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b3);
|
|
|
|
LOG_INST_3 (hcl, "class_enter %zu %zu %zu", b1, b2, b3);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-19 17:19:24 +00:00
|
|
|
case HCL_CODE_CLASS_EXIT:
|
|
|
|
LOG_INST_0 (hcl, "class_exit");
|
|
|
|
break;
|
2021-12-24 00:05:58 +00:00
|
|
|
|
2022-01-29 17:43:11 +00:00
|
|
|
case HCL_CODE_CLASS_PEXIT:
|
|
|
|
LOG_INST_0 (hcl, "class_pexit");
|
|
|
|
break;
|
|
|
|
|
2022-02-12 15:05:31 +00:00
|
|
|
case HCL_CODE_CLASS_CMSTORE:
|
2022-01-29 17:43:11 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2024-04-04 12:16:28 +00:00
|
|
|
LOG_INST_1 (hcl, "class_cmstore @%zu", b1);
|
2022-02-12 15:05:31 +00:00
|
|
|
break;
|
|
|
|
|
2022-03-17 13:22:17 +00:00
|
|
|
case HCL_CODE_CLASS_CIMSTORE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2024-04-04 12:16:28 +00:00
|
|
|
LOG_INST_1 (hcl, "class_cimstore @%zu", b1);
|
2022-03-17 13:22:17 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-12 15:05:31 +00:00
|
|
|
case HCL_CODE_CLASS_IMSTORE:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2024-04-04 12:16:28 +00:00
|
|
|
LOG_INST_1 (hcl, "class_imstore @%zu", b1);
|
2021-12-24 00:05:58 +00:00
|
|
|
break;
|
2021-06-19 17:19:24 +00:00
|
|
|
/* -------------------------------------------------------- */
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2016-09-29 13:20:09 +00:00
|
|
|
case HCL_CODE_PUSH_CTXTEMPVAR_X:
|
|
|
|
case HCL_CODE_STORE_INTO_CTXTEMPVAR_X:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_CTXTEMPVAR_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
goto handle_ctxtempvar;
|
2016-09-29 13:20:09 +00:00
|
|
|
case HCL_CODE_PUSH_CTXTEMPVAR_0:
|
|
|
|
case HCL_CODE_PUSH_CTXTEMPVAR_1:
|
|
|
|
case HCL_CODE_PUSH_CTXTEMPVAR_2:
|
|
|
|
case HCL_CODE_PUSH_CTXTEMPVAR_3:
|
|
|
|
case HCL_CODE_STORE_INTO_CTXTEMPVAR_0:
|
|
|
|
case HCL_CODE_STORE_INTO_CTXTEMPVAR_1:
|
|
|
|
case HCL_CODE_STORE_INTO_CTXTEMPVAR_2:
|
|
|
|
case HCL_CODE_STORE_INTO_CTXTEMPVAR_3:
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_POP_INTO_CTXTEMPVAR_0:
|
|
|
|
case HCL_CODE_POP_INTO_CTXTEMPVAR_1:
|
|
|
|
case HCL_CODE_POP_INTO_CTXTEMPVAR_2:
|
|
|
|
case HCL_CODE_POP_INTO_CTXTEMPVAR_3:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x3; /* low 2 bits */
|
|
|
|
FETCH_BYTE_CODE_TO (hcl, b2);
|
|
|
|
|
|
|
|
handle_ctxtempvar:
|
|
|
|
if ((bcode >> 3) & 1)
|
|
|
|
{
|
|
|
|
/* store or pop */
|
|
|
|
|
|
|
|
if ((bcode >> 2) & 1)
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "pop_into_ctxtempvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "store_into_ctxtempvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* push */
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "push_ctxtempvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_PUSH_OBJVAR_X:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJVAR_X:
|
|
|
|
case HCL_CODE_POP_INTO_OBJVAR_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
goto handle_objvar;
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_PUSH_OBJVAR_0:
|
|
|
|
case HCL_CODE_PUSH_OBJVAR_1:
|
|
|
|
case HCL_CODE_PUSH_OBJVAR_2:
|
|
|
|
case HCL_CODE_PUSH_OBJVAR_3:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJVAR_0:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJVAR_1:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJVAR_2:
|
|
|
|
case HCL_CODE_STORE_INTO_OBJVAR_3:
|
|
|
|
case HCL_CODE_POP_INTO_OBJVAR_0:
|
|
|
|
case HCL_CODE_POP_INTO_OBJVAR_1:
|
|
|
|
case HCL_CODE_POP_INTO_OBJVAR_2:
|
|
|
|
case HCL_CODE_POP_INTO_OBJVAR_3:
|
2016-09-28 14:40:37 +00:00
|
|
|
/* b1 -> variable index to 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);
|
|
|
|
|
|
|
|
handle_objvar:
|
|
|
|
if ((bcode >> 3) & 1)
|
|
|
|
{
|
|
|
|
/* store or pop */
|
|
|
|
if ((bcode >> 2) & 1)
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "pop_into_objvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "store_into_objvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_2 (hcl, "push_objvar %zu %zu", b1, b2);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
2022-01-23 16:46:13 +00:00
|
|
|
|
|
|
|
case HCL_CODE_SEND_R:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1); /* nargs */
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2); /* nrvars */
|
|
|
|
LOG_INST_2 (hcl, "send_r %zu %zu", b1, b2);
|
|
|
|
break;
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_R:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1); /* nargs */
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2); /* nrvars */
|
|
|
|
LOG_INST_2 (hcl, "send_to_super_r %zu %zu", b1, b2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_SEND_X:
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_X:
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-01-23 16:46:13 +00:00
|
|
|
goto handle_send;
|
|
|
|
|
|
|
|
case HCL_CODE_SEND_0:
|
|
|
|
case HCL_CODE_SEND_1:
|
|
|
|
case HCL_CODE_SEND_2:
|
|
|
|
case HCL_CODE_SEND_3:
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_0:
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_1:
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_2:
|
|
|
|
case HCL_CODE_SEND_TO_SUPER_3:
|
2016-09-28 14:40:37 +00:00
|
|
|
b1 = bcode & 0x3; /* low 2 bits */
|
|
|
|
|
2022-01-23 16:46:13 +00:00
|
|
|
handle_send:
|
|
|
|
LOG_INST_2 (hcl, "send%hs %zu", (((bcode >> 2) & 1)? "_to_super": ""), b1);
|
2021-03-27 10:32:23 +00:00
|
|
|
break;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_PUSH_CVAR_I_X:
|
2022-01-01 14:58:57 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "push_cvar_i %zu", b1);
|
2022-01-01 14:58:57 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_STORE_INTO_CVAR_I_X:
|
2022-01-01 14:58:57 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "store_into_cvar_i %zu", b1);
|
2022-01-01 14:58:57 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_POP_INTO_CVAR_I_X:
|
2022-01-01 14:58:57 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "pop_into_cvar_i %zu", b1);
|
2022-01-09 16:47:38 +00:00
|
|
|
break;
|
2023-11-09 15:03:03 +00:00
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
2022-01-09 16:47:38 +00:00
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_PUSH_CVAR_M_X:
|
2022-01-09 16:47:38 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "push_cvar_m %zu", b1);
|
2022-01-09 16:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_STORE_INTO_CVAR_M_X:
|
2022-01-09 16:47:38 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "store_into_cvar_m %zu", b1);
|
2022-01-09 16:47:38 +00:00
|
|
|
break;
|
|
|
|
|
2022-02-17 12:40:22 +00:00
|
|
|
case HCL_CODE_POP_INTO_CVAR_M_X:
|
2022-01-09 16:47:38 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2022-02-17 12:40:22 +00:00
|
|
|
LOG_INST_1 (hcl, "pop_into_cvar_m %zu", b1);
|
2022-01-01 14:58:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_PUSH_RECEIVER:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "push_receiver");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_NIL:
|
|
|
|
LOG_INST_0 (hcl, "push_nil");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_TRUE:
|
|
|
|
LOG_INST_0 (hcl, "push_true");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_FALSE:
|
|
|
|
LOG_INST_0 (hcl, "push_false");
|
|
|
|
break;
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_PUSH_CONTEXT:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "push_context");
|
|
|
|
break;
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_PUSH_PROCESS:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "push_process");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_NEGONE:
|
|
|
|
LOG_INST_0 (hcl, "push_negone");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_ZERO:
|
|
|
|
LOG_INST_0 (hcl, "push_zero");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_ONE:
|
|
|
|
LOG_INST_0 (hcl, "push_one");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_TWO:
|
|
|
|
LOG_INST_0 (hcl, "push_two");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_INTLIT:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_intlit %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_NEGINTLIT:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_negintlit %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_PUSH_CHARLIT:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2016-10-04 17:56:28 +00:00
|
|
|
LOG_INST_1 (hcl, "push_charlit %zu", b1);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2018-02-07 07:35:30 +00:00
|
|
|
case HCL_CODE_MAKE_ARRAY:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "make_array %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_POP_INTO_ARRAY:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "pop_into_array %zu", b1);
|
|
|
|
break;
|
|
|
|
|
2018-02-07 13:55:22 +00:00
|
|
|
case HCL_CODE_MAKE_BYTEARRAY:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "make_bytearray %zu", b1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_POP_INTO_BYTEARRAY:
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
LOG_INST_1 (hcl, "pop_into_bytearray %zu", b1);
|
|
|
|
break;
|
|
|
|
|
2018-02-07 10:55:20 +00:00
|
|
|
case HCL_CODE_MAKE_DIC:
|
2018-02-07 07:35:30 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2018-02-07 10:55:20 +00:00
|
|
|
LOG_INST_1 (hcl, "make_dic %zu", b1);
|
2018-02-07 07:35:30 +00:00
|
|
|
break;
|
|
|
|
|
2018-02-07 10:55:20 +00:00
|
|
|
case HCL_CODE_POP_INTO_DIC:
|
|
|
|
LOG_INST_0 (hcl, "pop_into_dic");
|
2018-02-07 07:35:30 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
case HCL_CODE_MAKE_CONS:
|
|
|
|
LOG_INST_0 (hcl, "make_cons");
|
2021-01-03 13:51:23 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
case HCL_CODE_POP_INTO_CONS:
|
|
|
|
LOG_INST_0 (hcl, "pop_into_cons");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_POP_INTO_CONS_END:
|
|
|
|
LOG_INST_0 (hcl, "pop_into_cons_end");
|
|
|
|
break;
|
2021-01-03 13:51:23 +00:00
|
|
|
|
2021-01-24 15:45:28 +00:00
|
|
|
case HCL_CODE_POP_INTO_CONS_CDR:
|
|
|
|
LOG_INST_0 (hcl, "pop_into_cons_cdr");
|
|
|
|
break;
|
2018-02-07 07:35:30 +00:00
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_DUP_STACKTOP:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "dup_stacktop");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_POP_STACKTOP:
|
|
|
|
LOG_INST_0 (hcl, "pop_stacktop");
|
|
|
|
break;
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_RETURN_STACKTOP:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "return_stacktop");
|
|
|
|
break;
|
|
|
|
|
2020-09-22 09:19:53 +00:00
|
|
|
case HCL_CODE_RETURN_RECEIVER:
|
2016-09-28 14:40:37 +00:00
|
|
|
LOG_INST_0 (hcl, "return_receiver");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_RETURN_FROM_BLOCK:
|
|
|
|
LOG_INST_0 (hcl, "return_from_block");
|
|
|
|
break;
|
|
|
|
|
2020-10-04 18:21:05 +00:00
|
|
|
case HCL_CODE_MAKE_FUNCTION:
|
2021-05-05 17:37:26 +00:00
|
|
|
{
|
|
|
|
hcl_oow_t b3, b4;
|
2023-11-09 15:03:03 +00:00
|
|
|
/* b1 - block mask
|
2022-03-17 13:22:17 +00:00
|
|
|
* b2 - block mask
|
2021-05-05 17:37:26 +00:00
|
|
|
* b3 - base literal frame start
|
|
|
|
* b4 - base literal frame end */
|
2020-10-04 18:21:05 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
FETCH_PARAM_CODE_TO (hcl, b3);
|
2021-05-05 17:37:26 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b4);
|
2020-10-04 18:21:05 +00:00
|
|
|
|
2021-05-05 17:37:26 +00:00
|
|
|
b1 = (b1 << (8 * HCL_CODE_LONG_PARAM_SIZE)) | b2;
|
2023-11-09 15:03:03 +00:00
|
|
|
LOG_INST_7 (hcl, "make_function %zu %zu %zu %zu %zu %zu %zu",
|
2022-03-17 13:22:17 +00:00
|
|
|
GET_BLK_MASK_INSTA(b1),
|
|
|
|
GET_BLK_MASK_VA(b1),
|
|
|
|
GET_BLK_MASK_NARGS(b1),
|
|
|
|
GET_BLK_MASK_NRVARS(b1),
|
|
|
|
GET_BLK_MASK_NLVARS(b1),
|
2021-05-05 17:37:26 +00:00
|
|
|
b3, b4);
|
2020-10-04 18:21:05 +00:00
|
|
|
|
|
|
|
HCL_ASSERT (hcl, b1 >= 0);
|
|
|
|
break;
|
2021-05-05 17:37:26 +00:00
|
|
|
}
|
2020-10-04 18:21:05 +00:00
|
|
|
|
2023-11-09 15:03:03 +00:00
|
|
|
case HCL_CODE_MAKE_LAMBDA:
|
2022-03-17 13:22:17 +00:00
|
|
|
/* b1 - block mask
|
|
|
|
* b2 - block mask */
|
2016-09-28 14:40:37 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
2021-05-05 17:37:26 +00:00
|
|
|
FETCH_PARAM_CODE_TO (hcl, b2);
|
|
|
|
b1 = (b1 << (8 * HCL_CODE_LONG_PARAM_SIZE)) | b2;
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2023-11-09 15:03:03 +00:00
|
|
|
LOG_INST_5 (hcl, "make_lambda %zu %zu %zu %zu %zu",
|
2022-03-17 13:22:17 +00:00
|
|
|
GET_BLK_MASK_INSTA(b1),
|
|
|
|
GET_BLK_MASK_VA(b1),
|
|
|
|
GET_BLK_MASK_NARGS(b1),
|
|
|
|
GET_BLK_MASK_NRVARS(b1),
|
|
|
|
GET_BLK_MASK_NLVARS(b1));
|
2016-09-28 14:40:37 +00:00
|
|
|
|
2018-02-05 10:43:25 +00:00
|
|
|
HCL_ASSERT (hcl, b1 >= 0);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HCL_CODE_NOOP:
|
|
|
|
/* do nothing */
|
|
|
|
LOG_INST_0 (hcl, "noop");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
LOG_INST_1 (hcl, "UNKNOWN BYTE CODE ENCOUNTERED %x", (int)bcode);
|
2018-02-05 10:43:25 +00:00
|
|
|
hcl_seterrnum (hcl, HCL_EINTERN);
|
2016-09-28 14:40:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 16:02:39 +00:00
|
|
|
|
2021-03-27 10:32:23 +00:00
|
|
|
/* TODO: this needs changes... */
|
2016-09-28 14:40:37 +00:00
|
|
|
/* print literal frame contents */
|
2023-12-27 00:09:40 +00:00
|
|
|
for (ip = 0; ip < code->lit.len; ip++)
|
2016-09-28 14:40:37 +00:00
|
|
|
{
|
2023-12-27 00:09:40 +00:00
|
|
|
HCL_LOG2(hcl, DECODE_LOG_MASK, "@%-9zd %O\n", ip, ((hcl_oop_oop_t)code->lit.arr)->slot[ip]);
|
2016-09-28 14:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|