[armedbear-cvs] r12581 - trunk/abcl/src/org/armedbear/lisp

Erik Huelsmann ehuelsmann at common-lisp.net
Mon Apr 5 21:00:16 UTC 2010


Author: ehuelsmann
Date: Mon Apr  5 17:00:13 2010
New Revision: 12581

Log:
Make LispCharacter constructor private in favor of getInstance();
  this allows checking character validity later on - and returning an appropriate value.

Modified:
   trunk/abcl/src/org/armedbear/lisp/JavaObject.java
   trunk/abcl/src/org/armedbear/lisp/LispCharacter.java
   trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

Modified: trunk/abcl/src/org/armedbear/lisp/JavaObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JavaObject.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Mon Apr  5 17:00:13 2010
@@ -215,7 +215,7 @@
             return ((Boolean)obj).booleanValue() ? T : NIL;
 
         if (obj instanceof Character)
-            return new LispCharacter((Character)obj);
+            return LispCharacter.getInstance((Character)obj);
 
         if (obj instanceof Object[]) {
             Object[] array = (Object[]) obj;

Modified: trunk/abcl/src/org/armedbear/lisp/LispCharacter.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispCharacter.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/LispCharacter.java	Mon Apr  5 17:00:13 2010
@@ -67,7 +67,7 @@
   }
 
   // This needs to be public for the compiler.
-  public LispCharacter(char c)
+  private LispCharacter(char c)
   {
     this.value = c;
   }

Modified: trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp	(original)
+++ trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp	Mon Apr  5 17:00:13 2010
@@ -2269,15 +2269,9 @@
         (*code* *static-code*))
      ;; no need to *declare-inline*: constants
     (declare-field g +lisp-character+ +field-access-private+)
-    (cond ((<= 0 n 255)
-           (emit 'getstatic +lisp-character-class+ "constants" +lisp-character-array+)
-           (emit-push-constant-int n)
-           (emit 'aaload))
-          (t
-           (emit 'new +lisp-character-class+)
-           (emit 'dup)
-           (emit-push-constant-int n)
-           (emit-invokespecial-init +lisp-character-class+ '("C"))))
+    (emit-push-constant-int n)
+    (emit-invokestatic +lisp-character-class+ "getInstance" '("C")
+                       +lisp-character+)
     (emit 'putstatic *this-class* g +lisp-character+)
     (setf *static-code* *code*)
     g))




More information about the armedbear-cvs mailing list