-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathproofgen.go
39 lines (29 loc) · 1.07 KB
/
proofgen.go
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
package proofgen
import (
"fmt"
"io"
"strings"
"github.com/goose-lang/goose/declfilter"
"github.com/goose-lang/goose/glang"
"golang.org/x/tools/go/packages"
)
func Package(w io.Writer, pkg *packages.Package, usingFfi bool, ffi string, filter declfilter.DeclFilter) {
fmt.Fprintf(w, "(* autogenerated by goose proofgen (types); do not modify *)\n")
if usingFfi {
fmt.Fprintf(w, "Require Export New.proof.%s_prelude.\n", ffi)
} else {
fmt.Fprintf(w, "Require Export New.proof.proof_prelude.\n")
}
coqPath := strings.ReplaceAll(glang.ThisIsBadAndShouldBeDeprecatedGoPathToCoqPath(pkg.PkgPath), "/", ".")
if filter.HasTrusted() {
fmt.Fprintf(w, "Require Export New.manualproof.%s.\n", coqPath)
}
tr := translateImports(w, pkg, usingFfi, ffi, filter)
fmt.Fprintf(w, "Require Export New.code.%s.\n", coqPath)
fmt.Fprintf(w, "Require Export New.golang.theory.\n\n")
fmt.Fprintf(w, "Module %s.\n", pkg.Name)
tr.translateImportList(w, pkg)
translateTypes(w, pkg, usingFfi, ffi, filter)
translateNames(w, pkg, usingFfi, ffi, filter)
fmt.Fprintf(w, "End %s.\n", pkg.Name)
}