Changeset 13825


Ignore:
Timestamp:
01/29/12 21:55:34 (12 years ago)
Author:
ehuelsmann
Message:

Implement fastProcessArgs() using the ArgumentListProcessor?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Closure.java

    r13824 r13825  
    922922  // No optional or keyword parameters.
    923923  protected final LispObject[] fastProcessArgs(LispObject[] args)
    924 
    925   {
    926     final int argsLength = args.length;
    927     if (arity >= 0)
    928       {
    929         // Fixed arity.
    930         if (argsLength != arity)
    931           error(new WrongNumberOfArgumentsException(this, arity));
    932         return args;
    933       }
    934     // Not fixed arity.
    935     if (argsLength < minArgs)
    936       error(new WrongNumberOfArgumentsException(this, minArgs, -1));
    937     final LispObject[] array = new LispObject[variables.length];
    938     int index = 0;
    939     // Required parameters.
    940     for (int i = 0; i < minArgs; i++)
    941       {
    942         array[index++] = args[i];
    943       }
    944     int argsUsed = minArgs;
    945     // &rest parameter.
    946     if (restVar != null)
    947       {
    948         LispObject rest = NIL;
    949         for (int j = argsLength; j-- > argsUsed;)
    950           rest = new Cons(args[j], rest);
    951         array[index++] = rest;
    952       }
    953     else if (argsUsed < argsLength)
    954       {
    955         // No keyword parameters.
    956         if (argsUsed + 2 <= argsLength)
    957           {
    958             // Check for :ALLOW-OTHER-KEYS.
    959             LispObject allowOtherKeysValue = NIL;
    960             int n = argsUsed;
    961             while (n < argsLength)
    962               {
    963                 LispObject keyword = args[n];
    964                 if (keyword == Keyword.ALLOW_OTHER_KEYS)
    965                   {
    966                     allowOtherKeysValue = args[n+1];
    967                     break;
    968                   }
    969                 n += 2;
    970               }
    971             if (allowOtherKeys || allowOtherKeysValue != NIL)
    972               {
    973                 // Skip keyword/value pairs.
    974                 while (argsUsed + 2 <= argsLength)
    975                   argsUsed += 2;
    976               }
    977             else if (andKey)
    978               {
    979                 LispObject keyword = args[argsUsed];
    980                 if (keyword == Keyword.ALLOW_OTHER_KEYS)
    981                   {
    982                     // Section 3.4.1.4: "Note that if &key is present, a
    983                     // keyword argument of :allow-other-keys is always
    984                     // permitted---regardless of whether the associated
    985                     // value is true or false."
    986                     argsUsed += 2;
    987                   }
    988               }
    989           }
    990         if (argsUsed < argsLength)
    991           {
    992             if (restVar == null)
    993               error(new WrongNumberOfArgumentsException(this));
    994           }
    995       }
    996     return array;
     924  {
     925    return arglist.match(args, environment, null, null);
    997926  }
    998927
Note: See TracChangeset for help on using the changeset viewer.