Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/artem/std-lib-print' into artem/…
Browse files Browse the repository at this point in the history
…test-flag
  • Loading branch information
agureev committed Nov 22, 2023
2 parents 1425aa6 + 3c7e9eb commit b125050
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
39 changes: 29 additions & 10 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")
(("test" #\t)
:type boolean :optional t :documentation "Prints a test equality with public parameters")
(("help" #\h #\?)
Expand All @@ -28,7 +30,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 test version)
(defun argument-handlers (&key help stlc output input entry-point vampir library test version)
(flet ((run (stream)
(cond (help
(command-line-arguments:show-option-help +command-line-spec+
Expand All @@ -41,6 +43,7 @@
(load input)
(compile-down :vampir vampir
:stlc stlc
:library library
:entry entry-point
:test test
:stream stream)))))
Expand All @@ -52,17 +55,27 @@
(run *standard-output*))))

;; this code is very bad please abstract out many of the components
(defun compile-down (&key vampir stlc entry test (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 test)
(defun compile-down (&key vampir stlc entry library test (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 test)
(let ((circuit (to-circuit eval vampir-name)))
(geb.vampir:extract (append circuit
(geb.seqn.trans:test-call
(car circuit)))
stream)
(geb.vampir:extract
(append geb.vampir::*standard-library*
circuit (geb.seqn.trans:test-call (car circuit)))
stream)
(format stream ";")))
((and vampir stlc test)
(let ((circuit (to-circuit eval vampir-name)))
(geb.vampir:extract
(append circuit (geb.seqn.trans:test-call (car circuit)))
stream)
(format stream ";")))
((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))
((and vampir test)
Expand All @@ -74,8 +87,14 @@
(format 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
5 changes: 5 additions & 0 deletions src/entry/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mariari@Gensokyo % ./geb.image -h
-o --output string Save the output to a file rather than printing
-v --version boolean Prints the current version of the compiler
-p --vampir string Return a vamp-ir expression
-s --library boolean Print standard library
-h -? --help boolean The current help message
mariari@Gensokyo % ./geb.image -v
Expand Down Expand Up @@ -84,6 +85,10 @@ the -l flag means that we are not expecting a geb term, but rather a
lambda frontend term, this is to simply notify us to compile it as a
lambda term rather than a geb term. In time this will go away
The flag -s prints the standard library the compiler uses. If -p is
used alongside it, the standard library gets printed before the
compiled circuit.
The flag -t after -p signals that the user wants to make an
automatically generated test equality. Given a compiled VampIR
function with name foo and arguments x1...xn prints an equality as
Expand Down

0 comments on commit b125050

Please sign in to comment.