Changeset 4052
- Timestamp:
- 09/25/03 16:33:18 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Primitives.java
r4050 r4052 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Primitives.java,v 1.43 7 2003-09-25 15:36:14piso Exp $5 * $Id: Primitives.java,v 1.438 2003-09-25 16:33:18 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 3440 3440 }; 3441 3441 3442 // ### write-string 3443 // write-string string &optional output-stream &key start end => string 3444 private static final Primitive WRITE_STRING = 3445 new Primitive("write-string") { 3442 // ### %write-string 3443 // write-string string output-stream start end => string 3444 private static final Primitive _WRITE_STRING = 3445 new Primitive("%write-string", PACKAGE_SYS, false) 3446 { 3446 3447 public LispObject execute(LispObject[] args) throws ConditionThrowable 3447 3448 { 3448 if (args.length == 0)3449 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3450 LispString string = checkString(args[0]);3449 if (args.length != 4) 3450 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 3451 String s = LispString.getValue(args[0]); 3451 3452 CharacterOutputStream out = null; 3452 3453 if (args.length == 1) … … 3454 3455 else { 3455 3456 LispObject streamArg = args[1]; 3457 if (streamArg == T) 3458 streamArg = _TERMINAL_IO_.symbolValue(); 3459 else if (streamArg == NIL) 3460 streamArg = _STANDARD_OUTPUT_.symbolValue(); 3456 3461 if (streamArg instanceof CharacterOutputStream) 3457 3462 out = (CharacterOutputStream) streamArg; 3458 else if (streamArg == T || streamArg == NIL)3459 out = getStandardOutput();3463 else if (streamArg instanceof TwoWayStream) 3464 out = ((TwoWayStream)streamArg).getOutputStream(); 3460 3465 else 3461 throw new ConditionThrowable(new TypeError(args[1], 3462 "character output stream")); 3463 } 3464 out.writeString(string); 3465 return string; 3466 throw new ConditionThrowable(new TypeError(args[1], "character output stream")); 3467 } 3468 int start = Fixnum.getValue(args[2]); 3469 int end = Fixnum.getValue(args[3]); 3470 out.writeString(s.substring(start, end)); 3471 return args[0]; 3472 } 3473 }; 3474 3475 // ### %write-newline 3476 // write-string string output-stream start end => string 3477 private static final Primitive1 _WRITE_NEWLINE = 3478 new Primitive1("%write-newline", PACKAGE_SYS, false) 3479 { 3480 public LispObject execute(LispObject arg) throws ConditionThrowable 3481 { 3482 LispObject streamArg = arg; 3483 if (streamArg == T) 3484 streamArg = _TERMINAL_IO_.symbolValue(); 3485 else if (streamArg == NIL) 3486 streamArg = _STANDARD_OUTPUT_.symbolValue(); 3487 final CharacterOutputStream out; 3488 if (streamArg instanceof CharacterOutputStream) 3489 out = (CharacterOutputStream) streamArg; 3490 else if (streamArg instanceof TwoWayStream) 3491 out = ((TwoWayStream)streamArg).getOutputStream(); 3492 else 3493 throw new ConditionThrowable(new TypeError(streamArg, "character output stream")); 3494 out.writeString(System.getProperty("line.separator")); 3495 return NIL; 3466 3496 } 3467 3497 }; … … 3506 3536 out = ((TwoWayStream)streamArg).getOutputStream(); 3507 3537 else 3508 throw new ConditionThrowable(new TypeError(args[ 1], "character output stream"));3538 throw new ConditionThrowable(new TypeError(args[0], "character output stream")); 3509 3539 } 3510 3540 out.flushOutput();
Note: See TracChangeset
for help on using the changeset viewer.