diff options
Diffstat (limited to 'module/language/assembly')
-rw-r--r-- | module/language/assembly/compile-bytecode.scm | 3 | ||||
-rw-r--r-- | module/language/assembly/decompile-bytecode.scm | 13 | ||||
-rw-r--r-- | module/language/assembly/disassemble.scm | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/module/language/assembly/compile-bytecode.scm b/module/language/assembly/compile-bytecode.scm index 17a71f21b..bf423ab74 100644 --- a/module/language/assembly/compile-bytecode.scm +++ b/module/language/assembly/compile-bytecode.scm @@ -81,12 +81,13 @@ (write-byte opcode) (pmatch asm ((load-program ,nargs ,nrest ,nlocs ,nexts - ,labels ,length . ,code) + ,labels ,length ,metalength . ,code) (write-byte nargs) (write-byte nrest) (write-byte nlocs) (write-byte nexts) (write-uint32-le length) ;; FIXME! + (write-uint32-le metalength) ;; FIXME! (letrec ((i 0) (write (lambda (x) (set! i (1+ i)) (write-byte x))) (get-addr (lambda () i))) diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm index 4bcae800b..e8d175d23 100644 --- a/module/language/assembly/decompile-bytecode.scm +++ b/module/language/assembly/decompile-bytecode.scm @@ -42,19 +42,22 @@ (define (decode-load-program pop) (let* ((nargs (pop)) (nrest (pop)) (nlocs (pop)) (nexts (pop)) (a (pop)) (b (pop)) (c (pop)) (d (pop)) + (e (pop)) (f (pop)) (g (pop)) (h (pop)) (len (+ a (ash b 8) (ash c 16) (ash d 24))) + (metalen (+ e (ash f 8) (ash g 16) (ash h 24))) + (totlen (+ len metalen)) (i 0)) (define (sub-pop) ;; ...records. ha. ha. - (let ((b (cond ((< i len) (pop)) - ((= i len) #f) + (let ((b (cond ((< i totlen) (pop)) + ((= i totlen) #f) (else (error "tried to decode too many bytes"))))) (if b (set! i (1+ i))) b)) (let lp ((out '())) - (cond ((> i len) + (cond ((> i totlen) (error "error decoding program -- read too many bytes" out)) - ((= i len) - `(load-program ,nargs ,nrest ,nlocs ,nexts () ,len + ((= i totlen) + `(load-program ,nargs ,nrest ,nlocs ,nexts () ,len ,metalen ,@(reverse! out))) (else (let ((exp (decode-bytecode sub-pop))) diff --git a/module/language/assembly/disassemble.scm b/module/language/assembly/disassemble.scm index 7c7ba15e2..7a5691952 100644 --- a/module/language/assembly/disassemble.scm +++ b/module/language/assembly/disassemble.scm @@ -36,7 +36,7 @@ (define (disassemble-load-program asm env) (pmatch asm - ((load-program ,nargs ,nrest ,nlocs ,nexts ,labels ,len . ,code) + ((load-program ,nargs ,nrest ,nlocs ,nexts ,labels ,len ,metalen . ,code) (let ((objs (and env (assq-ref env 'objects))) (meta (and env (assq-ref env 'meta))) (exts (and env (assq-ref env 'exts))) |