summaryrefslogtreecommitdiff
path: root/module/language/assembly/decompile-bytecode.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-06-19 02:35:57 +0200
committerLudovic Courtès <ludo@gnu.org>2009-06-19 02:37:04 +0200
commit159399850de811f23e45d439aecf452b0137d847 (patch)
tree6fc5267127dd0a85889e59cb31279da1f26ad5a5 /module/language/assembly/decompile-bytecode.scm
parent81e002fcb90c99ac2840dcde81f286772b1fb1a2 (diff)
downloadguile-159399850de811f23e45d439aecf452b0137d847.tar.gz
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.
Diffstat (limited to 'module/language/assembly/decompile-bytecode.scm')
-rw-r--r--module/language/assembly/decompile-bytecode.scm19
1 files changed, 15 insertions, 4 deletions
diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm
index 2ad3bc6a4..fdf27ec62 100644
--- a/module/language/assembly/decompile-bytecode.scm
+++ b/module/language/assembly/decompile-bytecode.scm
@@ -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