| 1 | /* | 
|---|
| 2 | * LispObject.java | 
|---|
| 3 | * | 
|---|
| 4 | * Copyright (C) 2002-2007 Peter Graves | 
|---|
| 5 | * $Id: LispObject.java 12637 2010-04-27 20:30:16Z vvoutilainen $ | 
|---|
| 6 | * | 
|---|
| 7 | * This program is free software; you can redistribute it and/or | 
|---|
| 8 | * modify it under the terms of the GNU General Public License | 
|---|
| 9 | * as published by the Free Software Foundation; either version 2 | 
|---|
| 10 | * of the License, or (at your option) any later version. | 
|---|
| 11 | * | 
|---|
| 12 | * This program is distributed in the hope that it will be useful, | 
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 15 | * GNU General Public License for more details. | 
|---|
| 16 | * | 
|---|
| 17 | * You should have received a copy of the GNU General Public License | 
|---|
| 18 | * along with this program; if not, write to the Free Software | 
|---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
| 20 | * | 
|---|
| 21 | * As a special exception, the copyright holders of this library give you | 
|---|
| 22 | * permission to link this library with independent modules to produce an | 
|---|
| 23 | * executable, regardless of the license terms of these independent | 
|---|
| 24 | * modules, and to copy and distribute the resulting executable under | 
|---|
| 25 | * terms of your choice, provided that you also meet, for each linked | 
|---|
| 26 | * independent module, the terms and conditions of the license of that | 
|---|
| 27 | * module.  An independent module is a module which is not derived from | 
|---|
| 28 | * or based on this library.  If you modify this library, you may extend | 
|---|
| 29 | * this exception to your version of the library, but you are not | 
|---|
| 30 | * obligated to do so.  If you do not wish to do so, delete this | 
|---|
| 31 | * exception statement from your version. | 
|---|
| 32 | */ | 
|---|
| 33 |  | 
|---|
| 34 | package org.armedbear.lisp; | 
|---|
| 35 |  | 
|---|
| 36 | import static org.armedbear.lisp.Lisp.*; | 
|---|
| 37 | import java.util.WeakHashMap; | 
|---|
| 38 |  | 
|---|
| 39 | public class LispObject //extends Lisp | 
|---|
| 40 | { | 
|---|
| 41 |  | 
|---|
| 42 | /** Function to allow objects to return the value | 
|---|
| 43 | * "they stand for". Used by AutoloadedFunctionProxy to return | 
|---|
| 44 | * the function it is proxying. | 
|---|
| 45 | */ | 
|---|
| 46 | public LispObject resolve() | 
|---|
| 47 | { | 
|---|
| 48 | return this; | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | public LispObject typeOf() | 
|---|
| 52 | { | 
|---|
| 53 | return T; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | static public LispObject getInstance(boolean b) { | 
|---|
| 57 | return b ? T : NIL; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | public LispObject classOf() | 
|---|
| 61 | { | 
|---|
| 62 | return BuiltInClass.CLASS_T; | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | public LispObject getDescription() | 
|---|
| 66 | { | 
|---|
| 67 | StringBuilder sb = new StringBuilder("An object of type "); | 
|---|
| 68 | sb.append(typeOf().writeToString()); | 
|---|
| 69 | sb.append(" at #x"); | 
|---|
| 70 | sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase()); | 
|---|
| 71 | return new SimpleString(sb); | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 | /** | 
|---|
| 75 | *  Implementing the getParts() protocol will allow INSPECT to | 
|---|
| 76 | *  return information about the substructure of a descendent of | 
|---|
| 77 | *  LispObject. | 
|---|
| 78 | * | 
|---|
| 79 | *  The protocol is to return a List of Cons pairs, where the car of | 
|---|
| 80 | *  each pair contains a decriptive string, and the cdr returns a | 
|---|
| 81 | *  subobject for inspection. | 
|---|
| 82 | */ | 
|---|
| 83 | public LispObject getParts() | 
|---|
| 84 | { | 
|---|
| 85 | return NIL; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | public boolean getBooleanValue() | 
|---|
| 89 | { | 
|---|
| 90 | return true; | 
|---|
| 91 | } | 
|---|
| 92 |  | 
|---|
| 93 | public LispObject typep(LispObject typeSpecifier) | 
|---|
| 94 | { | 
|---|
| 95 | if (typeSpecifier == T) | 
|---|
| 96 | return T; | 
|---|
| 97 | if (typeSpecifier == BuiltInClass.CLASS_T) | 
|---|
| 98 | return T; | 
|---|
| 99 | if (typeSpecifier == Symbol.ATOM) | 
|---|
| 100 | return T; | 
|---|
| 101 | return NIL; | 
|---|
| 102 | } | 
|---|
| 103 |  | 
|---|
| 104 | public boolean constantp() | 
|---|
| 105 | { | 
|---|
| 106 | return true; | 
|---|
| 107 | } | 
|---|
| 108 |  | 
|---|
| 109 | public final LispObject CONSTANTP() | 
|---|
| 110 | { | 
|---|
| 111 | return constantp() ? T : NIL; | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | public final LispObject ATOM() | 
|---|
| 115 | { | 
|---|
| 116 | return atom() ? T : NIL; | 
|---|
| 117 | } | 
|---|
| 118 |  | 
|---|
| 119 | public boolean atom() | 
|---|
| 120 | { | 
|---|
| 121 | return true; | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | public Object javaInstance() | 
|---|
| 125 | { | 
|---|
| 126 | return this; | 
|---|
| 127 | } | 
|---|
| 128 |  | 
|---|
| 129 | public Object javaInstance(Class<?> c) | 
|---|
| 130 | { | 
|---|
| 131 | if (c.isAssignableFrom(getClass())) | 
|---|
| 132 | return this; | 
|---|
| 133 | return error(new LispError("The value " + writeToString() + | 
|---|
| 134 | " is not of class " + c.getName())); | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | /** This method returns 'this' by default, but allows | 
|---|
| 138 | * objects to return different values to increase Java | 
|---|
| 139 | * interoperability | 
|---|
| 140 | * | 
|---|
| 141 | * @return An object to be used with synchronized, wait, notify, etc | 
|---|
| 142 | */ | 
|---|
| 143 | public Object lockableInstance() | 
|---|
| 144 | { | 
|---|
| 145 | return this; | 
|---|
| 146 | } | 
|---|
| 147 |  | 
|---|
| 148 |  | 
|---|
| 149 | public final LispObject car() | 
|---|
| 150 | { | 
|---|
| 151 | if (this instanceof Cons) { | 
|---|
| 152 | return ((Cons)this).car; | 
|---|
| 153 | } else if (this instanceof Nil) { | 
|---|
| 154 | return NIL; | 
|---|
| 155 | } | 
|---|
| 156 | return type_error(this, Symbol.LIST); | 
|---|
| 157 | } | 
|---|
| 158 |  | 
|---|
| 159 | public final void setCar(LispObject obj) | 
|---|
| 160 | { | 
|---|
| 161 | if (this instanceof Cons) { | 
|---|
| 162 | ((Cons)this).car = obj; | 
|---|
| 163 | return; | 
|---|
| 164 | } | 
|---|
| 165 | type_error(this, Symbol.CONS); | 
|---|
| 166 | } | 
|---|
| 167 |  | 
|---|
| 168 | public LispObject RPLACA(LispObject obj) | 
|---|
| 169 | { | 
|---|
| 170 | return type_error(this, Symbol.CONS); | 
|---|
| 171 | } | 
|---|
| 172 |  | 
|---|
| 173 | public final LispObject cdr() | 
|---|
| 174 | { | 
|---|
| 175 | if (this instanceof Cons) { | 
|---|
| 176 | return ((Cons)this).cdr; | 
|---|
| 177 | } else if (this instanceof Nil) { | 
|---|
| 178 | return NIL; | 
|---|
| 179 | } | 
|---|
| 180 | return type_error(this, Symbol.LIST); | 
|---|
| 181 | } | 
|---|
| 182 |  | 
|---|
| 183 | public final void setCdr(LispObject obj) | 
|---|
| 184 | { | 
|---|
| 185 | if (this instanceof Cons) { | 
|---|
| 186 | ((Cons)this).cdr = obj; | 
|---|
| 187 | return; | 
|---|
| 188 | } | 
|---|
| 189 |  | 
|---|
| 190 | type_error(this, Symbol.CONS); | 
|---|
| 191 | } | 
|---|
| 192 |  | 
|---|
| 193 | public LispObject RPLACD(LispObject obj) | 
|---|
| 194 | { | 
|---|
| 195 | return type_error(this, Symbol.CONS); | 
|---|
| 196 | } | 
|---|
| 197 |  | 
|---|
| 198 | public final LispObject cadr() | 
|---|
| 199 | { | 
|---|
| 200 | LispObject tail = cdr(); | 
|---|
| 201 | if (!(tail instanceof Nil)) { | 
|---|
| 202 | return tail.car(); | 
|---|
| 203 | } else | 
|---|
| 204 | return NIL; | 
|---|
| 205 | } | 
|---|
| 206 |  | 
|---|
| 207 | public final LispObject cddr() | 
|---|
| 208 | { | 
|---|
| 209 | LispObject tail = cdr(); | 
|---|
| 210 | if (!(tail instanceof Nil)) { | 
|---|
| 211 | return tail.cdr(); | 
|---|
| 212 | } else | 
|---|
| 213 | return NIL; | 
|---|
| 214 | } | 
|---|
| 215 |  | 
|---|
| 216 | public final LispObject caddr() | 
|---|
| 217 | { | 
|---|
| 218 | LispObject tail = cddr(); | 
|---|
| 219 | if (!(tail instanceof Nil)) { | 
|---|
| 220 | return tail.car(); | 
|---|
| 221 | } else | 
|---|
| 222 | return NIL; | 
|---|
| 223 | } | 
|---|
| 224 |  | 
|---|
| 225 | public final LispObject nthcdr(int n) | 
|---|
| 226 | { | 
|---|
| 227 | if (n < 0) | 
|---|
| 228 | return type_error(Fixnum.getInstance(n), | 
|---|
| 229 | list(Symbol.INTEGER, Fixnum.ZERO)); | 
|---|
| 230 | if (this instanceof Cons) { | 
|---|
| 231 | LispObject result = this; | 
|---|
| 232 | for (int i = n; i-- > 0;) { | 
|---|
| 233 | result = result.cdr(); | 
|---|
| 234 | if (result == NIL) | 
|---|
| 235 | break; | 
|---|
| 236 | } | 
|---|
| 237 | return result; | 
|---|
| 238 | } else if (this instanceof Nil) { | 
|---|
| 239 | return NIL; | 
|---|
| 240 | } | 
|---|
| 241 | return type_error(this, Symbol.LIST); | 
|---|
| 242 | } | 
|---|
| 243 |  | 
|---|
| 244 | public final LispObject push(LispObject obj) | 
|---|
| 245 | { | 
|---|
| 246 | if (this instanceof Cons) { | 
|---|
| 247 | return new Cons(obj, this); | 
|---|
| 248 | } else if (this instanceof Nil) { | 
|---|
| 249 | return new Cons(obj); | 
|---|
| 250 | } | 
|---|
| 251 | return type_error(this, Symbol.LIST); | 
|---|
| 252 | } | 
|---|
| 253 |  | 
|---|
| 254 | final public LispObject EQ(LispObject obj) | 
|---|
| 255 | { | 
|---|
| 256 | return this == obj ? T : NIL; | 
|---|
| 257 | } | 
|---|
| 258 |  | 
|---|
| 259 | public boolean eql(char c) | 
|---|
| 260 | { | 
|---|
| 261 | return false; | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | public boolean eql(int n) | 
|---|
| 265 | { | 
|---|
| 266 | return false; | 
|---|
| 267 | } | 
|---|
| 268 |  | 
|---|
| 269 | public boolean eql(LispObject obj) | 
|---|
| 270 | { | 
|---|
| 271 | return this == obj; | 
|---|
| 272 | } | 
|---|
| 273 |  | 
|---|
| 274 | public final LispObject EQL(LispObject obj) | 
|---|
| 275 | { | 
|---|
| 276 | return eql(obj) ? T : NIL; | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 | public final LispObject EQUAL(LispObject obj) | 
|---|
| 280 | { | 
|---|
| 281 | return equal(obj) ? T : NIL; | 
|---|
| 282 | } | 
|---|
| 283 |  | 
|---|
| 284 | public boolean equal(int n) | 
|---|
| 285 | { | 
|---|
| 286 | return false; | 
|---|
| 287 | } | 
|---|
| 288 |  | 
|---|
| 289 | public boolean equal(LispObject obj) | 
|---|
| 290 | { | 
|---|
| 291 | return this == obj; | 
|---|
| 292 | } | 
|---|
| 293 |  | 
|---|
| 294 | public boolean equalp(int n) | 
|---|
| 295 | { | 
|---|
| 296 | return false; | 
|---|
| 297 | } | 
|---|
| 298 |  | 
|---|
| 299 | public boolean equalp(LispObject obj) | 
|---|
| 300 | { | 
|---|
| 301 | return this == obj; | 
|---|
| 302 | } | 
|---|
| 303 |  | 
|---|
| 304 | public LispObject ABS() | 
|---|
| 305 | { | 
|---|
| 306 | return type_error(this, Symbol.NUMBER); | 
|---|
| 307 | } | 
|---|
| 308 |  | 
|---|
| 309 | public LispObject NUMERATOR() | 
|---|
| 310 | { | 
|---|
| 311 | return type_error(this, Symbol.RATIONAL); | 
|---|
| 312 | } | 
|---|
| 313 |  | 
|---|
| 314 | public LispObject DENOMINATOR() | 
|---|
| 315 | { | 
|---|
| 316 | return type_error(this, Symbol.RATIONAL); | 
|---|
| 317 | } | 
|---|
| 318 |  | 
|---|
| 319 | public final LispObject EVENP() | 
|---|
| 320 | { | 
|---|
| 321 | return evenp() ? T : NIL; | 
|---|
| 322 | } | 
|---|
| 323 |  | 
|---|
| 324 | public boolean evenp() | 
|---|
| 325 | { | 
|---|
| 326 | type_error(this, Symbol.INTEGER); | 
|---|
| 327 | // Not reached. | 
|---|
| 328 | return false; | 
|---|
| 329 | } | 
|---|
| 330 |  | 
|---|
| 331 | public final LispObject ODDP() | 
|---|
| 332 | { | 
|---|
| 333 | return oddp() ? T : NIL; | 
|---|
| 334 | } | 
|---|
| 335 |  | 
|---|
| 336 | public boolean oddp() | 
|---|
| 337 | { | 
|---|
| 338 | type_error(this, Symbol.INTEGER); | 
|---|
| 339 | // Not reached. | 
|---|
| 340 | return false; | 
|---|
| 341 | } | 
|---|
| 342 |  | 
|---|
| 343 | public final LispObject PLUSP() | 
|---|
| 344 | { | 
|---|
| 345 | return plusp() ? T : NIL; | 
|---|
| 346 | } | 
|---|
| 347 |  | 
|---|
| 348 | public boolean plusp() | 
|---|
| 349 | { | 
|---|
| 350 | type_error(this, Symbol.REAL); | 
|---|
| 351 | // Not reached. | 
|---|
| 352 | return false; | 
|---|
| 353 | } | 
|---|
| 354 |  | 
|---|
| 355 | public final LispObject MINUSP() | 
|---|
| 356 | { | 
|---|
| 357 | return minusp() ? T : NIL; | 
|---|
| 358 | } | 
|---|
| 359 |  | 
|---|
| 360 | public boolean minusp() | 
|---|
| 361 | { | 
|---|
| 362 | type_error(this, Symbol.REAL); | 
|---|
| 363 | // Not reached. | 
|---|
| 364 | return false; | 
|---|
| 365 | } | 
|---|
| 366 |  | 
|---|
| 367 | public final LispObject NUMBERP() | 
|---|
| 368 | { | 
|---|
| 369 | return numberp() ? T : NIL; | 
|---|
| 370 | } | 
|---|
| 371 |  | 
|---|
| 372 | public boolean numberp() | 
|---|
| 373 | { | 
|---|
| 374 | return false; | 
|---|
| 375 | } | 
|---|
| 376 |  | 
|---|
| 377 | public final LispObject ZEROP() | 
|---|
| 378 | { | 
|---|
| 379 | return zerop() ? T : NIL; | 
|---|
| 380 | } | 
|---|
| 381 |  | 
|---|
| 382 | public boolean zerop() | 
|---|
| 383 | { | 
|---|
| 384 | type_error(this, Symbol.NUMBER); | 
|---|
| 385 | // Not reached. | 
|---|
| 386 | return false; | 
|---|
| 387 | } | 
|---|
| 388 |  | 
|---|
| 389 | public LispObject COMPLEXP() | 
|---|
| 390 | { | 
|---|
| 391 | return NIL; | 
|---|
| 392 | } | 
|---|
| 393 |  | 
|---|
| 394 | public final LispObject FLOATP() | 
|---|
| 395 | { | 
|---|
| 396 | return floatp() ? T : NIL; | 
|---|
| 397 | } | 
|---|
| 398 |  | 
|---|
| 399 | public boolean floatp() | 
|---|
| 400 | { | 
|---|
| 401 | return false; | 
|---|
| 402 | } | 
|---|
| 403 |  | 
|---|
| 404 | public final LispObject INTEGERP() | 
|---|
| 405 | { | 
|---|
| 406 | return integerp() ? T : NIL; | 
|---|
| 407 | } | 
|---|
| 408 |  | 
|---|
| 409 | public boolean integerp() | 
|---|
| 410 | { | 
|---|
| 411 | return false; | 
|---|
| 412 | } | 
|---|
| 413 |  | 
|---|
| 414 | public final LispObject RATIONALP() | 
|---|
| 415 | { | 
|---|
| 416 | return rationalp() ? T : NIL; | 
|---|
| 417 | } | 
|---|
| 418 |  | 
|---|
| 419 | public boolean rationalp() | 
|---|
| 420 | { | 
|---|
| 421 | return false; | 
|---|
| 422 | } | 
|---|
| 423 |  | 
|---|
| 424 | public final LispObject REALP() | 
|---|
| 425 | { | 
|---|
| 426 | return realp() ? T : NIL; | 
|---|
| 427 | } | 
|---|
| 428 |  | 
|---|
| 429 | public boolean realp() | 
|---|
| 430 | { | 
|---|
| 431 | return false; | 
|---|
| 432 | } | 
|---|
| 433 |  | 
|---|
| 434 | public final LispObject STRINGP() | 
|---|
| 435 | { | 
|---|
| 436 | return stringp() ? T : NIL; | 
|---|
| 437 | } | 
|---|
| 438 |  | 
|---|
| 439 | public boolean stringp() | 
|---|
| 440 | { | 
|---|
| 441 | return false; | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | public LispObject SIMPLE_STRING_P() | 
|---|
| 445 | { | 
|---|
| 446 | return NIL; | 
|---|
| 447 | } | 
|---|
| 448 |  | 
|---|
| 449 | public final LispObject VECTORP() | 
|---|
| 450 | { | 
|---|
| 451 | return vectorp() ? T : NIL; | 
|---|
| 452 | } | 
|---|
| 453 |  | 
|---|
| 454 | public boolean vectorp() | 
|---|
| 455 | { | 
|---|
| 456 | return false; | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | public final LispObject CHARACTERP() | 
|---|
| 460 | { | 
|---|
| 461 | return characterp() ? T : NIL; | 
|---|
| 462 | } | 
|---|
| 463 |  | 
|---|
| 464 | public boolean characterp() | 
|---|
| 465 | { | 
|---|
| 466 | return false; | 
|---|
| 467 | } | 
|---|
| 468 |  | 
|---|
| 469 | public int length() | 
|---|
| 470 | { | 
|---|
| 471 | type_error(this, Symbol.SEQUENCE); | 
|---|
| 472 | // Not reached. | 
|---|
| 473 | return 0; | 
|---|
| 474 | } | 
|---|
| 475 |  | 
|---|
| 476 | public final LispObject LENGTH() | 
|---|
| 477 | { | 
|---|
| 478 | return Fixnum.getInstance(length()); | 
|---|
| 479 | } | 
|---|
| 480 |  | 
|---|
| 481 | public LispObject CHAR(int index) | 
|---|
| 482 | { | 
|---|
| 483 | return type_error(this, Symbol.STRING); | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | public LispObject SCHAR(int index) | 
|---|
| 487 | { | 
|---|
| 488 | return type_error(this, Symbol.SIMPLE_STRING); | 
|---|
| 489 | } | 
|---|
| 490 |  | 
|---|
| 491 | public LispObject NTH(int index) | 
|---|
| 492 | { | 
|---|
| 493 | return type_error(this, Symbol.LIST); | 
|---|
| 494 | } | 
|---|
| 495 |  | 
|---|
| 496 | public final LispObject NTH(LispObject arg) | 
|---|
| 497 | { | 
|---|
| 498 | return NTH(Fixnum.getValue(arg)); | 
|---|
| 499 | } | 
|---|
| 500 |  | 
|---|
| 501 | public LispObject elt(int index) | 
|---|
| 502 | { | 
|---|
| 503 | return type_error(this, Symbol.SEQUENCE); | 
|---|
| 504 | } | 
|---|
| 505 |  | 
|---|
| 506 | public LispObject reverse() | 
|---|
| 507 | { | 
|---|
| 508 | return type_error(this, Symbol.SEQUENCE); | 
|---|
| 509 | } | 
|---|
| 510 |  | 
|---|
| 511 | public LispObject nreverse() | 
|---|
| 512 | { | 
|---|
| 513 | return type_error(this, Symbol.SEQUENCE); | 
|---|
| 514 | } | 
|---|
| 515 |  | 
|---|
| 516 | public long aref_long(int index) | 
|---|
| 517 | { | 
|---|
| 518 | return AREF(index).longValue(); | 
|---|
| 519 | } | 
|---|
| 520 |  | 
|---|
| 521 | public int aref(int index) | 
|---|
| 522 | { | 
|---|
| 523 | return AREF(index).intValue(); | 
|---|
| 524 | } | 
|---|
| 525 |  | 
|---|
| 526 | public LispObject AREF(int index) | 
|---|
| 527 | { | 
|---|
| 528 | return type_error(this, Symbol.ARRAY); | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | public final LispObject AREF(LispObject index) | 
|---|
| 532 | { | 
|---|
| 533 | return AREF(Fixnum.getValue(index)); | 
|---|
| 534 | } | 
|---|
| 535 |  | 
|---|
| 536 | public void aset(int index, int n) | 
|---|
| 537 |  | 
|---|
| 538 | { | 
|---|
| 539 | aset(index, Fixnum.getInstance(n)); | 
|---|
| 540 | } | 
|---|
| 541 |  | 
|---|
| 542 | public void aset(int index, LispObject newValue) | 
|---|
| 543 |  | 
|---|
| 544 | { | 
|---|
| 545 | type_error(this, Symbol.ARRAY); | 
|---|
| 546 | } | 
|---|
| 547 |  | 
|---|
| 548 | public final void aset(LispObject index, LispObject newValue) | 
|---|
| 549 |  | 
|---|
| 550 | { | 
|---|
| 551 | aset(Fixnum.getValue(index), newValue); | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 | public LispObject SVREF(int index) | 
|---|
| 555 | { | 
|---|
| 556 | return type_error(this, Symbol.SIMPLE_VECTOR); | 
|---|
| 557 | } | 
|---|
| 558 |  | 
|---|
| 559 | public void svset(int index, LispObject newValue) | 
|---|
| 560 | { | 
|---|
| 561 | type_error(this, Symbol.SIMPLE_VECTOR); | 
|---|
| 562 | } | 
|---|
| 563 |  | 
|---|
| 564 | public void vectorPushExtend(LispObject element) | 
|---|
| 565 |  | 
|---|
| 566 | { | 
|---|
| 567 | noFillPointer(); | 
|---|
| 568 | } | 
|---|
| 569 |  | 
|---|
| 570 | public LispObject VECTOR_PUSH_EXTEND(LispObject element) | 
|---|
| 571 |  | 
|---|
| 572 | { | 
|---|
| 573 | return noFillPointer(); | 
|---|
| 574 | } | 
|---|
| 575 |  | 
|---|
| 576 | public LispObject VECTOR_PUSH_EXTEND(LispObject element, LispObject extension) | 
|---|
| 577 |  | 
|---|
| 578 | { | 
|---|
| 579 | return noFillPointer(); | 
|---|
| 580 | } | 
|---|
| 581 |  | 
|---|
| 582 | public final LispObject noFillPointer() | 
|---|
| 583 | { | 
|---|
| 584 | return type_error(this, list(Symbol.AND, Symbol.VECTOR, | 
|---|
| 585 | list(Symbol.SATISFIES, | 
|---|
| 586 | Symbol.ARRAY_HAS_FILL_POINTER_P))); | 
|---|
| 587 | } | 
|---|
| 588 |  | 
|---|
| 589 | public LispObject[] copyToArray() | 
|---|
| 590 | { | 
|---|
| 591 | type_error(this, Symbol.LIST); | 
|---|
| 592 | // Not reached. | 
|---|
| 593 | return null; | 
|---|
| 594 | } | 
|---|
| 595 |  | 
|---|
| 596 | public final LispObject SYMBOLP() | 
|---|
| 597 | { | 
|---|
| 598 | return (this instanceof Symbol) ? T : NIL; | 
|---|
| 599 | } | 
|---|
| 600 |  | 
|---|
| 601 | public final boolean listp() | 
|---|
| 602 | { | 
|---|
| 603 | return (this instanceof Cons) || (this instanceof Nil); | 
|---|
| 604 | } | 
|---|
| 605 |  | 
|---|
| 606 | public final LispObject LISTP() | 
|---|
| 607 | { | 
|---|
| 608 | return listp() ? T : NIL; | 
|---|
| 609 | } | 
|---|
| 610 |  | 
|---|
| 611 | public final boolean endp() | 
|---|
| 612 | { | 
|---|
| 613 | if (this instanceof Cons) | 
|---|
| 614 | return false; | 
|---|
| 615 | else if (this instanceof Nil) | 
|---|
| 616 | return true; | 
|---|
| 617 | type_error(this, Symbol.LIST); | 
|---|
| 618 | // Not reached. | 
|---|
| 619 | return false; | 
|---|
| 620 | } | 
|---|
| 621 |  | 
|---|
| 622 | public final LispObject ENDP() | 
|---|
| 623 | { | 
|---|
| 624 | return endp() ? T : NIL; | 
|---|
| 625 | } | 
|---|
| 626 |  | 
|---|
| 627 | public LispObject NOT() | 
|---|
| 628 | { | 
|---|
| 629 | return NIL; | 
|---|
| 630 | } | 
|---|
| 631 |  | 
|---|
| 632 | public boolean isSpecialOperator() | 
|---|
| 633 | { | 
|---|
| 634 | type_error(this, Symbol.SYMBOL); | 
|---|
| 635 | // Not reached. | 
|---|
| 636 | return false; | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 | public boolean isSpecialVariable() | 
|---|
| 640 | { | 
|---|
| 641 | return false; | 
|---|
| 642 | } | 
|---|
| 643 |  | 
|---|
| 644 | private static final WeakHashMap<LispObject, LispObject> | 
|---|
| 645 | documentationHashTable = new WeakHashMap<LispObject, LispObject>(); | 
|---|
| 646 |  | 
|---|
| 647 | public LispObject getDocumentation(LispObject docType) | 
|---|
| 648 |  | 
|---|
| 649 | { | 
|---|
| 650 | LispObject alist; | 
|---|
| 651 | synchronized (documentationHashTable) { | 
|---|
| 652 | alist = documentationHashTable.get(this); | 
|---|
| 653 | } | 
|---|
| 654 | if (alist != null) | 
|---|
| 655 | { | 
|---|
| 656 | LispObject entry = assq(docType, alist); | 
|---|
| 657 | if (entry instanceof Cons) | 
|---|
| 658 | return ((Cons)entry).cdr; | 
|---|
| 659 | } | 
|---|
| 660 | return NIL; | 
|---|
| 661 | } | 
|---|
| 662 |  | 
|---|
| 663 | public void setDocumentation(LispObject docType, LispObject documentation) | 
|---|
| 664 |  | 
|---|
| 665 | { | 
|---|
| 666 | synchronized (documentationHashTable) { | 
|---|
| 667 | LispObject alist = documentationHashTable.get(this); | 
|---|
| 668 | if (alist == null) | 
|---|
| 669 | alist = NIL; | 
|---|
| 670 | LispObject entry = assq(docType, alist); | 
|---|
| 671 | if (entry instanceof Cons) | 
|---|
| 672 | { | 
|---|
| 673 | ((Cons)entry).cdr = documentation; | 
|---|
| 674 | } | 
|---|
| 675 | else | 
|---|
| 676 | { | 
|---|
| 677 | alist = alist.push(new Cons(docType, documentation)); | 
|---|
| 678 | documentationHashTable.put(this, alist); | 
|---|
| 679 | } | 
|---|
| 680 | } | 
|---|
| 681 | } | 
|---|
| 682 |  | 
|---|
| 683 | public LispObject getPropertyList() | 
|---|
| 684 | { | 
|---|
| 685 | return null; | 
|---|
| 686 | } | 
|---|
| 687 |  | 
|---|
| 688 | public void setPropertyList(LispObject obj) | 
|---|
| 689 | { | 
|---|
| 690 | } | 
|---|
| 691 |  | 
|---|
| 692 | public LispObject getSymbolValue() | 
|---|
| 693 | { | 
|---|
| 694 | return type_error(this, Symbol.SYMBOL); | 
|---|
| 695 | } | 
|---|
| 696 |  | 
|---|
| 697 | public LispObject getSymbolFunction() | 
|---|
| 698 | { | 
|---|
| 699 | return type_error(this, Symbol.SYMBOL); | 
|---|
| 700 | } | 
|---|
| 701 |  | 
|---|
| 702 | public LispObject getSymbolFunctionOrDie() | 
|---|
| 703 | { | 
|---|
| 704 | return type_error(this, Symbol.SYMBOL); | 
|---|
| 705 | } | 
|---|
| 706 |  | 
|---|
| 707 | public LispObject getSymbolSetfFunction() | 
|---|
| 708 | { | 
|---|
| 709 | return type_error(this, Symbol.SYMBOL); | 
|---|
| 710 | } | 
|---|
| 711 |  | 
|---|
| 712 | public LispObject getSymbolSetfFunctionOrDie() | 
|---|
| 713 | { | 
|---|
| 714 | return type_error(this, Symbol.SYMBOL); | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | public String writeToString() | 
|---|
| 718 | { | 
|---|
| 719 | return toString(); | 
|---|
| 720 | } | 
|---|
| 721 |  | 
|---|
| 722 | public final String unreadableString(String s) { | 
|---|
| 723 | return unreadableString(s, true); | 
|---|
| 724 | } | 
|---|
| 725 | public final String unreadableString(Symbol sym) { | 
|---|
| 726 | return unreadableString(sym, true); | 
|---|
| 727 | } | 
|---|
| 728 |  | 
|---|
| 729 | public final String unreadableString(String s, boolean identity) | 
|---|
| 730 | { | 
|---|
| 731 | StringBuilder sb = new StringBuilder("#<"); | 
|---|
| 732 | sb.append(s); | 
|---|
| 733 | if (identity) { | 
|---|
| 734 | sb.append(" {"); | 
|---|
| 735 | sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase()); | 
|---|
| 736 | sb.append("}"); | 
|---|
| 737 | } | 
|---|
| 738 | sb.append(">"); | 
|---|
| 739 | return sb.toString(); | 
|---|
| 740 | } | 
|---|
| 741 |  | 
|---|
| 742 | public final String unreadableString(Symbol symbol, boolean identity) | 
|---|
| 743 |  | 
|---|
| 744 | { | 
|---|
| 745 | return unreadableString(symbol.writeToString(), identity); | 
|---|
| 746 | } | 
|---|
| 747 |  | 
|---|
| 748 | // Special operator | 
|---|
| 749 | public LispObject execute(LispObject args, Environment env) | 
|---|
| 750 |  | 
|---|
| 751 | { | 
|---|
| 752 | return error(new LispError()); | 
|---|
| 753 | } | 
|---|
| 754 |  | 
|---|
| 755 | public LispObject execute() | 
|---|
| 756 | { | 
|---|
| 757 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 758 | } | 
|---|
| 759 |  | 
|---|
| 760 | public LispObject execute(LispObject arg) | 
|---|
| 761 | { | 
|---|
| 762 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 763 | } | 
|---|
| 764 |  | 
|---|
| 765 | public LispObject execute(LispObject first, LispObject second) | 
|---|
| 766 |  | 
|---|
| 767 | { | 
|---|
| 768 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 769 | } | 
|---|
| 770 |  | 
|---|
| 771 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 772 | LispObject third) | 
|---|
| 773 |  | 
|---|
| 774 | { | 
|---|
| 775 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 776 | } | 
|---|
| 777 |  | 
|---|
| 778 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 779 | LispObject third, LispObject fourth) | 
|---|
| 780 |  | 
|---|
| 781 | { | 
|---|
| 782 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 783 | } | 
|---|
| 784 |  | 
|---|
| 785 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 786 | LispObject third, LispObject fourth, | 
|---|
| 787 | LispObject fifth) | 
|---|
| 788 |  | 
|---|
| 789 | { | 
|---|
| 790 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 791 | } | 
|---|
| 792 |  | 
|---|
| 793 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 794 | LispObject third, LispObject fourth, | 
|---|
| 795 | LispObject fifth, LispObject sixth) | 
|---|
| 796 |  | 
|---|
| 797 | { | 
|---|
| 798 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 799 | } | 
|---|
| 800 |  | 
|---|
| 801 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 802 | LispObject third, LispObject fourth, | 
|---|
| 803 | LispObject fifth, LispObject sixth, | 
|---|
| 804 | LispObject seventh) | 
|---|
| 805 |  | 
|---|
| 806 | { | 
|---|
| 807 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 808 | } | 
|---|
| 809 |  | 
|---|
| 810 | public LispObject execute(LispObject first, LispObject second, | 
|---|
| 811 | LispObject third, LispObject fourth, | 
|---|
| 812 | LispObject fifth, LispObject sixth, | 
|---|
| 813 | LispObject seventh, LispObject eighth) | 
|---|
| 814 |  | 
|---|
| 815 | { | 
|---|
| 816 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 817 | } | 
|---|
| 818 |  | 
|---|
| 819 | public LispObject execute(LispObject[] args) | 
|---|
| 820 | { | 
|---|
| 821 | return type_error(this, Symbol.FUNCTION); | 
|---|
| 822 | } | 
|---|
| 823 |  | 
|---|
| 824 | // Used by COMPILE-MULTIPLE-VALUE-CALL. | 
|---|
| 825 | public LispObject dispatch(LispObject[] args) | 
|---|
| 826 | { | 
|---|
| 827 | switch (args.length) | 
|---|
| 828 | { | 
|---|
| 829 | case 0: | 
|---|
| 830 | return execute(); | 
|---|
| 831 | case 1: | 
|---|
| 832 | return execute(args[0]); | 
|---|
| 833 | case 2: | 
|---|
| 834 | return execute(args[0], args[1]); | 
|---|
| 835 | case 3: | 
|---|
| 836 | return execute(args[0], args[1], args[2]); | 
|---|
| 837 | case 4: | 
|---|
| 838 | return execute(args[0], args[1], args[2], args[3]); | 
|---|
| 839 | case 5: | 
|---|
| 840 | return execute(args[0], args[1], args[2], args[3], args[4]); | 
|---|
| 841 | case 6: | 
|---|
| 842 | return execute(args[0], args[1], args[2], args[3], args[4], | 
|---|
| 843 | args[5]); | 
|---|
| 844 | case 7: | 
|---|
| 845 | return execute(args[0], args[1], args[2], args[3], args[4], | 
|---|
| 846 | args[5], args[6]); | 
|---|
| 847 | case 8: | 
|---|
| 848 | return execute(args[0], args[1], args[2], args[3], args[4], | 
|---|
| 849 | args[5], args[6], args[7]); | 
|---|
| 850 | default: | 
|---|
| 851 | return execute(args); | 
|---|
| 852 | } | 
|---|
| 853 | } | 
|---|
| 854 |  | 
|---|
| 855 | public int intValue() | 
|---|
| 856 | { | 
|---|
| 857 | type_error(this, Symbol.INTEGER); | 
|---|
| 858 | // Not reached. | 
|---|
| 859 | return 0; | 
|---|
| 860 | } | 
|---|
| 861 |  | 
|---|
| 862 | public long longValue() | 
|---|
| 863 | { | 
|---|
| 864 | type_error(this, Symbol.INTEGER); | 
|---|
| 865 | // Not reached. | 
|---|
| 866 | return 0; | 
|---|
| 867 | } | 
|---|
| 868 |  | 
|---|
| 869 | public float floatValue() | 
|---|
| 870 | { | 
|---|
| 871 | type_error(this, Symbol.SINGLE_FLOAT); | 
|---|
| 872 | // Not reached | 
|---|
| 873 | return 0; | 
|---|
| 874 | } | 
|---|
| 875 |  | 
|---|
| 876 | public double doubleValue() | 
|---|
| 877 | { | 
|---|
| 878 | type_error(this, Symbol.DOUBLE_FLOAT); | 
|---|
| 879 | // Not reached | 
|---|
| 880 | return 0; | 
|---|
| 881 | } | 
|---|
| 882 |  | 
|---|
| 883 | public LispObject incr() | 
|---|
| 884 | { | 
|---|
| 885 | return type_error(this, Symbol.NUMBER); | 
|---|
| 886 | } | 
|---|
| 887 |  | 
|---|
| 888 | public LispObject decr() | 
|---|
| 889 | { | 
|---|
| 890 | return type_error(this, Symbol.NUMBER); | 
|---|
| 891 | } | 
|---|
| 892 |  | 
|---|
| 893 | public LispObject negate() | 
|---|
| 894 | { | 
|---|
| 895 | return Fixnum.ZERO.subtract(this); | 
|---|
| 896 | } | 
|---|
| 897 |  | 
|---|
| 898 | public LispObject add(int n) | 
|---|
| 899 | { | 
|---|
| 900 | return add(Fixnum.getInstance(n)); | 
|---|
| 901 | } | 
|---|
| 902 |  | 
|---|
| 903 | public LispObject add(LispObject obj) | 
|---|
| 904 | { | 
|---|
| 905 | return type_error(this, Symbol.NUMBER); | 
|---|
| 906 | } | 
|---|
| 907 |  | 
|---|
| 908 | public LispObject subtract(int n) | 
|---|
| 909 | { | 
|---|
| 910 | return subtract(Fixnum.getInstance(n)); | 
|---|
| 911 | } | 
|---|
| 912 |  | 
|---|
| 913 | public LispObject subtract(LispObject obj) | 
|---|
| 914 | { | 
|---|
| 915 | return type_error(this, Symbol.NUMBER); | 
|---|
| 916 | } | 
|---|
| 917 |  | 
|---|
| 918 | public LispObject multiplyBy(int n) | 
|---|
| 919 | { | 
|---|
| 920 | return multiplyBy(Fixnum.getInstance(n)); | 
|---|
| 921 | } | 
|---|
| 922 |  | 
|---|
| 923 | public LispObject multiplyBy(LispObject obj) | 
|---|
| 924 | { | 
|---|
| 925 | return type_error(this, Symbol.NUMBER); | 
|---|
| 926 | } | 
|---|
| 927 |  | 
|---|
| 928 | public LispObject divideBy(LispObject obj) | 
|---|
| 929 | { | 
|---|
| 930 | return type_error(this, Symbol.NUMBER); | 
|---|
| 931 | } | 
|---|
| 932 |  | 
|---|
| 933 | public boolean isEqualTo(int n) | 
|---|
| 934 | { | 
|---|
| 935 | return isEqualTo(Fixnum.getInstance(n)); | 
|---|
| 936 | } | 
|---|
| 937 |  | 
|---|
| 938 | public boolean isEqualTo(LispObject obj) | 
|---|
| 939 | { | 
|---|
| 940 | type_error(this, Symbol.NUMBER); | 
|---|
| 941 | // Not reached. | 
|---|
| 942 | return false; | 
|---|
| 943 | } | 
|---|
| 944 |  | 
|---|
| 945 | public final LispObject IS_E(LispObject obj) | 
|---|
| 946 | { | 
|---|
| 947 | return isEqualTo(obj) ? T : NIL; | 
|---|
| 948 | } | 
|---|
| 949 |  | 
|---|
| 950 | public boolean isNotEqualTo(int n) | 
|---|
| 951 | { | 
|---|
| 952 | return isNotEqualTo(Fixnum.getInstance(n)); | 
|---|
| 953 | } | 
|---|
| 954 |  | 
|---|
| 955 | public boolean isNotEqualTo(LispObject obj) | 
|---|
| 956 | { | 
|---|
| 957 | type_error(this, Symbol.NUMBER); | 
|---|
| 958 | // Not reached. | 
|---|
| 959 | return false; | 
|---|
| 960 | } | 
|---|
| 961 |  | 
|---|
| 962 | public final LispObject IS_NE(LispObject obj) | 
|---|
| 963 | { | 
|---|
| 964 | return isNotEqualTo(obj) ? T : NIL; | 
|---|
| 965 | } | 
|---|
| 966 |  | 
|---|
| 967 | public boolean isLessThan(int n) | 
|---|
| 968 | { | 
|---|
| 969 | return isLessThan(Fixnum.getInstance(n)); | 
|---|
| 970 | } | 
|---|
| 971 |  | 
|---|
| 972 | public boolean isLessThan(LispObject obj) | 
|---|
| 973 | { | 
|---|
| 974 | type_error(this, Symbol.REAL); | 
|---|
| 975 | // Not reached. | 
|---|
| 976 | return false; | 
|---|
| 977 | } | 
|---|
| 978 |  | 
|---|
| 979 | public final LispObject IS_LT(LispObject obj) | 
|---|
| 980 | { | 
|---|
| 981 | return isLessThan(obj) ? T : NIL; | 
|---|
| 982 | } | 
|---|
| 983 |  | 
|---|
| 984 | public boolean isGreaterThan(int n) | 
|---|
| 985 | { | 
|---|
| 986 | return isGreaterThan(Fixnum.getInstance(n)); | 
|---|
| 987 | } | 
|---|
| 988 |  | 
|---|
| 989 | public boolean isGreaterThan(LispObject obj) | 
|---|
| 990 | { | 
|---|
| 991 | type_error(this, Symbol.REAL); | 
|---|
| 992 | // Not reached. | 
|---|
| 993 | return false; | 
|---|
| 994 | } | 
|---|
| 995 |  | 
|---|
| 996 | public final LispObject IS_GT(LispObject obj) | 
|---|
| 997 | { | 
|---|
| 998 | return isGreaterThan(obj) ? T : NIL; | 
|---|
| 999 | } | 
|---|
| 1000 |  | 
|---|
| 1001 | public boolean isLessThanOrEqualTo(int n) | 
|---|
| 1002 | { | 
|---|
| 1003 | return isLessThanOrEqualTo(Fixnum.getInstance(n)); | 
|---|
| 1004 | } | 
|---|
| 1005 |  | 
|---|
| 1006 | public boolean isLessThanOrEqualTo(LispObject obj) | 
|---|
| 1007 | { | 
|---|
| 1008 | type_error(this, Symbol.REAL); | 
|---|
| 1009 | // Not reached. | 
|---|
| 1010 | return false; | 
|---|
| 1011 | } | 
|---|
| 1012 |  | 
|---|
| 1013 | public final LispObject IS_LE(LispObject obj) | 
|---|
| 1014 | { | 
|---|
| 1015 | return isLessThanOrEqualTo(obj) ? T : NIL; | 
|---|
| 1016 | } | 
|---|
| 1017 |  | 
|---|
| 1018 | public boolean isGreaterThanOrEqualTo(int n) | 
|---|
| 1019 | { | 
|---|
| 1020 | return isGreaterThanOrEqualTo(Fixnum.getInstance(n)); | 
|---|
| 1021 | } | 
|---|
| 1022 |  | 
|---|
| 1023 | public boolean isGreaterThanOrEqualTo(LispObject obj) | 
|---|
| 1024 | { | 
|---|
| 1025 | type_error(this, Symbol.REAL); | 
|---|
| 1026 | // Not reached. | 
|---|
| 1027 | return false; | 
|---|
| 1028 | } | 
|---|
| 1029 |  | 
|---|
| 1030 | public final LispObject IS_GE(LispObject obj) | 
|---|
| 1031 | { | 
|---|
| 1032 | return isGreaterThanOrEqualTo(obj) ? T : NIL; | 
|---|
| 1033 | } | 
|---|
| 1034 |  | 
|---|
| 1035 | public LispObject truncate(LispObject obj) | 
|---|
| 1036 | { | 
|---|
| 1037 | return type_error(this, Symbol.REAL); | 
|---|
| 1038 | } | 
|---|
| 1039 |  | 
|---|
| 1040 | public LispObject MOD(LispObject divisor) | 
|---|
| 1041 | { | 
|---|
| 1042 | truncate(divisor); | 
|---|
| 1043 | final LispThread thread = LispThread.currentThread(); | 
|---|
| 1044 | LispObject remainder = thread._values[1]; | 
|---|
| 1045 | thread.clearValues(); | 
|---|
| 1046 | if (!remainder.zerop()) | 
|---|
| 1047 | { | 
|---|
| 1048 | if (divisor.minusp()) | 
|---|
| 1049 | { | 
|---|
| 1050 | if (plusp()) | 
|---|
| 1051 | return remainder.add(divisor); | 
|---|
| 1052 | } | 
|---|
| 1053 | else | 
|---|
| 1054 | { | 
|---|
| 1055 | if (minusp()) | 
|---|
| 1056 | return remainder.add(divisor); | 
|---|
| 1057 | } | 
|---|
| 1058 | } | 
|---|
| 1059 | return remainder; | 
|---|
| 1060 | } | 
|---|
| 1061 |  | 
|---|
| 1062 | public LispObject MOD(int divisor) | 
|---|
| 1063 | { | 
|---|
| 1064 | return MOD(Fixnum.getInstance(divisor)); | 
|---|
| 1065 | } | 
|---|
| 1066 |  | 
|---|
| 1067 | public LispObject ash(int shift) | 
|---|
| 1068 | { | 
|---|
| 1069 | return ash(Fixnum.getInstance(shift)); | 
|---|
| 1070 | } | 
|---|
| 1071 |  | 
|---|
| 1072 | public LispObject ash(LispObject obj) | 
|---|
| 1073 | { | 
|---|
| 1074 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1075 | } | 
|---|
| 1076 |  | 
|---|
| 1077 | public LispObject LOGNOT() | 
|---|
| 1078 | { | 
|---|
| 1079 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1080 | } | 
|---|
| 1081 |  | 
|---|
| 1082 | public LispObject LOGAND(int n) | 
|---|
| 1083 | { | 
|---|
| 1084 | return LOGAND(Fixnum.getInstance(n)); | 
|---|
| 1085 | } | 
|---|
| 1086 |  | 
|---|
| 1087 | public LispObject LOGAND(LispObject obj) | 
|---|
| 1088 | { | 
|---|
| 1089 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1090 | } | 
|---|
| 1091 |  | 
|---|
| 1092 | public LispObject LOGIOR(int n) | 
|---|
| 1093 | { | 
|---|
| 1094 | return LOGIOR(Fixnum.getInstance(n)); | 
|---|
| 1095 | } | 
|---|
| 1096 |  | 
|---|
| 1097 | public LispObject LOGIOR(LispObject obj) | 
|---|
| 1098 | { | 
|---|
| 1099 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1100 | } | 
|---|
| 1101 |  | 
|---|
| 1102 | public LispObject LOGXOR(int n) | 
|---|
| 1103 | { | 
|---|
| 1104 | return LOGXOR(Fixnum.getInstance(n)); | 
|---|
| 1105 | } | 
|---|
| 1106 |  | 
|---|
| 1107 | public LispObject LOGXOR(LispObject obj) | 
|---|
| 1108 | { | 
|---|
| 1109 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1110 | } | 
|---|
| 1111 |  | 
|---|
| 1112 | public LispObject LDB(int size, int position) | 
|---|
| 1113 | { | 
|---|
| 1114 | return type_error(this, Symbol.INTEGER); | 
|---|
| 1115 | } | 
|---|
| 1116 |  | 
|---|
| 1117 | public int sxhash() | 
|---|
| 1118 | { | 
|---|
| 1119 | return hashCode() & 0x7fffffff; | 
|---|
| 1120 | } | 
|---|
| 1121 |  | 
|---|
| 1122 | // For EQUALP hash tables. | 
|---|
| 1123 | public int psxhash() | 
|---|
| 1124 | { | 
|---|
| 1125 | return sxhash(); | 
|---|
| 1126 | } | 
|---|
| 1127 |  | 
|---|
| 1128 | public int psxhash(int depth) | 
|---|
| 1129 | { | 
|---|
| 1130 | return psxhash(); | 
|---|
| 1131 | } | 
|---|
| 1132 |  | 
|---|
| 1133 | public LispObject STRING() | 
|---|
| 1134 | { | 
|---|
| 1135 | return error(new TypeError(writeToString() + " cannot be coerced to a string.")); | 
|---|
| 1136 | } | 
|---|
| 1137 |  | 
|---|
| 1138 | public char[] chars() | 
|---|
| 1139 | { | 
|---|
| 1140 | type_error(this, Symbol.STRING); | 
|---|
| 1141 | // Not reached. | 
|---|
| 1142 | return null; | 
|---|
| 1143 | } | 
|---|
| 1144 |  | 
|---|
| 1145 | public char[] getStringChars() | 
|---|
| 1146 | { | 
|---|
| 1147 | type_error(this, Symbol.STRING); | 
|---|
| 1148 | // Not reached. | 
|---|
| 1149 | return null; | 
|---|
| 1150 | } | 
|---|
| 1151 |  | 
|---|
| 1152 | /** Returns a string representing the value | 
|---|
| 1153 | * of a 'string designator', if the instance is one. | 
|---|
| 1154 | * | 
|---|
| 1155 | * Throws an error if the instance isn't a string designator. | 
|---|
| 1156 | */ | 
|---|
| 1157 | public String getStringValue() | 
|---|
| 1158 | { | 
|---|
| 1159 | type_error(this, Symbol.STRING); | 
|---|
| 1160 | // Not reached. | 
|---|
| 1161 | return null; | 
|---|
| 1162 | } | 
|---|
| 1163 |  | 
|---|
| 1164 | public LispObject getSlotValue_0() | 
|---|
| 1165 | { | 
|---|
| 1166 | return type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1167 | } | 
|---|
| 1168 |  | 
|---|
| 1169 | public LispObject getSlotValue_1() | 
|---|
| 1170 | { | 
|---|
| 1171 | return type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1172 | } | 
|---|
| 1173 |  | 
|---|
| 1174 | public LispObject getSlotValue_2() | 
|---|
| 1175 | { | 
|---|
| 1176 | return type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1177 | } | 
|---|
| 1178 |  | 
|---|
| 1179 | public LispObject getSlotValue_3() | 
|---|
| 1180 | { | 
|---|
| 1181 | return type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1182 | } | 
|---|
| 1183 |  | 
|---|
| 1184 | public LispObject getSlotValue(int index) | 
|---|
| 1185 | { | 
|---|
| 1186 | return type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1187 | } | 
|---|
| 1188 |  | 
|---|
| 1189 | public int getFixnumSlotValue(int index) | 
|---|
| 1190 | { | 
|---|
| 1191 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1192 | // Not reached. | 
|---|
| 1193 | return 0; | 
|---|
| 1194 | } | 
|---|
| 1195 |  | 
|---|
| 1196 | public boolean getSlotValueAsBoolean(int index) | 
|---|
| 1197 | { | 
|---|
| 1198 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1199 | // Not reached. | 
|---|
| 1200 | return false; | 
|---|
| 1201 | } | 
|---|
| 1202 |  | 
|---|
| 1203 | public void setSlotValue_0(LispObject value) | 
|---|
| 1204 |  | 
|---|
| 1205 | { | 
|---|
| 1206 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1207 | } | 
|---|
| 1208 |  | 
|---|
| 1209 | public void setSlotValue_1(LispObject value) | 
|---|
| 1210 |  | 
|---|
| 1211 | { | 
|---|
| 1212 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1213 | } | 
|---|
| 1214 |  | 
|---|
| 1215 | public void setSlotValue_2(LispObject value) | 
|---|
| 1216 |  | 
|---|
| 1217 | { | 
|---|
| 1218 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1219 | } | 
|---|
| 1220 |  | 
|---|
| 1221 | public void setSlotValue_3(LispObject value) | 
|---|
| 1222 |  | 
|---|
| 1223 | { | 
|---|
| 1224 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1225 | } | 
|---|
| 1226 |  | 
|---|
| 1227 | public void setSlotValue(int index, LispObject value) | 
|---|
| 1228 |  | 
|---|
| 1229 | { | 
|---|
| 1230 | type_error(this, Symbol.STRUCTURE_OBJECT); | 
|---|
| 1231 | } | 
|---|
| 1232 |  | 
|---|
| 1233 | public LispObject SLOT_VALUE(LispObject slotName) | 
|---|
| 1234 | { | 
|---|
| 1235 | return type_error(this, Symbol.STANDARD_OBJECT); | 
|---|
| 1236 | } | 
|---|
| 1237 |  | 
|---|
| 1238 | public void setSlotValue(LispObject slotName, LispObject newValue) | 
|---|
| 1239 |  | 
|---|
| 1240 | { | 
|---|
| 1241 | type_error(this, Symbol.STANDARD_OBJECT); | 
|---|
| 1242 | } | 
|---|
| 1243 |  | 
|---|
| 1244 | // Profiling. | 
|---|
| 1245 | public int getCallCount() | 
|---|
| 1246 | { | 
|---|
| 1247 | return 0; | 
|---|
| 1248 | } | 
|---|
| 1249 |  | 
|---|
| 1250 | public void setCallCount(int n) | 
|---|
| 1251 | { | 
|---|
| 1252 | } | 
|---|
| 1253 |  | 
|---|
| 1254 | public void incrementCallCount() | 
|---|
| 1255 | { | 
|---|
| 1256 | } | 
|---|
| 1257 |  | 
|---|
| 1258 | public int getHotCount() | 
|---|
| 1259 | { | 
|---|
| 1260 | return 0; | 
|---|
| 1261 | } | 
|---|
| 1262 |  | 
|---|
| 1263 | public void setHotCount(int n) | 
|---|
| 1264 | { | 
|---|
| 1265 | } | 
|---|
| 1266 |  | 
|---|
| 1267 | public void incrementHotCount() | 
|---|
| 1268 | { | 
|---|
| 1269 | } | 
|---|
| 1270 | } | 
|---|