Changeset 3648


Ignore:
Timestamp:
09/10/03 13:48:42 (20 years ago)
Author:
piso
Message:

Moved LOGAND, LOGIOR, LOGNOT, LOGBITP to LogicalOperations?.java.

Location:
trunk/j/src/org/armedbear/lisp
Files:
2 edited

Legend:

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

    r3638 r3648  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Autoload.java,v 1.52 2003-09-09 23:17:27 piso Exp $
     5 * $Id: Autoload.java,v 1.53 2003-09-10 13:48:42 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    176176        autoload("import", "PackageFunctions");
    177177        autoload("list-all-packages", "PackageFunctions");
     178        autoload("logand", "LogicalOperations");
     179        autoload("logbitp", "LogicalOperations");
     180        autoload("logior", "LogicalOperations");
     181        autoload("lognot", "LogicalOperations");
    178182        autoload("make-string-output-stream", "StringOutputStream");
    179183        autoload("namestring", "Pathname");
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r3643 r3648  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.381 2003-09-10 00:58:14 piso Exp $
     5 * $Id: Primitives.java,v 1.382 2003-09-10 13:48:14 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    43884388    };
    43894389
    4390     // ### logand
    4391     // logand &rest integers => result-integer
    4392     private static final Primitive LOGAND = new Primitive("logand") {
    4393         public LispObject execute(LispObject first, LispObject second)
    4394             throws LispError
    4395         {
    4396             if (first instanceof Fixnum && second instanceof Fixnum) {
    4397                 return new Fixnum(((Fixnum)first).getValue() &
    4398                                   ((Fixnum)second).getValue());
    4399             } else {
    4400                 BigInteger n1, n2;
    4401                 if (first instanceof Fixnum)
    4402                     n1 = ((Fixnum)first).getBigInteger();
    4403                 else if (first instanceof Bignum)
    4404                     n1 = ((Bignum)first).getValue();
    4405                 else
    4406                     throw new TypeError(first, "integer");
    4407                 if (second instanceof Fixnum)
    4408                     n2 = ((Fixnum)second).getBigInteger();
    4409                 else if (second instanceof Bignum)
    4410                     n2 = ((Bignum)second).getValue();
    4411                 else
    4412                     throw new TypeError(second, "integer");
    4413                 return number(n1.and(n2));
    4414             }
    4415         }
    4416         public LispObject execute(LispObject[] args) throws LispError
    4417         {
    4418             BigInteger result = BigInteger.valueOf(-1);
    4419             for (int i = 0; i < args.length; i++) {
    4420                 BigInteger n;
    4421                 if (args[i] instanceof Fixnum)
    4422                     n = ((Fixnum)args[i]).getBigInteger();
    4423                 else if (args[i] instanceof Bignum)
    4424                     n = ((Bignum)args[i]).getValue();
    4425                 else
    4426                     throw new TypeError(args[i], "integer");
    4427                 result = result.and(n);
    4428             }
    4429             return number(result);
    4430         }
    4431     };
    4432 
    4433     // ### logior
    4434     // logior &rest integers => result-integer
    4435     private static final Primitive LOGIOR = new Primitive("logior") {
    4436         public LispObject execute(LispObject[] args) throws LispError
    4437         {
    4438             BigInteger result = BigInteger.ZERO;
    4439             for (int i = 0; i < args.length; i++) {
    4440                 BigInteger n;
    4441                 if (args[i] instanceof Fixnum)
    4442                     n = ((Fixnum)args[i]).getBigInteger();
    4443                 else if (args[i] instanceof Bignum)
    4444                     n = ((Bignum)args[i]).getValue();
    4445                 else
    4446                     throw new TypeError(args[i], "integer");
    4447                 result = result.or(n);
    4448             }
    4449             return number(result);
    4450         }
    4451     };
    4452 
    4453     // ### lognot
    4454     private static final Primitive1 LOGNOT = new Primitive1("lognot") {
    4455         public LispObject execute(LispObject arg) throws LispError
    4456         {
    4457             if (arg instanceof Fixnum)
    4458                 return number(~((Fixnum)arg).getValue());
    4459             if (arg instanceof Bignum)
    4460                 return number(((Bignum)arg).getValue().not());
    4461             throw new TypeError(arg, "integer");
    4462         }
    4463     };
    4464 
    4465     // ### logbitp
    4466     // logbitp index integer => generalized-boolean
    4467     private static final Primitive2 LOGBITP = new Primitive2("logbitp") {
    4468         public LispObject execute(LispObject first, LispObject second)
    4469             throws LispError
    4470         {
    4471             int index = -1;
    4472             if (first instanceof Fixnum) {
    4473                 index = ((Fixnum)first).getValue();
    4474             } else if (first instanceof Bignum) {
    4475                 // FIXME If the number is really that big, we're not checking
    4476                 // the right bit...
    4477                 if (((Bignum)first).getValue().signum() > 0)
    4478                     index = Integer.MAX_VALUE;
    4479             }
    4480             if (index < 0)
    4481                 throw new TypeError(first, "non-negative integer");
    4482             BigInteger n;
    4483             if (second instanceof Fixnum)
    4484                 n = ((Fixnum)second).getBigInteger();
    4485             else if (second instanceof Bignum)
    4486                 n = ((Bignum)second).getValue();
    4487             else
    4488                 throw new TypeError(second, "integer");
    4489             // FIXME See above.
    4490             if (index == Integer.MAX_VALUE)
    4491                 return n.signum() < 0 ? T : NIL;
    4492             return n.testBit(index) ? T : NIL;
    4493         }
    4494     };
    4495 
    44964390    // ### list
    44974391    private static final Primitive LIST = new Primitive("list") {
Note: See TracChangeset for help on using the changeset viewer.