Changeset 4006
- Timestamp:
- 09/22/03 17:26:40 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/TypeError.java
r3984 r4006 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: TypeError.java,v 1. 8 2003-09-22 02:17:35piso Exp $5 * $Id: TypeError.java,v 1.9 2003-09-22 17:26:40 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 22 22 package org.armedbear.lisp; 23 23 24 public finalclass TypeError extends LispError24 public class TypeError extends LispError 25 25 { 26 private final LispObject object; 27 private final String expectedType; 26 protected LispObject datum; 27 protected LispObject expectedType; 28 private String typeString; 28 29 29 30 public TypeError() 30 31 { 31 this(null, null); 32 } 33 34 public TypeError(LispObject initArgs) throws ConditionThrowable 35 { 36 LispObject datum = NIL; 37 LispObject expectedType = NIL; 38 LispObject first, second; 39 while (initArgs != NIL) { 40 first = initArgs.car(); 41 initArgs = initArgs.cdr(); 42 second = initArgs.car(); 43 initArgs = initArgs.cdr(); 44 if (first == Keyword.DATUM) 45 datum = second; 46 else if (first == Keyword.EXPECTED_TYPE) 47 expectedType = second; 48 } 49 this.datum = datum; 50 this.expectedType = expectedType; 51 this.typeString = String.valueOf(expectedType); 32 52 } 33 53 … … 35 55 { 36 56 super(message); 37 object = null;38 expectedType = null;39 57 } 40 58 41 public TypeError(LispObject object)59 public TypeError(LispObject datum, String typeString) 42 60 { 43 this(object, null); 44 } 45 46 public TypeError(LispObject object, String expectedType) 47 { 48 this.object = object; 49 this.expectedType = expectedType; 61 this.datum = datum; 62 this.typeString = typeString; 50 63 } 51 64 … … 75 88 return s; 76 89 StringBuffer sb = new StringBuffer("wrong type"); 77 String name = object != null ? String.valueOf(object) : null;78 if ( expectedType!= null) {90 String name = datum != null ? String.valueOf(datum) : null; 91 if (typeString != null) { 79 92 if (name == null) 80 name = " object";93 name = "datum"; 81 94 sb.append(": "); 82 95 sb.append(name); 83 96 sb.append(" is not a"); 84 if ("aeiou".indexOf( expectedType.charAt(0)) >= 0)97 if ("aeiou".indexOf(typeString.charAt(0)) >= 0) 85 98 sb.append('n'); 86 99 sb.append(' '); 87 sb.append( expectedType);100 sb.append(typeString); 88 101 } else if (name != null) { 89 102 sb.append(": ");
Note: See TracChangeset
for help on using the changeset viewer.