summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-07 10:16:46 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-07 10:16:46 -0700
commit0a1e7693df57971fd3eaf1e97c9f1b1e25634c72 (patch)
tree237f1a7b26305bd59c5ef460d1aedd6c1501a1a0 /share
parentd37a97e912b8711e3c0c824b27b01f6bec456221 (diff)
downloadtxr-0a1e7693df57971fd3eaf1e97c9f1b1e25634c72.tar.gz
txr-0a1e7693df57971fd3eaf1e97c9f1b1e25634c72.tar.bz2
txr-0a1e7693df57971fd3eaf1e97c9f1b1e25634c72.zip
new function: compile.
* lisplib.c (compiler_set_entries): Add compile to autoloads. * share/txr/stdlib/compiler.tl (usr:compile): New function.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/compiler.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 47d77d7f..0a46e0ae 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -1387,3 +1387,18 @@
(when (> (sys:parser-errors parser) 0)
(error "~s: compilation of ~s failed" 'compile-file
(stream-get-prop in-stream :name))))))))
+
+(defun usr:compile (obj)
+ (typecase obj
+ (fun (tree-bind (indicator args . body) (func-get-form obj)
+ (let* ((form ^(lambda ,args ,*body))
+ (vm-desc (compile-toplevel form)))
+ (vm-execute-toplevel vm-desc))))
+ (t (condlet
+ (((fun (symbol-function obj)))
+ (tree-bind (indicator args . body) (func-get-form fun)
+ (let* ((form ^(lambda ,args ,*body))
+ (vm-desc (compile-toplevel form))
+ (comp-fun (vm-execute-toplevel vm-desc)))
+ (set (symbol-function obj) comp-fun))))
+ (t (error "~s: cannot compile ~s" 'compile obj))))))