Changeset 4015
- Timestamp:
- 09/23/03 13:38:54 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/Primitives.java
r4014 r4015 3 3 * 4 4 * Copyright (C) 2002-2003 Peter Graves 5 * $Id: Primitives.java,v 1.42 6 2003-09-23 13:02:02piso Exp $5 * $Id: Primitives.java,v 1.427 2003-09-23 13:38:54 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 1579 1579 LispObject countForm = args.cadr(); 1580 1580 final LispThread thread = LispThread.currentThread(); 1581 int count = Fixnum.getInt(eval(countForm, env, thread));1582 1581 LispObject resultForm = args.cdr().cdr().car(); 1583 1582 Environment oldDynEnv = thread.getDynamicEnvironment(); 1584 int i; 1585 for (i = 0; i < count; i++) { 1583 LispObject limit = eval(countForm, env, thread); 1584 LispObject result; 1585 if (limit instanceof Fixnum) { 1586 int count = ((Fixnum)limit).getValue(); 1587 int i; 1588 for (i = 0; i < count; i++) { 1589 Environment ext = new Environment(env); 1590 bind(var, new Fixnum(i), ext); 1591 LispObject body = bodyForm; 1592 int depth = thread.getStackDepth(); 1593 try { 1594 while (body != NIL) { 1595 eval(body.car(), ext, thread); 1596 body = body.cdr(); 1597 } 1598 } 1599 catch (Return ret) { 1600 if (ret.getTag() == NIL) { 1601 thread.setStackDepth(depth); 1602 return ret.getResult(); 1603 } 1604 throw ret; 1605 } 1606 } 1586 1607 Environment ext = new Environment(env); 1587 1608 bind(var, new Fixnum(i), ext); 1588 LispObject body = bodyForm; 1589 int depth = thread.getStackDepth(); 1590 try { 1591 while (body != NIL) { 1592 LispObject result = eval(body.car(), ext, thread); 1593 body = body.cdr(); 1609 result = eval(resultForm, ext, thread); 1610 } else if (limit instanceof Bignum) { 1611 LispObject i = Fixnum.ZERO; 1612 while (i.isLessThan(limit)) { 1613 Environment ext = new Environment(env); 1614 bind(var, i, ext); 1615 LispObject body = bodyForm; 1616 int depth = thread.getStackDepth(); 1617 try { 1618 while (body != NIL) { 1619 eval(body.car(), ext, thread); 1620 body = body.cdr(); 1621 } 1594 1622 } 1595 } 1596 catch (Return ret) { 1597 if (ret.getTag() == NIL) { 1598 thread.setStackDepth(depth); 1599 return ret.getResult(); 1623 catch (Return ret) { 1624 if (ret.getTag() == NIL) { 1625 thread.setStackDepth(depth); 1626 return ret.getResult(); 1627 } 1628 throw ret; 1600 1629 } 1601 throw ret; 1602 } 1603 } 1604 Environment ext = new Environment(env); 1605 bind(var, new Fixnum(i), ext); 1606 LispObject result = eval(resultForm, ext, thread); 1630 i = i.incr(); 1631 } 1632 Environment ext = new Environment(env); 1633 bind(var, i, ext); 1634 result = eval(resultForm, ext, thread); 1635 } else 1636 throw new ConditionThrowable(new TypeError(limit, "integer")); 1607 1637 thread.setDynamicEnvironment(oldDynEnv); 1608 1638 return result;
Note: See TracChangeset
for help on using the changeset viewer.