Changeset 4032


Ignore:
Timestamp:
09/23/03 16:32:04 (19 years ago)
Author:
piso
Message:

Moved ASH to ash.java.

File:
1 edited

Legend:

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

    r4029 r4032  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.433 2003-09-23 16:25:03 piso Exp $
     5 * $Id: Primitives.java,v 1.434 2003-09-23 16:32:04 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    39433943    };
    39443944
    3945     // ### ash
    3946     // ash integer count => shifted-integer
    3947     private static final Primitive2 ASH = new Primitive2("ash") {
    3948         public LispObject execute(LispObject first, LispObject second)
    3949             throws ConditionThrowable
    3950         {
    3951             BigInteger n;
    3952             if (first instanceof Fixnum)
    3953                 n = BigInteger.valueOf(((Fixnum)first).getValue());
    3954             else if (first instanceof Bignum)
    3955                 n = ((Bignum)first).getValue();
    3956             else
    3957                 throw new ConditionThrowable(new TypeError(first, "integer"));
    3958             if (second instanceof Fixnum) {
    3959                 int count = Fixnum.getInt(second);
    3960                 if (count == 0)
    3961                     return first;
    3962                 // BigInteger.shiftLeft() succumbs to a stack overflow if count
    3963                 // is Integer.MIN_VALUE, so...
    3964                 if (count == Integer.MIN_VALUE)
    3965                     return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);
    3966                 return number(n.shiftLeft(count));
    3967             }
    3968             if (second instanceof Bignum) {
    3969                 BigInteger count = ((Bignum)second).getValue();
    3970                 if (count.signum() > 0)
    3971                     throw new ConditionThrowable(new LispError("can't represent result of left shift"));
    3972                 if (count.signum() < 0)
    3973                     return n.signum() >= 0 ? Fixnum.ZERO : new Fixnum(-1);
    3974                 Debug.bug(); // Shouldn't happen.
    3975             }
    3976             throw new ConditionThrowable(new TypeError(second, "integer"));
    3977         }
    3978     };
    3979 
    39803945    // ### expt
    39813946    // expt base-number power-number => result
Note: See TracChangeset for help on using the changeset viewer.