Changeset 11926


Ignore:
Timestamp:
05/22/09 18:04:53 (9 years ago)
Author:
ehuelsmann
Message:

Compilation of functions with a non-null
lexical environment part 2 [of 2]: Functions.

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

Legend:

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

    r11924 r11926  
    348348      }
    349349    };
     350
     351  // ### environment-all-functions
     352  private static final Primitive ENVIRONMENT_ALL_FUNS =
     353    new Primitive("environment-all-functions", PACKAGE_SYS, true, "environment")
     354    {
     355      @Override
     356      public LispObject execute(LispObject arg) throws ConditionThrowable
     357      {
     358            Environment env = checkEnvironment(arg);
     359            LispObject result = NIL;
     360            for (FunctionBinding binding = env.lastFunctionBinding;
     361                 binding != null; binding = binding.next)
     362            result = result.push(new Cons(binding.name, binding.value));
     363            return result.nreverse();
     364      }
     365    };
    350366}
  • trunk/abcl/src/org/armedbear/lisp/Primitives.java

    r11924 r11926  
    17871787      }
    17881788    };
     1789
     1790  // ### macro-function-p
     1791  private static final Primitive MACRO_FUNCTION_P =
     1792      new Primitive("macro-function-p", PACKAGE_SYS, true, "value")
     1793  {
     1794      @Override
     1795      public LispObject execute(LispObject arg) throws ConditionThrowable
     1796      {
     1797          return (arg instanceof MacroObject) ? T : NIL;
     1798      }
     1799  };
     1800
    17891801
    17901802  // ### make-symbol-macro
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11925 r11926  
    30293029                             (local-function-variable local-function))
    30303030                            'stack nil))
     3031          ((local-function-environment local-function)
     3032           (assert (local-function-references-allowed-p local-function))
     3033           (assert (not *file-compilation*))
     3034           (emit 'getstatic *this-class*
     3035                 (declare-object (local-function-environment local-function)
     3036                                 +lisp-environment+
     3037                                 +lisp-environment-class+)
     3038                 +lisp-environment+)
     3039           (emit 'getstatic *this-class*
     3040                 (declare-object (local-function-name local-function))
     3041                 +lisp-object+)
     3042           (emit-invokevirtual +lisp-environment-class+ "lookupFunction"
     3043                               (list +lisp-object+)
     3044                               +lisp-object+))
    30313045          (t
    30323046           (dformat t "compile-local-function-call default case~%")
     
    82418255        (*closure-variables* nil)
    82428256        (*undefined-variables* nil)
    8243         (*local-functions* nil)
     8257        (*local-functions* *local-functions*)
    82448258        (*current-compiland* compiland))
    82458259    (with-saved-compiler-policy
     
    84188432        (*file-compilation* nil)
    84198433        (*visible-variables* nil)
     8434        (*local-functions* nil)
    84208435        (*pathnames-generator* #'make-temp-file)
    84218436        (sys::*fasl-anonymous-package* (sys::%make-package))
     
    84428457                             (not (sys:symbol-macro-p (cdr var)))
    84438458                             :compiland NIL) *visible-variables*)))
     8459    (when environment
     8460      (dolist (fun (reverse (environment-all-functions environment)))
     8461        (push (make-local-function :name (car fun)
     8462                                   :references-allowed-p
     8463                                   (not (macro-function-p (cdr fun)))
     8464                                   :environment environment)
     8465              *local-functions*)))
    84448466    ;; FIXME: we still need to add local functions, ofcourse.
    84458467    (handler-bind
  • trunk/abcl/src/org/armedbear/lisp/jvm.lisp

    r11924 r11926  
    338338  compiland
    339339  inline-expansion
    340   function  ;; the function loaded through load-compiled-function
    341   class-file
    342   variable  ;; the variable which contains the loaded compiled function
    343             ;; or compiled closure
     340  function    ;; the function loaded through load-compiled-function
     341  class-file  ;; the class file structure for this function
     342  variable    ;; the variable which contains the loaded compiled function
     343              ;; or compiled closure
     344  environment ;; the environment in which the function is stored in
     345              ;; case of a function from an enclosing lexical environment
     346              ;; which itself isn't being compiled
     347  (references-allowed-p t)
    344348  )
    345349
Note: See TracChangeset for help on using the changeset viewer.