001: /*
002: * Nil.java
003: *
004: * Copyright (C) 2002-2004 Peter Graves
005: * $Id: Nil.java,v 1.37 2004/05/22 19:31:00 piso Exp $
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021:
022: package org.armedbear.lisp;
023:
024: public final class Nil extends Symbol {
025: public Nil(Package pkg) {
026: super ("NIL", pkg);
027: pkg.addSymbol(this );
028: setSymbolValue(this );
029: setSpecial(true);
030: setConstant(true);
031: }
032:
033: public LispObject typeOf() {
034: return Symbol.NULL;
035: }
036:
037: public LispClass classOf() {
038: return BuiltInClass.NULL;
039: }
040:
041: public LispObject getDescription() {
042: return new SimpleString("The symbol NIL");
043: }
044:
045: public boolean getBooleanValue() {
046: return false;
047: }
048:
049: public LispObject typep(LispObject typeSpecifier)
050: throws ConditionThrowable {
051: if (typeSpecifier == Symbol.NULL)
052: return T;
053: if (typeSpecifier == Symbol.LIST)
054: return T;
055: if (typeSpecifier == Symbol.SEQUENCE)
056: return T;
057: if (typeSpecifier == Symbol.SYMBOL)
058: return T;
059: if (typeSpecifier == Symbol.BOOLEAN)
060: return T;
061: if (typeSpecifier == BuiltInClass.NULL)
062: return T;
063: if (typeSpecifier == BuiltInClass.LIST)
064: return T;
065: if (typeSpecifier == BuiltInClass.SEQUENCE)
066: return T;
067: if (typeSpecifier == BuiltInClass.SYMBOL)
068: return T;
069: return super .typep(typeSpecifier);
070: }
071:
072: public boolean constantp() {
073: return true;
074: }
075:
076: public final LispObject getSymbolValue() {
077: return this ;
078: }
079:
080: public LispObject car() {
081: return this ;
082: }
083:
084: public LispObject cdr() {
085: return this ;
086: }
087:
088: public final LispObject cadr() {
089: return this ;
090: }
091:
092: public final LispObject cddr() {
093: return this ;
094: }
095:
096: public int length() {
097: return 0;
098: }
099:
100: public LispObject push(LispObject obj) {
101: return new Cons(obj);
102: }
103:
104: public LispObject elt(int index) throws ConditionThrowable {
105: return signal(new TypeError("ELT: invalid index " + index
106: + " for " + this + "."));
107: }
108:
109: public LispObject nreverse() {
110: return this ;
111: }
112:
113: public LispObject[] copyToArray() {
114: return new LispObject[0];
115: }
116:
117: public boolean listp() {
118: return true;
119: }
120:
121: public LispObject LISTP() {
122: return T;
123: }
124:
125: public boolean endp() {
126: return true;
127: }
128:
129: public LispObject ENDP() {
130: return T;
131: }
132:
133: public LispObject NOT() {
134: return T;
135: }
136:
137: public final LispObject getSymbolFunction() {
138: return null;
139: }
140:
141: public String toString() {
142: if (_PRINT_READABLY_.symbolValueNoThrow() != NIL)
143: return "|COMMON-LISP|::|NIL|";
144: return "NIL";
145: }
146: }
|