Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ecl
ecl
Commits
3adc8b22
Commit
3adc8b22
authored
Sep 04, 2018
by
Daniel Kochmański
Browse files
Merge branch 'read-bclosure' into 'develop'
fix reading of bclosures See merge request embeddable-common-lisp/ecl!118
parents
ba6e6ddd
30fa0cd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/c/printer/write_code.d
View file @
3adc8b22
...
...
@@ -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
)(-
1
l
)
;
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
)(-
1
l
)
;
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
);
...
...
src/c/read.d
View file @
3adc8b22
...
...
@@ -729,7 +729,7 @@ sharp_Y_reader(cl_object in, cl_object c, cl_object d)
cl_object
x
,
rv
,
nth
,
lex
;
if
(
d
!=
ECL_NIL
&&
!
read_suppress
)
extra_argument
(
'
C
'
,
in
,
d
);
extra_argument
(
'
Y
'
,
in
,
d
);
x
=
ecl_read_object
(
in
);
unlikely_if
(
x
==
OBJNULL
)
{
FEend_of_file
(
in
);
...
...
@@ -780,6 +780,14 @@ sharp_Y_reader(cl_object in, cl_object c, cl_object d)
rv
->
bytecodes
.
file_position
=
nth
;
rv
->
bytecodes
.
entry
=
_ecl_bytecodes_dispatch_vararg
;
if
(
lex
!=
ECL_NIL
)
{
cl_object
x
=
ecl_alloc_object
(
t_bclosure
);
x
->
bclosure
.
code
=
rv
;
x
->
bclosure
.
lex
=
lex
;
x
->
bclosure
.
entry
=
_ecl_bclosure_dispatch_vararg
;
rv
=
x
;
}
@
(
return
rv
);
}
...
...
@@ -1241,7 +1249,7 @@ do_patch_sharp(cl_object x, cl_object table)
}
case
t_bclosure
:
{
x
->
bclosure
.
lex
=
do_patch_sharp
(
x
->
bclosure
.
lex
,
table
);
x
=
x
->
bclosure
.
code
=
do_patch_sharp
(
x
->
bclosure
.
code
,
table
);
x
->
bclosure
.
code
=
do_patch_sharp
(
x
->
bclosure
.
code
,
table
);
break
;
}
case
t_bytecodes
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment