-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.lisp
85 lines (73 loc) · 2.14 KB
/
main.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PVS to C translator
;;
;; Author: Gaspard ferey
;;
;; -> https://github.com/Gaspi/pvs2c.git
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; The whole project is available on Github at the following address
;; https://github.com/Gaspi/pvs2c.git
;;
;; To make this work, you need:
;; - The following files:
;; main.lisp (this file)
;; Cutils.lisp
;; Ctypes.lisp
;; Ccode.lisp
;; Canalysis.lisp
;; Cprimop.lisp
;; pvs2c.lisp
;; GC.c
;; - The GNU GMP library installed
;; -> https://gmplib.org/
;;
;;
;; To use:
;; - Copy all the files above (8 files) in the folder containing
;; the .pvs file (e.g. "foo.pvs") you're interested in
;; translating to C.
;; - Start PVS, open this .pvs file and typecheck it.
;; - Switch to the *pvs* buffer and execute:
;; (load "pvs2c")
;; (generate-C-for-pvs-file "foo")
;; - "foo.c" and "foo.h" were created.
;; - (optionnal) Compile with:
;; gcc -o foo foo.c GC.c -lgmp
;; - (optionnal) Execute with:
;; ./foo
;;
;;
;; TODO: management of GC of variables
;; GC_free all variables at the end
;; f( GC(*A*) ) => f( A ) and remove GC_free(A)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package :pvs)
(defvar *tests-on-load* nil )
(defun load-and-test (&rest tests)
(setq *tests-on-load* tests)
(load "main"))
(load "Cutils")
;; Use for debugging purposes...
;; (setq *Cshow-safe* t )
;; (setq *Cshow-bang* t )
;; (setq *Cshow-dupl* t )
;; (setq *Cdebug* t )
;; (setq *Csimple-names* nil )
;; (setq *Crename-uli* t )
;; (setq *C-analysis* t )
;; (setq *C-replace-analysis* t )
;; ;; The tests to perform on load
;; (setq *tests-on-load* (list "test" "draft"))
(load "Ctypes")
(load "Ccode")
(load "Canalysis")
(load "Cprimop")
(load "pvs2c")
;; Perform tests
(when *tests-on-load*
(setf *tests-on-load* nil)
(format t "All Lisp files loaded.~%")
(test-cases))