reader: fix reading of bclosures

The syntax had been changed in commit
    991bc3ab78, but the reader macro
    became broken in the process and commit
    835e85bc99 removed the broken
    parts. Since the reason for the change in the syntax is unclear,
    go back to the old syntax.
This commit is contained in:
Marius Gerbershagen 2018-08-26 18:32:13 +02:00
parent ba6e6ddde7
commit 741a01da09
2 changed files with 35 additions and 21 deletions

View file

@ -16,22 +16,35 @@
#include <ecl/internal.h>
#include <ecl/bytecodes.h>
void
_ecl_write_bytecodes_readably(cl_object x, cl_object stream, cl_object lex)
{
cl_index i;
cl_object code_l = ECL_NIL;
/* INV: We don't write the definition of the closure, hence we don't
* need to write the macros it closes over either */
for (; !Null(lex); lex = ECL_CONS_CDR(lex)) {
cl_object record = ECL_CONS_CAR(lex);
if (!ECL_CONSP(record) || (ECL_CONS_CAR(record) != @'si::macro' &&
ECL_CONS_CAR(record) != @'si::symbol-macro'))
break;
}
for ( i=x->bytecodes.code_size-1 ; i<(cl_index)(-1l) ; i-- )
code_l = ecl_cons(ecl_make_fixnum(((cl_opcode*)(x->bytecodes.code))[i]), code_l);
writestr_stream("#Y", stream);
si_write_ugly_object(cl_list(7, x->bytecodes.name, lex,
ECL_NIL /* x->bytecodes.definition */,
code_l, x->bytecodes.data,
x->bytecodes.file,
x->bytecodes.file_position),
stream);
}
void
_ecl_write_bytecodes(cl_object x, cl_object stream)
{
if (ecl_print_readably()) {
cl_index i;
cl_object lex = ECL_NIL;
cl_object code_l=ECL_NIL;
for ( i=x->bytecodes.code_size-1 ; i<(cl_index)(-1l) ; i-- )
code_l = ecl_cons(ecl_make_fixnum(((cl_opcode*)(x->bytecodes.code))[i]), code_l);
writestr_stream("#Y", stream);
si_write_ugly_object(cl_list(7, x->bytecodes.name, lex,
ECL_NIL /* x->bytecodes.definition */,
code_l, x->bytecodes.data,
x->bytecodes.file,
x->bytecodes.file_position),
stream);
_ecl_write_bytecodes_readably(x, stream, ECL_NIL);
} else {
_ecl_write_unreadable(x, "bytecompiled-function", x->bytecodes.name, stream);
}
@ -41,14 +54,7 @@ void
_ecl_write_bclosure(cl_object x, cl_object stream)
{
if (ecl_print_readably()) {
cl_object lex = x->bclosure.lex;
if (Null(lex)) {
_ecl_write_bytecodes(x->bclosure.code, stream);
} else {
writestr_stream("#Y", stream);
si_write_ugly_object(cl_list(2, x->bclosure.code, lex),
stream);
}
_ecl_write_bytecodes_readably(x->bclosure.code, stream, x->bclosure.lex);
} else {
cl_object name = x->bytecodes.name;
writestr_stream("#<bytecompiled-closure ", stream);