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

Erik Huelsmann ehuelsmann at common-lisp.net
Wed Jan 21 22:35:45 UTC 2009


Author: ehuelsmann
Date: Wed Jan 21 22:35:44 2009
New Revision: 11574

Log:
Introduce LispInteger super-type to Bignum and Fixnum:
  The LispInteger logically can return both Bignum as well as Fixnum
values for its getInstance() method.

Added:
   trunk/abcl/src/org/armedbear/lisp/LispInteger.java
Modified:
   trunk/abcl/src/org/armedbear/lisp/Bignum.java
   trunk/abcl/src/org/armedbear/lisp/Fixnum.java

Modified: trunk/abcl/src/org/armedbear/lisp/Bignum.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Bignum.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Bignum.java	Wed Jan 21 22:35:44 2009
@@ -35,15 +35,12 @@
 
 import java.math.BigInteger;
 
-public final class Bignum extends LispObject
+public final class Bignum extends LispInteger
 {
   public final BigInteger value;
 
-  public static LispObject getInstance(long l) {
-      if (Integer.MIN_VALUE <= l && l <= Integer.MAX_VALUE)
-          return Fixnum.getInstance((int)l);
-      else
-          return new Bignum(l);
+  public static Bignum getInstance(long l) {
+    return new Bignum(l);
   }
 
   public Bignum(long l)

Modified: trunk/abcl/src/org/armedbear/lisp/Fixnum.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Fixnum.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Fixnum.java	Wed Jan 21 22:35:44 2009
@@ -35,7 +35,7 @@
 
 import java.math.BigInteger;
 
-public final class Fixnum extends LispObject
+public final class Fixnum extends LispInteger
 {
   public static final Fixnum[] constants = new Fixnum[256];
   static

Added: trunk/abcl/src/org/armedbear/lisp/LispInteger.java
==============================================================================
--- (empty file)
+++ trunk/abcl/src/org/armedbear/lisp/LispInteger.java	Wed Jan 21 22:35:44 2009
@@ -0,0 +1,54 @@
+/*
+ * LispInteger.java
+ *
+ * Copyright (C) 2003-2007 Peter Graves
+ * $Id: Bignum.java 11573 2009-01-21 22:14:47Z ehuelsmann $
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on this library.  If you modify this library, you may extend
+ * this exception to your version of the library, but you are not
+ * obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+package org.armedbear.lisp;
+
+/** This class merely serves as the super class for
+ * Fixnum and Bignum
+ */
+public class LispInteger extends LispObject
+{
+
+  public static LispInteger getInstance(long l) {
+      if (Integer.MIN_VALUE <= l && l <= Integer.MAX_VALUE)
+          return Fixnum.getInstance((int)l);
+      else
+          return new Bignum(l);
+  }
+
+  public static LispInteger getInstance(int i) {
+      return Fixnum.getInstance(i);
+  }
+
+
+}




More information about the armedbear-cvs mailing list