Changeset 11573


Ignore:
Timestamp:
01/21/09 22:14:47 (12 years ago)
Author:
ehuelsmann
Message:

Add a 'getInstance' static method to all lisp classes which have a
compiler primitive for (part of) their domain.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Bignum.java

    r11486 r11573  
    3939{
    4040  public final BigInteger value;
     41
     42  public static LispObject getInstance(long l) {
     43      if (Integer.MIN_VALUE <= l && l <= Integer.MAX_VALUE)
     44          return Fixnum.getInstance((int)l);
     45      else
     46          return new Bignum(l);
     47  }
    4148
    4249  public Bignum(long l)
  • trunk/abcl/src/org/armedbear/lisp/DoubleFloat.java

    r11488 r11573  
    5454    }
    5555
     56    public static DoubleFloat getInstance(double d) {
     57        if (d == 0)
     58            return ZERO;
     59        else if (d == -0.0d )
     60            return MINUS_ZERO;
     61        else if (d == 1)
     62            return ONE;
     63        else if (d == -1)
     64            return MINUS_ONE;
     65        else
     66            return new DoubleFloat(d);
     67    }
     68
    5669    public final double value;
    5770
  • trunk/abcl/src/org/armedbear/lisp/LispCharacter.java

    r11539 r11573  
    289289            String name = ((Symbol)arg).getName();
    290290            if (name.length() == 1)
    291               return getInstance(name.charAt(0));
     291              return LispCharacter.getInstance(name.charAt(0));
    292292          }
    293293        return type_error(arg, Symbol.CHARACTER_DESIGNATOR);
     
    439439        if (c < 128)
    440440          return constants[LOWER_CASE_CHARS[c]];
    441         return getInstance(toLowerCase(c));
     441        return LispCharacter.getInstance(toLowerCase(c));
    442442      }
    443443    };
     
    461461        if (c < 128)
    462462          return constants[UPPER_CASE_CHARS[c]];
    463         return getInstance(toUpperCase(c));
     463        return LispCharacter.getInstance(toUpperCase(c));
    464464      }
    465465    };
  • trunk/abcl/src/org/armedbear/lisp/LispObject.java

    r11391 r11573  
    4141  }
    4242
     43  static public LispObject getInstance(boolean b) {
     44      return b ? T : NIL;
     45  }
     46
    4347  public LispObject classOf()
    4448  {
  • trunk/abcl/src/org/armedbear/lisp/SingleFloat.java

    r11488 r11573  
    5454    }
    5555
     56    public static SingleFloat getInstance(float f) {
     57        if (f == 0)
     58            return ZERO;
     59        else if (f == -0.0f )
     60            return MINUS_ZERO;
     61        else if (f == 1)
     62            return ONE;
     63        else if (f == -1)
     64            return MINUS_ONE;
     65        else
     66            return new SingleFloat(f);
     67    }
     68
    5669    public final float value;
    5770
Note: See TracChangeset for help on using the changeset viewer.