Changeset 13850


Ignore:
Timestamp:
02/04/12 13:09:35 (11 years ago)
Author:
ehuelsmann
Message:

Remove Closure.fastProcessArgs(): it's concept has been abstracted away
in ArgumentListProcessor?.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
4 edited

Legend:

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

    r13849 r13850  
    546546   * including validation of the keywords passed. */
    547547  private class SlowMatcher extends ArgumentMatcher {
     548      private LispObject[] _match(LispObject[] args, Environment _environment,
     549                Environment env, LispThread thread) {
     550        final ArgList argslist = new ArgList(_environment, args);
     551        final LispObject[] array = new LispObject[variables.length];
     552        int index = 0;
     553
     554       
     555        for (Param p : positionalParameters)
     556            index = p.assign(index, array, argslist, env, thread);
     557
     558        if (andKey) {
     559            argslist.assertRemainderKeywords();
     560
     561            for (Param p : keywordParameters)
     562                index = p.assign(index, array, argslist, env, thread);
     563        }
     564        for (Param p : auxVars)
     565            index = p.assign(index, array, argslist, env, thread);
     566
     567        if (andKey) {
     568            if (allowOtherKeys)
     569                return array;
     570
     571            if (!argslist.consumed()) // verify keywords
     572              {
     573                LispObject allowOtherKeysValue =
     574                        argslist.findKeywordArg(Keyword.ALLOW_OTHER_KEYS, NIL);
     575
     576                if (allowOtherKeysValue != NIL)
     577                    return array;
     578
     579                // verify keywords
     580                next_key:
     581                  while (! argslist.consumed()) {
     582                      LispObject key = argslist.consume();
     583                      argslist.consume(); // consume value
     584
     585                      if (key == Keyword.ALLOW_OTHER_KEYS)
     586                          continue next_key;
     587
     588                      for (KeywordParam k : keywordParameters)
     589                          if (k.keyword == key)
     590                              continue next_key;
     591
     592                      error(new ProgramError("Unrecognized keyword argument " +
     593                                              key.printObject()));
     594                  }
     595              }
     596        }
     597
     598        if (restVar == null && !argslist.consumed())
     599            error(new WrongNumberOfArgumentsException(function));
     600
     601        return array;
     602      }
     603     
    548604      @Override
    549605      LispObject[] match(LispObject[] args, Environment _environment,
     
    561617          error(new WrongNumberOfArgumentsException(function, minArgs, -1));
    562618
     619        if (thread == null)
     620            return _match(args, _environment, env, thread);
    563621         
    564622        final SpecialBindingsMark mark = thread.markSpecialBindings();
    565         final LispObject[] array = new LispObject[variables.length];
    566         int index = 0;
    567         ArgList argslist = new ArgList(_environment, args);
    568        
    569623        try {
    570             for (Param p : positionalParameters)
    571                 index = p.assign(index, array, argslist, env, thread);
    572            
    573             if (andKey) {
    574                 argslist.assertRemainderKeywords();
    575            
    576                 for (Param p : keywordParameters)
    577                     index = p.assign(index, array, argslist, env, thread);
    578             }
    579             for (Param p : auxVars)
    580                 index = p.assign(index, array, argslist, env, thread);
    581            
    582             if (andKey) {
    583                 if (allowOtherKeys)
    584                     return array;
    585                
    586                 if (!argslist.consumed()) // verify keywords
    587                   {
    588                     LispObject allowOtherKeysValue =
    589                             argslist.findKeywordArg(Keyword.ALLOW_OTHER_KEYS, NIL);
    590 
    591                     if (allowOtherKeysValue != NIL)
    592                         return array;
    593 
    594                     // verify keywords
    595                     next_key:
    596                       while (! argslist.consumed()) {
    597                           LispObject key = argslist.consume();
    598                           argslist.consume(); // consume value
    599 
    600                           if (key == Keyword.ALLOW_OTHER_KEYS)
    601                               continue next_key;
    602 
    603                           for (KeywordParam k : keywordParameters)
    604                               if (k.keyword == key)
    605                                   continue next_key;
    606 
    607                           error(new ProgramError("Unrecognized keyword argument " +
    608                                                   key.printObject()));
    609                       }
    610                   }
    611             }
    612            
    613             if (restVar == null && !argslist.consumed())
    614                 error(new WrongNumberOfArgumentsException(function));
    615                
    616             return array;
     624            return _match(args, _environment, env, thread);
    617625        }
    618626        finally {
  • trunk/abcl/src/org/armedbear/lisp/Closure.java

    r13849 r13850  
    222222  }
    223223
    224   // No optional or keyword parameters.
    225   protected final LispObject[] fastProcessArgs(LispObject[] args)
    226   {
    227     return arglist.match(args, environment, null, null);
    228   }
    229 
    230224  // ### lambda-list-names
    231225  private static final Primitive LAMBDA_LIST_NAMES =
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r13849 r13850  
    70477047         (class-file (compiland-class-file compiland))
    70487048         (*this-class* (abcl-class-file-class class-file))
    7049          (args (cadr p1-result))
    70507049         (closure-args (intersection *closure-variables*
    70517050                                     (compiland-arg-vars compiland)))
     
    72347233          (aver (not (null (compiland-argument-register compiland))))
    72357234          (aload (compiland-argument-register compiland)) ; arg vector
    7236           (cond ((or (memq '&OPTIONAL args) (memq '&KEY args))
    7237                  (ensure-thread-var-initialized)
    7238                  (maybe-initialize-thread-var)
    7239                  (emit-push-current-thread)
    7240                  (emit-invokevirtual *this-class* "processArgs"
    7241                                      (list +lisp-object-array+ +lisp-thread+)
    7242                                      +lisp-object-array+))
    7243                 (t
    7244                  (emit-invokevirtual *this-class* "fastProcessArgs"
    7245                                      (list +lisp-object-array+)
    7246                                      +lisp-object-array+)))
     7235          (emit 'aconst_null) ;; no thread arg required:
     7236                 ;; there's no non-constant initform or special
     7237                 ;; which might require the thread
     7238          (emit-invokevirtual *this-class* "processArgs"
     7239                              (list +lisp-object-array+ +lisp-thread+)
     7240                              +lisp-object-array+)
    72477241          (astore (compiland-argument-register compiland)))
    72487242
    7249         (unless (and *hairy-arglist-p*
    7250                      (or (memq '&OPTIONAL args) (memq '&KEY args)))
    7251           (maybe-initialize-thread-var))
    7252         (setf *code* (nconc code *code*)))
    7253       ))
     7243        (maybe-initialize-thread-var)
     7244        (setf *code* (nconc code *code*)))))
    72547245  t)
    72557246
  • trunk/abcl/src/org/armedbear/lisp/jvm-class-file.lisp

    r13849 r13850  
    190190(define-class-name +alp-keyword-parameter+
    191191    "org.armedbear.lisp.ArgumentListProcessor$KeywordParam")
    192 (defconstant +lisp-closure-parameter-array+
    193   (class-array +lisp-closure-parameter+))
    194192
    195193#|
Note: See TracChangeset for help on using the changeset viewer.