Documentation ¶
Index ¶
- Variables
- func ImportToPath(pkgPath, pkgName string) string
- func InterfaceMethodName(interfaceName string, funcName string) string
- func MethodName(tyName string, funcName string) string
- type AliasDecl
- type ArrayType
- type ArrowType
- type BinOp
- type BinaryExpr
- type Binder
- type Binding
- type BlockExpr
- type BoolLiteral
- type ByteLiteral
- type CallExpr
- type CommentDecl
- type ConstDecl
- type Decl
- type DerefExpr
- type Expr
- type FieldDecl
- type File
- type ForLoopExpr
- type FuncDecl
- type FuncLit
- type FuncType
- type GallinaIdent
- type GallinaString
- type HashTableInsert
- type IdentExpr
- type IfExpr
- type ImportDecl
- type ImportDecls
- type Int32Literal
- type IntLiteral
- type InterfaceDecl
- type LoggingStmt
- type MapIterExpr
- type MapType
- type NotExpr
- type PackageIdent
- type PtrType
- type RefExpr
- type ReturnExpr
- type SliceLoopExpr
- type SliceType
- type SpawnExpr
- type StoreStmt
- type StringLiteral
- type StructDecl
- type StructFieldAccessExpr
- type StructLiteral
- type StructName
- type StructToInterface
- type StructToInterfaceDecl
- type TupleExpr
- type TupleType
- type Type
- type TypeDef
- type TypeIdent
- type UnitLiteral
Constants ¶
This section is empty.
Variables ¶
var LoopBreak = GallinaIdent("Break")
var LoopContinue = GallinaIdent("Continue")
var Null = nullLiteral{}
Null represents a nil pointer in Go
Functions ¶
func ImportToPath ¶
ImportToPath converts a Go import path to a Coq path
TODO: we basically don't handle the package name (determined by the package
statement in Go) differing from the basename of its parent directory
func InterfaceMethodName ¶
func MethodName ¶
Types ¶
type ArrowType ¶
type BinaryExpr ¶
func (BinaryExpr) Coq ¶
func (be BinaryExpr) Coq(needs_paren bool) string
type Binding ¶
type Binding struct { // Names is a list to support anonymous and tuple-destructuring bindings. // // If Names is an empty list the binding is anonymous. Names []string Expr Expr }
Binding is a Coq binding (a part of a Bind expression)
Note that a Binding is not an Expr. This is because emitting a binding requires knowing if it is the last binding in a sequence (in which case no binder should be written). A more accurate representation would be a cons representation, but this recursive structure is more awkward to work with; in practice delaying handling the special last-binding to printing time is easier.
type BlockExpr ¶
type BlockExpr struct {
Bindings []Binding
}
A BlockExpr is a sequence of bindings, ending with some expression.
type BoolLiteral ¶
type BoolLiteral bool
var ( False BoolLiteral = false True BoolLiteral = true )
func (BoolLiteral) Coq ¶
func (b BoolLiteral) Coq(needs_paren bool) string
type ByteLiteral ¶
type ByteLiteral struct {
Value uint8
}
func (ByteLiteral) Coq ¶
func (l ByteLiteral) Coq(needs_paren bool) string
type CallExpr ¶
CallExpr includes primitives and references to other functions.
func NewCallExpr ¶
NewCallExpr is a convenience to construct a CallExpr statically, especially for a fixed number of arguments.
type CommentDecl ¶
type CommentDecl string
CommentDecl is a top-level comment
Pretends to be a declaration so it can sit among declarations within a file.
func NewComment ¶
func NewComment(s string) CommentDecl
NewComment creates a CommentDecl with proper whitespacing.
func (CommentDecl) CoqDecl ¶
func (d CommentDecl) CoqDecl() string
CoqDecl implements the Decl interface
For CommentDecl this emits a Coq top-level comment.
type Decl ¶
type Decl interface {
CoqDecl() string
}
Decl is a FuncDecl, StructDecl, CommentDecl, or ConstDecl
type Expr ¶
type Expr interface { // If needs_paren is true, this should be generated with parentheses. Coq(needs_paren bool) string }
var Skip Expr = GallinaIdent("Skip")
func StructDesc ¶
type File ¶
type File struct { ImportHeader string PkgPath string GoPackage string Imports ImportDecls Decls []Decl }
File represents a complete Coq file (a sequence of declarations).
type ForLoopExpr ¶
func (ForLoopExpr) Coq ¶
func (e ForLoopExpr) Coq(needs_paren bool) string
type FuncDecl ¶
type FuncDecl struct { Name string TypeParams []TypeIdent Args []FieldDecl ReturnType Type Body Expr Comment string AddTypes bool }
FuncDecl declares a function, including its parameters and body.
func (FuncDecl) CoqDecl ¶
CoqDecl implements the Decl interface
For FuncDecl this emits the Coq vernacular Definition that defines the whole function.
type GallinaIdent ¶
type GallinaIdent string
GallinaIdent is a identifier in Gallina (and not a variable)
A GallinaIdent is translated literally to Coq.
func (GallinaIdent) Coq ¶
func (e GallinaIdent) Coq(needs_paren bool) string
type GallinaString ¶
type GallinaString string
GallinaString is a Gallina string, wrapped in quotes
This is functionally identical to IdentExpr, but semantically quite different.
func (GallinaString) Coq ¶
func (s GallinaString) Coq(needs_paren bool) string
type HashTableInsert ¶
type HashTableInsert struct {
Value Expr
}
func (HashTableInsert) Coq ¶
func (e HashTableInsert) Coq(needs_paren bool) string
type IdentExpr ¶
type IdentExpr string
IdentExpr is a go_lang-level variable
An IdentExpr is quoted in Coq.
type ImportDecl ¶
These will not end up in `File.Decls`, they are put into `File.Imports` by `translatePackage`.
func (ImportDecl) CoqDecl ¶
func (decl ImportDecl) CoqDecl() string
type ImportDecls ¶
type ImportDecls []ImportDecl
ImportDecls groups imports into one declaration so they can be printed without intervening blank spaces.
func (ImportDecls) PrintImports ¶
func (decls ImportDecls) PrintImports() string
type Int32Literal ¶
type Int32Literal struct {
Value uint32
}
func (Int32Literal) Coq ¶
func (l Int32Literal) Coq(needs_paren bool) string
type IntLiteral ¶
type IntLiteral struct {
Value uint64
}
func (IntLiteral) Coq ¶
func (l IntLiteral) Coq(needs_paren bool) string
type InterfaceDecl ¶
func (InterfaceDecl) Coq ¶
func (d InterfaceDecl) Coq(needs_paren bool) string
func (InterfaceDecl) CoqDecl ¶
func (d InterfaceDecl) CoqDecl() string
type LoggingStmt ¶
type LoggingStmt struct {
GoCall string
}
func (LoggingStmt) Coq ¶
func (s LoggingStmt) Coq(needs_paren bool) string
type MapIterExpr ¶
type MapIterExpr struct {
// name of key and value identifiers
KeyIdent, ValueIdent string
// map to iterate over
Map Expr
// body of loop, with KeyIdent and ValueIdent as free variables
Body BlockExpr
}
MapIterExpr is a call to the map iteration helper.
func (MapIterExpr) Coq ¶
func (e MapIterExpr) Coq(needs_paren bool) string
type PackageIdent ¶
A Go qualified identifier, which is translated to a Gallina qualified identifier.
func (PackageIdent) Coq ¶
func (e PackageIdent) Coq(needs_paren bool) string
type ReturnExpr ¶
type ReturnExpr struct {
Value Expr
}
func (ReturnExpr) Coq ¶
func (e ReturnExpr) Coq(needs_paren bool) string
type SliceLoopExpr ¶
func (SliceLoopExpr) Coq ¶
func (e SliceLoopExpr) Coq(needs_paren bool) string
type SpawnExpr ¶
type SpawnExpr struct {
Body BlockExpr
}
SpawnExpr is a call to Spawn a thread running a procedure.
The body can capture variables in the environment.
type StringLiteral ¶
type StringLiteral struct {
Value string
}
func (StringLiteral) Coq ¶
func (l StringLiteral) Coq(needs_paren bool) string
type StructDecl ¶
StructDecl is a Coq record for a Go struct
func (StructDecl) CoqDecl ¶
func (d StructDecl) CoqDecl() string
CoqDecl implements the Decl interface
A struct declaration simply consists of the struct descriptor (wrapped in a module in case we eventually want to add more things related to the struct).
type StructFieldAccessExpr ¶
type StructFieldAccessExpr struct { Struct string Field string X Expr // the expression X is a pointer to a struct (whether because of pointer // wrapping or because it was a pointer in the program) ThroughPointer bool }
func (StructFieldAccessExpr) Coq ¶
func (e StructFieldAccessExpr) Coq(needs_paren bool) string
type StructLiteral ¶
type StructLiteral struct { StructName string Allocation bool // if true, struct is being allocated on the heap // contains filtered or unexported fields }
A StructLiteral represents a record literal construction using name fields.
Relies on Coq record syntax to correctly order fields for the record's constructor.
func NewStructLiteral ¶
func NewStructLiteral(structName string) StructLiteral
NewStructLiteral creates a StructLiteral with no values.
func (*StructLiteral) AddField ¶
func (sl *StructLiteral) AddField(field string, value Expr)
AddField appends a new (field, val) pair to a StructLiteral.
func (StructLiteral) Coq ¶
func (sl StructLiteral) Coq(needs_paren bool) string
type StructName ¶
type StructName string
StructName refers to a struct type from its name.
This is Type rather than an Expr.
func (StructName) Coq ¶
func (t StructName) Coq(needs_paren bool) string
type StructToInterface ¶
func (StructToInterface) Coq ¶
func (d StructToInterface) Coq(needs_paren bool) string
func (StructToInterface) CoqDecl ¶
func (d StructToInterface) CoqDecl() string
func (StructToInterface) MethodList ¶
func (d StructToInterface) MethodList() []string
func (StructToInterface) Name ¶
func (d StructToInterface) Name() string
type StructToInterfaceDecl ¶
func (StructToInterfaceDecl) Coq ¶
func (d StructToInterfaceDecl) Coq(needs_paren bool) string
type Type ¶
type Type interface { // If needs_paren is true, this should be generated with parentheses. Coq(needs_paren bool) string }
Type represents some Coq type.
Structurally identical to Expr but serves as a nice annotation in the type system for where types are expected.
func NewTupleType ¶
NewTupleType is a smart constructor that wraps multiple types in a TupleType
type TypeIdent ¶
type TypeIdent string
TypeIdent is an identifier referencing a type.
Much like the Type interface this is the same as Ident but signals that a Go type rather than a value is being referenced.
type UnitLiteral ¶
type UnitLiteral struct{}
var Tt UnitLiteral = struct{}{}
func (UnitLiteral) Coq ¶
func (tt UnitLiteral) Coq(needs_paren bool) string