diff options
author | Andy Wingo <wingo@pobox.com> | 2009-02-01 10:15:00 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-02-01 10:15:00 +0100 |
commit | 1f1ec13b5c459717b22030565e591f1f713ee39d (patch) | |
tree | 8e404fed86e857fd6a860cfdc9eaae0466dc0bbf /module/language/assembly/compile-bytecode.scm | |
parent | 9aeaabdc4571b5a2319c88e02904bd8996d5ac01 (diff) | |
download | guile-1f1ec13b5c459717b22030565e591f1f713ee39d.tar.gz |
add code for writing out metadata to the end of a program
* libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice):
Verify the lengths with the meta-length.
(scm_objcode_meta): New procedure, for getting at the meta-info of an
objcode.
(scm_objcode_to_bytecode):
(scm_write_objcode): Write bytecode with the metadata too.
* module/system/vm/objcode.scm: Export object-meta.
* module/language/assembly.scm (byte-length):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/disassemble.scm (disassemble-load-program):
* module/language/glil/compile-assembly.scm (glil->assembly):
* test-suite/tests/asm-to-bytecode.test ("compiler"): Change to
load-program format to have meta-or-#f instead of meta-length, so that
we can serialize the meta as objcode without a load-program byte. Add a
test for writing out the meta.
Diffstat (limited to 'module/language/assembly/compile-bytecode.scm')
-rw-r--r-- | module/language/assembly/compile-bytecode.scm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/module/language/assembly/compile-bytecode.scm b/module/language/assembly/compile-bytecode.scm index bf423ab74..7f1271d2c 100644 --- a/module/language/assembly/compile-bytecode.scm +++ b/module/language/assembly/compile-bytecode.scm @@ -81,19 +81,27 @@ (write-byte opcode) (pmatch asm ((load-program ,nargs ,nrest ,nlocs ,nexts - ,labels ,length ,metalength . ,code) + ,labels ,length ,meta . ,code) (write-byte nargs) (write-byte nrest) (write-byte nlocs) (write-byte nexts) (write-uint32-le length) ;; FIXME! - (write-uint32-le metalength) ;; FIXME! + (write-uint32-le (if meta (1- (byte-length meta)) 0)) ;; FIXME! (letrec ((i 0) (write (lambda (x) (set! i (1+ i)) (write-byte x))) (get-addr (lambda () i))) (for-each (lambda (asm) (write-bytecode asm write get-addr labels)) - code))) + code)) + (if meta + ;; don't write the load-program byte for metadata + (letrec ((i -1) + (write (lambda (x) + (set! i (1+ i)) + (if (> i 0) (write-byte x)))) + (get-addr (lambda () i))) + (write-bytecode meta write get-addr '())))) ((load-integer ,str) (write-loader str)) ((load-number ,str) (write-loader str)) ((load-string ,str) (write-loader str)) |