[armedbear-cvs] r13824 - trunk/abcl/src/org/armedbear/lisp

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Sun Jan 29 21:41:47 UTC 2012


Author: ehuelsmann
Date: Sun Jan 29 13:41:47 2012
New Revision: 13824

Log:
Use the arglist parser in some places.

Modified:
   trunk/abcl/src/org/armedbear/lisp/Closure.java

Modified: trunk/abcl/src/org/armedbear/lisp/Closure.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Closure.java	Sun Jan 29 13:15:48 2012	(r13823)
+++ trunk/abcl/src/org/armedbear/lisp/Closure.java	Sun Jan 29 13:41:47 2012	(r13824)
@@ -459,16 +459,10 @@
   {
     final LispThread thread = LispThread.currentThread();
     final SpecialBindingsMark mark = thread.markSpecialBindings();
+
     Environment ext = new Environment(environment);
-    bindRequiredParameters(ext, thread, objects);
-    if (arity != minArgs)
-      {
-        bindParameterDefaults(optionalParameters, ext, thread);
-        if (restVar != null)
-          bindArg(specials, restVar, NIL, ext, thread);
-        bindParameterDefaults(keywordParameters, ext, thread);
-      }
-    bindAuxVars(ext, thread);
+    LispObject[] args = arglist.match(objects, environment, ext, thread);
+    arglist.bindVars(args, ext, thread);
     declareFreeSpecials(ext);
     try
       {
@@ -480,20 +474,6 @@
       }
   }
 
-  private final void bindRequiredParameters(Environment ext,
-                                            LispThread thread,
-                                            LispObject[] objects)
-
-  {
-    // &whole and &environment before anything
-    if (envVar != null)
-      bindArg(specials, envVar, environment, ext, thread);
-    for (int i = 0; i < objects.length; ++i)
-      {
-        bindArg(specials, requiredParameters[i].var, objects[i], ext, thread);
-      }
-  }
-
   public final LispObject invokeArrayExecute(LispObject... objects)
 
   {
@@ -654,21 +634,8 @@
     final LispThread thread = LispThread.currentThread();
     final SpecialBindingsMark mark = thread.markSpecialBindings();
     Environment ext = new Environment(environment);
-    if (optionalParameters.length == 0 && keywordParameters.length == 0)
-      args = fastProcessArgs(args);
-    else
-      args = processArgs(args, thread);
-    Debug.assertTrue(args.length == variables.length);
-    if (envVar != null)
-      {
-        bindArg(specials, envVar, environment, ext, thread);
-      }
-    for (int i = 0; i < variables.length; i++)
-      {
-        Symbol sym = variables[i];
-        bindArg(specials, sym, args[i], ext, thread);
-      }
-    bindAuxVars(ext, thread);
+    args = arglist.match(args, environment, ext, thread);
+    arglist.bindVars(args, ext, thread);
     declareFreeSpecials(ext);
     try
       {
@@ -1029,42 +996,6 @@
     return array;
   }
 
-  private final void bindParameterDefaults(Parameter[] parameters,
-                                           Environment env,
-                                           LispThread thread)
-
-  {
-    for (Parameter parameter : parameters)
-      {
-        LispObject value;
-        if (parameter.initVal != null)
-          value = parameter.initVal;
-        else
-          value = eval(parameter.initForm, env, thread);
-        bindArg(specials, parameter.var, value, env, thread);
-        if (parameter.svar != NIL)
-	  bindArg(specials, (Symbol)parameter.svar, NIL, env, thread);
-      }
-  }
-
-  private final void bindAuxVars(Environment env, LispThread thread)
-
-  {
-    // Aux variable processing is analogous to LET* processing.
-    for (Parameter parameter : auxVars)
-      {
-        Symbol sym = parameter.var;
-        LispObject value;
-
-        if (parameter.initVal != null)
-          value = parameter.initVal;
-        else
-          value = eval(parameter.initForm, env, thread);
-
-        bindArg(specials, sym, value, env, thread);
-      }
-  }
-
   public static class Parameter
   {
     final Symbol var;




More information about the armedbear-cvs mailing list