Plaster
New
List
Login
text
apl
aspx
asterisk
brainfuck
c
c++hdr
c++src
cassandra
ceylon
clojure
clojurescript
cmake
cobol
coffeescript
common-lisp
crystal
csharp
css
cypher-query
cython
d
dart
diff
django
dockerfile
dylan
ebnf
ecl
ecmascript
edn
eiffel
ejs
elm
erb
erlang
ez80
factor
fcl
feature
forth
fortran
fragment
gfm
go
gql
groovy
gss
haml
handlebars-template
haskell
haxe
hive
html
http
httpd-php
httpd-php-open
hxml
ini
java
javascript
json
jsp
jsx
julia
kotlin
latex
less
literate-haskell
lua
mariadb
markdown
mbox
mirc
mscgen
msgenny
mssql
mumps
mysql
n-triples
nesc
nginx-conf
nsis
objectivec
octave
oz
pascal
perl
pgp
pgp-keys
pgp-signature
pgsql
php
pig
plsql
properties
protobuf
puppet
python
q
rpm-changes
rpm-spec
rsrc
ruby
rustsrc
sas
sass
scala
scheme
scss
sieve
slim
smarty
solr
soy
sparql-query
spreadsheet
sql
squirrel
stex
styl
swift
systemverilog
tcl
textile
tiddlywiki
tiki
tlv
tornado
ttcn-asn
ttcn-cfg
turtle
twig
typescript
typescript-jsx
vb
vbscript
velocity
verilog
vertex
vhdl
vue
webidl
xml
xml-dtd
xquery
xu
yaml
z80
default
Visibility:
public
unlisted
private
(defstruct (defcomponent-info (:constructor %make-defcomponent-info)) (process-reads (make-hash-table)) (process-writes (make-hash-table))) (defvar *defcomponent-info* (make-hash-table :test #'equalp)) (defun defcomponent-info (cid) (values (gethash cid *defcomponent-info*))) (defun (setf defcomponent-info) (info cid) (setf (gethash cid *defcomponent-info*) info)) (defun ensure-defcomponent-info (cid) (orf (defcomponent-info cid) (%make-defcomponent-info))) (defun clear-defcomponent-info () (setf *defcomponent-info* (make-hash-table :test #'equalp))) (defun process-reads (cid pid) (let ((info (ensure-defcomponent-info cid))) (values (gethash pid (defcomponent-info-process-reads info))))) (defun (setf process-reads) (signals cid pid) (let ((info (ensure-defcomponent-info cid))) (setf (gethash pid (defcomponent-info-process-reads info)) signals))) (defun process-writes (cid pid) (let ((info (ensure-defcomponent-info cid))) (values (gethash pid (defcomponent-info-process-writes info))))) (defun (setf process-writes) (signals cid pid) (let ((info (ensure-defcomponent-info cid))) (setf (gethash pid (defcomponent-info-process-writes info)) signals))) (defun make-process-lambda (cid pid body signals) (alexandria:with-gensyms (read-sym) `(lambda () (macrolet ((,read-sym (sym) (pushnew sym (process-reads ',cid ',pid)) sym) (<- (sym value) (pushnew sym (process-writes ',cid ',pid)) `(%<- ',sym ,value))) (symbol-macrolet ,(mapcar (lambda (s) `(,s (,read-sym ,s))) signals) ,@body))))) (defmacro defcomponent (name pins &body options) (let* ((cid (gensym)) (wires (assoc-collect :signals options)) (signals (append pins wires)) (processes (assoc-value-all :process options)) (connections (assoc-value-all :<= options)) (subcomponents (assoc-collect :map options)) (process-function-exprs (mapcar (lambda (p) (let* ((pid (gensym)) (process-function-sym (gensym)) (name (car p)) (body (cdr p))) `(let ((,process-function-sym ;; The process-lambda returned my MAKE-PROCESS-LAMBDA ;; and interpolated within this expansion will be ;; compiled/expanded on another "pass". That's when the ;; information is generated. ,(make-process-lambda cid pid body signals))) ;; I want to use the computed information here, as arguments ;; to :reads and :writes. (list 'process-spec :name ,name :body ,process-function-sym ;; ,(process-reads cid pid) ;; (process-reads ',cid ',pid) :reads |???| ;; ,(process-writes cid pid))))) ;; (process-writes ',cid ',pid) :writes |???| processes))) `(ensure-component-spec ',name :pins ',pins :wires ',wires :connections ',connections :subcomponents ',subcomponents :processes (list ,@process-function-exprs))))