(let ((start (port-position port)))
(lambda ()
(+ address (- (port-position port) start)))))
- (define (write-string s)
- (put-bytevector port (string->utf8 s)))
+ (define (write-latin1-string s)
+ (write-loader-len (string-length s))
+ (string-for-each (lambda (c) (write-byte (char->integer c))) s))
(define (write-int24-be x)
(bytevector-s32-set! u32-bv 0 x (endianness big))
(put-bytevector port u32-bv 1 3))
(write-byte (ash len -16))
(write-byte (logand (ash len -8) 255))
(write-byte (logand len 255)))
- (define (write-loader str)
- (write-loader-len (string-length str))
- (write-string str))
(define (write-bytevector bv)
(write-loader-len (bytevector-length bv))
(put-bytevector port bv))
;; assembly)'.
(write-bytecode meta port '() 0 #f)))
((make-char32 ,x) (write-uint32-be x))
- ((load-number ,str) (write-loader str))
- ((load-string ,str) (write-loader str))
+ ((load-number ,str) (write-latin1-string str))
+ ((load-string ,str) (write-latin1-string str))
((load-wide-string ,str) (write-wide-string str))
- ((load-symbol ,str) (write-loader str))
+ ((load-symbol ,str) (write-latin1-string str))
((load-array ,bv) (write-bytevector bv))
((br ,l) (write-break l))
((br-if ,l) (write-break l))
-;;;; test assembly to bytecode compilation -*- scheme -*-
+;;;; Assembly to bytecode compilation -*- mode: scheme; coding: iso-8859-1; -*-
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(comp-test '(load-symbol "foo")
(vector 'load-symbol 0 0 3 (char->integer #\f) (char->integer #\o)
(char->integer #\o)))
-
+
+ (comp-test '(load-string "æ") ;; a non-ASCII Latin-1 string
+ (vector 'load-string 0 0 1 230))
+
(comp-test '(load-program () 3 #f (make-int8 3) (return))
#(load-program
(uint32 3) ;; len