added some code to handle while
This commit is contained in:
parent
36cdf2e062
commit
ad671fb493
142
lib/comp.c
142
lib/comp.c
@ -241,7 +241,7 @@ static int emit_single_param_instruction (hcl_t* hcl, int cmd, hcl_oow_t param_1
|
|||||||
case HCL_CODE_JUMP_FORWARD_0:
|
case HCL_CODE_JUMP_FORWARD_0:
|
||||||
case HCL_CODE_JUMP_BACKWARD_0:
|
case HCL_CODE_JUMP_BACKWARD_0:
|
||||||
case BCODE_JUMP_IF_TRUE_0:
|
case BCODE_JUMP_IF_TRUE_0:
|
||||||
case BCODE_JUMP_IF_FALSE_0:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_0:
|
||||||
case HCL_CODE_CALL_0:
|
case HCL_CODE_CALL_0:
|
||||||
if (param_1 < 4)
|
if (param_1 < 4)
|
||||||
{
|
{
|
||||||
@ -542,11 +542,18 @@ enum
|
|||||||
COP_EMIT_POP,
|
COP_EMIT_POP,
|
||||||
COP_EMIT_CALL,
|
COP_EMIT_CALL,
|
||||||
COP_EMIT_LAMBDA,
|
COP_EMIT_LAMBDA,
|
||||||
|
COP_EMIT_RETURN,
|
||||||
COP_EMIT_SET
|
COP_EMIT_SET
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
|
static int compile_if (hcl_t* hcl, hcl_oop_t src)
|
||||||
|
{
|
||||||
|
/* TODO: NOT IMPLEMENTED */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int compile_lambda (hcl_t* hcl, hcl_oop_t src)
|
static int compile_lambda (hcl_t* hcl, hcl_oop_t src)
|
||||||
{
|
{
|
||||||
hcl_oop_t obj, args;
|
hcl_oop_t obj, args;
|
||||||
@ -702,9 +709,10 @@ static int compile_lambda (hcl_t* hcl, hcl_oop_t src)
|
|||||||
* count of temporaries in the home context */
|
* count of temporaries in the home context */
|
||||||
if (emit_double_param_instruction (hcl, HCL_CODE_MAKE_BLOCK, nargs, hcl->c->tv.size/*ntmprs*/) <= -1) return -1;
|
if (emit_double_param_instruction (hcl, HCL_CODE_MAKE_BLOCK, nargs, hcl->c->tv.size/*ntmprs*/) <= -1) return -1;
|
||||||
|
|
||||||
|
|
||||||
|
jump_inst_pos = hcl->code.bc.len;
|
||||||
/* specifying MAX_CODE_JUMP causes emit_single_param_instruction() to
|
/* specifying MAX_CODE_JUMP causes emit_single_param_instruction() to
|
||||||
* produce the long jump instruction (BCODE_JUMP_FORWARD_X) */
|
* produce the long jump instruction (BCODE_JUMP_FORWARD_X) */
|
||||||
jump_inst_pos = hcl->code.bc.len;
|
|
||||||
if (emit_single_param_instruction (hcl, HCL_CODE_JUMP_FORWARD_0, MAX_CODE_JUMP) <= -1) return -1;
|
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);
|
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT_LIST, obj);
|
||||||
@ -715,6 +723,47 @@ static int compile_lambda (hcl_t* hcl, hcl_oop_t src)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int compile_return (hcl_t* hcl, hcl_oop_t src)
|
||||||
|
{
|
||||||
|
hcl_oop_t obj, val;
|
||||||
|
|
||||||
|
obj = HCL_CONS_CDR(src);
|
||||||
|
|
||||||
|
HCL_ASSERT (HCL_BRANDOF(hcl,src) == HCL_BRAND_CONS);
|
||||||
|
HCL_ASSERT (HCL_CONS_CAR(src) == hcl->_return);
|
||||||
|
|
||||||
|
if (HCL_IS_NIL(hcl, obj))
|
||||||
|
{
|
||||||
|
/* TODO: should i allow (return)? does it return the last value on the stack? */
|
||||||
|
/* no value */
|
||||||
|
HCL_DEBUG1 (hcl, "Syntax error - no value specified in return - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_ARGCOUNT, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (HCL_BRANDOF(hcl, obj) != HCL_BRAND_CONS)
|
||||||
|
{
|
||||||
|
HCL_DEBUG1 (hcl, "Syntax error - redundant cdr in return - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_DOTBANNED, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = HCL_CONS_CAR(obj);
|
||||||
|
|
||||||
|
obj = HCL_CONS_CDR(obj);
|
||||||
|
if (!HCL_IS_NIL(hcl, obj))
|
||||||
|
{
|
||||||
|
HCL_DEBUG1 (hcl, "Synatx error - too many arguments to return - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_ARGCOUNT, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT, val);
|
||||||
|
PUSH_SUBCFRAME (hcl, COP_EMIT_RETURN, hcl->_nil);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int compile_set (hcl_t* hcl, hcl_oop_t src)
|
static int compile_set (hcl_t* hcl, hcl_oop_t src)
|
||||||
{
|
{
|
||||||
hcl_cframe_t* cf;
|
hcl_cframe_t* cf;
|
||||||
@ -793,7 +842,58 @@ static int compile_set (hcl_t* hcl, hcl_oop_t src)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int compile_cons (hcl_t* hcl, hcl_oop_t obj)
|
static int compile_while (hcl_t* hcl, hcl_oop_t src)
|
||||||
|
{
|
||||||
|
/* (while (xxxx) ... ) */
|
||||||
|
hcl_oop_t obj, cond;
|
||||||
|
hcl_oow_t cond_pos;
|
||||||
|
|
||||||
|
obj = HCL_CONS_CDR(src);
|
||||||
|
|
||||||
|
HCL_ASSERT (HCL_BRANDOF(hcl,src) == HCL_BRAND_CONS);
|
||||||
|
HCL_ASSERT (HCL_CONS_CAR(src) == hcl->_while);
|
||||||
|
|
||||||
|
if (HCL_IS_NIL(hcl, obj))
|
||||||
|
{
|
||||||
|
/* no value */
|
||||||
|
HCL_DEBUG1 (hcl, "Syntax error - no condition specified in while - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_ARGCOUNT, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (HCL_BRANDOF(hcl, obj) != HCL_BRAND_CONS)
|
||||||
|
{
|
||||||
|
HCL_DEBUG1 (hcl, "Syntax error - redundant cdr in while - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_DOTBANNED, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cond_pos = hcl->code.bc.len;
|
||||||
|
cond = HCL_CONS_CAR(obj);
|
||||||
|
|
||||||
|
obj = HCL_CONS_CDR(obj);
|
||||||
|
if (!HCL_IS_NIL(hcl, obj))
|
||||||
|
{
|
||||||
|
HCL_DEBUG1 (hcl, "Synatx error - too many arguments to return - %O\n", src);
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_ARGCOUNT, HCL_NULL, HCL_NULL); /* TODO: error location */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* specifying MAX_CODE_JUMP causes emit_single_param_instruction() to
|
||||||
|
* produce the long jump instruction (BCODE_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);
|
||||||
|
|
||||||
|
HCL_ASSERT (cond_pos < HCL_SMOOI_MAX); /* guaranteed in emit_byte_instruction() */
|
||||||
|
PUSH_SUBCFRAME (hcl, COP_EMIT_LAMBDA, HCL_SMOOI_TO_OOP(cond_pos));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ========================================================================= */
|
||||||
|
|
||||||
|
|
||||||
|
static int compile_cons_expression (hcl_t* hcl, hcl_oop_t obj)
|
||||||
{
|
{
|
||||||
hcl_oop_t car;
|
hcl_oop_t car;
|
||||||
int syncode;
|
int syncode;
|
||||||
@ -807,8 +907,11 @@ static int compile_cons (hcl_t* hcl, hcl_oop_t obj)
|
|||||||
{
|
{
|
||||||
case HCL_SYNCODE_BEGIN:
|
case HCL_SYNCODE_BEGIN:
|
||||||
case HCL_SYNCODE_DEFUN:
|
case HCL_SYNCODE_DEFUN:
|
||||||
|
/* TODO: not implemented yet */
|
||||||
|
break;
|
||||||
|
|
||||||
case HCL_SYNCODE_IF:
|
case HCL_SYNCODE_IF:
|
||||||
/* TODO: */
|
if (compile_if (hcl, obj) <= -1) return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCL_SYNCODE_LAMBDA:
|
case HCL_SYNCODE_LAMBDA:
|
||||||
@ -822,6 +925,16 @@ static int compile_cons (hcl_t* hcl, hcl_oop_t obj)
|
|||||||
if (compile_set (hcl, obj) <= -1) return -1;
|
if (compile_set (hcl, obj) <= -1) return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HCL_SYNCODE_RETURN:
|
||||||
|
/* (return 10)
|
||||||
|
* (return (+ 10 20)) */
|
||||||
|
if (compile_return (hcl, obj) <= -1) return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HCL_SYNCODE_WHILE:
|
||||||
|
if (compile_while (hcl, obj) <= -1) return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HCL_DEBUG3 (hcl, "Internal error - unknown syncode %d at %s:%d\n", syncode, __FILE__, __LINE__);
|
HCL_DEBUG3 (hcl, "Internal error - unknown syncode %d at %s:%d\n", syncode, __FILE__, __LINE__);
|
||||||
hcl->errnum = HCL_EINTERN;
|
hcl->errnum = HCL_EINTERN;
|
||||||
@ -981,7 +1094,7 @@ static int compile_object (hcl_t* hcl)
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
case HCL_BRAND_CONS:
|
case HCL_BRAND_CONS:
|
||||||
if (compile_cons (hcl, cf->operand) <= -1) return -1;
|
if (compile_cons_expression (hcl, cf->operand) <= -1) return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HCL_BRAND_SYMBOL_ARRAY:
|
case HCL_BRAND_SYMBOL_ARRAY:
|
||||||
@ -1146,6 +1259,21 @@ static HCL_INLINE int emit_call (hcl_t* hcl)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HCL_INLINE int emit_return (hcl_t* hcl)
|
||||||
|
{
|
||||||
|
hcl_cframe_t* cf;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
cf = GET_TOP_CFRAME(hcl);
|
||||||
|
HCL_ASSERT (cf->opcode == COP_EMIT_RETURN);
|
||||||
|
HCL_ASSERT (HCL_IS_NIL(hcl, cf->operand));
|
||||||
|
|
||||||
|
n = emit_byte_instruction (hcl, HCL_CODE_RETURN_FROM_BLOCK);
|
||||||
|
|
||||||
|
POP_CFRAME (hcl);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static HCL_INLINE int emit_set (hcl_t* hcl)
|
static HCL_INLINE int emit_set (hcl_t* hcl)
|
||||||
{
|
{
|
||||||
hcl_cframe_t* cf;
|
hcl_cframe_t* cf;
|
||||||
@ -1232,6 +1360,10 @@ int hcl_compile (hcl_t* hcl, hcl_oop_t obj)
|
|||||||
if (emit_lambda (hcl) <= -1) goto oops;
|
if (emit_lambda (hcl) <= -1) goto oops;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case COP_EMIT_RETURN:
|
||||||
|
if (emit_return (hcl) <= -1) goto oops;
|
||||||
|
break;
|
||||||
|
|
||||||
case COP_EMIT_SET:
|
case COP_EMIT_SET:
|
||||||
if (emit_set (hcl) <= -1) goto oops;
|
if (emit_set (hcl) <= -1) goto oops;
|
||||||
break;
|
break;
|
||||||
|
26
lib/decode.c
26
lib/decode.c
@ -269,18 +269,28 @@ int hcl_decode (hcl_t* hcl, hcl_ooi_t start, hcl_ooi_t end)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP_IF_TRUE_X:
|
case BCODE_JUMP_IF_TRUE_X:
|
||||||
case BCODE_JUMP_IF_FALSE_X:
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||||
|
LOG_INST_1 (hcl, "jump_if_true %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP_IF_TRUE_0:
|
case BCODE_JUMP_IF_TRUE_0:
|
||||||
case BCODE_JUMP_IF_TRUE_1:
|
case BCODE_JUMP_IF_TRUE_1:
|
||||||
case BCODE_JUMP_IF_TRUE_2:
|
case BCODE_JUMP_IF_TRUE_2:
|
||||||
case BCODE_JUMP_IF_TRUE_3:
|
case BCODE_JUMP_IF_TRUE_3:
|
||||||
case BCODE_JUMP_IF_FALSE_0:
|
LOG_INST_1 (hcl, "jump_if_true %zu", (hcl_oow_t)(bcode & 0x3)); /* low 2 bits */
|
||||||
case BCODE_JUMP_IF_FALSE_1:
|
break;
|
||||||
case BCODE_JUMP_IF_FALSE_2:
|
|
||||||
case BCODE_JUMP_IF_FALSE_3:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_X:
|
||||||
LOG_INST_0 (hcl, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>");
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||||
hcl->errnum = HCL_ENOIMPL;
|
LOG_INST_1 (hcl, "jump_forward_if_false %zu", b1);
|
||||||
return -1;
|
break;
|
||||||
|
|
||||||
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_0:
|
||||||
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_1:
|
||||||
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_2:
|
||||||
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_3:
|
||||||
|
LOG_INST_1 (hcl, "jump_forward_if_false %zu", (hcl_oow_t)(bcode & 0x3)); /* low 2 bits */
|
||||||
|
break;
|
||||||
|
|
||||||
case HCL_CODE_JUMP2_FORWARD:
|
case HCL_CODE_JUMP2_FORWARD:
|
||||||
FETCH_PARAM_CODE_TO (hcl, b1);
|
FETCH_PARAM_CODE_TO (hcl, b1);
|
||||||
|
10
lib/exec.c
10
lib/exec.c
@ -1499,15 +1499,15 @@ static int execute (hcl_t* hcl)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP_IF_TRUE_X:
|
case BCODE_JUMP_IF_TRUE_X:
|
||||||
case BCODE_JUMP_IF_FALSE_X:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_X:
|
||||||
case BCODE_JUMP_IF_TRUE_0:
|
case BCODE_JUMP_IF_TRUE_0:
|
||||||
case BCODE_JUMP_IF_TRUE_1:
|
case BCODE_JUMP_IF_TRUE_1:
|
||||||
case BCODE_JUMP_IF_TRUE_2:
|
case BCODE_JUMP_IF_TRUE_2:
|
||||||
case BCODE_JUMP_IF_TRUE_3:
|
case BCODE_JUMP_IF_TRUE_3:
|
||||||
case BCODE_JUMP_IF_FALSE_0:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_0:
|
||||||
case BCODE_JUMP_IF_FALSE_1:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_1:
|
||||||
case BCODE_JUMP_IF_FALSE_2:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_2:
|
||||||
case BCODE_JUMP_IF_FALSE_3:
|
case HCL_CODE_JUMP_FORWARD_IF_FALSE_3:
|
||||||
HCL_LOG0 (hcl, HCL_LOG_IC | HCL_LOG_FATAL, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>\n");
|
HCL_LOG0 (hcl, HCL_LOG_IC | HCL_LOG_FATAL, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>\n");
|
||||||
hcl->errnum = HCL_ENOIMPL;
|
hcl->errnum = HCL_ENOIMPL;
|
||||||
return -1;
|
return -1;
|
||||||
|
14
lib/gc.c
14
lib/gc.c
@ -34,12 +34,14 @@ static struct
|
|||||||
hcl_oow_t offset;
|
hcl_oow_t offset;
|
||||||
} syminfo[] =
|
} syminfo[] =
|
||||||
{
|
{
|
||||||
{ 5, { 'b', 'e', 'g', 'i', 'n' }, HCL_SYNCODE_BEGIN, HCL_OFFSETOF(hcl_t,_begin) },
|
{ 5, { 'b','e','g','i','n' }, HCL_SYNCODE_BEGIN, HCL_OFFSETOF(hcl_t,_begin) },
|
||||||
{ 5, { 'd', 'e', 'f', 'u', 'n' }, HCL_SYNCODE_DEFUN, HCL_OFFSETOF(hcl_t,_defun) },
|
{ 5, { 'd','e','f','u','n' }, HCL_SYNCODE_DEFUN, HCL_OFFSETOF(hcl_t,_defun) },
|
||||||
{ 2, { 'i', 'f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,_if) },
|
{ 2, { 'i','f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,_if) },
|
||||||
{ 6, { 'l', 'a', 'm', 'b', 'd', 'a' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_lambda) },
|
{ 6, { 'l','a','m','b','d','a' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_lambda) },
|
||||||
{ 5, { 'q', 'u', 'o', 't', 'e' }, HCL_SYNCODE_QUOTE, HCL_OFFSETOF(hcl_t,_quote) },
|
{ 5, { 'q','u','o','t','e' }, HCL_SYNCODE_QUOTE, HCL_OFFSETOF(hcl_t,_quote) },
|
||||||
{ 3, { 's', 'e', 't' }, HCL_SYNCODE_SET, HCL_OFFSETOF(hcl_t,_set) }
|
{ 6, { 'r','e','t','u','r','n'}, HCL_SYNCODE_RETURN, HCL_OFFSETOF(hcl_t,_return) },
|
||||||
|
{ 3, { 's','e','t' }, HCL_SYNCODE_SET, HCL_OFFSETOF(hcl_t,_set) },
|
||||||
|
{ 5, { 'w','h','i','l','e' }, HCL_SYNCODE_WHILE, HCL_OFFSETOF(hcl_t,_while) }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
202
lib/hcl-prv.h
202
lib/hcl-prv.h
@ -540,148 +540,148 @@ enum hcl_bcode_t
|
|||||||
HCL_CODE_STORE_INTO_OBJECT_2 = 0x3A,
|
HCL_CODE_STORE_INTO_OBJECT_2 = 0x3A,
|
||||||
HCL_CODE_STORE_INTO_OBJECT_3 = 0x3B,
|
HCL_CODE_STORE_INTO_OBJECT_3 = 0x3B,
|
||||||
|
|
||||||
BCODE_POP_INTO_OBJECT_0 = 0x3C,
|
BCODE_POP_INTO_OBJECT_0 = 0x3C,
|
||||||
BCODE_POP_INTO_OBJECT_1 = 0x3D,
|
BCODE_POP_INTO_OBJECT_1 = 0x3D,
|
||||||
BCODE_POP_INTO_OBJECT_2 = 0x3E,
|
BCODE_POP_INTO_OBJECT_2 = 0x3E,
|
||||||
BCODE_POP_INTO_OBJECT_3 = 0x3F,
|
BCODE_POP_INTO_OBJECT_3 = 0x3F,
|
||||||
|
|
||||||
HCL_CODE_PUSH_OBJECT_0 = 0x40,
|
HCL_CODE_PUSH_OBJECT_0 = 0x40,
|
||||||
HCL_CODE_PUSH_OBJECT_1 = 0x41,
|
HCL_CODE_PUSH_OBJECT_1 = 0x41,
|
||||||
HCL_CODE_PUSH_OBJECT_2 = 0x42,
|
HCL_CODE_PUSH_OBJECT_2 = 0x42,
|
||||||
HCL_CODE_PUSH_OBJECT_3 = 0x43,
|
HCL_CODE_PUSH_OBJECT_3 = 0x43,
|
||||||
|
|
||||||
HCL_CODE_JUMP_FORWARD_0 = 0x44, /* 68 */
|
HCL_CODE_JUMP_FORWARD_0 = 0x44, /* 68 */
|
||||||
HCL_CODE_JUMP_FORWARD_1 = 0x45, /* 69 */
|
HCL_CODE_JUMP_FORWARD_1 = 0x45, /* 69 */
|
||||||
HCL_CODE_JUMP_FORWARD_2 = 0x46, /* 70 */
|
HCL_CODE_JUMP_FORWARD_2 = 0x46, /* 70 */
|
||||||
HCL_CODE_JUMP_FORWARD_3 = 0x47, /* 71 */
|
HCL_CODE_JUMP_FORWARD_3 = 0x47, /* 71 */
|
||||||
|
|
||||||
HCL_CODE_JUMP_BACKWARD_0 = 0x48,
|
HCL_CODE_JUMP_BACKWARD_0 = 0x48,
|
||||||
HCL_CODE_JUMP_BACKWARD_1 = 0x49,
|
HCL_CODE_JUMP_BACKWARD_1 = 0x49,
|
||||||
HCL_CODE_JUMP_BACKWARD_2 = 0x4A,
|
HCL_CODE_JUMP_BACKWARD_2 = 0x4A,
|
||||||
HCL_CODE_JUMP_BACKWARD_3 = 0x4B,
|
HCL_CODE_JUMP_BACKWARD_3 = 0x4B,
|
||||||
|
|
||||||
BCODE_JUMP_IF_TRUE_0 = 0x4C,
|
BCODE_JUMP_IF_TRUE_0 = 0x4C,
|
||||||
BCODE_JUMP_IF_TRUE_1 = 0x4D,
|
BCODE_JUMP_IF_TRUE_1 = 0x4D,
|
||||||
BCODE_JUMP_IF_TRUE_2 = 0x4E,
|
BCODE_JUMP_IF_TRUE_2 = 0x4E,
|
||||||
BCODE_JUMP_IF_TRUE_3 = 0x4F,
|
BCODE_JUMP_IF_TRUE_3 = 0x4F,
|
||||||
|
|
||||||
BCODE_JUMP_IF_FALSE_0 = 0x50, /* 80 */
|
HCL_CODE_JUMP_FORWARD_IF_FALSE_0 = 0x50, /* 80 */
|
||||||
BCODE_JUMP_IF_FALSE_1 = 0x51, /* 81 */
|
HCL_CODE_JUMP_FORWARD_IF_FALSE_1 = 0x51, /* 81 */
|
||||||
BCODE_JUMP_IF_FALSE_2 = 0x52, /* 82 */
|
HCL_CODE_JUMP_FORWARD_IF_FALSE_2 = 0x52, /* 82 */
|
||||||
BCODE_JUMP_IF_FALSE_3 = 0x53, /* 83 */
|
HCL_CODE_JUMP_FORWARD_IF_FALSE_3 = 0x53, /* 83 */
|
||||||
|
|
||||||
HCL_CODE_CALL_0 = 0x54, /* 84 */
|
HCL_CODE_CALL_0 = 0x54, /* 84 */
|
||||||
HCL_CODE_CALL_1 = 0x55, /* 85 */
|
HCL_CODE_CALL_1 = 0x55, /* 85 */
|
||||||
HCL_CODE_CALL_2 = 0x56, /* 86 */
|
HCL_CODE_CALL_2 = 0x56, /* 86 */
|
||||||
HCL_CODE_CALL_3 = 0x57, /* 87 */
|
HCL_CODE_CALL_3 = 0x57, /* 87 */
|
||||||
|
|
||||||
HCL_CODE_STORE_INTO_CTXTEMPVAR_0 = 0x58, /* 88 */
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_0 = 0x58, /* 88 */
|
||||||
HCL_CODE_STORE_INTO_CTXTEMPVAR_1 = 0x59, /* 89 */
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_1 = 0x59, /* 89 */
|
||||||
HCL_CODE_STORE_INTO_CTXTEMPVAR_2 = 0x5A, /* 90 */
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_2 = 0x5A, /* 90 */
|
||||||
HCL_CODE_STORE_INTO_CTXTEMPVAR_3 = 0x5B, /* 91 */
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_3 = 0x5B, /* 91 */
|
||||||
|
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_0 = 0x5C, /* 92 */
|
BCODE_POP_INTO_CTXTEMPVAR_0 = 0x5C, /* 92 */
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_1 = 0x5D, /* 93 */
|
BCODE_POP_INTO_CTXTEMPVAR_1 = 0x5D, /* 93 */
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_2 = 0x5E, /* 94 */
|
BCODE_POP_INTO_CTXTEMPVAR_2 = 0x5E, /* 94 */
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_3 = 0x5F, /* 95 */
|
BCODE_POP_INTO_CTXTEMPVAR_3 = 0x5F, /* 95 */
|
||||||
|
|
||||||
HCL_CODE_PUSH_CTXTEMPVAR_0 = 0x60, /* 96 */
|
HCL_CODE_PUSH_CTXTEMPVAR_0 = 0x60, /* 96 */
|
||||||
HCL_CODE_PUSH_CTXTEMPVAR_1 = 0x61, /* 97 */
|
HCL_CODE_PUSH_CTXTEMPVAR_1 = 0x61, /* 97 */
|
||||||
HCL_CODE_PUSH_CTXTEMPVAR_2 = 0x62, /* 98 */
|
HCL_CODE_PUSH_CTXTEMPVAR_2 = 0x62, /* 98 */
|
||||||
HCL_CODE_PUSH_CTXTEMPVAR_3 = 0x63, /* 99 */
|
HCL_CODE_PUSH_CTXTEMPVAR_3 = 0x63, /* 99 */
|
||||||
|
|
||||||
BCODE_PUSH_OBJVAR_0 = 0x64,
|
BCODE_PUSH_OBJVAR_0 = 0x64,
|
||||||
BCODE_PUSH_OBJVAR_1 = 0x65,
|
BCODE_PUSH_OBJVAR_1 = 0x65,
|
||||||
BCODE_PUSH_OBJVAR_2 = 0x66,
|
BCODE_PUSH_OBJVAR_2 = 0x66,
|
||||||
BCODE_PUSH_OBJVAR_3 = 0x67,
|
BCODE_PUSH_OBJVAR_3 = 0x67,
|
||||||
|
|
||||||
BCODE_STORE_INTO_OBJVAR_0 = 0x68,
|
BCODE_STORE_INTO_OBJVAR_0 = 0x68,
|
||||||
BCODE_STORE_INTO_OBJVAR_1 = 0x69,
|
BCODE_STORE_INTO_OBJVAR_1 = 0x69,
|
||||||
BCODE_STORE_INTO_OBJVAR_2 = 0x6A,
|
BCODE_STORE_INTO_OBJVAR_2 = 0x6A,
|
||||||
BCODE_STORE_INTO_OBJVAR_3 = 0x6B,
|
BCODE_STORE_INTO_OBJVAR_3 = 0x6B,
|
||||||
|
|
||||||
BCODE_POP_INTO_OBJVAR_0 = 0x6C,
|
BCODE_POP_INTO_OBJVAR_0 = 0x6C,
|
||||||
BCODE_POP_INTO_OBJVAR_1 = 0x6D,
|
BCODE_POP_INTO_OBJVAR_1 = 0x6D,
|
||||||
BCODE_POP_INTO_OBJVAR_2 = 0x6E,
|
BCODE_POP_INTO_OBJVAR_2 = 0x6E,
|
||||||
BCODE_POP_INTO_OBJVAR_3 = 0x6F,
|
BCODE_POP_INTO_OBJVAR_3 = 0x6F,
|
||||||
|
|
||||||
BCODE_SEND_MESSAGE_0 = 0x70,
|
BCODE_SEND_MESSAGE_0 = 0x70,
|
||||||
BCODE_SEND_MESSAGE_1 = 0x71,
|
BCODE_SEND_MESSAGE_1 = 0x71,
|
||||||
BCODE_SEND_MESSAGE_2 = 0x72,
|
BCODE_SEND_MESSAGE_2 = 0x72,
|
||||||
BCODE_SEND_MESSAGE_3 = 0x73,
|
BCODE_SEND_MESSAGE_3 = 0x73,
|
||||||
|
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_0 = 0x74,
|
BCODE_SEND_MESSAGE_TO_SUPER_0 = 0x74,
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_1 = 0x75,
|
BCODE_SEND_MESSAGE_TO_SUPER_1 = 0x75,
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_2 = 0x76,
|
BCODE_SEND_MESSAGE_TO_SUPER_2 = 0x76,
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_3 = 0x77,
|
BCODE_SEND_MESSAGE_TO_SUPER_3 = 0x77,
|
||||||
|
|
||||||
/* UNUSED 0x78 - 0x7F */
|
/* UNUSED 0x78 - 0x7F */
|
||||||
|
|
||||||
BCODE_STORE_INTO_INSTVAR_X = 0x80, /* 128 */
|
BCODE_STORE_INTO_INSTVAR_X = 0x80, /* 128 */
|
||||||
BCODE_POP_INTO_INSTVAR_X = 0x88, /* 136 */
|
BCODE_POP_INTO_INSTVAR_X = 0x88, /* 136 */
|
||||||
BCODE_PUSH_INSTVAR_X = 0x90, /* 144 */
|
BCODE_PUSH_INSTVAR_X = 0x90, /* 144 */
|
||||||
|
|
||||||
HCL_CODE_PUSH_TEMPVAR_X = 0x98, /* 152 */
|
HCL_CODE_PUSH_TEMPVAR_X = 0x98, /* 152 */
|
||||||
HCL_CODE_STORE_INTO_TEMPVAR_X = 0xA0, /* 160 */
|
HCL_CODE_STORE_INTO_TEMPVAR_X = 0xA0, /* 160 */
|
||||||
BCODE_POP_INTO_TEMPVAR_X = 0xA8, /* 168 */
|
BCODE_POP_INTO_TEMPVAR_X = 0xA8, /* 168 */
|
||||||
|
|
||||||
HCL_CODE_PUSH_LITERAL_X = 0xB0, /* 176 */
|
HCL_CODE_PUSH_LITERAL_X = 0xB0, /* 176 */
|
||||||
HCL_CODE_PUSH_LITERAL_X2 = 0xB1, /* 177 */
|
HCL_CODE_PUSH_LITERAL_X2 = 0xB1, /* 177 */
|
||||||
|
|
||||||
/* SEE FURTHER DOWN FOR SPECIAL CODES - 0xB2 - 0xB7 */
|
/* SEE FURTHER DOWN FOR SPECIAL CODES - 0xB2 - 0xB7 */
|
||||||
|
|
||||||
HCL_CODE_STORE_INTO_OBJECT_X = 0xB8, /* 184 */
|
HCL_CODE_STORE_INTO_OBJECT_X = 0xB8, /* 184 */
|
||||||
BCODE_POP_INTO_OBJECT_X = 0xBC, /* 188 */
|
BCODE_POP_INTO_OBJECT_X = 0xBC, /* 188 */
|
||||||
HCL_CODE_PUSH_OBJECT_X = 0xC0, /* 192 */
|
HCL_CODE_PUSH_OBJECT_X = 0xC0, /* 192 */
|
||||||
|
|
||||||
HCL_CODE_JUMP_FORWARD_X = 0xC4, /* 196 */
|
HCL_CODE_JUMP_FORWARD_X = 0xC4, /* 196 */
|
||||||
HCL_CODE_JUMP_BACKWARD_X = 0xC8, /* 200 */
|
HCL_CODE_JUMP_BACKWARD_X = 0xC8, /* 200 */
|
||||||
BCODE_JUMP_IF_TRUE_X = 0xCC, /* 204 */
|
BCODE_JUMP_IF_TRUE_X = 0xCC, /* 204 */
|
||||||
BCODE_JUMP_IF_FALSE_X = 0xD0, /* 208 */
|
HCL_CODE_JUMP_FORWARD_IF_FALSE_X = 0xD0, /* 208 */
|
||||||
|
|
||||||
HCL_CODE_CALL_X = 0xD4, /* 212 */
|
HCL_CODE_CALL_X = 0xD4, /* 212 */
|
||||||
|
|
||||||
HCL_CODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 */
|
HCL_CODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 */
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 */
|
BCODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 */
|
||||||
HCL_CODE_PUSH_CTXTEMPVAR_X = 0xE0, /* 224 */
|
HCL_CODE_PUSH_CTXTEMPVAR_X = 0xE0, /* 224 */
|
||||||
|
|
||||||
BCODE_PUSH_OBJVAR_X = 0xE4, /* 228 */
|
BCODE_PUSH_OBJVAR_X = 0xE4, /* 228 */
|
||||||
BCODE_STORE_INTO_OBJVAR_X = 0xE8, /* 232 */
|
BCODE_STORE_INTO_OBJVAR_X = 0xE8, /* 232 */
|
||||||
BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 */
|
BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 */
|
||||||
|
|
||||||
BCODE_SEND_MESSAGE_X = 0xF0, /* 240 */
|
BCODE_SEND_MESSAGE_X = 0xF0, /* 240 */
|
||||||
BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 */
|
BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 */
|
||||||
|
|
||||||
/* -------------------------------------- */
|
/* -------------------------------------- */
|
||||||
|
|
||||||
HCL_CODE_JUMP2_FORWARD = 0xC5, /* 197 */
|
HCL_CODE_JUMP2_FORWARD = 0xC5, /* 197 */
|
||||||
HCL_CODE_JUMP2_BACKWARD = 0xC9, /* 201 */
|
HCL_CODE_JUMP2_BACKWARD = 0xC9, /* 201 */
|
||||||
|
|
||||||
BCODE_PUSH_RECEIVER = 0x81, /* 129 */
|
BCODE_PUSH_RECEIVER = 0x81, /* 129 */
|
||||||
HCL_CODE_PUSH_NIL = 0x82, /* 130 */
|
HCL_CODE_PUSH_NIL = 0x82, /* 130 */
|
||||||
HCL_CODE_PUSH_TRUE = 0x83, /* 131 */
|
HCL_CODE_PUSH_TRUE = 0x83, /* 131 */
|
||||||
HCL_CODE_PUSH_FALSE = 0x84, /* 132 */
|
HCL_CODE_PUSH_FALSE = 0x84, /* 132 */
|
||||||
BCODE_PUSH_CONTEXT = 0x85, /* 133 */
|
BCODE_PUSH_CONTEXT = 0x85, /* 133 */
|
||||||
BCODE_PUSH_PROCESS = 0x86, /* 134 */
|
BCODE_PUSH_PROCESS = 0x86, /* 134 */
|
||||||
HCL_CODE_PUSH_NEGONE = 0x87, /* 135 */
|
HCL_CODE_PUSH_NEGONE = 0x87, /* 135 */
|
||||||
HCL_CODE_PUSH_ZERO = 0x89, /* 137 */
|
HCL_CODE_PUSH_ZERO = 0x89, /* 137 */
|
||||||
HCL_CODE_PUSH_ONE = 0x8A, /* 138 */
|
HCL_CODE_PUSH_ONE = 0x8A, /* 138 */
|
||||||
HCL_CODE_PUSH_TWO = 0x8B, /* 139 */
|
HCL_CODE_PUSH_TWO = 0x8B, /* 139 */
|
||||||
|
|
||||||
HCL_CODE_PUSH_INTLIT = 0xB2, /* 178 */
|
HCL_CODE_PUSH_INTLIT = 0xB2, /* 178 */
|
||||||
HCL_CODE_PUSH_NEGINTLIT = 0xB3, /* 179 */
|
HCL_CODE_PUSH_NEGINTLIT = 0xB3, /* 179 */
|
||||||
HCL_CODE_PUSH_CHARLIT = 0xB4, /* 180 */
|
HCL_CODE_PUSH_CHARLIT = 0xB4, /* 180 */
|
||||||
|
|
||||||
/* UNUSED 0xE8 - 0xF7 */
|
/* UNUSED 0xE8 - 0xF7 */
|
||||||
|
|
||||||
BCODE_DUP_STACKTOP = 0xF8,
|
BCODE_DUP_STACKTOP = 0xF8,
|
||||||
HCL_CODE_POP_STACKTOP = 0xF9,
|
HCL_CODE_POP_STACKTOP = 0xF9,
|
||||||
BCODE_RETURN_STACKTOP = 0xFA, /* ^something */
|
BCODE_RETURN_STACKTOP = 0xFA, /* ^something */
|
||||||
BCODE_RETURN_RECEIVER = 0xFB, /* ^self */
|
BCODE_RETURN_RECEIVER = 0xFB, /* ^self */
|
||||||
HCL_CODE_RETURN_FROM_BLOCK = 0xFC, /* return the stack top from a block */
|
HCL_CODE_RETURN_FROM_BLOCK = 0xFC, /* return the stack top from a block */
|
||||||
HCL_CODE_MAKE_BLOCK = 0xFD,
|
HCL_CODE_MAKE_BLOCK = 0xFD,
|
||||||
BCODE_SEND_BLOCK_COPY = 0xFE,
|
BCODE_SEND_BLOCK_COPY = 0xFE,
|
||||||
HCL_CODE_NOOP = 0xFF
|
HCL_CODE_NOOP = 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
@ -837,7 +837,9 @@ struct hcl_t
|
|||||||
hcl_oop_t _if; /* symbol */
|
hcl_oop_t _if; /* symbol */
|
||||||
hcl_oop_t _lambda; /* symbol */
|
hcl_oop_t _lambda; /* symbol */
|
||||||
hcl_oop_t _quote; /* symbol */
|
hcl_oop_t _quote; /* symbol */
|
||||||
|
hcl_oop_t _return; /* symbol */
|
||||||
hcl_oop_t _set; /* symbol */
|
hcl_oop_t _set; /* symbol */
|
||||||
|
hcl_oop_t _while; /* symbol */
|
||||||
|
|
||||||
/* == NEVER CHANGE THE ORDER OF FIELDS BELOW == */
|
/* == NEVER CHANGE THE ORDER OF FIELDS BELOW == */
|
||||||
/* hcl_ignite() assumes this order. make sure to update symnames in ignite_3() */
|
/* hcl_ignite() assumes this order. make sure to update symnames in ignite_3() */
|
||||||
@ -1022,7 +1024,9 @@ enum
|
|||||||
HCL_SYNCODE_IF,
|
HCL_SYNCODE_IF,
|
||||||
HCL_SYNCODE_LAMBDA,
|
HCL_SYNCODE_LAMBDA,
|
||||||
HCL_SYNCODE_QUOTE,
|
HCL_SYNCODE_QUOTE,
|
||||||
HCL_SYNCODE_SET
|
HCL_SYNCODE_RETURN,
|
||||||
|
HCL_SYNCODE_SET,
|
||||||
|
HCL_SYNCODE_WHILE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hcl_cons_t
|
struct hcl_cons_t
|
||||||
|
Loading…
Reference in New Issue
Block a user