Coverage report: /home/ellis/comp/core/app/skel/comp/lisp.lisp

KindCoveredAll%
expression0128 0.0
branch04 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; lisp.lisp --- Lisp files
2
 
3
 ;; SK-LISP-FILE
4
 
5
 ;;; Code:
6
 (in-package :skel/comp/lisp)
7
 
8
 (defclass sk-lisp-component (sk-component ast) ())
9
 (defclass sk-lisp-file (sk-lisp-component sk-meta) ())
10
 
11
 (defmethod sk-new ((self (eql :lisp)) &rest args)
12
   (apply #'make-instance 'sk-lisp-file args))
13
 
14
 (defmethod sk-convert ((self cl-source-file))
15
   (make-instance 'sk-lisp-file 
16
     :path #1=(component-pathname self)
17
     :name (component-name self)
18
     :parent (component-parent self)
19
     :version (component-version self)))
20
 
21
 (defmethod sk-compile ((self sk-lisp-file) &rest args)
22
   (apply 'compile-file (path self) args))
23
 
24
 (defmethod sk-load ((self sk-lisp-file) &key (compile t))
25
   (if compile
26
       (compile-and-load (path self))
27
       (load (path self))))
28
 
29
 (defmethod sk-run ((self sk-lisp-file))
30
   (compile-and-eval `(progn ,@(ast self))))
31
   
32
 (defmethods sk-load-component 
33
   (((self (eql :lisp)) (form pathname) &optional (path (project-root)))
34
    (declare (ignore self))
35
    (let* ((type (pathname-type form))
36
           (name (namestring (if type (pathname-name form) form)))
37
           (fname (if type form (make-pathname :directory (namestring path) :name name :type "lisp")))
38
           (comp (make-instance 'sk-lisp-file :parent *skel-project* :path fname :name name)))
39
      comp))
40
   (((self (eql :lisp)) (form list) &optional (path (project-root)))
41
    (let ((opts (cdr form))
42
          (comp (sk-load-component self (pathname (car form)) (namestring path))))
43
      (when-let ((eval (getf opts :eval)))
44
        (case eval
45
          (:always (sk-run comp))
46
          ((or :never nil))
47
          (:load (sk-load comp :compile nil))
48
          ;; default is :COMPILE
49
          (t (sk-load comp :compile t))))
50
      (when (getf opts :read)
51
        (sk-read-file comp (path comp)))
52
      comp)))
53
 
54
 (defmethod print-object ((object sk-lisp-component) stream)
55
   (print-unreadable-object (object stream :type t)
56
     (format stream ":ID ~A" (format-sxhash (id object)))))
57
 
58
 (defmethod read-ast ((self sk-lisp-component) stream &key)
59
   (setf (ast self) (read-lisp-until-end stream)))
60
 
61
 (defmethod sk-read-file ((self sk-lisp-component) path)
62
   (with-input-from-file (f path)
63
     (read-ast self f)))
64
 
65
 (defmethod write-ast ((self sk-lisp-component) stream &key)
66
   (write (ast self) :stream stream))
67
 
68
 (defmethod sk-write-file ((self sk-lisp-component) &key path)
69
   (with-output-to-file (f (or path (path self)))
70
     (write-ast self f)))
71
 
72
 (defmethod load-ast ((self sk-lisp-component))
73
   (if (ast self)
74
       (sk-run (ast self))
75
       (sk-load self)))
76
       
77