Changeset 4016


Ignore:
Timestamp:
09/23/03 14:29:17 (20 years ago)
Author:
piso
Message:

DOTIMES: make sure implicit nil block has the right scope.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r4015 r4016  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.427 2003-09-23 13:38:54 piso Exp $
     5 * $Id: Primitives.java,v 1.428 2003-09-23 14:29:17 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    15811581            LispObject resultForm = args.cdr().cdr().car();
    15821582            Environment oldDynEnv = thread.getDynamicEnvironment();
    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 {
     1583            int depth = thread.getStackDepth();
     1584            try {
     1585                LispObject limit = eval(countForm, env, thread);
     1586                LispObject result;
     1587                if (limit instanceof Fixnum) {
     1588                    int count = ((Fixnum)limit).getValue();
     1589                    int i;
     1590                    for (i = 0; i < count; i++) {
     1591                        Environment ext = new Environment(env);
     1592                        bind(var, new Fixnum(i), ext);
     1593                        LispObject body = bodyForm;
    15941594                        while (body != NIL) {
    15951595                            eval(body.car(), ext, thread);
     
    15971597                        }
    15981598                    }
    1599                     catch (Return ret) {
    1600                         if (ret.getTag() == NIL) {
    1601                             thread.setStackDepth(depth);
    1602                             return ret.getResult();
    1603                         }
    1604                         throw ret;
    1605                     }
    1606                 }
    1607                 Environment ext = new Environment(env);
    1608                 bind(var, new Fixnum(i), ext);
    1609                 result = eval(resultForm, ext, thread);
    1610             } else if (limit instanceof Bignum) {
    1611                 LispObject i = Fixnum.ZERO;
    1612                 while (i.isLessThan(limit)) {
    16131599                    Environment ext = new Environment(env);
    1614                     bind(var, i, ext);
    1615                     LispObject body = bodyForm;
    1616                     int depth = thread.getStackDepth();
    1617                     try {
     1600                    bind(var, new Fixnum(i), ext);
     1601                    result = eval(resultForm, ext, thread);
     1602                } else if (limit instanceof Bignum) {
     1603                    LispObject i = Fixnum.ZERO;
     1604                    while (i.isLessThan(limit)) {
     1605                        Environment ext = new Environment(env);
     1606                        bind(var, i, ext);
     1607                        LispObject body = bodyForm;
    16181608                        while (body != NIL) {
    16191609                            eval(body.car(), ext, thread);
    16201610                            body = body.cdr();
    16211611                        }
     1612                        i = i.incr();
    16221613                    }
    1623                     catch (Return ret) {
    1624                         if (ret.getTag() == NIL) {
    1625                             thread.setStackDepth(depth);
    1626                             return ret.getResult();
    1627                         }
    1628                         throw ret;
    1629                     }
    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"));
    1637             thread.setDynamicEnvironment(oldDynEnv);
    1638             return result;
     1614                    Environment ext = new Environment(env);
     1615                    bind(var, i, ext);
     1616                    result = eval(resultForm, ext, thread);
     1617                } else
     1618                    throw new ConditionThrowable(new TypeError(limit, "integer"));
     1619                return result;
     1620            }
     1621            catch (Return ret) {
     1622                if (ret.getTag() == NIL) {
     1623                    thread.setStackDepth(depth);
     1624                    return ret.getResult();
     1625                }
     1626                throw ret;
     1627            }
     1628            finally {
     1629                thread.setDynamicEnvironment(oldDynEnv);
     1630            }
    16391631        }
    16401632    };
Note: See TracChangeset for help on using the changeset viewer.