Skip to content

Commit

Permalink
Add Standard Library Flag for Entry
Browse files Browse the repository at this point in the history
Adds a `library` flag which can be included while using Geb as a
binary to print the standard library alongside the compiled STLC or
Geb term.
  • Loading branch information
agureev committed Nov 21, 2023
1 parent 4eb67b8 commit cb83981
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/entry/entry.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
:type boolean :optional t :documentation "Prints the current version of the compiler")
(("vampir" #\p)
:type string :optional t :documentation "Return a vamp-ir expression")
(("library" #\s)
:type boolean :optional t :documentation "Prints standard library")
(("help" #\h #\?)
:type boolean :optional t :documentation "The current help message")))

Expand All @@ -26,7 +28,7 @@
(defparameter *no-input-text*
"Please provide an input file with -p or see the help command with -h")

(defun argument-handlers (&key help stlc output input entry-point vampir version)
(defun argument-handlers (&key help stlc output input entry-point vampir library version)
(flet ((run (stream)
(cond (help
(command-line-arguments:show-option-help +command-line-spec+
Expand All @@ -39,6 +41,7 @@
(load input)
(compile-down :vampir vampir
:stlc stlc
:library library
:entry entry-point
:stream stream)))))
(if output
Expand All @@ -49,16 +52,26 @@
(run *standard-output*))))

;; this code is very bad please abstract out many of the components
(defun compile-down (&key vampir stlc entry (stream *standard-output*))
(let* ((name (read-from-string entry))
(eval (eval name))
(vampir-name (renaming-scheme (intern (symbol-name name) 'keyword))))
(cond ((and vampir stlc)
(defun compile-down (&key vampir stlc entry library (stream *standard-output*))
(let* ((name (read-from-string entry))
(eval (eval name))
(vampir-name (renaming-scheme (intern (symbol-name name) 'keyword))))
(cond ((and vampir stlc library)
(geb.vampir:extract
(append geb.vampir::*standard-library*
(to-circuit eval vampir-name))))
((and vampir stlc)
(geb.vampir:extract (to-circuit eval vampir-name) stream))
(stlc
(format stream "~A" (to-cat nil eval)))
((and vampir library)
(geb.vampir:extract
(append geb.vampir::*standard-library*
(to-circuit eval vampir-name))))
(vampir
(geb.vampir:extract (to-circuit eval vampir-name) stream))
(library
(geb.vampir:extract geb.vampir::*standard-library*))
(t
(format stream eval)))))

Expand Down

0 comments on commit cb83981

Please sign in to comment.