Changeset 5137


Ignore:
Timestamp:
12/15/03 01:40:53 (17 years ago)
Author:
asimon
Message:

ARGLIST works for macros and special operators defined as macros

File:
1 edited

Legend:

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

    r5062 r5137  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: arglist.java,v 1.4 2003-12-10 21:36:12 asimon Exp $
     5 * $Id: arglist.java,v 1.5 2003-12-15 01:40:53 asimon Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2525{
    2626
     27  private static final Functional getFunctional(LispObject obj)
     28        throws ConditionThrowable
     29    {
     30        if (obj instanceof Functional)
     31            return (Functional) obj;
     32        if (obj instanceof Symbol) {
     33            LispObject fun = obj.getSymbolFunction();
     34      if (fun instanceof Autoload) {
     35                Autoload autoload = (Autoload) fun;
     36                autoload.load();
     37                fun = (Functional)autoload.getSymbol().getSymbolFunction();
     38      }
     39            if (fun instanceof Functional) {
     40        Functional func = (Functional) fun;
     41        if (func.getArglist() != null) return  func;
     42        return getFunctional(get(checkSymbol(obj), Symbol.MACROEXPAND_MACRO, NIL));
     43      }
     44        } else if (obj instanceof Cons && obj.car() == Symbol.LAMBDA)
     45            return new Closure(obj.cadr(), obj.cddr(), new Environment());
     46        throw new ConditionThrowable(new UndefinedFunction(obj));
     47    }
     48
    2749    static final Primitive1 ARGLIST =
    2850        new Primitive1("arglist", PACKAGE_EXT, true)
     
    3153        {
    3254            LispThread thread = LispThread.currentThread();
    33             Functional functional = coerceToFunctional(arg);
    34             if (functional instanceof Autoload) {
    35                 Autoload autoload = (Autoload) functional;
    36                 autoload.load();
    37                 functional = (Functional)autoload.getSymbol().getSymbolFunction();
    38             }
     55            Functional functional = getFunctional(arg);
    3956            LispObject arglist = functional.getArglist();
    4057            final LispObject value1, value2;
     
    6279                value2 = NIL;
    6380            }
    64  
    65 
    6681            return thread.setValues(value1, value2);
    6782        }
Note: See TracChangeset for help on using the changeset viewer.