- Timestamp:
- 08/09/10 15:16:05 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12884 r12885 786 786 787 787 788 789 790 (declaim (inline write-u1))791 (defun write-u1 (n stream)792 (declare (optimize speed))793 (declare (type (unsigned-byte 8) n))794 (declare (type stream stream))795 (write-8-bits n stream))796 797 (defknown write-u2 (t t) t)798 (defun write-u2 (n stream)799 (declare (optimize speed))800 (declare (type (unsigned-byte 16) n))801 (declare (type stream stream))802 (write-8-bits (logand (ash n -8) #xFF) stream)803 (write-8-bits (logand n #xFF) stream))804 805 (defknown write-u4 (integer stream) t)806 (defun write-u4 (n stream)807 (declare (optimize speed))808 (declare (type (unsigned-byte 32) n))809 (write-u2 (logand (ash n -16) #xFFFF) stream)810 (write-u2 (logand n #xFFFF) stream))811 812 (declaim (ftype (function (t t) t) write-s4))813 (defun write-s4 (n stream)814 (declare (optimize speed))815 (cond ((minusp n)816 (write-u4 (1+ (logxor (- n) #xFFFFFFFF)) stream))817 (t818 (write-u4 n stream))))819 820 (declaim (ftype (function (t t t) t) write-ascii))821 (defun write-ascii (string length stream)822 (declare (type string string))823 (declare (type (unsigned-byte 16) length))824 (declare (type stream stream))825 (write-u2 length stream)826 (dotimes (i length)827 (declare (type (unsigned-byte 16) i))828 (write-8-bits (char-code (char string i)) stream)))829 830 (declaim (ftype (function (t t) t) write-utf8))831 (defun write-utf8 (string stream)832 (declare (optimize speed))833 (declare (type string string))834 (declare (type stream stream))835 (let ((length (length string))836 (must-convert nil))837 (declare (type fixnum length))838 (dotimes (i length)839 (declare (type fixnum i))840 (unless (< 0 (char-code (char string i)) #x80)841 (setf must-convert t)842 (return)))843 (if must-convert844 (let ((octets (make-array (* length 2)845 :element-type '(unsigned-byte 8)846 :adjustable t847 :fill-pointer 0)))848 (declare (type (vector (unsigned-byte 8)) octets))849 (dotimes (i length)850 (declare (type fixnum i))851 (let* ((c (char string i))852 (n (char-code c)))853 (cond ((zerop n)854 (vector-push-extend #xC0 octets)855 (vector-push-extend #x80 octets))856 ((< 0 n #x80)857 (vector-push-extend n octets))858 (t859 (let ((char-octets (char-to-utf8 c)))860 (dotimes (j (length char-octets))861 (declare (type fixnum j))862 (vector-push-extend (svref char-octets j) octets)))))))863 (write-u2 (length octets) stream)864 (dotimes (i (length octets))865 (declare (type fixnum i))866 (write-8-bits (aref octets i) stream)))867 (write-ascii string length stream))))868 788 869 789 (defstruct (java-method (:include method)
Note: See TracChangeset
for help on using the changeset viewer.