Changeset 13834


Ignore:
Timestamp:
01/30/12 20:13:16 (12 years ago)
Author:
ehuelsmann
Message:

Further reduce footprint and complexity by eliminating
helper functions.

File:
1 edited

Legend:

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

    r13833 r13834  
    172172  public LispObject execute()
    173173  {
    174     if (arity == 0)
    175       {
    176         return progn(executionBody, environment,
    177                      LispThread.currentThread());
    178       }
    179     else
    180174      return execute(new LispObject[0]);
    181175  }
    182176   
    183   private final LispObject bindParametersAndExecute(LispObject... objects)
    184 
    185   {
    186     final LispThread thread = LispThread.currentThread();
    187     final SpecialBindingsMark mark = thread.markSpecialBindings();
    188 
    189     Environment ext = new Environment(environment);
    190     LispObject[] args = arglist.match(objects, environment, ext, thread);
    191     arglist.bindVars(args, ext, thread);
    192     declareFreeSpecials(ext);
    193     try
    194       {
    195         return progn(executionBody, ext, thread);
    196       }
    197     finally
    198       {
    199         thread.resetSpecialBindings(mark);
    200       }
    201   }
    202 
    203   public final LispObject invokeArrayExecute(LispObject... objects)
    204 
    205   {
    206     return execute(objects);
    207   }
    208 
    209177  @Override
    210178  public LispObject execute(LispObject arg)
    211179  {
    212     if (minArgs == 1)
    213       {
    214         return bindParametersAndExecute(arg);
    215       }
    216     else
    217       {
    218         return invokeArrayExecute(arg);
    219       }
     180        return execute(new LispObject[] {arg});
    220181  }
    221182
    222183  @Override
    223184  public LispObject execute(LispObject first, LispObject second)
    224 
    225   {
    226     if (minArgs == 2)
    227       {
    228         return bindParametersAndExecute(first, second);
    229       }
    230     else
    231       {
    232         return invokeArrayExecute(first, second);
    233       }
     185  {
     186        return execute(new LispObject[] {first, second});
    234187  }
    235188
     
    237190  public LispObject execute(LispObject first, LispObject second,
    238191                            LispObject third)
    239 
    240   {
    241     if (minArgs == 3)
    242       {
    243         return bindParametersAndExecute(first, second, third);
    244       }
    245     else
    246       {
    247         return invokeArrayExecute(first, second, third);
    248       }
     192  {
     193        return execute(new LispObject[] {first, second, third});
    249194  }
    250195
     
    252197  public LispObject execute(LispObject first, LispObject second,
    253198                            LispObject third, LispObject fourth)
    254 
    255   {
    256     if (minArgs == 4)
    257       {
    258         return bindParametersAndExecute(first, second, third, fourth);
    259       }
    260     else
    261       {
    262         return invokeArrayExecute(first, second, third, fourth);
    263       }
     199  {
     200        return execute(new LispObject[] {first, second, third, fourth});
    264201  }
    265202
     
    268205                            LispObject third, LispObject fourth,
    269206                            LispObject fifth)
    270 
    271   {
    272     if (minArgs == 5)
    273       {
    274         return bindParametersAndExecute(first, second, third, fourth,
    275                                         fifth);
    276       }
    277     else
    278       {
    279         return invokeArrayExecute(first, second, third, fourth, fifth);
    280       }
     207  {
     208        return execute(new LispObject[] {first, second, third, fourth, fifth});
    281209  }
    282210
     
    285213                            LispObject third, LispObject fourth,
    286214                            LispObject fifth, LispObject sixth)
    287 
    288   {
    289     if (minArgs == 6)
    290       {
    291         return bindParametersAndExecute(first, second, third, fourth,
    292                                         fifth, sixth);
    293       }
    294     else
    295       {
    296         return invokeArrayExecute(first, second, third, fourth, fifth,
    297                                   sixth);
    298       }
     215  {
     216        return execute(new LispObject[] {first, second, third, fourth, fifth,
     217                                  sixth});
    299218  }
    300219
     
    304223                            LispObject fifth, LispObject sixth,
    305224                            LispObject seventh)
    306 
    307   {
    308     if (minArgs == 7)
    309       {
    310         return bindParametersAndExecute(first, second, third, fourth,
    311                                fifth, sixth, seventh);
    312       }
    313     else
    314       {
    315         return invokeArrayExecute(first, second, third, fourth, fifth,
    316                                   sixth, seventh);
    317       }
     225  {
     226        return execute(new LispObject[] {first, second, third, fourth, fifth,
     227                                  sixth, seventh});
    318228  }
    319229
     
    323233                            LispObject fifth, LispObject sixth,
    324234                            LispObject seventh, LispObject eighth)
    325 
    326   {
    327     if (minArgs == 8)
    328       {
    329         return bindParametersAndExecute(first, second, third, fourth,
    330                                fifth, sixth, seventh, eighth);
    331       }
    332     else
    333       {
    334         return invokeArrayExecute(first, second, third, fourth, fifth,
    335                                   sixth, seventh, eighth);
    336       }
    337   }
    338 
    339   private void declareFreeSpecials(Environment ext)
    340   {
    341       for (Symbol special : freeSpecials)
    342         ext.declareSpecial(special);
     235  {
     236        return execute(new LispObject[] {first, second, third, fourth, fifth,
     237                                  sixth, seventh, eighth});
    343238  }
    344239
     
    351246    args = arglist.match(args, environment, ext, thread);
    352247    arglist.bindVars(args, ext, thread);
    353     declareFreeSpecials(ext);
     248    for (Symbol special : freeSpecials)
     249      ext.declareSpecial(special);
    354250    try
    355251      {
Note: See TracChangeset for help on using the changeset viewer.