Changeset 5118


Ignore:
Timestamp:
12/13/03 20:23:28 (17 years ago)
Author:
piso
Message:

Moved DO-SYMBOLS and DO-EXTERNAL-SYMBOLS to boot.lisp.

File:
1 edited

Legend:

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

    r5116 r5118  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.528 2003-12-13 15:21:10 piso Exp $
     5 * $Id: Primitives.java,v 1.529 2003-12-13 20:23:28 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    27362736    };
    27372737
    2738     // ### do-external-symbols
    2739     // do-external-symbols (var [package [result-form]]) declaration* {tag | statement}*
    2740     // => result*
    2741     // Should be a macro.
    2742     private static final SpecialOperator DO_EXTERNAL_SYMBOLS =
    2743         new SpecialOperator("do-external-symbols") {
    2744         public LispObject execute(LispObject args, Environment env)
    2745             throws ConditionThrowable
    2746         {
    2747             return doSymbols(args, env, true);
    2748         }
    2749     };
    2750 
    2751     // ### do-symbols
    2752     // do-symbols (var [package [result-form]]) declaration* {tag | statement}*
    2753     // => result*
    2754     // Should be a macro.
    2755     private static final SpecialOperator DO_SYMBOLS =
    2756         new SpecialOperator("do-symbols") {
    2757         public LispObject execute(LispObject args, Environment env)
    2758             throws ConditionThrowable
    2759         {
    2760             return doSymbols(args, env, false);
    2761         }
    2762     };
    2763 
    2764     private static final LispObject doSymbols(LispObject args, Environment env,
    2765                                               boolean externalOnly)
    2766         throws ConditionThrowable
    2767     {
    2768         LispObject bodyForm = args.cdr();
    2769         args = args.car();
    2770         Symbol var = checkSymbol(args.car());
    2771         args = args.cdr();
    2772         final LispThread thread = LispThread.currentThread();
    2773         // Defaults.
    2774         Package pkg = getCurrentPackage();
    2775         LispObject resultForm = NIL;
    2776         if (args != NIL) {
    2777             pkg = coerceToPackage(eval(args.car(), env, thread));
    2778             args = args.cdr();
    2779             if (args != NIL)
    2780                 resultForm = args.car();
    2781         }
    2782         Environment oldDynEnv = thread.getDynamicEnvironment();
    2783         final List list;
    2784         if (externalOnly)
    2785             list = pkg.getExternalSymbols();
    2786         else
    2787             list = pkg.getAccessibleSymbols();
    2788         for (Iterator it = list.iterator(); it.hasNext();) {
    2789             Symbol symbol = (Symbol) it.next();
    2790             Environment ext = new Environment(env);
    2791             bind(var, symbol, ext);
    2792             LispObject body = bodyForm;
    2793             int depth = thread.getStackDepth();
    2794             try {
    2795                 while (body != NIL) {
    2796                     eval(body.car(), ext, thread);
    2797                     body = body.cdr();
    2798                 }
    2799             }
    2800             catch (Return ret) {
    2801                 if (ret.getTag() == NIL) {
    2802                     thread.setStackDepth(depth);
    2803                     return ret.getResult();
    2804                 }
    2805                 throw ret;
    2806             }
    2807         }
    2808         Environment ext = new Environment(env);
    2809         bind(var, NIL, ext);
    2810         LispObject result = eval(resultForm, ext, thread);
    2811         thread.setDynamicEnvironment(oldDynEnv);
    2812         return result;
    2813     }
    2814 
    28152738    // ### package-symbols
    28162739    private static final Primitive1 PACKAGE_SYMBOLS =
    2817         new Primitive1("package-symbols", PACKAGE_SYS, false) {
     2740        new Primitive1("package-symbols", PACKAGE_SYS, false)
     2741    {
    28182742        public LispObject execute(LispObject arg) throws ConditionThrowable
    28192743        {
     
    28242748    // ### package-internal-symbols
    28252749    private static final Primitive1 PACKAGE_INTERNAL_SYMBOLS =
    2826         new Primitive1("package-internal-symbols", PACKAGE_SYS, false) {
     2750        new Primitive1("package-internal-symbols", PACKAGE_SYS, false)
     2751    {
    28272752        public LispObject execute(LispObject arg) throws ConditionThrowable
    28282753        {
     
    28332758    // ### package-external-symbols
    28342759    private static final Primitive1 PACKAGE_EXTERNAL_SYMBOLS =
    2835         new Primitive1("package-external-symbols", PACKAGE_SYS, false) {
     2760        new Primitive1("package-external-symbols", PACKAGE_SYS, false)
     2761    {
    28362762        public LispObject execute(LispObject arg) throws ConditionThrowable
    28372763        {
     
    28422768    // ### package-inherited-symbols
    28432769    private static final Primitive1 PACKAGE_INHERITED_SYMBOLS =
    2844         new Primitive1("package-inherited-symbols", PACKAGE_SYS, false) {
     2770        new Primitive1("package-inherited-symbols", PACKAGE_SYS, false)
     2771    {
    28452772        public LispObject execute(LispObject arg) throws ConditionThrowable
    28462773        {
Note: See TracChangeset for help on using the changeset viewer.