Changeset 13828


Ignore:
Timestamp:
01/29/12 23:13:37 (9 years ago)
Author:
ehuelsmann
Message:

Remove variables 'variables' and 'bindInitForms'.
Simplify free specials binding.

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

Legend:

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

    r13821 r13828  
    472472  }
    473473 
     474  public Symbol[] freeSpecials(LispObject specials) {
     475      ArrayList<Symbol> list = new ArrayList<Symbol>();
     476     
     477      next_special:
     478          while (specials != NIL) {
     479              Symbol special = (Symbol)specials.car();
     480              specials = specials.cdr();
     481
     482              for (Symbol v : variables)
     483                  if (v == special)
     484                      continue next_special;
     485
     486              list.add(special);
     487          }
     488
     489      Symbol[] rv = new Symbol[list.size()];
     490      return list.toArray(rv);
     491  }
     492 
    474493  public int getArity() {
    475494      return arity;
     
    482501  public int getMaxArgs() {
    483502      return maxArgs;
     503  }
     504 
     505  public Symbol[] getVariables() {
     506      return variables;
    484507  }
    485508 
  • trunk/abcl/src/org/armedbear/lisp/Closure.java

    r13826 r13828  
    7171  private int maxArgs;
    7272
    73   private Symbol[] variables = new Symbol[0];
    7473  private LispObject specials = NIL;
    75 
    76   private boolean bindInitForms;
    77 
     74  private Symbol[] freeSpecials = new Symbol[0];
    7875
    7976  private ArgumentListProcessor arglist;
     
    111108      andKey = keys != NIL;
    112109      allowOtherKeys = moreKeys != NIL;
    113       variables = processVariables();
    114       bindInitForms = false;
    115110
    116111      // stuff we don't need: we're a compiled function
     
    373368    if (arity >= 0)
    374369      Debug.assertTrue(arity == minArgs);
    375     variables = processVariables();
    376370
    377371    arglist = new ArgumentListProcessor(this, lambdaList, specials);
     372    freeSpecials = arglist.freeSpecials(specials);
    378373  }
    379374
     
    386381        if (parameter.svar != NIL)
    387382          vars.add((Symbol)parameter.svar);
    388         if (!bindInitForms)
    389           if (!parameter.initForm.constantp())
    390             bindInitForms = true;
    391       }
    392   }
    393 
    394   // Also sets bindInitForms.
    395   private final Symbol[] processVariables()
    396   {
    397     ArrayList<Symbol> vars = new ArrayList<Symbol>();
    398     for (Parameter parameter : requiredParameters)
    399       vars.add(parameter.var);
    400     processParameters(vars, optionalParameters);
    401     if (restVar != null)
    402       {
    403         vars.add(restVar);
    404       }
    405     processParameters(vars, keywordParameters);
    406     Symbol[] array = new Symbol[vars.size()];
    407     vars.toArray(array);
    408     return array;
     383      }
    409384  }
    410385
     
    426401  public final LispObject getVariableList()
    427402  {
     403    Symbol[] variables = arglist.getVariables();
    428404    LispObject result = NIL;
    429405    for (int i = variables.length; i-- > 0;)
     
    611587  }
    612588
    613   private final void declareFreeSpecials(Environment ext)
    614 
    615   {
    616     LispObject s = specials;
    617     special:
    618     while (s != NIL) {
    619       Symbol special = (Symbol)s.car();
    620       s = s.cdr();
    621       for (Symbol var : variables)
    622   if (special == var)
    623           continue special;
    624       for (Parameter parameter : auxVars)
    625         if (special == parameter.var)
    626           continue special;
    627       ext.declareSpecial(special);
    628     }
     589  private void declareFreeSpecials(Environment ext)
     590  {
     591      for (Symbol special : freeSpecials)
     592        ext.declareSpecial(special);
    629593  }
    630594
Note: See TracChangeset for help on using the changeset viewer.