Coverage report: /home/ellis/comp/core/lib/syn/gen/c/sym.lisp
Kind | Covered | All | % |
expression | 2 | 169 | 1.2 |
branch | 0 | 26 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; sym.lisp --- GEN/C Symbols
6
(in-package :syn/gen/c/sym)
8
;;standard functions/macros
9
(defmacro when (test &body forms)
15
;;; new cons with (t ...) and without "else {}"
16
(defmacro cond (&rest clauses)
17
(let ((head (first clauses)))
20
(if (eql (first head) t)
21
(cons 'progn (cdr head))
24
(cons 'progn (cdr head)))
26
`(cond ,@(cdr clauses)))))))))
34
(defmacro cpp (&rest args)
35
`(make-instance 'comment :comment ,(format nil "~{~a~^ ~}" args) :chars "#"))
37
(defmacro pragma (&rest args)
38
`(cpp "pragma" ,@args))
40
;; Code proposed by plops on issue #17
41
;; https://github.com/kiselgra/c-mera/issues/17
42
(defun replace-newline-with-backslash-newline (string)
43
;; this is from common lisp cookbook i got it from here:
44
;; http://stackoverflow.com/questions/4366668/str-replace-in-lisp
45
;; i modified it to only search for newlines
47
(let ((part #\Newline)
50
(with-output-to-string (out)
52
for old-pos = 0 then (+ pos 1)
53
for pos = (position part string
56
do (write-string string out
58
:end (or pos (cl:length string)))
59
when pos do (write-string replacement out)
62
(defmacro codestring (&body body)
63
`(make-instance 'comment
66
(replace-newline-with-backslash-newline
67
(with-output-to-string (*standard-output*)
68
(simple-print (progn ,@body)))))
71
(defun symbol-append (&rest symbols)
72
"Generate a symbol by combining the names of a number of symbols."
74
(intern (apply #'concatenate 'string
75
(mapcar #'symbol-name symbols)))))
77
(defun extract-parameter-names-from-lambda-list (args)
78
"Find the names of all parameters in a DEFMACRO-sytle (i.e. nested) lambda list."
84
until (member arg lambda-list-keywords)
85
if (listp arg) append (extract-parameter-names-from-lambda-list arg)
87
finally (setf special i))))
89
(loop for arg in (common-lisp:subseq args special)
90
if (listp arg) collect (first arg)
91
else if (not (member arg lambda-list-keywords)) collect arg)))))
93
(defun get-declaration-name (item)
95
(let ((symbol (first (last (butlast item)))))
96
(cl:and (symbolp symbol)
97
(equal (symbol-name symbol) "=")))
99
(first (last item)))))
100
(cl:if (cl:and (listp id)
101
(let ((first (first id)))
102
(cl:or (eql first 'aref)
104
(eql first 'fpointer)
105
(eql first 'funcall))))
106
(first (last (std:flatten (second id))))
107
(first (std:flatten id)))))
110
(defmacro use-variables (&rest variables)
112
,@(loop for i in variables collect
113
`(defparameter ,i ',i))
116
(defmacro use-functions (&rest functions)
118
,@(loop for i in functions collect
119
`(defmacro ,i (&rest body) `(funcall ,',i ,@body)))))
122
(defmacro fn (&body body)