[armedbear-cvs] r13828 - trunk/abcl/src/org/armedbear/lisp
ehuelsmann at common-lisp.net
ehuelsmann at common-lisp.net
Sun Jan 29 23:13:38 UTC 2012
Author: ehuelsmann
Date: Sun Jan 29 15:13:37 2012
New Revision: 13828
Log:
Remove variables 'variables' and 'bindInitForms'.
Simplify free specials binding.
Modified:
trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java
trunk/abcl/src/org/armedbear/lisp/Closure.java
Modified: trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java Sun Jan 29 14:47:09 2012 (r13827)
+++ trunk/abcl/src/org/armedbear/lisp/ArgumentListProcessor.java Sun Jan 29 15:13:37 2012 (r13828)
@@ -471,6 +471,25 @@
}
}
+ public Symbol[] freeSpecials(LispObject specials) {
+ ArrayList<Symbol> list = new ArrayList<Symbol>();
+
+ next_special:
+ while (specials != NIL) {
+ Symbol special = (Symbol)specials.car();
+ specials = specials.cdr();
+
+ for (Symbol v : variables)
+ if (v == special)
+ continue next_special;
+
+ list.add(special);
+ }
+
+ Symbol[] rv = new Symbol[list.size()];
+ return list.toArray(rv);
+ }
+
public int getArity() {
return arity;
}
@@ -483,6 +502,10 @@
return maxArgs;
}
+ public Symbol[] getVariables() {
+ return variables;
+ }
+
private static void invalidParameter(LispObject obj) {
error(new ProgramError(obj.princToString() +
" may not be used as a variable in a lambda list."));
Modified: trunk/abcl/src/org/armedbear/lisp/Closure.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Closure.java Sun Jan 29 14:47:09 2012 (r13827)
+++ trunk/abcl/src/org/armedbear/lisp/Closure.java Sun Jan 29 15:13:37 2012 (r13828)
@@ -70,11 +70,8 @@
private int minArgs;
private int maxArgs;
- private Symbol[] variables = new Symbol[0];
private LispObject specials = NIL;
-
- private boolean bindInitForms;
-
+ private Symbol[] freeSpecials = new Symbol[0];
private ArgumentListProcessor arglist;
@@ -110,8 +107,6 @@
andKey = keys != NIL;
allowOtherKeys = moreKeys != NIL;
- variables = processVariables();
- bindInitForms = false;
// stuff we don't need: we're a compiled function
body = null;
@@ -372,9 +367,9 @@
minArgs = requiredParameters.length;
if (arity >= 0)
Debug.assertTrue(arity == minArgs);
- variables = processVariables();
arglist = new ArgumentListProcessor(this, lambdaList, specials);
+ freeSpecials = arglist.freeSpecials(specials);
}
private final void processParameters(ArrayList<Symbol> vars,
@@ -385,27 +380,7 @@
vars.add(parameter.var);
if (parameter.svar != NIL)
vars.add((Symbol)parameter.svar);
- if (!bindInitForms)
- if (!parameter.initForm.constantp())
- bindInitForms = true;
- }
- }
-
- // Also sets bindInitForms.
- private final Symbol[] processVariables()
- {
- ArrayList<Symbol> vars = new ArrayList<Symbol>();
- for (Parameter parameter : requiredParameters)
- vars.add(parameter.var);
- processParameters(vars, optionalParameters);
- if (restVar != null)
- {
- vars.add(restVar);
}
- processParameters(vars, keywordParameters);
- Symbol[] array = new Symbol[vars.size()];
- vars.toArray(array);
- return array;
}
private static final void invalidParameter(LispObject obj)
@@ -425,6 +400,7 @@
public final LispObject getVariableList()
{
+ Symbol[] variables = arglist.getVariables();
LispObject result = NIL;
for (int i = variables.length; i-- > 0;)
result = new Cons(variables[i], result);
@@ -610,22 +586,10 @@
}
}
- private final void declareFreeSpecials(Environment ext)
-
+ private void declareFreeSpecials(Environment ext)
{
- LispObject s = specials;
- special:
- while (s != NIL) {
- Symbol special = (Symbol)s.car();
- s = s.cdr();
- for (Symbol var : variables)
- if (special == var)
- continue special;
- for (Parameter parameter : auxVars)
- if (special == parameter.var)
- continue special;
- ext.declareSpecial(special);
- }
+ for (Symbol special : freeSpecials)
+ ext.declareSpecial(special);
}
@Override
More information about the armedbear-cvs
mailing list