[armedbear-cvs] r11573 - trunk/abcl/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Wed Jan 21 22:14:49 UTC 2009
Author: ehuelsmann
Date: Wed Jan 21 22:14:47 2009
New Revision: 11573
Log:
Add a 'getInstance' static method to all lisp classes which have a
compiler primitive for (part of) their domain.
Modified:
trunk/abcl/src/org/armedbear/lisp/Bignum.java
trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
trunk/abcl/src/org/armedbear/lisp/LispCharacter.java
trunk/abcl/src/org/armedbear/lisp/LispObject.java
trunk/abcl/src/org/armedbear/lisp/SingleFloat.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:14:47 2009
@@ -39,6 +39,13 @@
{
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 Bignum(long l)
{
value = BigInteger.valueOf(l);
Modified: trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java Wed Jan 21 22:14:47 2009
@@ -53,6 +53,19 @@
Symbol.DOUBLE_FLOAT_NEGATIVE_INFINITY.initializeConstant(DOUBLE_FLOAT_NEGATIVE_INFINITY);
}
+ public static DoubleFloat getInstance(double d) {
+ if (d == 0)
+ return ZERO;
+ else if (d == -0.0d )
+ return MINUS_ZERO;
+ else if (d == 1)
+ return ONE;
+ else if (d == -1)
+ return MINUS_ONE;
+ else
+ return new DoubleFloat(d);
+ }
+
public final double value;
public DoubleFloat(double value)
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 Wed Jan 21 22:14:47 2009
@@ -288,7 +288,7 @@
{
String name = ((Symbol)arg).getName();
if (name.length() == 1)
- return getInstance(name.charAt(0));
+ return LispCharacter.getInstance(name.charAt(0));
}
return type_error(arg, Symbol.CHARACTER_DESIGNATOR);
}
@@ -438,7 +438,7 @@
}
if (c < 128)
return constants[LOWER_CASE_CHARS[c]];
- return getInstance(toLowerCase(c));
+ return LispCharacter.getInstance(toLowerCase(c));
}
};
@@ -460,7 +460,7 @@
}
if (c < 128)
return constants[UPPER_CASE_CHARS[c]];
- return getInstance(toUpperCase(c));
+ return LispCharacter.getInstance(toUpperCase(c));
}
};
Modified: trunk/abcl/src/org/armedbear/lisp/LispObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/LispObject.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/LispObject.java Wed Jan 21 22:14:47 2009
@@ -40,6 +40,10 @@
return T;
}
+ static public LispObject getInstance(boolean b) {
+ return b ? T : NIL;
+ }
+
public LispObject classOf()
{
return BuiltInClass.CLASS_T;
Modified: trunk/abcl/src/org/armedbear/lisp/SingleFloat.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/SingleFloat.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/SingleFloat.java Wed Jan 21 22:14:47 2009
@@ -53,6 +53,19 @@
Symbol.SINGLE_FLOAT_NEGATIVE_INFINITY.initializeConstant(SINGLE_FLOAT_NEGATIVE_INFINITY);
}
+ public static SingleFloat getInstance(float f) {
+ if (f == 0)
+ return ZERO;
+ else if (f == -0.0f )
+ return MINUS_ZERO;
+ else if (f == 1)
+ return ONE;
+ else if (f == -1)
+ return MINUS_ONE;
+ else
+ return new SingleFloat(f);
+ }
+
public final float value;
public SingleFloat(float value)
More information about the armedbear-cvs
mailing list