Changeset 4589
- Timestamp:
- 10/31/03 18:30:33 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/SpecialOperators.java
r4577 r4589 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: SpecialOperators.java,v 1.1 2 2003-10-30 18:38:00piso Exp $5 * $Id: SpecialOperators.java,v 1.13 2003-10-31 18:30:33 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 289 289 290 290 // ### progv 291 private static final SpecialOperator PROGV = new SpecialOperator("progv") { 292 public LispObject execute(LispObject args, Environment env) 293 throws ConditionThrowable 294 { 295 throw new ConditionThrowable(new LispError("PROGV is not implemented")); 291 private static final SpecialOperator PROGV = new SpecialOperator("progv") 292 { 293 public LispObject execute(LispObject args, Environment env) 294 throws ConditionThrowable 295 { 296 if (args.length() < 2) 297 throw new ConditionThrowable(new WrongNumberOfArgumentsException(this)); 298 final LispThread thread = LispThread.currentThread(); 299 final LispObject symbols = checkList(eval(args.car(), env, thread)); 300 LispObject values = checkList(eval(args.cadr(), env, thread)); 301 // Save current values of symbols. 302 final LispObject[] oldValues = new LispObject[symbols.length()]; 303 int i = 0; 304 for (LispObject list = symbols; list != NIL; list = list.cdr()) { 305 LispObject symbol = list.car(); 306 oldValues[i++] = symbol.getSymbolValue(); 307 } 308 Environment oldDynEnv = thread.getDynamicEnvironment(); 309 try { 310 // Set up the new bindings. 311 for (LispObject list = symbols; list != NIL; list = list.cdr()) { 312 Symbol symbol = checkSymbol(list.car()); 313 LispObject value; 314 if (values != NIL) { 315 value = values.car(); 316 values = values.cdr(); 317 } else 318 value = null; 319 if (symbol.isSpecialVariable()) 320 thread.bindSpecial(symbol, value); 321 else 322 symbol.setSymbolValue(value); 323 } 324 // Implicit PROGN. 325 LispObject result = NIL; 326 LispObject body = args.cdr().cdr(); 327 while (body != NIL) { 328 result = eval(body.car(), env, thread); 329 body = body.cdr(); 330 } 331 return result; 332 } 333 finally { 334 thread.setDynamicEnvironment(oldDynEnv); 335 // Undo bindings. 336 i = 0; 337 for (LispObject list = symbols; list != NIL; list = list.cdr()) { 338 Symbol symbol = (Symbol) list.car(); 339 symbol.setSymbolValue(oldValues[i]); 340 } 341 } 296 342 } 297 343 };
Note: See TracChangeset
for help on using the changeset viewer.