diff --git a/lib/comp.c b/lib/comp.c index 1f4c255..5bfa866 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -196,12 +196,12 @@ static int emit_single_param_instruction (hcl_t* hcl, int cmd, hcl_oow_t param_1 switch (cmd) { - case BCODE_PUSH_INSTVAR_0: - case BCODE_STORE_INTO_INSTVAR_0: - case BCODE_POP_INTO_INSTVAR_0: + case HCL_CODE_PUSH_INSTVAR_0: + case HCL_CODE_STORE_INTO_INSTVAR_0: + case HCL_CODE_POP_INTO_INSTVAR_0: case HCL_CODE_PUSH_TEMPVAR_0: case HCL_CODE_STORE_INTO_TEMPVAR_0: - case BCODE_POP_INTO_TEMPVAR_0: + case HCL_CODE_POP_INTO_TEMPVAR_0: if (param_1 < 8) { /* low 3 bits to hold the parameter */ @@ -235,7 +235,7 @@ static int emit_single_param_instruction (hcl_t* hcl, int cmd, hcl_oow_t param_1 case HCL_CODE_PUSH_OBJECT_0: case HCL_CODE_STORE_INTO_OBJECT_0: - case BCODE_POP_INTO_OBJECT_0: + case HCL_CODE_POP_INTO_OBJECT_0: case HCL_CODE_JUMP_FORWARD_0: case HCL_CODE_JUMP_BACKWARD_0: case HCL_CODE_CALL_0: @@ -284,7 +284,7 @@ write_long: hcl_seterrnum (hcl, HCL_ERANGE); return -1; } -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) if (emit_byte_instruction(hcl, bc) <= -1 || emit_byte_instruction(hcl, (param_1 >> 8) & 0xFF) <= -1 || emit_byte_instruction(hcl, param_1 & 0xFF) <= -1) return -1; @@ -300,7 +300,7 @@ write_long2: hcl_seterrnum (hcl, HCL_ERANGE); return -1; } -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) if (emit_byte_instruction(hcl, bc) <= -1 || emit_byte_instruction(hcl, (param_1 >> 24) & 0xFF) <= -1 || emit_byte_instruction(hcl, (param_1 >> 16) & 0xFF) <= -1 || @@ -321,13 +321,13 @@ static int emit_double_param_instruction (hcl_t* hcl, int cmd, hcl_oow_t param_1 switch (cmd) { case HCL_CODE_STORE_INTO_CTXTEMPVAR_0: - case BCODE_POP_INTO_CTXTEMPVAR_0: + case HCL_CODE_POP_INTO_CTXTEMPVAR_0: case HCL_CODE_PUSH_CTXTEMPVAR_0: - case BCODE_PUSH_OBJVAR_0: - case BCODE_STORE_INTO_OBJVAR_0: - case BCODE_POP_INTO_OBJVAR_0: - case BCODE_SEND_MESSAGE_0: - case BCODE_SEND_MESSAGE_TO_SUPER_0: + case HCL_CODE_PUSH_OBJVAR_0: + case HCL_CODE_STORE_INTO_OBJVAR_0: + case HCL_CODE_POP_INTO_OBJVAR_0: + case HCL_CODE_SEND_MESSAGE_0: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_0: if (param_1 < 4 && param_2 < 0xFF) { /* low 2 bits of the instruction code is the first parameter */ @@ -361,7 +361,7 @@ write_long: hcl_seterrnum (hcl, HCL_ERANGE); return -1; } -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) if (emit_byte_instruction(hcl, bc) <= -1 || emit_byte_instruction(hcl, param_1 >> 8) <= -1 || emit_byte_instruction(hcl, param_1 & 0xFF) <= -1 || @@ -381,7 +381,7 @@ write_long2: hcl_seterrnum (hcl, HCL_ERANGE); return -1; } -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) if (emit_byte_instruction(hcl, bc) <= -1 || emit_byte_instruction(hcl, (param_1 >> 24) & 0xFF) <= -1 || emit_byte_instruction(hcl, (param_1 >> 16) & 0xFF) <= -1 || @@ -470,7 +470,7 @@ static HCL_INLINE void patch_long_jump (hcl_t* hcl, hcl_ooi_t jip, hcl_ooi_t jum jump_offset -= MAX_CODE_JUMP; } -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) patch_instruction (hcl, jip + 1, jump_offset >> 8); patch_instruction (hcl, jip + 2, jump_offset & 0xFF); #else @@ -1037,7 +1037,7 @@ static int compile_lambda (hcl_t* hcl, hcl_oop_t src, int defun) HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX); /* guaranteed in emit_byte_instruction() */ jump_inst_pos = hcl->code.bc.len; /* specifying MAX_CODE_JUMP causes emit_single_param_instruction() to - * produce the long jump instruction (BCODE_JUMP_FORWARD_X) */ + * produce the long jump instruction (HCL_CODE_JUMP_FORWARD_X) */ if (emit_single_param_instruction(hcl, HCL_CODE_JUMP_FORWARD_0, MAX_CODE_JUMP) <= -1) return -1; SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT_LIST, obj); @@ -1948,7 +1948,7 @@ static HCL_INLINE int patch_nearest_post_if_body (hcl_t* hcl) if (emit_single_param_instruction (hcl, HCL_CODE_JUMP_FORWARD_0, MAX_CODE_JUMP) <= -1) return -1; /* HCL_CODE_LONG_PARAM_SIZE + 1 => size of the long JUMP_FORWARD instruction */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); if (jump_offset > MAX_CODE_JUMP * 2) { @@ -2100,7 +2100,7 @@ static HCL_INLINE int post_and_expr (hcl_t* hcl) jip = HCL_OOP_TO_SMOOI(cf->operand); /* patch the jump insruction emitted after each expression inside the 'and' expression */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); patch_long_jump (hcl, jip, jump_offset); POP_CFRAME(hcl); @@ -2167,7 +2167,7 @@ static HCL_INLINE int post_or_expr (hcl_t* hcl) jip = HCL_OOP_TO_SMOOI(cf->operand); /* patch the jump insruction emitted after each expression inside the 'and' expression */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); patch_long_jump (hcl, jip, jump_offset); POP_CFRAME(hcl); @@ -2222,7 +2222,7 @@ static HCL_INLINE int post_if_body (hcl_t* hcl) } /* HCL_CODE_LONG_PARAM_SIZE + 1 => size of the long JUMP_FORWARD_IF_FALSE instruction */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); if (jump_offset > MAX_CODE_JUMP * 2) { @@ -2303,12 +2303,12 @@ static HCL_INLINE int post_while_body (hcl_t* hcl) HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX); jump_offset = hcl->code.bc.len - cf->u.post_while.cond_pos + 1; - if (jump_offset > 3) jump_offset += HCL_BCODE_LONG_PARAM_SIZE; + if (jump_offset > 3) jump_offset += HCL_HCL_CODE_LONG_PARAM_SIZE; if (emit_single_param_instruction (hcl, HCL_CODE_JUMP_BACKWARD_0, jump_offset) <= -1) return -1; jip = HCL_OOP_TO_SMOOI(cf->operand); /* HCL_CODE_LONG_PARAM_SIZE + 1 => size of the long JUMP_FORWARD_IF_FALSE/JUMP_FORWARD_IF_TRUE instruction */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); if (jump_offset > MAX_CODE_JUMP * 2) { HCL_DEBUG1 (hcl, "code in loop body too big - size %zu\n", jump_offset); @@ -2335,7 +2335,7 @@ static int update_break (hcl_t* hcl) jip = HCL_OOP_TO_SMOOI(cf->operand); /* HCL_CODE_LONG_PARAM_SIZE + 1 => size of the long JUMP_FORWARD instruction */ - jump_offset = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + jump_offset = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); /* no explicit about jump_offset. because break can only place inside * a loop, the same check in post_while_body() must assert @@ -2469,7 +2469,7 @@ static HCL_INLINE int emit_lambda (hcl_t* hcl) hcl->c->tv.size = hcl->c->blk.tmprcnt[hcl->c->blk.depth]; /* HCL_CODE_LONG_PARAM_SIZE + 1 => size of the long JUMP_FORWARD instruction */ - block_code_size = hcl->code.bc.len - jip - (HCL_BCODE_LONG_PARAM_SIZE + 1); + block_code_size = hcl->code.bc.len - jip - (HCL_HCL_CODE_LONG_PARAM_SIZE + 1); if (block_code_size == 0) { @@ -2479,7 +2479,7 @@ static HCL_INLINE int emit_lambda (hcl_t* hcl) block_code_size++; } - if (emit_byte_instruction (hcl, HCL_CODE_RETURN_FROM_BLOCK) <= -1) return -1; + if (emit_byte_instruction(hcl, HCL_CODE_RETURN_FROM_BLOCK) <= -1) return -1; block_code_size++; if (block_code_size > MAX_CODE_JUMP * 2) diff --git a/lib/decode.c b/lib/decode.c index 8305e8e..4a5d4b2 100644 --- a/lib/decode.c +++ b/lib/decode.c @@ -44,7 +44,7 @@ #define FETCH_BYTE_CODE(hcl) (cdptr[ip++]) #define FETCH_BYTE_CODE_TO(hcl,v_ooi) (v_ooi = FETCH_BYTE_CODE(hcl)) -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) # define FETCH_PARAM_CODE_TO(hcl,v_ooi) \ do { \ v_ooi = FETCH_BYTE_CODE(hcl); \ @@ -85,17 +85,17 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) switch (bcode) { - case BCODE_PUSH_INSTVAR_X: + case HCL_CODE_PUSH_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto push_instvar; - case BCODE_PUSH_INSTVAR_0: - case BCODE_PUSH_INSTVAR_1: - case BCODE_PUSH_INSTVAR_2: - case BCODE_PUSH_INSTVAR_3: - case BCODE_PUSH_INSTVAR_4: - case BCODE_PUSH_INSTVAR_5: - case BCODE_PUSH_INSTVAR_6: - case BCODE_PUSH_INSTVAR_7: + case HCL_CODE_PUSH_INSTVAR_0: + case HCL_CODE_PUSH_INSTVAR_1: + case HCL_CODE_PUSH_INSTVAR_2: + case HCL_CODE_PUSH_INSTVAR_3: + case HCL_CODE_PUSH_INSTVAR_4: + case HCL_CODE_PUSH_INSTVAR_5: + case HCL_CODE_PUSH_INSTVAR_6: + case HCL_CODE_PUSH_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ push_instvar: LOG_INST_1 (hcl, "push_instvar %zu", b1); @@ -103,33 +103,33 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) /* ------------------------------------------------- */ - case BCODE_STORE_INTO_INSTVAR_X: + case HCL_CODE_STORE_INTO_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto store_instvar; - case BCODE_STORE_INTO_INSTVAR_0: - case BCODE_STORE_INTO_INSTVAR_1: - case BCODE_STORE_INTO_INSTVAR_2: - case BCODE_STORE_INTO_INSTVAR_3: - case BCODE_STORE_INTO_INSTVAR_4: - case BCODE_STORE_INTO_INSTVAR_5: - case BCODE_STORE_INTO_INSTVAR_6: - case BCODE_STORE_INTO_INSTVAR_7: + case HCL_CODE_STORE_INTO_INSTVAR_0: + case HCL_CODE_STORE_INTO_INSTVAR_1: + case HCL_CODE_STORE_INTO_INSTVAR_2: + case HCL_CODE_STORE_INTO_INSTVAR_3: + case HCL_CODE_STORE_INTO_INSTVAR_4: + case HCL_CODE_STORE_INTO_INSTVAR_5: + case HCL_CODE_STORE_INTO_INSTVAR_6: + case HCL_CODE_STORE_INTO_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ store_instvar: LOG_INST_1 (hcl, "store_into_instvar %zu", b1); break; - case BCODE_POP_INTO_INSTVAR_X: + case HCL_CODE_POP_INTO_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto pop_into_instvar; - case BCODE_POP_INTO_INSTVAR_0: - case BCODE_POP_INTO_INSTVAR_1: - case BCODE_POP_INTO_INSTVAR_2: - case BCODE_POP_INTO_INSTVAR_3: - case BCODE_POP_INTO_INSTVAR_4: - case BCODE_POP_INTO_INSTVAR_5: - case BCODE_POP_INTO_INSTVAR_6: - case BCODE_POP_INTO_INSTVAR_7: + case HCL_CODE_POP_INTO_INSTVAR_0: + case HCL_CODE_POP_INTO_INSTVAR_1: + case HCL_CODE_POP_INTO_INSTVAR_2: + case HCL_CODE_POP_INTO_INSTVAR_3: + case HCL_CODE_POP_INTO_INSTVAR_4: + case HCL_CODE_POP_INTO_INSTVAR_5: + case HCL_CODE_POP_INTO_INSTVAR_6: + case HCL_CODE_POP_INTO_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ pop_into_instvar: LOG_INST_1 (hcl, "pop_into_instvar %zu", b1); @@ -138,7 +138,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) /* ------------------------------------------------- */ case HCL_CODE_PUSH_TEMPVAR_X: case HCL_CODE_STORE_INTO_TEMPVAR_X: - case BCODE_POP_INTO_TEMPVAR_X: + case HCL_CODE_POP_INTO_TEMPVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto handle_tempvar; @@ -158,14 +158,14 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) case HCL_CODE_STORE_INTO_TEMPVAR_5: case HCL_CODE_STORE_INTO_TEMPVAR_6: case HCL_CODE_STORE_INTO_TEMPVAR_7: - case BCODE_POP_INTO_TEMPVAR_0: - case BCODE_POP_INTO_TEMPVAR_1: - case BCODE_POP_INTO_TEMPVAR_2: - case BCODE_POP_INTO_TEMPVAR_3: - case BCODE_POP_INTO_TEMPVAR_4: - case BCODE_POP_INTO_TEMPVAR_5: - case BCODE_POP_INTO_TEMPVAR_6: - case BCODE_POP_INTO_TEMPVAR_7: + 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: b1 = bcode & 0x7; /* low 3 bits */ handle_tempvar: @@ -193,7 +193,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) case HCL_CODE_PUSH_LITERAL_X2: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); - #if (HCL_BCODE_LONG_PARAM_SIZE == 2) + #if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) b1 = (b1 << 16) | b2; #else b1 = (b1 << 8) | b2; @@ -220,7 +220,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) /* ------------------------------------------------- */ case HCL_CODE_PUSH_OBJECT_X: case HCL_CODE_STORE_INTO_OBJECT_X: - case BCODE_POP_INTO_OBJECT_X: + case HCL_CODE_POP_INTO_OBJECT_X: FETCH_PARAM_CODE_TO (hcl, b1); goto handle_object; @@ -232,10 +232,10 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) case HCL_CODE_STORE_INTO_OBJECT_1: case HCL_CODE_STORE_INTO_OBJECT_2: case HCL_CODE_STORE_INTO_OBJECT_3: - case BCODE_POP_INTO_OBJECT_0: - case BCODE_POP_INTO_OBJECT_1: - case BCODE_POP_INTO_OBJECT_2: - case BCODE_POP_INTO_OBJECT_3: + 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: b1 = bcode & 0x3; /* low 2 bits */ handle_object: if ((bcode >> 3) & 1) @@ -331,7 +331,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) case HCL_CODE_PUSH_CTXTEMPVAR_X: case HCL_CODE_STORE_INTO_CTXTEMPVAR_X: - case BCODE_POP_INTO_CTXTEMPVAR_X: + case HCL_CODE_POP_INTO_CTXTEMPVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_ctxtempvar; @@ -343,10 +343,10 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) case HCL_CODE_STORE_INTO_CTXTEMPVAR_1: case HCL_CODE_STORE_INTO_CTXTEMPVAR_2: case HCL_CODE_STORE_INTO_CTXTEMPVAR_3: - case BCODE_POP_INTO_CTXTEMPVAR_0: - case BCODE_POP_INTO_CTXTEMPVAR_1: - case BCODE_POP_INTO_CTXTEMPVAR_2: - case BCODE_POP_INTO_CTXTEMPVAR_3: + 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: b1 = bcode & 0x3; /* low 2 bits */ FETCH_BYTE_CODE_TO (hcl, b2); @@ -373,25 +373,25 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) break; /* -------------------------------------------------------- */ - case BCODE_PUSH_OBJVAR_X: - case BCODE_STORE_INTO_OBJVAR_X: - case BCODE_POP_INTO_OBJVAR_X: + case HCL_CODE_PUSH_OBJVAR_X: + case HCL_CODE_STORE_INTO_OBJVAR_X: + case HCL_CODE_POP_INTO_OBJVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_objvar; - case BCODE_PUSH_OBJVAR_0: - case BCODE_PUSH_OBJVAR_1: - case BCODE_PUSH_OBJVAR_2: - case BCODE_PUSH_OBJVAR_3: - case BCODE_STORE_INTO_OBJVAR_0: - case BCODE_STORE_INTO_OBJVAR_1: - case BCODE_STORE_INTO_OBJVAR_2: - case BCODE_STORE_INTO_OBJVAR_3: - case BCODE_POP_INTO_OBJVAR_0: - case BCODE_POP_INTO_OBJVAR_1: - case BCODE_POP_INTO_OBJVAR_2: - case BCODE_POP_INTO_OBJVAR_3: + 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: /* b1 -> variable index to the object indicated by b2. * b2 -> object index stored in the literal frame. */ b1 = bcode & 0x3; /* low 2 bits */ @@ -418,22 +418,22 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) break; /* -------------------------------------------------------- */ - case BCODE_SEND_MESSAGE_X: - case BCODE_SEND_MESSAGE_TO_SUPER_X: + case HCL_CODE_SEND_MESSAGE_X: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_X: /* b1 -> number of arguments * b2 -> selector index stored in the literal frame */ FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_send_message; - case BCODE_SEND_MESSAGE_0: - case BCODE_SEND_MESSAGE_1: - case BCODE_SEND_MESSAGE_2: - case BCODE_SEND_MESSAGE_3: - case BCODE_SEND_MESSAGE_TO_SUPER_0: - case BCODE_SEND_MESSAGE_TO_SUPER_1: - case BCODE_SEND_MESSAGE_TO_SUPER_2: - case BCODE_SEND_MESSAGE_TO_SUPER_3: + case HCL_CODE_SEND_MESSAGE_0: + case HCL_CODE_SEND_MESSAGE_1: + case HCL_CODE_SEND_MESSAGE_2: + case HCL_CODE_SEND_MESSAGE_3: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_0: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_1: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_2: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_3: b1 = bcode & 0x3; /* low 2 bits */ FETCH_BYTE_CODE_TO (hcl, b2); @@ -443,7 +443,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) /* -------------------------------------------------------- */ - case BCODE_PUSH_RECEIVER: + case HCL_CODE_PUSH_RECEIVER: LOG_INST_0 (hcl, "push_receiver"); break; @@ -459,11 +459,11 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) LOG_INST_0 (hcl, "push_false"); break; - case BCODE_PUSH_CONTEXT: + case HCL_CODE_PUSH_CONTEXT: LOG_INST_0 (hcl, "push_context"); break; - case BCODE_PUSH_PROCESS: + case HCL_CODE_PUSH_PROCESS: LOG_INST_0 (hcl, "push_process"); break; @@ -530,7 +530,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) /* -------------------------------------------------------- */ - case BCODE_DUP_STACKTOP: + case HCL_CODE_DUP_STACKTOP: LOG_INST_0 (hcl, "dup_stacktop"); break; @@ -538,11 +538,11 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) LOG_INST_0 (hcl, "pop_stacktop"); break; - case BCODE_RETURN_STACKTOP: + case HCL_CODE_RETURN_STACKTOP: LOG_INST_0 (hcl, "return_stacktop"); break; - case BCODE_RETURN_RECEIVER: + case HCL_CODE_RETURN_RECEIVER: LOG_INST_0 (hcl, "return_receiver"); break; @@ -562,7 +562,7 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) HCL_ASSERT (hcl, b2 >= b1); break; - case BCODE_SEND_BLOCK_COPY: + case HCL_CODE_SEND_BLOCK_COPY: LOG_INST_0 (hcl, "send_block_copy"); break; diff --git a/lib/exec.c b/lib/exec.c index 5a88acf..46ce5eb 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -89,7 +89,7 @@ static HCL_INLINE const char* proc_state_to_string (int state) #define FETCH_BYTE_CODE(hcl) ((hcl)->code.bc.arr->slot[(hcl)->ip++]) #define FETCH_BYTE_CODE_TO(hcl, v_oow) (v_oow = FETCH_BYTE_CODE(hcl)) -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) # define FETCH_PARAM_CODE_TO(hcl, v_oow) \ do { \ v_oow = FETCH_BYTE_CODE(hcl); \ @@ -1411,17 +1411,17 @@ static int execute (hcl_t* hcl) /* ------------------------------------------------- */ #if 0 - case BCODE_PUSH_INSTVAR_X: + case HCL_CODE_PUSH_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto push_instvar; - case BCODE_PUSH_INSTVAR_0: - case BCODE_PUSH_INSTVAR_1: - case BCODE_PUSH_INSTVAR_2: - case BCODE_PUSH_INSTVAR_3: - case BCODE_PUSH_INSTVAR_4: - case BCODE_PUSH_INSTVAR_5: - case BCODE_PUSH_INSTVAR_6: - case BCODE_PUSH_INSTVAR_7: + case HCL_CODE_PUSH_INSTVAR_0: + case HCL_CODE_PUSH_INSTVAR_1: + case HCL_CODE_PUSH_INSTVAR_2: + case HCL_CODE_PUSH_INSTVAR_3: + case HCL_CODE_PUSH_INSTVAR_4: + case HCL_CODE_PUSH_INSTVAR_5: + case HCL_CODE_PUSH_INSTVAR_6: + case HCL_CODE_PUSH_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ push_instvar: LOG_INST_1 (hcl, "push_instvar %zu", b1); @@ -1431,17 +1431,17 @@ static int execute (hcl_t* hcl) /* ------------------------------------------------- */ - case BCODE_STORE_INTO_INSTVAR_X: + case HCL_CODE_STORE_INTO_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto store_instvar; - case BCODE_STORE_INTO_INSTVAR_0: - case BCODE_STORE_INTO_INSTVAR_1: - case BCODE_STORE_INTO_INSTVAR_2: - case BCODE_STORE_INTO_INSTVAR_3: - case BCODE_STORE_INTO_INSTVAR_4: - case BCODE_STORE_INTO_INSTVAR_5: - case BCODE_STORE_INTO_INSTVAR_6: - case BCODE_STORE_INTO_INSTVAR_7: + case HCL_CODE_STORE_INTO_INSTVAR_0: + case HCL_CODE_STORE_INTO_INSTVAR_1: + case HCL_CODE_STORE_INTO_INSTVAR_2: + case HCL_CODE_STORE_INTO_INSTVAR_3: + case HCL_CODE_STORE_INTO_INSTVAR_4: + case HCL_CODE_STORE_INTO_INSTVAR_5: + case HCL_CODE_STORE_INTO_INSTVAR_6: + case HCL_CODE_STORE_INTO_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ store_instvar: LOG_INST_1 (hcl, "store_into_instvar %zu", b1); @@ -1450,17 +1450,17 @@ static int execute (hcl_t* hcl) break; /* ------------------------------------------------- */ - case BCODE_POP_INTO_INSTVAR_X: + case HCL_CODE_POP_INTO_INSTVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto pop_into_instvar; - case BCODE_POP_INTO_INSTVAR_0: - case BCODE_POP_INTO_INSTVAR_1: - case BCODE_POP_INTO_INSTVAR_2: - case BCODE_POP_INTO_INSTVAR_3: - case BCODE_POP_INTO_INSTVAR_4: - case BCODE_POP_INTO_INSTVAR_5: - case BCODE_POP_INTO_INSTVAR_6: - case BCODE_POP_INTO_INSTVAR_7: + case HCL_CODE_POP_INTO_INSTVAR_0: + case HCL_CODE_POP_INTO_INSTVAR_1: + case HCL_CODE_POP_INTO_INSTVAR_2: + case HCL_CODE_POP_INTO_INSTVAR_3: + case HCL_CODE_POP_INTO_INSTVAR_4: + case HCL_CODE_POP_INTO_INSTVAR_5: + case HCL_CODE_POP_INTO_INSTVAR_6: + case HCL_CODE_POP_INTO_INSTVAR_7: b1 = bcode & 0x7; /* low 3 bits */ pop_into_instvar: LOG_INST_1 (hcl, "pop_into_instvar %zu", b1); @@ -1473,7 +1473,7 @@ static int execute (hcl_t* hcl) /* ------------------------------------------------- */ case HCL_CODE_PUSH_TEMPVAR_X: case HCL_CODE_STORE_INTO_TEMPVAR_X: - case BCODE_POP_INTO_TEMPVAR_X: + case HCL_CODE_POP_INTO_TEMPVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); goto handle_tempvar; @@ -1493,14 +1493,14 @@ static int execute (hcl_t* hcl) case HCL_CODE_STORE_INTO_TEMPVAR_5: case HCL_CODE_STORE_INTO_TEMPVAR_6: case HCL_CODE_STORE_INTO_TEMPVAR_7: - case BCODE_POP_INTO_TEMPVAR_0: - case BCODE_POP_INTO_TEMPVAR_1: - case BCODE_POP_INTO_TEMPVAR_2: - case BCODE_POP_INTO_TEMPVAR_3: - case BCODE_POP_INTO_TEMPVAR_4: - case BCODE_POP_INTO_TEMPVAR_5: - case BCODE_POP_INTO_TEMPVAR_6: - case BCODE_POP_INTO_TEMPVAR_7: + 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: { hcl_oop_context_t ctx; hcl_ooi_t bx; @@ -1590,7 +1590,7 @@ static int execute (hcl_t* hcl) case HCL_CODE_PUSH_LITERAL_X2: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); - #if (HCL_BCODE_LONG_PARAM_SIZE == 2) + #if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) b1 = (b1 << 16) | b2; #else b1 = (b1 << 8) | b2; @@ -1618,7 +1618,7 @@ static int execute (hcl_t* hcl) /* ------------------------------------------------- */ case HCL_CODE_PUSH_OBJECT_X: case HCL_CODE_STORE_INTO_OBJECT_X: - case BCODE_POP_INTO_OBJECT_X: + case HCL_CODE_POP_INTO_OBJECT_X: FETCH_PARAM_CODE_TO (hcl, b1); goto handle_object; @@ -1630,10 +1630,10 @@ static int execute (hcl_t* hcl) case HCL_CODE_STORE_INTO_OBJECT_1: case HCL_CODE_STORE_INTO_OBJECT_2: case HCL_CODE_STORE_INTO_OBJECT_3: - case BCODE_POP_INTO_OBJECT_0: - case BCODE_POP_INTO_OBJECT_1: - case BCODE_POP_INTO_OBJECT_2: - case BCODE_POP_INTO_OBJECT_3: + 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: { hcl_oop_cons_t ass; @@ -1781,7 +1781,7 @@ static int execute (hcl_t* hcl) case HCL_CODE_PUSH_CTXTEMPVAR_X: case HCL_CODE_STORE_INTO_CTXTEMPVAR_X: - case BCODE_POP_INTO_CTXTEMPVAR_X: + case HCL_CODE_POP_INTO_CTXTEMPVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_ctxtempvar; @@ -1793,10 +1793,10 @@ static int execute (hcl_t* hcl) case HCL_CODE_STORE_INTO_CTXTEMPVAR_1: case HCL_CODE_STORE_INTO_CTXTEMPVAR_2: case HCL_CODE_STORE_INTO_CTXTEMPVAR_3: - case BCODE_POP_INTO_CTXTEMPVAR_0: - case BCODE_POP_INTO_CTXTEMPVAR_1: - case BCODE_POP_INTO_CTXTEMPVAR_2: - case BCODE_POP_INTO_CTXTEMPVAR_3: + 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: { hcl_ooi_t i; hcl_oop_context_t ctx; @@ -1840,25 +1840,25 @@ static int execute (hcl_t* hcl) } /* -------------------------------------------------------- */ - case BCODE_PUSH_OBJVAR_X: - case BCODE_STORE_INTO_OBJVAR_X: - case BCODE_POP_INTO_OBJVAR_X: + case HCL_CODE_PUSH_OBJVAR_X: + case HCL_CODE_STORE_INTO_OBJVAR_X: + case HCL_CODE_POP_INTO_OBJVAR_X: FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_objvar; - case BCODE_PUSH_OBJVAR_0: - case BCODE_PUSH_OBJVAR_1: - case BCODE_PUSH_OBJVAR_2: - case BCODE_PUSH_OBJVAR_3: - case BCODE_STORE_INTO_OBJVAR_0: - case BCODE_STORE_INTO_OBJVAR_1: - case BCODE_STORE_INTO_OBJVAR_2: - case BCODE_STORE_INTO_OBJVAR_3: - case BCODE_POP_INTO_OBJVAR_0: - case BCODE_POP_INTO_OBJVAR_1: - case BCODE_POP_INTO_OBJVAR_2: - case BCODE_POP_INTO_OBJVAR_3: + 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: { hcl_oop_oop_t t; @@ -1900,22 +1900,22 @@ static int execute (hcl_t* hcl) /* -------------------------------------------------------- */ #if 0 - case BCODE_SEND_MESSAGE_X: - case BCODE_SEND_MESSAGE_TO_SUPER_X: + case HCL_CODE_SEND_MESSAGE_X: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_X: /* b1 -> number of arguments * b2 -> selector index stored in the literal frame */ FETCH_PARAM_CODE_TO (hcl, b1); FETCH_PARAM_CODE_TO (hcl, b2); goto handle_send_message; - case BCODE_SEND_MESSAGE_0: - case BCODE_SEND_MESSAGE_1: - case BCODE_SEND_MESSAGE_2: - case BCODE_SEND_MESSAGE_3: - case BCODE_SEND_MESSAGE_TO_SUPER_0: - case BCODE_SEND_MESSAGE_TO_SUPER_1: - case BCODE_SEND_MESSAGE_TO_SUPER_2: - case BCODE_SEND_MESSAGE_TO_SUPER_3: + case HCL_CODE_SEND_MESSAGE_0: + case HCL_CODE_SEND_MESSAGE_1: + case HCL_CODE_SEND_MESSAGE_2: + case HCL_CODE_SEND_MESSAGE_3: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_0: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_1: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_2: + case HCL_CODE_SEND_MESSAGE_TO_SUPER_3: { hcl_oop_char_t selector; @@ -1934,7 +1934,7 @@ static int execute (hcl_t* hcl) #endif /* -------------------------------------------------------- */ - case BCODE_PUSH_RECEIVER: + case HCL_CODE_PUSH_RECEIVER: LOG_INST_0 (hcl, "push_receiver"); HCL_STACK_PUSH (hcl, hcl->active_context->origin->receiver_or_source); break; @@ -1954,12 +1954,12 @@ static int execute (hcl_t* hcl) HCL_STACK_PUSH (hcl, hcl->_false); break; - case BCODE_PUSH_CONTEXT: + case HCL_CODE_PUSH_CONTEXT: LOG_INST_0 (hcl, "push_context"); HCL_STACK_PUSH (hcl, (hcl_oop_t)hcl->active_context); break; - case BCODE_PUSH_PROCESS: + case HCL_CODE_PUSH_PROCESS: LOG_INST_0 (hcl, "push_process"); HCL_STACK_PUSH (hcl, (hcl_oop_t)hcl->processor->active); break; @@ -2098,7 +2098,7 @@ static int execute (hcl_t* hcl) /* -------------------------------------------------------- */ - case BCODE_DUP_STACKTOP: + case HCL_CODE_DUP_STACKTOP: { hcl_oop_t t; LOG_INST_0 (hcl, "dup_stacktop"); @@ -2120,13 +2120,13 @@ static int execute (hcl_t* hcl) HCL_STACK_POP (hcl); break; - case BCODE_RETURN_STACKTOP: + case HCL_CODE_RETURN_STACKTOP: LOG_INST_0 (hcl, "return_stacktop"); return_value = HCL_STACK_GETTOP(hcl); HCL_STACK_POP (hcl); goto handle_return; - case BCODE_RETURN_RECEIVER: + case HCL_CODE_RETURN_RECEIVER: LOG_INST_0 (hcl, "return_receiver"); return_value = hcl->active_context->origin->receiver_or_source; @@ -2288,7 +2288,7 @@ static int execute (hcl_t* hcl) hcl_oow_t joff; HCL_ASSERT (hcl, hcl->code.bc.arr->slot[hcl->ip] == HCL_CODE_JUMP_FORWARD_X); joff = hcl->code.bc.arr->slot[hcl->ip + 1]; -#if (HCL_BCODE_LONG_PARAM_SIZE == 2) +#if (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) joff = (joff << 8) | hcl->code.bc.arr->slot[hcl->ip + 2]; #endif @@ -2307,9 +2307,9 @@ HCL_DEBUG1(hcl, "**** MAKE BLOCK joff = %zu\n", joff); /* the long forward jump instruction has the format of * 11000100 KKKKKKKK or 11000100 KKKKKKKK KKKKKKKK - * depending on HCL_BCODE_LONG_PARAM_SIZE. change 'ip' to point to + * depending on HCL_HCL_CODE_LONG_PARAM_SIZE. change 'ip' to point to * the instruction after the jump. */ - blkctx->ip = HCL_SMOOI_TO_OOP(hcl->ip + HCL_BCODE_LONG_PARAM_SIZE + 1); + blkctx->ip = HCL_SMOOI_TO_OOP(hcl->ip + HCL_HCL_CODE_LONG_PARAM_SIZE + 1); /* stack pointer below the bottom. this base block context * has an empty stack anyway. */ blkctx->sp = HCL_SMOOI_TO_OOP(-1); @@ -2331,7 +2331,7 @@ HCL_DEBUG1(hcl, "**** MAKE BLOCK joff = %zu\n", joff); break; } - case BCODE_SEND_BLOCK_COPY: + case HCL_CODE_SEND_BLOCK_COPY: { hcl_ooi_t nargs, ntmprs; hcl_oop_context_t rctx; @@ -2375,8 +2375,8 @@ HCL_DEBUG1(hcl, "**** MAKE BLOCK joff = %zu\n", joff); * blkctx->home is set here to the active context. * it's redundant to have them pushed to the stack * though it is to emulate the message sending of - * blockCopy:withNtmprs:. BCODE_MAKE_BLOCK has been - * added to replace BCODE_SEND_BLOCK_COPY and pusing + * blockCopy:withNtmprs:. HCL_CODE_MAKE_BLOCK has been + * added to replace HCL_CODE_SEND_BLOCK_COPY and pusing * arguments to the stack. * * blkctx->origin is set here by copying the origin @@ -2385,9 +2385,9 @@ HCL_DEBUG1(hcl, "**** MAKE BLOCK joff = %zu\n", joff); /* the extended jump instruction has the format of * 0000XXXX KKKKKKKK or 0000XXXX KKKKKKKK KKKKKKKK - * depending on HCL_BCODE_LONG_PARAM_SIZE. change 'ip' to point to + * depending on HCL_HCL_CODE_LONG_PARAM_SIZE. change 'ip' to point to * the instruction after the jump. */ - blkctx->ip = HCL_SMOOI_TO_OOP(hcl->ip + HCL_BCODE_LONG_PARAM_SIZE + 1); + blkctx->ip = HCL_SMOOI_TO_OOP(hcl->ip + HCL_HCL_CODE_LONG_PARAM_SIZE + 1); blkctx->sp = HCL_SMOOI_TO_OOP(-1); /* the number of arguments for a block context is local to the block */ blkctx->method_or_nargs = HCL_SMOOI_TO_OOP(nargs); diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index f9755c9..8dcf1e2 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -31,7 +31,7 @@ #include "hcl-utl.h" /* you can define this to either 1 or 2 */ -#define HCL_BCODE_LONG_PARAM_SIZE 2 +#define HCL_HCL_CODE_LONG_PARAM_SIZE 2 /* this is useful for debugging. hcl_gc() can be called * while hcl has not been fully initialized when this is defined*/ @@ -312,7 +312,7 @@ struct hcl_compiler_t #endif -#if defined(HCL_BCODE_LONG_PARAM_SIZE) && (HCL_BCODE_LONG_PARAM_SIZE == 1) +#if defined(HCL_HCL_CODE_LONG_PARAM_SIZE) && (HCL_HCL_CODE_LONG_PARAM_SIZE == 1) # define MAX_CODE_INDEX (0xFFu) # define MAX_CODE_NTMPRS (0xFFu) # define MAX_CODE_NARGS (0xFFu) @@ -321,7 +321,7 @@ struct hcl_compiler_t # define MAX_CODE_JUMP (0xFFu) # define MAX_CODE_PARAM (0xFFu) # define MAX_CODE_PARAM2 (0xFFFFu) -#elif defined(HCL_BCODE_LONG_PARAM_SIZE) && (HCL_BCODE_LONG_PARAM_SIZE == 2) +#elif defined(HCL_HCL_CODE_LONG_PARAM_SIZE) && (HCL_HCL_CODE_LONG_PARAM_SIZE == 2) # define MAX_CODE_INDEX (0xFFFFu) # define MAX_CODE_NTMPRS (0xFFFFu) # define MAX_CODE_NARGS (0xFFFFu) @@ -331,7 +331,7 @@ struct hcl_compiler_t # define MAX_CODE_PARAM (0xFFFFu) # define MAX_CODE_PARAM2 (0xFFFFFFFFu) #else -# error Unsupported HCL_BCODE_LONG_PARAM_SIZE +# error Unsupported HCL_HCL_CODE_LONG_PARAM_SIZE #endif @@ -402,75 +402,75 @@ SHORT INSTRUCTION CODE LONG INSTRUCTION C enum hcl_bcode_t { - BCODE_STORE_INTO_INSTVAR_0 = 0x00, - BCODE_STORE_INTO_INSTVAR_1 = 0x01, - BCODE_STORE_INTO_INSTVAR_2 = 0x02, - BCODE_STORE_INTO_INSTVAR_3 = 0x03, + HCL_CODE_STORE_INTO_INSTVAR_0 = 0x00, + HCL_CODE_STORE_INTO_INSTVAR_1 = 0x01, + HCL_CODE_STORE_INTO_INSTVAR_2 = 0x02, + HCL_CODE_STORE_INTO_INSTVAR_3 = 0x03, - BCODE_STORE_INTO_INSTVAR_4 = 0x04, - BCODE_STORE_INTO_INSTVAR_5 = 0x05, - BCODE_STORE_INTO_INSTVAR_6 = 0x06, - BCODE_STORE_INTO_INSTVAR_7 = 0x07, + HCL_CODE_STORE_INTO_INSTVAR_4 = 0x04, + HCL_CODE_STORE_INTO_INSTVAR_5 = 0x05, + HCL_CODE_STORE_INTO_INSTVAR_6 = 0x06, + HCL_CODE_STORE_INTO_INSTVAR_7 = 0x07, - BCODE_POP_INTO_INSTVAR_0 = 0x08, - BCODE_POP_INTO_INSTVAR_1 = 0x09, - BCODE_POP_INTO_INSTVAR_2 = 0x0A, - BCODE_POP_INTO_INSTVAR_3 = 0x0B, + HCL_CODE_POP_INTO_INSTVAR_0 = 0x08, + HCL_CODE_POP_INTO_INSTVAR_1 = 0x09, + HCL_CODE_POP_INTO_INSTVAR_2 = 0x0A, + HCL_CODE_POP_INTO_INSTVAR_3 = 0x0B, - BCODE_POP_INTO_INSTVAR_4 = 0x0C, - BCODE_POP_INTO_INSTVAR_5 = 0x0D, - BCODE_POP_INTO_INSTVAR_6 = 0x0E, - BCODE_POP_INTO_INSTVAR_7 = 0x0F, + HCL_CODE_POP_INTO_INSTVAR_4 = 0x0C, + HCL_CODE_POP_INTO_INSTVAR_5 = 0x0D, + HCL_CODE_POP_INTO_INSTVAR_6 = 0x0E, + HCL_CODE_POP_INTO_INSTVAR_7 = 0x0F, - BCODE_PUSH_INSTVAR_0 = 0x10, - BCODE_PUSH_INSTVAR_1 = 0x11, - BCODE_PUSH_INSTVAR_2 = 0x12, - BCODE_PUSH_INSTVAR_3 = 0x13, + HCL_CODE_PUSH_INSTVAR_0 = 0x10, + HCL_CODE_PUSH_INSTVAR_1 = 0x11, + HCL_CODE_PUSH_INSTVAR_2 = 0x12, + HCL_CODE_PUSH_INSTVAR_3 = 0x13, - BCODE_PUSH_INSTVAR_4 = 0x14, - BCODE_PUSH_INSTVAR_5 = 0x15, - BCODE_PUSH_INSTVAR_6 = 0x16, - BCODE_PUSH_INSTVAR_7 = 0x17, + HCL_CODE_PUSH_INSTVAR_4 = 0x14, + HCL_CODE_PUSH_INSTVAR_5 = 0x15, + HCL_CODE_PUSH_INSTVAR_6 = 0x16, + HCL_CODE_PUSH_INSTVAR_7 = 0x17, - HCL_CODE_PUSH_TEMPVAR_0 = 0x18, - HCL_CODE_PUSH_TEMPVAR_1 = 0x19, - HCL_CODE_PUSH_TEMPVAR_2 = 0x1A, - HCL_CODE_PUSH_TEMPVAR_3 = 0x1B, + HCL_CODE_PUSH_TEMPVAR_0 = 0x18, + HCL_CODE_PUSH_TEMPVAR_1 = 0x19, + HCL_CODE_PUSH_TEMPVAR_2 = 0x1A, + HCL_CODE_PUSH_TEMPVAR_3 = 0x1B, - HCL_CODE_PUSH_TEMPVAR_4 = 0x1C, - HCL_CODE_PUSH_TEMPVAR_5 = 0x1D, - HCL_CODE_PUSH_TEMPVAR_6 = 0x1E, - HCL_CODE_PUSH_TEMPVAR_7 = 0x1F, + HCL_CODE_PUSH_TEMPVAR_4 = 0x1C, + HCL_CODE_PUSH_TEMPVAR_5 = 0x1D, + HCL_CODE_PUSH_TEMPVAR_6 = 0x1E, + HCL_CODE_PUSH_TEMPVAR_7 = 0x1F, - HCL_CODE_STORE_INTO_TEMPVAR_0 = 0x20, - HCL_CODE_STORE_INTO_TEMPVAR_1 = 0x21, - HCL_CODE_STORE_INTO_TEMPVAR_2 = 0x22, - HCL_CODE_STORE_INTO_TEMPVAR_3 = 0x23, + HCL_CODE_STORE_INTO_TEMPVAR_0 = 0x20, + HCL_CODE_STORE_INTO_TEMPVAR_1 = 0x21, + HCL_CODE_STORE_INTO_TEMPVAR_2 = 0x22, + HCL_CODE_STORE_INTO_TEMPVAR_3 = 0x23, - HCL_CODE_STORE_INTO_TEMPVAR_4 = 0x24, - HCL_CODE_STORE_INTO_TEMPVAR_5 = 0x25, - HCL_CODE_STORE_INTO_TEMPVAR_6 = 0x26, - HCL_CODE_STORE_INTO_TEMPVAR_7 = 0x27, + HCL_CODE_STORE_INTO_TEMPVAR_4 = 0x24, + HCL_CODE_STORE_INTO_TEMPVAR_5 = 0x25, + HCL_CODE_STORE_INTO_TEMPVAR_6 = 0x26, + HCL_CODE_STORE_INTO_TEMPVAR_7 = 0x27, - BCODE_POP_INTO_TEMPVAR_0 = 0x28, - BCODE_POP_INTO_TEMPVAR_1 = 0x29, - BCODE_POP_INTO_TEMPVAR_2 = 0x2A, - BCODE_POP_INTO_TEMPVAR_3 = 0x2B, + HCL_CODE_POP_INTO_TEMPVAR_0 = 0x28, + HCL_CODE_POP_INTO_TEMPVAR_1 = 0x29, + HCL_CODE_POP_INTO_TEMPVAR_2 = 0x2A, + HCL_CODE_POP_INTO_TEMPVAR_3 = 0x2B, - BCODE_POP_INTO_TEMPVAR_4 = 0x2C, - BCODE_POP_INTO_TEMPVAR_5 = 0x2D, - BCODE_POP_INTO_TEMPVAR_6 = 0x2E, - BCODE_POP_INTO_TEMPVAR_7 = 0x2F, + HCL_CODE_POP_INTO_TEMPVAR_4 = 0x2C, + HCL_CODE_POP_INTO_TEMPVAR_5 = 0x2D, + HCL_CODE_POP_INTO_TEMPVAR_6 = 0x2E, + HCL_CODE_POP_INTO_TEMPVAR_7 = 0x2F, - HCL_CODE_PUSH_LITERAL_0 = 0x30, - HCL_CODE_PUSH_LITERAL_1 = 0x31, - HCL_CODE_PUSH_LITERAL_2 = 0x32, - HCL_CODE_PUSH_LITERAL_3 = 0x33, + HCL_CODE_PUSH_LITERAL_0 = 0x30, + HCL_CODE_PUSH_LITERAL_1 = 0x31, + HCL_CODE_PUSH_LITERAL_2 = 0x32, + HCL_CODE_PUSH_LITERAL_3 = 0x33, - HCL_CODE_PUSH_LITERAL_4 = 0x34, - HCL_CODE_PUSH_LITERAL_5 = 0x35, - HCL_CODE_PUSH_LITERAL_6 = 0x36, - HCL_CODE_PUSH_LITERAL_7 = 0x37, + HCL_CODE_PUSH_LITERAL_4 = 0x34, + HCL_CODE_PUSH_LITERAL_5 = 0x35, + HCL_CODE_PUSH_LITERAL_6 = 0x36, + HCL_CODE_PUSH_LITERAL_7 = 0x37, /* -------------------------------------- */ @@ -479,10 +479,10 @@ enum hcl_bcode_t HCL_CODE_STORE_INTO_OBJECT_2 = 0x3A, HCL_CODE_STORE_INTO_OBJECT_3 = 0x3B, - BCODE_POP_INTO_OBJECT_0 = 0x3C, - BCODE_POP_INTO_OBJECT_1 = 0x3D, - BCODE_POP_INTO_OBJECT_2 = 0x3E, - BCODE_POP_INTO_OBJECT_3 = 0x3F, + HCL_CODE_POP_INTO_OBJECT_0 = 0x3C, + HCL_CODE_POP_INTO_OBJECT_1 = 0x3D, + HCL_CODE_POP_INTO_OBJECT_2 = 0x3E, + HCL_CODE_POP_INTO_OBJECT_3 = 0x3F, HCL_CODE_PUSH_OBJECT_0 = 0x40, HCL_CODE_PUSH_OBJECT_1 = 0x41, @@ -500,15 +500,15 @@ enum hcl_bcode_t HCL_CODE_JUMP_BACKWARD_3 = 0x4B, /* 75 */ #if 0 - BCODE_JUMP_BACKWARD_IF_FALSE_0 = 0x4C, /* 76 */ - BCODE_JUMP_BACKWARD_IF_FALSE_1 = 0x4D, /* 77 */ - BCODE_JUMP_BACKWARD_IF_FALSE_2 = 0x4E, /* 78 */ - BCODE_JUMP_BACKWARD_IF_FALSE_3 = 0x4F, /* 79 */ + HCL_CODE_JUMP_BACKWARD_IF_FALSE_0 = 0x4C, /* 76 */ + HCL_CODE_JUMP_BACKWARD_IF_FALSE_1 = 0x4D, /* 77 */ + HCL_CODE_JUMP_BACKWARD_IF_FALSE_2 = 0x4E, /* 78 */ + HCL_CODE_JUMP_BACKWARD_IF_FALSE_3 = 0x4F, /* 79 */ - BCODE_JUMP_BACKWARD_IF_TRUE_0 = 0x50, /* 80 */ - BCODE_JUMP_BACKWARD_IF_TRUE_1 = 0x51, /* 81 */ - BCODE_JUMP_BACKWARD_IF_TRUE_2 = 0x52, /* 82 */ - BCODE_JUMP_BACKWARD_IF_TRUE_3 = 0x53, /* 83 */ + HCL_CODE_JUMP_BACKWARD_IF_TRUE_0 = 0x50, /* 80 */ + HCL_CODE_JUMP_BACKWARD_IF_TRUE_1 = 0x51, /* 81 */ + HCL_CODE_JUMP_BACKWARD_IF_TRUE_2 = 0x52, /* 82 */ + HCL_CODE_JUMP_BACKWARD_IF_TRUE_3 = 0x53, /* 83 */ #endif HCL_CODE_CALL_0 = 0x54, /* 84 */ @@ -521,65 +521,65 @@ enum hcl_bcode_t HCL_CODE_STORE_INTO_CTXTEMPVAR_2 = 0x5A, /* 90 */ HCL_CODE_STORE_INTO_CTXTEMPVAR_3 = 0x5B, /* 91 */ - BCODE_POP_INTO_CTXTEMPVAR_0 = 0x5C, /* 92 */ - BCODE_POP_INTO_CTXTEMPVAR_1 = 0x5D, /* 93 */ - BCODE_POP_INTO_CTXTEMPVAR_2 = 0x5E, /* 94 */ - BCODE_POP_INTO_CTXTEMPVAR_3 = 0x5F, /* 95 */ + HCL_CODE_POP_INTO_CTXTEMPVAR_0 = 0x5C, /* 92 */ + HCL_CODE_POP_INTO_CTXTEMPVAR_1 = 0x5D, /* 93 */ + HCL_CODE_POP_INTO_CTXTEMPVAR_2 = 0x5E, /* 94 */ + HCL_CODE_POP_INTO_CTXTEMPVAR_3 = 0x5F, /* 95 */ HCL_CODE_PUSH_CTXTEMPVAR_0 = 0x60, /* 96 */ HCL_CODE_PUSH_CTXTEMPVAR_1 = 0x61, /* 97 */ HCL_CODE_PUSH_CTXTEMPVAR_2 = 0x62, /* 98 */ HCL_CODE_PUSH_CTXTEMPVAR_3 = 0x63, /* 99 */ - BCODE_PUSH_OBJVAR_0 = 0x64, - BCODE_PUSH_OBJVAR_1 = 0x65, - BCODE_PUSH_OBJVAR_2 = 0x66, - BCODE_PUSH_OBJVAR_3 = 0x67, + HCL_CODE_PUSH_OBJVAR_0 = 0x64, + HCL_CODE_PUSH_OBJVAR_1 = 0x65, + HCL_CODE_PUSH_OBJVAR_2 = 0x66, + HCL_CODE_PUSH_OBJVAR_3 = 0x67, - BCODE_STORE_INTO_OBJVAR_0 = 0x68, - BCODE_STORE_INTO_OBJVAR_1 = 0x69, - BCODE_STORE_INTO_OBJVAR_2 = 0x6A, - BCODE_STORE_INTO_OBJVAR_3 = 0x6B, + HCL_CODE_STORE_INTO_OBJVAR_0 = 0x68, + HCL_CODE_STORE_INTO_OBJVAR_1 = 0x69, + HCL_CODE_STORE_INTO_OBJVAR_2 = 0x6A, + HCL_CODE_STORE_INTO_OBJVAR_3 = 0x6B, - BCODE_POP_INTO_OBJVAR_0 = 0x6C, - BCODE_POP_INTO_OBJVAR_1 = 0x6D, - BCODE_POP_INTO_OBJVAR_2 = 0x6E, - BCODE_POP_INTO_OBJVAR_3 = 0x6F, + HCL_CODE_POP_INTO_OBJVAR_0 = 0x6C, + HCL_CODE_POP_INTO_OBJVAR_1 = 0x6D, + HCL_CODE_POP_INTO_OBJVAR_2 = 0x6E, + HCL_CODE_POP_INTO_OBJVAR_3 = 0x6F, - BCODE_SEND_MESSAGE_0 = 0x70, - BCODE_SEND_MESSAGE_1 = 0x71, - BCODE_SEND_MESSAGE_2 = 0x72, - BCODE_SEND_MESSAGE_3 = 0x73, + HCL_CODE_SEND_MESSAGE_0 = 0x70, + HCL_CODE_SEND_MESSAGE_1 = 0x71, + HCL_CODE_SEND_MESSAGE_2 = 0x72, + HCL_CODE_SEND_MESSAGE_3 = 0x73, - BCODE_SEND_MESSAGE_TO_SUPER_0 = 0x74, - BCODE_SEND_MESSAGE_TO_SUPER_1 = 0x75, - BCODE_SEND_MESSAGE_TO_SUPER_2 = 0x76, - BCODE_SEND_MESSAGE_TO_SUPER_3 = 0x77, + 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, /* UNUSED 0x78 - 0x7F */ - BCODE_STORE_INTO_INSTVAR_X = 0x80, /* 128 */ + HCL_CODE_STORE_INTO_INSTVAR_X = 0x80, /* 128 */ - BCODE_PUSH_RECEIVER = 0x81, /* 129 */ + HCL_CODE_PUSH_RECEIVER = 0x81, /* 129 */ HCL_CODE_PUSH_NIL = 0x82, /* 130 */ HCL_CODE_PUSH_TRUE = 0x83, /* 131 */ HCL_CODE_PUSH_FALSE = 0x84, /* 132 */ - BCODE_PUSH_CONTEXT = 0x85, /* 133 */ - BCODE_PUSH_PROCESS = 0x86, /* 134 */ + HCL_CODE_PUSH_CONTEXT = 0x85, /* 133 */ + HCL_CODE_PUSH_PROCESS = 0x86, /* 134 */ /* UNUSED135 */ - BCODE_POP_INTO_INSTVAR_X = 0x88, /* 136 ## */ + HCL_CODE_POP_INTO_INSTVAR_X = 0x88, /* 136 ## */ HCL_CODE_PUSH_NEGONE = 0x89, /* 137 */ HCL_CODE_PUSH_ZERO = 0x8A, /* 138 */ HCL_CODE_PUSH_ONE = 0x8B, /* 139 */ HCL_CODE_PUSH_TWO = 0x8C, /* 140 */ - BCODE_PUSH_INSTVAR_X = 0x90, /* 144 ## */ + HCL_CODE_PUSH_INSTVAR_X = 0x90, /* 144 ## */ HCL_CODE_PUSH_TEMPVAR_X = 0x98, /* 152 ## */ HCL_CODE_STORE_INTO_TEMPVAR_X = 0xA0, /* 160 ## */ - BCODE_POP_INTO_TEMPVAR_X = 0xA8, /* 168 ## */ + HCL_CODE_POP_INTO_TEMPVAR_X = 0xA8, /* 168 ## */ HCL_CODE_PUSH_LITERAL_X = 0xB0, /* 176 ## */ HCL_CODE_PUSH_LITERAL_X2 = 0xB1, /* 177 */ @@ -589,7 +589,7 @@ enum hcl_bcode_t HCL_CODE_PUSH_CHARLIT = 0xB4, /* 180 */ HCL_CODE_STORE_INTO_OBJECT_X = 0xB8, /* 184 ## */ - BCODE_POP_INTO_OBJECT_X = 0xBC, /* 188 ## */ + HCL_CODE_POP_INTO_OBJECT_X = 0xBC, /* 188 ## */ HCL_CODE_PUSH_OBJECT_X = 0xC0, /* 192 ## */ HCL_CODE_JUMP_FORWARD_X = 0xC4, /* 196 ## */ @@ -606,38 +606,38 @@ enum hcl_bcode_t HCL_CODE_CALL_X = 0xD4, /* 212 */ HCL_CODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 ## */ - BCODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 ## */ + HCL_CODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 ## */ HCL_CODE_PUSH_CTXTEMPVAR_X = 0xE0, /* 224 ## */ - BCODE_PUSH_OBJVAR_X = 0xE4, /* 228 ## */ - BCODE_STORE_INTO_OBJVAR_X = 0xE8, /* 232 ## */ - BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */ + HCL_CODE_PUSH_OBJVAR_X = 0xE4, /* 228 ## */ + HCL_CODE_STORE_INTO_OBJVAR_X = 0xE8, /* 232 ## */ + HCL_CODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */ /* UNUSED 237 */ HCL_CODE_MAKE_BYTEARRAY = 0xEE, /* 238 */ HCL_CODE_POP_INTO_BYTEARRAY = 0xEF, /* 239 */ - BCODE_SEND_MESSAGE_X = 0xF0, /* 240 ## */ + HCL_CODE_SEND_MESSAGE_X = 0xF0, /* 240 ## */ /* UNUSED 241 */ HCL_CODE_MAKE_DIC = 0xF2, /* 242 */ HCL_CODE_POP_INTO_DIC = 0xF3, /* 243 */ - BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 ## */ + HCL_CODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 ## */ /* -------------------------------------- */ HCL_CODE_MAKE_ARRAY = 0xF5, /* 245 */ HCL_CODE_POP_INTO_ARRAY = 0xF6, /* 246 */ - BCODE_DUP_STACKTOP = 0xF7, + HCL_CODE_DUP_STACKTOP = 0xF7, HCL_CODE_POP_STACKTOP = 0xF8, - BCODE_RETURN_STACKTOP = 0xF9, /* ^something */ - BCODE_RETURN_RECEIVER = 0xFA, /* ^self */ + HCL_CODE_RETURN_STACKTOP = 0xF9, /* ^something */ + HCL_CODE_RETURN_RECEIVER = 0xFA, /* ^self */ HCL_CODE_RETURN_FROM_BLOCK = 0xFB, /* return the stack top from a block */ /* UNUSED 252 */ HCL_CODE_MAKE_BLOCK = 0xFD, /* 253 */ - BCODE_SEND_BLOCK_COPY = 0xFE, /* 254 */ + HCL_CODE_SEND_BLOCK_COPY = 0xFE, /* 254 */ HCL_CODE_NOOP = 0xFF /* 255 */ }; diff --git a/lib/hcl.c b/lib/hcl.c index b24c221..6927958 100644 --- a/lib/hcl.c +++ b/lib/hcl.c @@ -93,9 +93,46 @@ static void free_heap (hcl_t* hcl, void* ptr) hcl_freemem (hcl, ptr); } +static int push_code_container (hcl_t* hcl) +{ + hcl_code_container_t* cc; + + cc = hcl_callocmem(hcl, HCL_SIZEOF(*cc)); + if (HCL_UNLIKELY(!cc)) return -1; + + cc->_par = hcl->ccstk; + hcl->ccstk = cc; + + return 0; +} + +static void pop_code_container (hcl_t* hcl) +{ + hcl_code_container_t* cc = hcl->ccstk; + + if (cc->bc.arr) + { + hcl_freengcobj (hcl, (hcl_oop_t)cc->bc.arr); + cc->bc.arr = HCL_NULL; + cc->bc.len = 0; + } + + if (cc->lit.arr) + { + hcl_freengcobj (hcl, (hcl_oop_t)cc->lit.arr); + cc->lit.arr = HCL_NULL; + cc->lit.len = 0; + } + + hcl->ccstk = cc->_par; + hcl_freemem (hcl, cc); +} + + int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t* vmprim) { int modtab_inited = 0; + int n; if (!vmprim->syserrstrb && !vmprim->syserrstru) { @@ -135,9 +172,10 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t * reallocation fails */ /* +1 required for consistency with put_oocs and put_ooch in logfmt.c */ hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem(hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr)); - if (!hcl->log.ptr) goto oops; + if (HCL_UNLIKELY(!hcl->log.ptr)) goto oops; - if (hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1) <= -1) goto oops; + n = hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1); + if (HCL_UNLIKELY(n <= -1)) goto oops; modtab_inited = 1; hcl_rbt_setstyle(&hcl->modtab, hcl_get_rbt_style(HCL_RBT_STYLE_INLINE_COPIERS)); @@ -154,14 +192,18 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t /*hcl->permheap = hcl_makeheap (hcl, what is the best size???); if (!hcl->curheap) goto oops; */ hcl->curheap = hcl_makeheap(hcl, heapsz); - if (!hcl->curheap) goto oops; + if (HCL_UNLIKELY(!hcl->curheap)) goto oops; hcl->newheap = hcl_makeheap(hcl, heapsz); - if (!hcl->newheap) goto oops; + if (HCL_UNLIKELY(!hcl->newheap)) goto oops; + + n = push_code_container(hcl); + if (HCL_UNLIKELY(n <= -1)) goto oops; if (hcl->vmprim.dl_startup) hcl->vmprim.dl_startup (hcl); return 0; oops: + if (hcl->ccstk) pop_code_container(hcl); if (hcl->newheap) hcl_killheap (hcl, hcl->newheap); if (hcl->curheap) hcl_killheap (hcl, hcl->curheap); if (hcl->permheap) hcl_killheap (hcl, hcl->permheap); @@ -253,6 +295,8 @@ void hcl_fini (hcl_t* hcl) hcl->code.lit.len = 0; } + while (hcl->ccstk) pop_code_container(hcl); + if (hcl->p.s.ptr) { hcl_freemem (hcl, hcl->p.s.ptr); @@ -320,6 +364,12 @@ void hcl_reset (hcl_t* hcl) hcl->code.bc.len = 0; hcl->code.lit.len = 0; + /* keep the base container */ + HCL_ASSERT (hcl, hcl->ccstk != HCL_NULL); + while (hcl->ccstk->_par) pop_code_container(hcl); + hcl->ccstk->bc.len = 0; + hcl->ccstk->lit.len = 0; + /* clean up object memory */ hcl_gc (hcl); } diff --git a/lib/hcl.h b/lib/hcl.h index 48dcfb6..0ae910a 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1091,6 +1091,25 @@ typedef struct hcl_compiler_t hcl_compiler_t; #define HCL_ERRMSG_CAPA (2048) +typedef struct hcl_code_container_t hcl_code_container_t; +struct hcl_code_container_t +{ + struct + { + hcl_oop_byte_t arr; /* byte code array - not part of object memory */ + hcl_oow_t len; + } bc; + + struct + { + hcl_oop_oop_t arr; /* literal array - not part of object memory */ + hcl_oow_t len; + } lit; + + hcl_code_container_t* _par; +}; + + struct hcl_t { hcl_oow_t _instsize; @@ -1241,20 +1260,8 @@ struct hcl_t } xbuf; /* buffer to support sprintf */ } sprintf; - struct - { - struct - { - hcl_oop_byte_t arr; /* byte code array - not part of object memory */ - hcl_oow_t len; - } bc; - - struct - { - hcl_oop_oop_t arr; /* literal array - not part of object memory */ - hcl_oow_t len; - } lit; - } code; + hcl_code_container_t* ccstk; /* byte-code container stack */ + hcl_code_container_t code; /* byte-code structure generated by compilers */ /* == PRINTER == */ struct