Changeset 3906
- Timestamp:
- 09/19/03 17:42:09 (20 years ago)
- Location:
- trunk/j/src/org/armedbear/j
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/JLisp.java
r3805 r3906 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: JLisp.java,v 1.1 2 2003-09-16 00:45:48piso Exp $5 * $Id: JLisp.java,v 1.13 2003-09-19 17:42:09 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 26 26 import java.net.ServerSocket; 27 27 import java.net.Socket; 28 import org.armedbear.lisp.ConditionThrowable; 28 29 import org.armedbear.lisp.Interpreter; 29 import org.armedbear.lisp.Condition;30 30 31 31 public final class JLisp extends LispShell … … 194 194 } 195 195 196 public static void runStartupScript(File file) throws Condition 196 public static void runStartupScript(File file) throws ConditionThrowable 197 197 { 198 198 if (!Editor.isLispInitialized()) { … … 216 216 } 217 217 218 public static void runLispCommand(String command) throws Condition 218 public static void runLispCommand(String command) throws ConditionThrowable 219 219 { 220 220 if (!Editor.isLispInitialized()) { -
trunk/j/src/org/armedbear/j/JVar.java
r2672 r3906 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: JVar.java,v 1. 1 2003-06-30 19:09:20piso Exp $5 * $Id: JVar.java,v 1.2 2003-09-19 17:42:09 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 23 23 24 24 import java.util.ArrayList; 25 import org.armedbear.lisp.ConditionThrowable; 25 26 import org.armedbear.lisp.LispError; 26 27 import org.armedbear.lisp.LispObject; … … 55 56 } 56 57 57 public static JVar getJVar(Symbol symbol) throws LispError58 public static JVar getJVar(Symbol symbol) throws ConditionThrowable 58 59 { 59 60 LispObject obj = get(symbol, J_VARIABLE_VALUE, null); 60 61 if (!(obj instanceof JVar)) 61 throw new LispError(String.valueOf(symbol) +62 " is not defined as an editor variable");62 throw new ConditionThrowable(new LispError(String.valueOf(symbol) + 63 " is not defined as an editor variable")); 63 64 return (JVar) obj; 64 65 } -
trunk/j/src/org/armedbear/j/LispAPI.java
r3794 r3906 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: LispAPI.java,v 1.2 5 2003-09-15 16:18:13piso Exp $5 * $Id: LispAPI.java,v 1.26 2003-09-19 17:42:09 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 24 24 import java.util.Iterator; 25 25 import javax.swing.undo.CompoundEdit; 26 import org.armedbear.lisp.ConditionThrowable; 26 27 import org.armedbear.lisp.Fixnum; 27 28 import org.armedbear.lisp.JavaObject; … … 60 61 61 62 public static final Editor checkEditor(LispObject obj) 62 throws LispError63 throws ConditionThrowable 63 64 { 64 65 if (obj == null) … … 68 69 } 69 70 catch (ClassCastException e) { 70 throw new TypeError(obj, "editor");71 throw new ConditionThrowable(new TypeError(obj, "editor")); 71 72 } 72 73 } 73 74 74 75 public static final Buffer checkBuffer(LispObject obj) 75 throws LispError76 throws ConditionThrowable 76 77 { 77 78 if (obj == null) … … 81 82 } 82 83 catch (ClassCastException e) { 83 throw new TypeError(obj, "buffer");84 throw new ConditionThrowable(new TypeError(obj, "buffer")); 84 85 } 85 86 } 86 87 87 88 public static final Position checkMarker(LispObject obj) 88 throws LispError89 throws ConditionThrowable 89 90 { 90 91 if (obj == null) … … 94 95 } 95 96 catch (ClassCastException e) { 96 throw new TypeError(obj, "marker");97 throw new ConditionThrowable(new TypeError(obj, "marker")); 97 98 } 98 99 } 99 100 100 101 public static final Line checkLine(LispObject obj) 101 throws LispError102 throws ConditionThrowable 102 103 { 103 104 if (obj == null) … … 107 108 } 108 109 catch (ClassCastException e) { 109 throw new TypeError(obj, "line");110 throw new ConditionThrowable(new TypeError(obj, "line")); 110 111 } 111 112 } … … 129 130 "Makes EDITOR the current editor.") 130 131 { 131 public LispObject execute(LispObject arg) throws LispError132 public LispObject execute(LispObject arg) throws ConditionThrowable 132 133 { 133 134 Editor.setCurrentEditor(checkEditor(arg)); … … 158 159 private static final Primitive1 BUFFER = 159 160 new Primitive1("buffer", PACKAGE_J, true) { 160 public LispObject execute(LispObject arg) throws LispError161 public LispObject execute(LispObject arg) throws ConditionThrowable 161 162 { 162 163 return new JavaObject(checkEditor(arg).getBuffer()); … … 167 168 private static final Primitive1 BUFFER_PATHNAME = 168 169 new Primitive1("buffer-pathname", PACKAGE_J, true) { 169 public LispObject execute(LispObject arg) throws LispError170 public LispObject execute(LispObject arg) throws ConditionThrowable 170 171 { 171 172 File file = checkBuffer(arg).getFile(); … … 182 183 private static final Primitive BUFFER_STRING = 183 184 new Primitive("buffer-string", PACKAGE_J, true) { 184 public LispObject execute() throws LispError185 public LispObject execute() throws ConditionThrowable 185 186 { 186 187 return new LispString(Editor.currentBuffer().getText()); 187 188 } 188 public LispObject execute(LispObject arg) throws LispError189 public LispObject execute(LispObject arg) throws ConditionThrowable 189 190 { 190 191 return new LispString(checkBuffer(arg).getText()); … … 195 196 private static final Primitive1 COPY_MARK = 196 197 new Primitive1("copy-marker", PACKAGE_J, true) { 197 public LispObject execute(LispObject arg) throws LispError198 public LispObject execute(LispObject arg) throws ConditionThrowable 198 199 { 199 200 try { … … 201 202 } 202 203 catch (Exception e) { 203 throw new TypeError(arg, "marker");204 throw new ConditionThrowable(new TypeError(arg, "marker")); 204 205 } 205 206 } … … 210 211 private static final Primitive GOTO_CHAR = 211 212 new Primitive("goto-char", PACKAGE_J, true) { 212 public LispObject execute(LispObject arg) throws LispError213 public LispObject execute(LispObject arg) throws ConditionThrowable 213 214 { 214 215 // Move dot to position. … … 218 219 } 219 220 public LispObject execute(LispObject first, LispObject second) 220 throws LispError221 throws ConditionThrowable 221 222 { 222 223 Log.debug("goto-char two argument case"); … … 268 269 new Primitive1("make-marker", PACKAGE_J, true) { 269 270 public LispObject execute(LispObject first, LispObject second) 270 throws LispError271 throws ConditionThrowable 271 272 { 272 273 Line line = checkLine(first); … … 279 280 private static final Primitive1 MARKER_LINE = 280 281 new Primitive1("marker-line", PACKAGE_J, true) { 281 public LispObject execute(LispObject arg) throws LispError282 public LispObject execute(LispObject arg) throws ConditionThrowable 282 283 { 283 284 return new JavaObject(checkMarker(arg).getLine()); … … 288 289 private static final Primitive1 MARKER_CHARPOS = 289 290 new Primitive1("marker-charpos", PACKAGE_J, true) { 290 public LispObject execute(LispObject arg) throws LispError291 public LispObject execute(LispObject arg) throws ConditionThrowable 291 292 { 292 293 return number(checkMarker(arg).getOffset()); … … 310 311 private static final Primitive1 LINE_NEXT = 311 312 new Primitive1("line-next", PACKAGE_J, true) { 312 public LispObject execute(LispObject arg) throws LispError313 public LispObject execute(LispObject arg) throws ConditionThrowable 313 314 { 314 315 Line next = checkLine(arg).next(); … … 320 321 private static final Primitive1 LINE_PREVIOUS = 321 322 new Primitive1("line-previous", PACKAGE_J, true) { 322 public LispObject execute(LispObject arg) throws LispError323 public LispObject execute(LispObject arg) throws ConditionThrowable 323 324 { 324 325 Line prev = checkLine(arg).previous(); … … 330 331 private static final Primitive1 LINE_CHARS = 331 332 new Primitive1("line-chars", PACKAGE_J, true) { 332 public LispObject execute(LispObject arg) throws LispError333 public LispObject execute(LispObject arg) throws ConditionThrowable 333 334 { 334 335 String s = checkLine(arg).getText(); … … 340 341 private static final Primitive1 LINE_FLAGS = 341 342 new Primitive1("line-flags", PACKAGE_J, true) { 342 public LispObject execute(LispObject arg) throws LispError343 public LispObject execute(LispObject arg) throws ConditionThrowable 343 344 { 344 345 return number(checkLine(arg).flags()); … … 350 351 private static final Primitive1 CHAR_AFTER = 351 352 new Primitive1("char-after", PACKAGE_J, true) { 352 public LispObject execute(LispObject arg) throws LispError353 public LispObject execute(LispObject arg) throws ConditionThrowable 353 354 { 354 355 return LispCharacter.getInstance(checkMarker(arg).getChar()); … … 360 361 private static final Primitive1 CHAR_BEFORE = 361 362 new Primitive1("char-before", PACKAGE_J, true) { 362 public LispObject execute(LispObject arg) throws LispError363 public LispObject execute(LispObject arg) throws ConditionThrowable 363 364 { 364 365 Position pos = checkMarker(arg).copy(); … … 371 372 private static final Primitive FORWARD_CHAR = 372 373 new Primitive("forward-char", PACKAGE_J, true) { 373 public LispObject execute() throws LispError374 public LispObject execute() throws ConditionThrowable 374 375 { 375 376 return forwardChar(1); 376 377 } 377 public LispObject execute(LispObject arg) throws LispError378 public LispObject execute(LispObject arg) throws ConditionThrowable 378 379 { 379 380 return forwardChar(Fixnum.getValue(arg)); … … 385 386 private static final Primitive BACKWARD_CHAR = 386 387 new Primitive("backward-char", PACKAGE_J, true) { 387 public LispObject execute() throws LispError388 public LispObject execute() throws ConditionThrowable 388 389 { 389 390 return forwardChar(-1); 390 391 } 391 public LispObject execute(LispObject arg) throws LispError392 public LispObject execute(LispObject arg) throws ConditionThrowable 392 393 { 393 394 return forwardChar(-Fixnum.getValue(arg)); … … 395 396 }; 396 397 397 private static final LispObject forwardChar(int n) throws LispError398 private static final LispObject forwardChar(int n) throws ConditionThrowable 398 399 { 399 400 if (n != 0) { … … 405 406 while (n-- > 0) { 406 407 if (!pos.next()) 407 throw new LispError("reached end of buffer");408 throw new ConditionThrowable(new LispError("reached end of buffer")); 408 409 } 409 410 } else { … … 411 412 while (n++ < 0) { 412 413 if (!pos.prev()) 413 throw new LispError("reached beginning of buffer");414 throw new ConditionThrowable(new LispError("reached beginning of buffer")); 414 415 } 415 416 } … … 423 424 private static final Primitive BEGINNING_OF_LINE = 424 425 new Primitive("beginning-of-line", PACKAGE_J, true) { 425 public LispObject execute() throws LispError426 public LispObject execute() throws ConditionThrowable 426 427 { 427 428 Editor.currentEditor().bol(); 428 429 return NIL; 429 430 } 430 public LispObject execute(LispObject arg) throws LispError431 public LispObject execute(LispObject arg) throws ConditionThrowable 431 432 { 432 433 int n = (arg != NIL) ? Fixnum.getValue(arg) : 1; … … 452 453 private static final Primitive END_OF_LINE = 453 454 new Primitive("end-of-line", PACKAGE_J, true) { 454 public LispObject execute() throws LispError455 public LispObject execute() throws ConditionThrowable 455 456 { 456 457 Editor.currentEditor().eol(); 457 458 return NIL; 458 459 } 459 public LispObject execute(LispObject arg) throws LispError460 public LispObject execute(LispObject arg) throws ConditionThrowable 460 461 { 461 462 int n = (arg != NIL) ? Fixnum.getValue(arg) : 1; … … 492 493 new Primitive3("%variable-value", PACKAGE_J, false) { 493 494 public LispObject execute(LispObject first, LispObject second, 494 LispObject third) throws LispError495 LispObject third) throws ConditionThrowable 495 496 { 496 497 Symbol symbol = checkSymbol(first); … … 502 503 if (kind == KEYWORD_CURRENT) { 503 504 if (where != NIL) 504 throw new LispError("bad argument " + where);505 throw new ConditionThrowable(new LispError("bad argument " + where)); 505 506 final Buffer buffer = editor.getBuffer(); 506 507 if (property.isBooleanProperty()) … … 541 542 return new LispString(buffer.getStringProperty(property)); 542 543 } 543 throw new LispError("bad keyword argument: " + kind);544 throw new ConditionThrowable(new LispError("bad keyword argument: " + kind)); 544 545 } 545 546 }; … … 549 550 private static final Primitive _SET_VARIABLE_VALUE = 550 551 new Primitive("%set-variable-value", PACKAGE_J, false) { 551 public LispObject execute(LispObject[] args) throws LispError552 public LispObject execute(LispObject[] args) throws ConditionThrowable 552 553 { 553 554 if (args.length != 4) 554 throw new WrongNumberOfArgumentsException(this);555 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 555 556 Symbol symbol = checkSymbol(args[0]); 556 557 JVar jvar = JVar.getJVar(symbol); … … 610 611 return newValue; 611 612 } 612 throw new LispError("bad keyword argument: " + kind);613 throw new ConditionThrowable(new LispError("bad keyword argument: " + kind)); 613 614 } 614 615 }; … … 638 639 new Primitive2("global-map-key", PACKAGE_J, true) { 639 640 public LispObject execute(LispObject first, LispObject second) 640 throws LispError641 throws ConditionThrowable 641 642 { 642 643 String keyText = LispString.getValue(first); … … 657 658 new Primitive1("global-unmap-key", PACKAGE_J, true) { 658 659 public LispObject execute(LispObject arg) 659 throws LispError660 throws ConditionThrowable 660 661 { 661 662 String keyText = LispString.getValue(arg); … … 669 670 public LispObject execute(LispObject first, LispObject second, 670 671 LispObject third) 671 throws LispError672 throws ConditionThrowable 672 673 { 673 674 String keyText = LispString.getValue(first); … … 683 684 Mode mode = Editor.getModeList().getModeFromModeName(modeName); 684 685 if (mode == null) 685 throw new LispError("unknown mode \"".concat(modeName).concat("\""));686 throw new ConditionThrowable(new LispError("unknown mode \"".concat(modeName).concat("\""))); 686 687 return mode.getKeyMap().mapKey(keyText, command) ? T : NIL; 687 688 } … … 692 693 new Primitive2("unmap-key-for-mode", PACKAGE_J, true) { 693 694 public LispObject execute(LispObject first, LispObject second) 694 throws LispError695 throws ConditionThrowable 695 696 { 696 697 String keyText = LispString.getValue(first); … … 698 699 Mode mode = Editor.getModeList().getModeFromModeName(modeName); 699 700 if (mode == null) 700 throw new LispError("unknown mode \"".concat(modeName).concat("\""));701 throw new ConditionThrowable(new LispError("unknown mode \"".concat(modeName).concat("\""))); 701 702 return mode.getKeyMap().unmapKey(keyText) ? T : NIL; 702 703 } … … 707 708 new Primitive2("%set-global-property", PACKAGE_J, false) { 708 709 public LispObject execute(LispObject first, LispObject second) 709 throws LispError710 throws ConditionThrowable 710 711 { 711 712 String key = LispString.getValue(first); … … 723 724 private static final Primitive INSERT = 724 725 new Primitive("insert", PACKAGE_J, true) { 725 public LispObject execute(LispObject[] args) throws LispError726 public LispObject execute(LispObject[] args) throws ConditionThrowable 726 727 { 727 728 if (args.length == 0) … … 739 740 editor.insertString(((LispString)obj).getValue()); 740 741 } else 741 throw new TypeError(obj, "character or string");742 throw new ConditionThrowable(new TypeError(obj, "character or string")); 742 743 } 743 744 return NIL; … … 759 760 private static final Primitive1 END_COMPOUND_EDIT = 760 761 new Primitive1("end-compound-edit", PACKAGE_J, false) { 761 public LispObject execute(LispObject arg) throws LispError762 public LispObject execute(LispObject arg) throws ConditionThrowable 762 763 { 763 764 try { … … 768 769 } 769 770 catch (ClassCastException e) { 770 throw new TypeError(arg, "compound edit");771 throw new ConditionThrowable(new TypeError(arg, "compound edit")); 771 772 } 772 773 }
Note: See TracChangeset
for help on using the changeset viewer.