mirror of https://github.com/rusefi/bldc.git
Squashed 'lispBM/lispBM/' changes from ffbedbdf..ced143b0
ced143b0 set! 3e054ca0 troubleshooting segfaults, heap was freed (on C side before evaluation thread finished running GC git-subtree-dir: lispBM/lispBM git-subtree-split: ced143b0f6bb2cdc2e7a1c7575055a5fb8e0fab6
This commit is contained in:
parent
3a3ab9dae1
commit
e9e8db8597
|
@ -53,6 +53,7 @@
|
||||||
#define SYM_MACRO_EXPAND 0x10
|
#define SYM_MACRO_EXPAND 0x10
|
||||||
#define SYM_CALLCC 0x11
|
#define SYM_CALLCC 0x11
|
||||||
#define SYM_CONT 0x12
|
#define SYM_CONT 0x12
|
||||||
|
#define SYM_SETVAR 0x13
|
||||||
|
|
||||||
|
|
||||||
// 0x20 - 0x2F are errors
|
// 0x20 - 0x2F are errors
|
||||||
|
@ -64,14 +65,14 @@
|
||||||
#define SYM_DIVZERO 0x25
|
#define SYM_DIVZERO 0x25
|
||||||
#define SYM_FATAL_ERROR 0x26 /* Runtime system is corrupt */
|
#define SYM_FATAL_ERROR 0x26 /* Runtime system is corrupt */
|
||||||
#define SYM_STACK_ERROR 0x27
|
#define SYM_STACK_ERROR 0x27
|
||||||
|
#define SYM_RECOVERED 0x28
|
||||||
|
|
||||||
|
|
||||||
#define SYM_ARRAY_TYPE 0x30
|
#define SYM_ARRAY_TYPE 0x30
|
||||||
#define SYM_BOXED_I_TYPE 0x31
|
#define SYM_BOXED_I_TYPE 0x31
|
||||||
#define SYM_BOXED_U_TYPE 0x32
|
#define SYM_BOXED_U_TYPE 0x32
|
||||||
#define SYM_BOXED_F_TYPE 0x33
|
#define SYM_BOXED_F_TYPE 0x33
|
||||||
#define SYM_REF_TYPE 0x34
|
#define SYM_STREAM_TYPE 0x34
|
||||||
#define SYM_RECOVERED 0x36
|
|
||||||
#define SYM_BYTECODE_TYPE 0x37
|
#define SYM_BYTECODE_TYPE 0x37
|
||||||
#define SYM_NONSENSE 0x38
|
#define SYM_NONSENSE 0x38
|
||||||
|
|
||||||
|
@ -170,8 +171,6 @@
|
||||||
#define SYM_BITWISE_XOR 0x174
|
#define SYM_BITWISE_XOR 0x174
|
||||||
#define SYM_BITWISE_NOT 0x175
|
#define SYM_BITWISE_NOT 0x175
|
||||||
|
|
||||||
#define SYM_SETVAR 0x180
|
|
||||||
|
|
||||||
#define SYM_TYPE_OF 0x200
|
#define SYM_TYPE_OF 0x200
|
||||||
#define FUNDAMENTALS_END 0x200
|
#define FUNDAMENTALS_END 0x200
|
||||||
|
|
||||||
|
|
|
@ -34,83 +34,161 @@
|
||||||
- exec(open('gen_codes.py').read())
|
- exec(open('gen_codes.py').read())
|
||||||
- print(make_c())
|
- print(make_c())
|
||||||
*/
|
*/
|
||||||
|
//Total number of bits 433
|
||||||
|
|
||||||
#define NUM_CODES 69
|
#define NUM_CODES 70
|
||||||
#define MAX_KEY_LENGTH 6
|
#define MAX_KEY_LENGTH 6
|
||||||
#define MAX_CODE_LENGTH 10
|
#define MAX_CODE_LENGTH 7
|
||||||
char *codes[NUM_CODES][2] = {
|
char *codes[NUM_CODES][2] = {
|
||||||
{ "nil", "0011001110" },
|
{ "9", "101001" },
|
||||||
{ "cdr", "0011001111" },
|
{ "8", "110100" },
|
||||||
{ "car", "001100000" },
|
{ "7", "100110" },
|
||||||
{ "cons", "001100001" },
|
{ "6", "100000" },
|
||||||
{ "let", "001100010" },
|
{ "5", "100111" },
|
||||||
{ "define", "001100011" },
|
{ "4", "100010" },
|
||||||
{ "progn", "001100100" },
|
{ "3", "111000" },
|
||||||
{ "quote", "0011001010" },
|
{ "2", "110000" },
|
||||||
{ "list", "0011001011" },
|
{ "1", "101100" },
|
||||||
{ "if", "0011001100" },
|
{ "0", "101101" },
|
||||||
{ "lambda", "0011001101" },
|
{ "_", "000011" },
|
||||||
{ "((", "1101" },
|
{ ",@", "000000" },
|
||||||
{ "))", "1110" },
|
{ ",", "000001" },
|
||||||
{ ")", "000" },
|
{ "`", "1111010" },
|
||||||
{ "(", "1111" },
|
{ " ", "1111011" },
|
||||||
{ "?", "101010" },
|
{ "'", "1110010" },
|
||||||
{ "z", "011000" },
|
{ "\\", "1110011" },
|
||||||
{ "y", "101100" },
|
{ "\"", "1110110" },
|
||||||
{ "x", "101011" },
|
{ "#", "1110111" },
|
||||||
{ "w", "101001" },
|
{ ".", "000010" },
|
||||||
{ "v", "100000" },
|
{ ">", "1110101" },
|
||||||
{ "u", "011111" },
|
{ "<", "1111100" },
|
||||||
{ "t", "110001" },
|
{ "=", "1111101" },
|
||||||
{ "s", "010110" },
|
{ "/", "1111110" },
|
||||||
{ "r", "110011" },
|
{ "*", "1111111" },
|
||||||
{ "q", "100100" },
|
{ "-", "1111000" },
|
||||||
{ "p", "100001" },
|
{ "+", "1111001" },
|
||||||
{ "o", "110000" },
|
{ "nil", "110001" },
|
||||||
{ "n", "101111" },
|
{ "cdr", "101010" },
|
||||||
{ "m", "00100" },
|
{ "car", "101011" },
|
||||||
{ "l", "101110" },
|
{ "cons", "101110" },
|
||||||
{ "k", "00101" },
|
{ "let", "101111" },
|
||||||
{ "j", "100010" },
|
{ "define", "110010" },
|
||||||
{ "i", "011010" },
|
{ "progn", "110011" },
|
||||||
{ "h", "100110" },
|
{ "quote", "101000" },
|
||||||
{ "g", "010111" },
|
{ "list", "100101" },
|
||||||
{ "f", "011011" },
|
{ "if", "100100" },
|
||||||
{ "e", "100101" },
|
{ "lambda", "100001" },
|
||||||
{ "d", "101101" },
|
{ "((", "110101" },
|
||||||
{ "c", "011110" },
|
{ "))", "100011" },
|
||||||
{ "b", "101000" },
|
{ ")", "110110" },
|
||||||
{ "a", "011001" },
|
{ "(", "110111" },
|
||||||
{ "9", "1000110" },
|
{ "?", "001011" },
|
||||||
{ "8", "1000111" },
|
{ "!", "011100" },
|
||||||
{ "7", "1100100" },
|
{ "z", "000111" },
|
||||||
{ "6", "1100101" },
|
{ "y", "001000" },
|
||||||
{ "5", "1001110" },
|
{ "x", "011000" },
|
||||||
{ "4", "1001111" },
|
{ "w", "011001" },
|
||||||
{ "3", "0111010" },
|
{ "v", "010000" },
|
||||||
{ "2", "0111011" },
|
{ "u", "011110" },
|
||||||
{ "1", "0111000" },
|
{ "t", "000100" },
|
||||||
{ "0", "0111001" },
|
{ "s", "000101" },
|
||||||
{ "_", "0101001" },
|
{ "r", "010100" },
|
||||||
{ ",@", "0101000" },
|
{ "q", "010101" },
|
||||||
{ ",", "0011010" },
|
{ "p", "011011" },
|
||||||
{ "`", "0100011" },
|
{ "o", "001100" },
|
||||||
{ " ", "0011100" },
|
{ "n", "010111" },
|
||||||
{ "'", "0100100" },
|
{ "m", "000110" },
|
||||||
{ "\\", "0100101" },
|
{ "l", "001001" },
|
||||||
{ "\"", "0011111" },
|
{ "k", "001111" },
|
||||||
{ "#", "0100111" },
|
{ "j", "011111" },
|
||||||
{ ".", "0100110" },
|
{ "i", "010010" },
|
||||||
{ ">", "0011011" },
|
{ "h", "011010" },
|
||||||
{ "<", "0011101" },
|
{ "g", "001101" },
|
||||||
{ "=", "0011110" },
|
{ "f", "011101" },
|
||||||
{ "/", "0101011" },
|
{ "e", "001110" },
|
||||||
{ "*", "0100000" },
|
{ "d", "010011" },
|
||||||
{ "-", "0101010" },
|
{ "c", "010110" },
|
||||||
{ "+", "0100010" }
|
{ "b", "010001" },
|
||||||
|
{ "a", "001010" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* #define NUM_CODES 69 */
|
||||||
|
/* #define MAX_KEY_LENGTH 6 */
|
||||||
|
/* #define MAX_CODE_LENGTH 10 */
|
||||||
|
/* char *codes[NUM_CODES][2] = { */
|
||||||
|
/* { "nil", "0011001110" }, */
|
||||||
|
/* { "cdr", "0011001111" }, */
|
||||||
|
/* { "car", "001100000" }, */
|
||||||
|
/* { "cons", "001100001" }, */
|
||||||
|
/* { "let", "001100010" }, */
|
||||||
|
/* { "define", "001100011" }, */
|
||||||
|
/* { "progn", "001100100" }, */
|
||||||
|
/* { "quote", "0011001010" }, */
|
||||||
|
/* { "list", "0011001011" }, */
|
||||||
|
/* { "if", "0011001100" }, */
|
||||||
|
/* { "lambda", "0011001101" }, */
|
||||||
|
/* { "((", "1101" }, */
|
||||||
|
/* { "))", "1110" }, */
|
||||||
|
/* { ")", "000" }, */
|
||||||
|
/* { "(", "1111" }, */
|
||||||
|
/* { "?", "101010" }, */
|
||||||
|
/* { "z", "011000" }, */
|
||||||
|
/* { "y", "101100" }, */
|
||||||
|
/* { "x", "101011" }, */
|
||||||
|
/* { "w", "101001" }, */
|
||||||
|
/* { "v", "100000" }, */
|
||||||
|
/* { "u", "011111" }, */
|
||||||
|
/* { "t", "110001" }, */
|
||||||
|
/* { "s", "010110" }, */
|
||||||
|
/* { "r", "110011" }, */
|
||||||
|
/* { "q", "100100" }, */
|
||||||
|
/* { "p", "100001" }, */
|
||||||
|
/* { "o", "110000" }, */
|
||||||
|
/* { "n", "101111" }, */
|
||||||
|
/* { "m", "00100" }, */
|
||||||
|
/* { "l", "101110" }, */
|
||||||
|
/* { "k", "00101" }, */
|
||||||
|
/* { "j", "100010" }, */
|
||||||
|
/* { "i", "011010" }, */
|
||||||
|
/* { "h", "100110" }, */
|
||||||
|
/* { "g", "010111" }, */
|
||||||
|
/* { "f", "011011" }, */
|
||||||
|
/* { "e", "100101" }, */
|
||||||
|
/* { "d", "101101" }, */
|
||||||
|
/* { "c", "011110" }, */
|
||||||
|
/* { "b", "101000" }, */
|
||||||
|
/* { "a", "011001" }, */
|
||||||
|
/* { "9", "1000110" }, */
|
||||||
|
/* { "8", "1000111" }, */
|
||||||
|
/* { "7", "1100100" }, */
|
||||||
|
/* { "6", "1100101" }, */
|
||||||
|
/* { "5", "1001110" }, */
|
||||||
|
/* { "4", "1001111" }, */
|
||||||
|
/* { "3", "0111010" }, */
|
||||||
|
/* { "2", "0111011" }, */
|
||||||
|
/* { "1", "0111000" }, */
|
||||||
|
/* { "0", "0111001" }, */
|
||||||
|
/* { "_", "0101001" }, */
|
||||||
|
/* { ",@", "0101000" }, */
|
||||||
|
/* { ",", "0011010" }, */
|
||||||
|
/* { "`", "0100011" }, */
|
||||||
|
/* { " ", "0011100" }, */
|
||||||
|
/* { "'", "0100100" }, */
|
||||||
|
/* { "\\", "0100101" }, */
|
||||||
|
/* { "\"", "0011111" }, */
|
||||||
|
/* { "#", "0100111" }, */
|
||||||
|
/* { ".", "0100110" }, */
|
||||||
|
/* { ">", "0011011" }, */
|
||||||
|
/* { "<", "0011101" }, */
|
||||||
|
/* { "=", "0011110" }, */
|
||||||
|
/* { "/", "0101011" }, */
|
||||||
|
/* { "*", "0100000" }, */
|
||||||
|
/* { "-", "0101010" }, */
|
||||||
|
/* { "+", "0100010" } */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
|
|
||||||
int match_longest_key(char *string) {
|
int match_longest_key(char *string) {
|
||||||
|
|
||||||
int longest_match_ix = -1;
|
int longest_match_ix = -1;
|
||||||
|
|
|
@ -585,6 +585,7 @@ static void finish_ctx(void) {
|
||||||
|
|
||||||
lbm_memory_free((uint32_t*)ctx_running);
|
lbm_memory_free((uint32_t*)ctx_running);
|
||||||
ctx_running = NULL;
|
ctx_running = NULL;
|
||||||
|
gc(NIL,NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void context_exists(eval_context_t *ctx, void *cid, void *b) {
|
static void context_exists(eval_context_t *ctx, void *cid, void *b) {
|
||||||
|
@ -1575,6 +1576,32 @@ static inline void cont_application(eval_context_t *ctx) {
|
||||||
lbm_uint dfun = lbm_dec_sym(fun);
|
lbm_uint dfun = lbm_dec_sym(fun);
|
||||||
|
|
||||||
switch(dfun) {
|
switch(dfun) {
|
||||||
|
case SYM_SETVAR: {
|
||||||
|
if (lbm_dec_u(count) == 2 && lbm_is_symbol(fun_args[1])) {
|
||||||
|
lbm_uint s = lbm_dec_sym(fun_args[1]);
|
||||||
|
if (s >= VARIABLE_SYMBOLS_START &&
|
||||||
|
s < VARIABLE_SYMBOLS_END) {
|
||||||
|
ctx->r = lbm_set_var(s, fun_args[2]);
|
||||||
|
} else {
|
||||||
|
lbm_value new_env = lbm_env_modify_binding(ctx->curr_env, fun_args[1], fun_args[2]);
|
||||||
|
if (lbm_type_of(new_env) == LBM_VAL_TYPE_SYMBOL &&
|
||||||
|
lbm_dec_sym(new_env) == SYM_NOT_FOUND) {
|
||||||
|
new_env = lbm_env_modify_binding(lbm_get_env(), fun_args[1], fun_args[2]);
|
||||||
|
}
|
||||||
|
if (lbm_type_of(new_env) == LBM_VAL_TYPE_SYMBOL &&
|
||||||
|
lbm_dec_sym(new_env) == SYM_NOT_FOUND) {
|
||||||
|
ctx->r = NIL;
|
||||||
|
} else {
|
||||||
|
ctx->r = fun_args[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error_ctx(lbm_enc_sym(SYM_EERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lbm_stack_drop(&ctx->K, lbm_dec_u(count)+1);
|
||||||
|
ctx->app_cont = true;
|
||||||
|
} break;
|
||||||
case SYM_READ: /* fall through */
|
case SYM_READ: /* fall through */
|
||||||
case SYM_READ_PROGRAM:
|
case SYM_READ_PROGRAM:
|
||||||
if (lbm_dec_u(count) == 1) {
|
if (lbm_dec_u(count) == 1) {
|
||||||
|
@ -1689,7 +1716,7 @@ static inline void cont_application(eval_context_t *ctx) {
|
||||||
lbm_value status = lbm_enc_sym(SYM_EERROR);
|
lbm_value status = lbm_enc_sym(SYM_EERROR);
|
||||||
if (lbm_dec_u(count) == 2) {
|
if (lbm_dec_u(count) == 2) {
|
||||||
|
|
||||||
if (lbm_type_of(fun_args[1]) == LBM_VAL_TYPE_U) { /* CID is of U type */
|
if (lbm_type_of(fun_args[1]) == LBM_VAL_TYPE_I) { /* CID is of U type */
|
||||||
lbm_cid cid = (lbm_cid)lbm_dec_i(fun_args[1]);
|
lbm_cid cid = (lbm_cid)lbm_dec_i(fun_args[1]);
|
||||||
lbm_value msg = fun_args[2];
|
lbm_value msg = fun_args[2];
|
||||||
|
|
||||||
|
|
|
@ -581,17 +581,17 @@ lbm_value lbm_fundamental(lbm_value* args, lbm_uint nargs, lbm_value op) {
|
||||||
int cmp_res = -1;
|
int cmp_res = -1;
|
||||||
|
|
||||||
switch (lbm_dec_sym(op)) {
|
switch (lbm_dec_sym(op)) {
|
||||||
case SYM_SETVAR:
|
/* case SYM_SETVAR: */
|
||||||
if (nargs == 2 && lbm_is_symbol(args[0])) {
|
/* if (nargs == 2 && lbm_is_symbol(args[0])) { */
|
||||||
lbm_uint s = lbm_dec_sym(args[0]);
|
/* lbm_uint s = lbm_dec_sym(args[0]); */
|
||||||
if (s >= VARIABLE_SYMBOLS_START &&
|
/* if (s >= VARIABLE_SYMBOLS_START && */
|
||||||
s < VARIABLE_SYMBOLS_END) {
|
/* s < VARIABLE_SYMBOLS_END) { */
|
||||||
result = lbm_set_var(s, args[1]);
|
/* result = lbm_set_var(s, args[1]); */
|
||||||
} else {
|
/* } else { */
|
||||||
*lbm_get_env_ptr() = lbm_env_set(lbm_get_env(), args[0], args[1]);
|
/* *lbm_get_env_ptr() = lbm_env_set(lbm_get_env(), args[0], args[1]); */
|
||||||
result = args[1];
|
/* result = args[1]; */
|
||||||
}
|
/* } */
|
||||||
} break;
|
/* } break; */
|
||||||
case SYM_IX:
|
case SYM_IX:
|
||||||
if (nargs == 2 && lbm_is_number(args[0])) {
|
if (nargs == 2 && lbm_is_number(args[0])) {
|
||||||
result = index_list(args[1], lbm_dec_as_u(args[0]));
|
result = index_list(args[1], lbm_dec_as_u(args[0]));
|
||||||
|
|
34
src/heap.c
34
src/heap.c
|
@ -424,11 +424,11 @@ int lbm_gc_mark_freelist() {
|
||||||
|
|
||||||
curr = fl;
|
curr = fl;
|
||||||
while (lbm_is_ptr(curr)){
|
while (lbm_is_ptr(curr)){
|
||||||
t = ref_cell(curr);
|
t = ref_cell(curr);
|
||||||
set_gc_mark(t);
|
set_gc_mark(t);
|
||||||
curr = read_cdr(t);
|
curr = lbm_cdr(curr);
|
||||||
|
|
||||||
heap_state.gc_marked ++;
|
heap_state.gc_marked ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -471,14 +471,26 @@ int lbm_gc_sweep_phase(void) {
|
||||||
|
|
||||||
// Check if this cell is a pointer to an array
|
// Check if this cell is a pointer to an array
|
||||||
// and free it.
|
// and free it.
|
||||||
if (lbm_type_of(heap[i].cdr) == LBM_VAL_TYPE_SYMBOL &&
|
if (lbm_type_of(heap[i].cdr) == LBM_VAL_TYPE_SYMBOL) {
|
||||||
lbm_dec_sym(heap[i].cdr) == SYM_ARRAY_TYPE) {
|
switch(lbm_dec_sym(heap[i].cdr)) {
|
||||||
lbm_array_header_t *arr = (lbm_array_header_t*)heap[i].car;
|
|
||||||
if (lbm_memory_ptr_inside((uint32_t*)arr->data)) {
|
case SYM_ARRAY_TYPE:{
|
||||||
lbm_memory_free((uint32_t *)arr->data);
|
lbm_array_header_t *arr = (lbm_array_header_t*)heap[i].car;
|
||||||
heap_state.gc_recovered_arrays++;
|
if (lbm_memory_ptr_inside((uint32_t*)arr->data)) {
|
||||||
|
lbm_memory_free((uint32_t *)arr->data);
|
||||||
|
heap_state.gc_recovered_arrays++;
|
||||||
|
}
|
||||||
|
lbm_memory_free((uint32_t *)arr);
|
||||||
|
} break;
|
||||||
|
case SYM_STREAM_TYPE:{
|
||||||
|
lbm_stream_t *stream = (lbm_stream_t*)heap[i].car;
|
||||||
|
if (lbm_memory_ptr_inside((uint32_t*)stream)) {
|
||||||
|
lbm_memory_free((uint32_t*)stream);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
lbm_memory_free((uint32_t *)arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create pointer to use as new freelist
|
// create pointer to use as new freelist
|
||||||
|
|
|
@ -39,7 +39,7 @@ lbm_value lbm_stream_put(lbm_stream_t *str, lbm_value v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lbm_value lbm_stream_create(lbm_stream_t *str) {
|
lbm_value lbm_stream_create(lbm_stream_t *str) {
|
||||||
lbm_value s = lbm_cons((lbm_value)str, lbm_enc_sym(SYM_TYPE_STREAM));
|
lbm_value s = lbm_cons((lbm_value)str, lbm_enc_sym(SYM_STREAM_TYPE));
|
||||||
if (lbm_type_of(s) == LBM_PTR_TYPE_CONS) {
|
if (lbm_type_of(s) == LBM_PTR_TYPE_CONS) {
|
||||||
s = s | LBM_PTR_TYPE_STREAM;
|
s = s | LBM_PTR_TYPE_STREAM;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ special_sym const special_symbols[NUM_SPECIAL_SYMBOLS] = {
|
||||||
{"call-cc" , SYM_CALLCC},
|
{"call-cc" , SYM_CALLCC},
|
||||||
{"continuation" , SYM_CONT},
|
{"continuation" , SYM_CONT},
|
||||||
|
|
||||||
|
{"set!" , SYM_SETVAR},
|
||||||
|
|
||||||
// pattern matching
|
// pattern matching
|
||||||
{"?" , SYM_MATCH_ANY},
|
{"?" , SYM_MATCH_ANY},
|
||||||
{"?i28" , SYM_MATCH_I28},
|
{"?i28" , SYM_MATCH_I28},
|
||||||
|
@ -79,7 +81,7 @@ special_sym const special_symbols[NUM_SPECIAL_SYMBOLS] = {
|
||||||
{"sym_boxed_i" , SYM_BOXED_I_TYPE},
|
{"sym_boxed_i" , SYM_BOXED_I_TYPE},
|
||||||
{"sym_boxed_u" , SYM_BOXED_U_TYPE},
|
{"sym_boxed_u" , SYM_BOXED_U_TYPE},
|
||||||
{"sym_boxed_f" , SYM_BOXED_F_TYPE},
|
{"sym_boxed_f" , SYM_BOXED_F_TYPE},
|
||||||
{"sym_ref" , SYM_REF_TYPE},
|
{"sym_stream" , SYM_STREAM_TYPE},
|
||||||
{"sym_recovered" , SYM_RECOVERED},
|
{"sym_recovered" , SYM_RECOVERED},
|
||||||
{"sym_bytecode" , SYM_BYTECODE_TYPE},
|
{"sym_bytecode" , SYM_BYTECODE_TYPE},
|
||||||
{"sym_nonsense" , SYM_NONSENSE},
|
{"sym_nonsense" , SYM_NONSENSE},
|
||||||
|
@ -151,8 +153,6 @@ special_sym const special_symbols[NUM_SPECIAL_SYMBOLS] = {
|
||||||
{"bitwise-xor" , SYM_BITWISE_XOR},
|
{"bitwise-xor" , SYM_BITWISE_XOR},
|
||||||
{"bitwise-not" , SYM_BITWISE_NOT},
|
{"bitwise-not" , SYM_BITWISE_NOT},
|
||||||
|
|
||||||
{"setvar" , SYM_SETVAR},
|
|
||||||
|
|
||||||
// Streams
|
// Streams
|
||||||
// {"stream-get" , SYM_STREAM_GET},
|
// {"stream-get" , SYM_STREAM_GET},
|
||||||
// {"stream-more" , SYM_STREAM_MORE},
|
// {"stream-more" , SYM_STREAM_MORE},
|
||||||
|
|
|
@ -154,7 +154,7 @@ bool symchar0(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool symchar(char c) {
|
bool symchar(char c) {
|
||||||
const char *allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/=<>";
|
const char *allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/=<>!";
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (allowed[i] != 0) {
|
while (allowed[i] != 0) {
|
||||||
|
|
|
@ -17,16 +17,6 @@ expected_fails=("test_lisp_code_cps -h 512 test_qq_4.lisp"
|
||||||
"test_lisp_code_cps -c -h 512 test_sumtree_0.lisp"
|
"test_lisp_code_cps -c -h 512 test_sumtree_0.lisp"
|
||||||
"test_lisp_code_cps -c -h 512 test_sumtree_1.lisp"
|
"test_lisp_code_cps -c -h 512 test_sumtree_1.lisp"
|
||||||
"test_lisp_code_cps -c -h 512 test_sumtree_2.lisp"
|
"test_lisp_code_cps -c -h 512 test_sumtree_2.lisp"
|
||||||
"test_lisp_code_cps_nc -h 512 test_qq_4.lisp"
|
|
||||||
"test_lisp_code_cps_nc -h 512 test_qq_5.lisp"
|
|
||||||
"test_lisp_code_cps_nc -h 512 test_sumtree_0.lisp"
|
|
||||||
"test_lisp_code_cps_nc -h 512 test_sumtree_1.lisp"
|
|
||||||
"test_lisp_code_cps_nc -h 512 test_sumtree_2.lisp"
|
|
||||||
"test_lisp_code_cps_nc -c -h 512 test_qq_4.lisp"
|
|
||||||
"test_lisp_code_cps_nc -c -h 512 test_qq_5.lisp"
|
|
||||||
"test_lisp_code_cps_nc -c -h 512 test_sumtree_0.lisp"
|
|
||||||
"test_lisp_code_cps_nc -c -h 512 test_sumtree_1.lisp"
|
|
||||||
"test_lisp_code_cps_nc -c -h 512 test_sumtree_2.lisp"
|
|
||||||
"test_lisp_code_cps -h 1024 test_take_iota_0.lisp"
|
"test_lisp_code_cps -h 1024 test_take_iota_0.lisp"
|
||||||
"test_lisp_code_cps -c -h 1024 test_take_iota_0.lisp"
|
"test_lisp_code_cps -c -h 1024 test_take_iota_0.lisp"
|
||||||
"test_lisp_code_cps -h 512 test_take_iota_0.lisp"
|
"test_lisp_code_cps -h 512 test_take_iota_0.lisp"
|
||||||
|
|
|
@ -178,6 +178,8 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
char *code_buffer = malloc((unsigned long)size * sizeof(char) + 1);
|
char *code_buffer = malloc((unsigned long)size * sizeof(char) + 1);
|
||||||
|
if (!code_buffer) return 0;
|
||||||
|
memset(code_buffer, 0, (unsigned long)size * sizeof(char) + 1);
|
||||||
size_t r = fread (code_buffer, 1, (unsigned int)size, fp);
|
size_t r = fread (code_buffer, 1, (unsigned int)size, fp);
|
||||||
|
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
@ -273,6 +275,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
lbm_set_timestamp_us_callback(timestamp_callback);
|
lbm_set_timestamp_us_callback(timestamp_callback);
|
||||||
lbm_set_usleep_callback(sleep_callback);
|
lbm_set_usleep_callback(sleep_callback);
|
||||||
|
lbm_set_printf_callback(printf);
|
||||||
|
|
||||||
lbm_variables_init(variable_storage, VARIABLE_STORAGE_SIZE);
|
lbm_variables_init(variable_storage, VARIABLE_STORAGE_SIZE);
|
||||||
|
|
||||||
|
@ -287,6 +290,11 @@ int main(int argc, char **argv) {
|
||||||
printf("Waiting for prelude timed out.\n");
|
printf("Waiting for prelude timed out.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lbm_pause_eval();
|
||||||
|
while (lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED) {
|
||||||
|
sleep_callback(1000);
|
||||||
|
}
|
||||||
|
|
||||||
char *compressed_code;
|
char *compressed_code;
|
||||||
if (compress_decompress) {
|
if (compress_decompress) {
|
||||||
uint32_t compressed_size = 0;
|
uint32_t compressed_size = 0;
|
||||||
|
@ -301,23 +309,30 @@ int main(int argc, char **argv) {
|
||||||
printf("\n\nDECOMPRESS TEST: %s\n\n", decompress_code);
|
printf("\n\nDECOMPRESS TEST: %s\n\n", decompress_code);
|
||||||
|
|
||||||
lbm_create_char_stream_from_compressed(&comp_tok_state,
|
lbm_create_char_stream_from_compressed(&comp_tok_state,
|
||||||
&string_tok,
|
&string_tok,
|
||||||
compressed_code);
|
compressed_code);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
lbm_create_char_stream_from_string(&string_tok_state,
|
lbm_create_char_stream_from_string(&string_tok_state,
|
||||||
&string_tok,
|
&string_tok,
|
||||||
code_buffer);
|
code_buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lbm_set_ctx_done_callback(context_done_callback);
|
lbm_set_ctx_done_callback(context_done_callback);
|
||||||
cid = lbm_load_and_eval_program(&string_tok);
|
cid = lbm_load_and_eval_program(&string_tok);
|
||||||
|
|
||||||
|
lbm_continue_eval();
|
||||||
|
|
||||||
|
|
||||||
while (!experiment_done) {
|
while (!experiment_done) {
|
||||||
sleep_callback(1000);
|
sleep_callback(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lbm_pause_eval();
|
||||||
|
while(lbm_get_eval_state() != EVAL_CPS_STATE_PAUSED);
|
||||||
|
|
||||||
if (compress_decompress) {
|
if (compress_decompress) {
|
||||||
free(compressed_code);
|
free(compressed_code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import huffman
|
import huffman
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
symchars = 'abcdefghijklmnopqrstuvwxyz?'
|
symchars = 'abcdefghijklmnopqrstuvwxyz!?'
|
||||||
numchars = '0123456789'
|
numchars = '0123456789'
|
||||||
funchars = ['+','-','*','/','=','<','>','.','#','\\\"','\\\\', '\'', ' ', '`', ',',',@', '_', '.']
|
funchars = ['+','-','*','/','=','<','>','.','#','\\\"','\\\\', '\'', ' ', '`', ',',',@', '_', '.']
|
||||||
short_lispnames = ['(', ')', '))', '((']
|
short_lispnames = ['(', ')', '))', '((']
|
||||||
|
|
Loading…
Reference in New Issue