1 21 22 package org.armedbear.lisp; 23 24 public class ArithmeticError extends LispError 25 { 26 private final LispObject operation; 27 private final LispObject operands; 28 29 public ArithmeticError() 30 { 31 operation = NIL; 32 operands = NIL; 33 } 34 35 public ArithmeticError(LispObject initArgs) throws ConditionThrowable 36 { 37 super(initArgs); 38 LispObject operation = NIL; 39 LispObject operands = NIL; 40 LispObject first, second; 41 while (initArgs != NIL) { 42 first = initArgs.car(); 43 initArgs = initArgs.cdr(); 44 second = initArgs.car(); 45 initArgs = initArgs.cdr(); 46 if (first == Keyword.OPERATION) 47 operation = second; 48 else if (first == Keyword.OPERANDS) 49 operands = second; 50 } 51 this.operation = operation; 52 this.operands = operands; 53 } 54 55 public ArithmeticError(String message) 56 { 57 super(message); 58 operation = NIL; 59 operands = NIL; 60 } 61 62 public LispObject typeOf() 63 { 64 return Symbol.ARITHMETIC_ERROR; 65 } 66 67 public LispClass classOf() 68 { 69 return BuiltInClass.ARITHMETIC_ERROR; 70 } 71 72 public LispObject typep(LispObject type) throws ConditionThrowable 73 { 74 if (type == Symbol.ARITHMETIC_ERROR) 75 return T; 76 if (type == BuiltInClass.ARITHMETIC_ERROR) 77 return T; 78 return super.typep(type); 79 } 80 81 private static final Primitive1 ARITHMETIC_ERROR_OPERATION = 83 new Primitive1("arithmetic-error-operation", "condition") 84 { 85 public LispObject execute(LispObject arg) throws ConditionThrowable 86 { 87 try { 88 return ((ArithmeticError)arg).operation; 89 } 90 catch (ClassCastException e) { 91 return signal(new TypeError(arg, Symbol.ARITHMETIC_ERROR)); 92 } 93 } 94 }; 95 private static final Primitive1 ARITHMETIC_ERROR_OPERANDS = 97 new Primitive1("arithmetic-error-operands", "condition") 98 { 99 public LispObject execute(LispObject arg) throws ConditionThrowable 100 { 101 try { 102 return ((ArithmeticError)arg).operands; 103 } 104 catch (ClassCastException e) { 105 return signal(new TypeError(arg, Symbol.ARITHMETIC_ERROR)); 106 } 107 } 108 }; 109 } 110 | Popular Tags |