From 15402fe9dbdacd598a723e3b39fc9e90032680cd Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 7 Jul 2019 09:23:10 +0200 Subject: [PATCH] add comp.el --- lisp/emacs-lisp/comp.el | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lisp/emacs-lisp/comp.el diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el new file mode 100644 index 00000000000..d72127a6eb1 --- /dev/null +++ b/lisp/emacs-lisp/comp.el @@ -0,0 +1,50 @@ +;;; comp.el --- compilation of Lisp code into native code -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Keywords: lisp +;; Package: emacs + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'disass) +(eval-when-compile (require 'cl-lib)) + +(defgroup comp nil + "Emacs Lisp native compiler." + :group 'lisp) + +(defun comp-recuparate-lap (fun) + "Compile FUN if necessary and recuparate its LAP rapresentation." + (byte-compile-close-variables + (byte-compile-top-level (byte-compile-preprocess fun)) + byte-compile-lap-output)) + +(defun comp-compute-blocks (obj) + "Split OBJ in basic blocks." + obj) + +(defun native-compile (fun) + "FUN is the function definition to be compiled to native code." + (if-let ((f (symbol-function fun))) + (comp-recuparate-lap f) + (error "Trying to native compile not a function"))) + +(provide 'comp) + +;;; comp.el ends here