Changeset 11771


Ignore:
Timestamp:
04/20/09 18:32:46 (15 years ago)
Author:
vvoutilainen
Message:

Cleanup copy-paste again, this time we get rid of repetition
in the execute methods.

File:
1 edited

Legend:

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

    r11754 r11771  
    419419  }
    420420   
    421   private final LispObject bindParametersAndExecute(
    422                                               Environment ext,
    423                                               LispThread thread,
    424                                               SpecialBinding lastSpecialBinding)
     421  private final LispObject bindParametersAndExecute(LispObject... objects)
    425422  throws ConditionThrowable
    426423  {
     424    final LispThread thread = LispThread.currentThread();
     425    final SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
     426    Environment ext = new Environment(environment);
     427    bindRequiredParameters(ext, thread, objects);
    427428    if (arity != minArgs)
    428429      {
     
    445446  private final void bindRequiredParameters(Environment ext,
    446447                                            LispThread thread,
    447                                             LispObject... objects)
     448                                            LispObject[] objects)
    448449  throws ConditionThrowable
    449450  {
     
    468469    if (minArgs == 1)
    469470      {
    470         final LispThread thread = LispThread.currentThread();
    471         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    472         Environment ext = new Environment(environment);
    473         bindRequiredParameters(ext, thread, arg);
    474         return bindParametersAndExecute(ext, thread,
    475                                         lastSpecialBinding);
     471        return bindParametersAndExecute(arg);
    476472      }
    477473    else
     
    487483    if (minArgs == 2)
    488484      {
    489         final LispThread thread = LispThread.currentThread();
    490         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    491         Environment ext = new Environment(environment);
    492         bindRequiredParameters(ext, thread, first, second);
    493         return bindParametersAndExecute(ext, thread,
    494                                         lastSpecialBinding);
     485        return bindParametersAndExecute(first, second);
    495486      }
    496487    else
     
    507498    if (minArgs == 3)
    508499      {
    509         final LispThread thread = LispThread.currentThread();
    510         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    511         Environment ext = new Environment(environment);
    512         bindRequiredParameters(ext, thread, first, second, third);
    513         return bindParametersAndExecute(ext, thread,
    514                                         lastSpecialBinding);
     500        return bindParametersAndExecute(first, second, third);
    515501      }
    516502    else
     
    527513    if (minArgs == 4)
    528514      {
    529         final LispThread thread = LispThread.currentThread();
    530         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    531         Environment ext = new Environment(environment);
    532         bindRequiredParameters(ext, thread, first, second, third, fourth);
    533         return bindParametersAndExecute(ext, thread,
    534                                         lastSpecialBinding);
     515        return bindParametersAndExecute(first, second, third, fourth);
    535516      }
    536517    else
     
    548529    if (minArgs == 5)
    549530      {
    550         final LispThread thread = LispThread.currentThread();
    551         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    552         Environment ext = new Environment(environment);
    553         bindRequiredParameters(ext, thread, first, second, third, fourth,
    554                                fifth);
    555         return bindParametersAndExecute(ext, thread,
    556                                         lastSpecialBinding);
     531        return bindParametersAndExecute(first, second, third, fourth,
     532                                        fifth);
    557533      }
    558534    else
     
    570546    if (minArgs == 6)
    571547      {
    572         final LispThread thread = LispThread.currentThread();
    573         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    574         Environment ext = new Environment(environment);
    575         bindRequiredParameters(ext, thread, first, second, third, fourth,
    576                                fifth, sixth);
    577         return bindParametersAndExecute(ext, thread,
    578                                         lastSpecialBinding);
     548        return bindParametersAndExecute(first, second, third, fourth,
     549                                        fifth, sixth);
    579550      }
    580551    else
     
    594565    if (minArgs == 7)
    595566      {
    596         final LispThread thread = LispThread.currentThread();
    597         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    598         Environment ext = new Environment(environment);
    599         bindRequiredParameters(ext, thread, first, second, third, fourth,
     567        return bindParametersAndExecute(first, second, third, fourth,
    600568                               fifth, sixth, seventh);
    601         return bindParametersAndExecute(ext, thread,
    602                                         lastSpecialBinding);
    603569      }
    604570    else
     
    618584    if (minArgs == 8)
    619585      {
    620         final LispThread thread = LispThread.currentThread();
    621         SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    622         Environment ext = new Environment(environment);
    623         bindRequiredParameters(ext, thread, first, second, third, fourth,
     586        return bindParametersAndExecute(first, second, third, fourth,
    624587                               fifth, sixth, seventh, eighth);
    625         return bindParametersAndExecute(ext, thread,
    626                                         lastSpecialBinding);
    627588      }
    628589    else
Note: See TracChangeset for help on using the changeset viewer.