Changeset 4954


Ignore:
Timestamp:
12/03/03 18:03:30 (18 years ago)
Author:
piso
Message:

WRITE-UTF8, UTF8-LENGTH, WRITE-CP-ENTRY

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/jvm.lisp

    r4949 r4954  
    22;;;
    33;;; Copyright (C) 2003 Peter Graves
    4 ;;; $Id: jvm.lisp,v 1.48 2003-12-03 01:15:25 piso Exp $
     4;;; $Id: jvm.lisp,v 1.49 2003-12-03 18:03:30 piso Exp $
    55;;;
    66;;; This program is free software; you can redistribute it and/or
     
    930930(defun write-utf8 (string)
    931931  (dotimes (i (length string))
    932     (write-u1 (char-int (char string i)))))
     932    (let ((c (char string i)))
     933      (if (eql c #\null)
     934          (progn
     935            (write-u1 #xC0)
     936            (write-u1 #x80))
     937          (write-u1 (char-int c))))))
     938
     939(defun utf8-length (string)
     940  (let ((len 0))
     941    (dotimes (i (length string))
     942      (incf len (if (eql (char string i) #\null) 2 1)))
     943    len))
    933944
    934945(defun write-cp-entry (entry)
    935946  (write-u1 (first entry))
    936947  (case (first entry)
    937     (1
    938      (write-u2 (second entry))
     948    (1 ; UTF8
     949     (write-u2 (utf8-length (third entry)))
    939950     (write-utf8 (third entry)))
    940951    ((5 6)
     
    11861197
    11871198(defun declare-string (string)
     1199;;   (format t "declare-string string = |~S|~%" string)
     1200;;   (when (position #\0 string)
     1201;;     (setf string (utf8 string)))
    11881202  (let ((g (symbol-name (gensym)))
    11891203        (*code* *static-code*))
     
    12041218(defun compile-constant (form)
    12051219  (cond
    1206    ((sys::fixnump form)
     1220   ((fixnump form)
    12071221    (let ((n form))
    12081222      (cond ((zerop n)
     
    12381252            "Lorg/armedbear/lisp/LispObject;")
    12391253      (emit-store-value)))
     1254   ((stringp form)
     1255    (let ((g (declare-string form)))
     1256      (emit 'getstatic
     1257            *this-class*
     1258            g
     1259            "Lorg/armedbear/lisp/LispString;")
     1260      (emit-store-value)))
    12401261   ((vectorp form)
    12411262    (let ((g (declare-object-as-string form)))
     
    12441265            g
    12451266            "Lorg/armedbear/lisp/LispObject;")
    1246       (emit-store-value)))
    1247    ((stringp form)
    1248     (let ((g (declare-string form)))
    1249       (emit 'getstatic
    1250             *this-class*
    1251             g
    1252             "Lorg/armedbear/lisp/LispString;")
    12531267      (emit-store-value)))
    12541268   ((characterp form)
Note: See TracChangeset for help on using the changeset viewer.