core: display: Prepare for pointer cells, M2-Planet.

Rewrite C-constructs not supported by M2-Planet

    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;
    // ...                 -> /* ... */

* src/display.c (display_helper): Use cell_ref.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2020-08-18 16:16:13 +02:00
parent 19ecbfe950
commit 99040a38c4
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
3 changed files with 28 additions and 28 deletions

View File

@ -86,17 +86,18 @@ char *g_arena;
SCM cell_arena;
SCM cell_zero;
#if POINTER_CELLS
SCM g_free;
long g_stack;
#else
#if !POINTER_CELLS
long g_free;
SCM g_stack;
long g_symbol;
#else
SCM g_free;
SCM g_symbol;
#endif
SCM *g_stack_array;
struct scm *g_cells;
struct scm *g_news;
long g_stack;
char **__execl_c_argv;
char *__getcwd_buf;

View File

@ -42,8 +42,9 @@ fdwrite_char (char v, int fd)
fdputs ("\\vtab", fd);
else if (v == '\f')
fdputs ("\\page", fd);
//Nyacc bug
// else if (v == '\r') fdputs ("return", fd);
/* Nyacc bug
else if (v == '\r') fdputs ("return", fd);
*/
else if (v == 13)
fdputs ("\\return", fd);
else if (v == ' ')
@ -73,17 +74,14 @@ fdwrite_string_char (char v, int fd)
fdputs ("\\n", fd);
else if (v == '\f')
fdputs ("\\f", fd);
#if 1 //__MESC__
//Nyacc bug
/* Nyacc bug
else if (v == '\r') fdputs ("\\r", fd);
else if (v == '\e') fdputs ("\\e", fd);
*/
else if (v == 13)
fdputs ("\\r", fd);
else if (v == 27)
fdputs ("\\e", fd);
#else
//else if (v == '\r') fdputs ("\\r", fd);
//Nyacc crash
//else if (v == '\e') fdputs ("\\e", fd);
#endif
else if (v == '\\')
fdputs ("\\\\", fd);
else if (v == '"')
@ -168,11 +166,11 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
}
else
{
if (x && x != cell_nil)
if (x != 0 && x != cell_nil)
fdisplay_ (CAR (x), fd, write_p);
if (CDR (x) && TYPE (CDR (x)) == TPAIR)
if (CDR (x) != 0 && TYPE (CDR (x)) == TPAIR)
display_helper (CDR (x), 1, " ", fd, write_p);
else if (CDR (x) && CDR (x) != cell_nil)
else if (CDR (x) != 0 && CDR (x) != cell_nil)
{
if (TYPE (CDR (x)) != TPAIR)
fdputs (" . ", fd);
@ -215,7 +213,6 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
fdisplay_ (REF (x), fd, write_p);
else if (t == TSTRUCT)
{
//SCM printer = STRUCT (x) + 1;
SCM printer = struct_ref_ (x, STRUCT_PRINTER);
if (TYPE (printer) == TREF)
printer = REF (printer);
@ -231,7 +228,7 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
for (i = 2; i < size; i = i + 1)
{
fdputc (' ', fd);
fdisplay_ (STRUCT (x) + i, fd, write_p);
fdisplay_ (cell_ref (STRUCT (x), i), fd, write_p);
}
fdputc ('>', fd);
}
@ -245,7 +242,7 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
{
if (i != 0)
fdputc (' ', fd);
fdisplay_ (VECTOR (x) + i, fd, write_p);
fdisplay_ (cell_ref (VECTOR (x), i), fd, write_p);
}
fdputc (')', fd);
}
@ -257,7 +254,7 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
fdputs (itoa (x), fd);
fdputs (">", fd);
}
return 0;
return cell_unspecified;
}
SCM

View File

@ -62,6 +62,7 @@ gc_init ()
ARENA_SIZE = 100000000; /* 2.3GiB */
#elif ! __M2_PLANET__
ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */
ARENA_SIZE = 600000; /* 32b: 6MiB, 64b: 12 MiB */
#else
ARENA_SIZE = 20000000;
#endif
@ -573,25 +574,26 @@ gc_ ()
gc_up_arena ();
}
#if POINTER_CELLS
SCM save_gfree = g_free;
#endif
SCM new_cell_nil = g_free;
SCM s;
for (s = cell_nil; s < g_symbol_max; s = s + M2_CELL_SIZE)
gc_copy (s);
#if POINTER_CELLS
cell_nil = new_cell_nil;
#if GC_TEST
cell_nil = save_gfree;
cell_zero = cell_nil - M2_CELL_SIZE;
g_symbol_max = g_free;
#else
long save_gsymbols = g_symbols;
cell_nil = save_gfree;
g_symbols = 0;
g_free = save_gfree;
g_free = new_cell_nil;
init_symbols_ ();
g_symbol_max = g_symbol;
g_symbols = save_gsymbols;
#endif
#endif
g_symbols = gc_copy (g_symbols);
@ -602,7 +604,7 @@ gc_ ()
for (i = g_stack; i < STACK_SIZE; i = i + 1)
copy_stack (i, gc_copy (g_stack_array[i]));
gc_loop (cell_nil);
gc_loop (new_cell_nil);
}
SCM