mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
Fix decompilation of the `load-array' instruction.
This allows, e.g., ",c #u8(1 2 3)" at the REPL to actually work instead of failing to decode `load-array'. * module/language/assembly/decompile-bytecode.scm (decode-bytecode): Account for the `load-array' instruction, which is followed by a bytevector instead of a string. We should find a more elegant way to do that.
This commit is contained in:
parent
81e002fcb9
commit
159399850d
1 changed files with 15 additions and 4 deletions
|
@ -22,6 +22,7 @@
|
|||
#:use-module (system vm instruction)
|
||||
#:use-module (system base pmatch)
|
||||
#:use-module (srfi srfi-4)
|
||||
#:use-module (rnrs bytevector)
|
||||
#:use-module (language assembly)
|
||||
#:export (decompile-bytecode))
|
||||
|
||||
|
@ -97,14 +98,24 @@
|
|||
((eq? inst 'load-program)
|
||||
(decode-load-program pop))
|
||||
((< (instruction-length inst) 0)
|
||||
(let* ((len (let* ((a (pop)) (b (pop)) (c (pop)))
|
||||
(let* ((make-sequence
|
||||
(if (eq? inst 'load-array)
|
||||
make-bytevector
|
||||
make-string))
|
||||
(sequence-set!
|
||||
(if (eq? inst 'load-array)
|
||||
bytevector-u8-set!
|
||||
(lambda (str pos value)
|
||||
(string-set! str pos (integer->char value)))))
|
||||
|
||||
(len (let* ((a (pop)) (b (pop)) (c (pop)))
|
||||
(+ (ash a 16) (ash b 8) c)))
|
||||
(str (make-string len)))
|
||||
(seq (make-sequence len)))
|
||||
(let lp ((i 0))
|
||||
(if (= i len)
|
||||
`(,inst ,str)
|
||||
`(,inst ,seq)
|
||||
(begin
|
||||
(string-set! str i (integer->char (pop)))
|
||||
(sequence-set! seq i (pop))
|
||||
(lp (1+ i)))))))
|
||||
(else
|
||||
;; fixed length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue