mirror of https://github.com/rusefi/bldc.git
Squashed 'lispBM/lispBM/' changes from ac1d06ab..f7c74492
f7c74492 tweak lbm_is_closure 072e2063 bug fixes realted to move-to-flash git-subtree-dir: lispBM/lispBM git-subtree-split: f7c74492b8413b5d55b45f85e0e6cce3b16e35a2
This commit is contained in:
parent
5a9ec0efd6
commit
d012c202a1
|
@ -801,6 +801,12 @@ static inline bool lbm_is_closure(lbm_value exp) {
|
|||
(lbm_dec_sym(lbm_car(exp)) == SYM_CLOSURE));
|
||||
}
|
||||
|
||||
static inline bool lbm_is_closure_general(lbm_value exp) {
|
||||
return ((lbm_is_cons_general(exp)) &&
|
||||
(lbm_type_of(lbm_car(exp)) == LBM_TYPE_SYMBOL) &&
|
||||
(lbm_dec_sym(lbm_car(exp)) == SYM_CLOSURE));
|
||||
}
|
||||
|
||||
static inline bool lbm_is_continuation(lbm_value exp) {
|
||||
return ((lbm_type_of(exp) == LBM_TYPE_CONS) &&
|
||||
(lbm_type_of(lbm_car(exp)) == LBM_TYPE_SYMBOL) &&
|
||||
|
|
|
@ -1826,12 +1826,12 @@ static void apply_spawn_base(lbm_value *args, lbm_uint nargs, eval_context_t *ct
|
|||
|
||||
if (nargs >= 2 &&
|
||||
lbm_is_number(args[0]) &&
|
||||
lbm_is_closure(args[1])) {
|
||||
lbm_is_closure_general(args[1])) {
|
||||
stack_size = lbm_dec_as_u32(args[0]);
|
||||
closure_pos = 1;
|
||||
}
|
||||
|
||||
if (!lbm_is_closure(args[closure_pos]) ||
|
||||
if (!lbm_is_closure_general(args[closure_pos]) ||
|
||||
nargs < 1) {
|
||||
error_ctx(ENC_SYM_EERROR);
|
||||
return;
|
||||
|
@ -3385,7 +3385,7 @@ static lbm_value request_flash_storage_cell(lbm_value val) {
|
|||
new_val &= ~LBM_PTR_VAL_MASK; // clear the value part of the ptr
|
||||
new_val |= (flash_cell & LBM_PTR_VAL_MASK);
|
||||
new_val |= LBM_PTR_TO_CONSTANT_BIT;
|
||||
return flash_cell;
|
||||
return new_val;
|
||||
}
|
||||
|
||||
static void cont_move_to_flash(eval_context_t *ctx) {
|
||||
|
@ -3523,6 +3523,7 @@ static void cont_move_val_to_flash_dispatch(eval_context_t *ctx) {
|
|||
}
|
||||
ctx->r = flash_cell;
|
||||
ctx->app_cont = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->r = val;
|
||||
|
|
|
@ -930,23 +930,22 @@ static lbm_value fundamental_append(lbm_value *args, lbm_uint nargs, eval_contex
|
|||
(void) ctx;
|
||||
if (nargs == 0) return ENC_SYM_NIL;
|
||||
if (nargs == 1 && !lbm_is_list_general(args[0])) return ENC_SYM_TERROR;
|
||||
if (nargs > 0) {
|
||||
lbm_value res = args[nargs-1];
|
||||
for (int i = (int)nargs -2; i >= 0; i --) {
|
||||
lbm_value curr = args[i];
|
||||
if (!lbm_is_list_general(curr)) return ENC_SYM_TERROR;
|
||||
int n = 0;
|
||||
while (lbm_type_of(curr) == LBM_TYPE_CONS) {
|
||||
n++;
|
||||
curr = lbm_cdr(curr);
|
||||
}
|
||||
curr = args[i];
|
||||
for (int j = n-1; j >= 0; j --) {
|
||||
res = lbm_cons(index_list(curr,j),res);
|
||||
}
|
||||
|
||||
lbm_value res = args[nargs-1];
|
||||
for (int i = (int)nargs -2; i >= 0; i --) {
|
||||
lbm_value curr = args[i];
|
||||
if (!lbm_is_list_general(curr)) return ENC_SYM_TERROR;
|
||||
int n = 0;
|
||||
while (lbm_type_of(curr) == LBM_TYPE_CONS) {
|
||||
n++;
|
||||
curr = lbm_cdr(curr);
|
||||
}
|
||||
curr = args[i];
|
||||
for (int j = n-1; j >= 0; j --) {
|
||||
res = lbm_cons(index_list(curr,j),res);
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
|
||||
static lbm_value fundamental_undefine(lbm_value *args, lbm_uint nargs, eval_context_t *ctx) {
|
||||
|
|
|
@ -389,7 +389,7 @@ int lbm_print_internal(lbm_char_channel_t *chan, lbm_value v) {
|
|||
case LBM_TYPE_CONS: {
|
||||
int res = lbm_push_2(&print_stack, curr, START_LIST);
|
||||
if (!res) {
|
||||
r = print_emit_string(chan,"Error: Out of print stack\n");
|
||||
print_emit_string(chan," ...");
|
||||
return EMIT_OK;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue