Documentation ¶
Overview ¶
Package types contains the Plan interpreter, which is used to validate a Plan source file's structure and contents, then store the result in a more constrained representation.
Index ¶
- type Arch
- type Array
- type Bitfield
- type CodeText
- type Docs
- type DocsItem
- type Enumeration
- type Field
- type File
- type Group
- type Integer
- type ItemReference
- type Name
- type NewInteger
- type Newline
- type Padding
- type Parameter
- type Parameters
- type Pointer
- type Reference
- type ReferenceText
- type Structure
- type Syscall
- type SyscallReference
- type Text
- type Type
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arch ¶
type Arch uint8
Arch represents an instruction set architecture, which is used to customise types for a particular architecture.
type Bitfield ¶
type Bitfield struct { Name Name Node *ast.List Docs Docs Groups []Name Type Integer Values []*Value }
Bitfield represents a numerical type with a constrained set of valid values in a syscalls plan. The values can be combined together, but each value uses one bit in the underlying integer, resulting in a smaller number of individual values than an enumeration of the same size.
type CodeText ¶
type CodeText string
CodeText represents plain text in a set of documentation that should be formatted as source code.
type Docs ¶
type Docs []DocsItem
Docs represents a set of documentation for a type Plan a source file. The docs are split into lines.
type DocsItem ¶
type DocsItem interface {
// contains filtered or unexported methods
}
DocsItem represents an item in the set of documentation for a type, syscall, or field.
type Enumeration ¶
type Enumeration struct { Name Name Node *ast.List Docs Docs Groups []Name Type Integer Embeds []*Enumeration Values []*Value }
Enumeration represents a numerical type with a constrained set of valid values in a syscalls plan.
func (*Enumeration) Alignment ¶
func (e *Enumeration) Alignment(a Arch) int
func (*Enumeration) End ¶
func (e *Enumeration) End() token.Position
func (*Enumeration) Parameter ¶
func (e *Enumeration) Parameter(a Arch) bool
func (*Enumeration) Pos ¶
func (e *Enumeration) Pos() token.Position
func (*Enumeration) Size ¶
func (e *Enumeration) Size(a Arch) int
func (*Enumeration) String ¶
func (e *Enumeration) String() string
type File ¶
type File struct { // Data structures. Arrays []*Array Bitfields []*Bitfield Enumerations []*Enumeration NewIntegers []*NewInteger Structures []*Structure // System calls. Syscalls []*Syscall // Item groups. Groups []*Group }
File represents a parsed syscalls plan.
func Interpret ¶
Interpret processes a Plan source file, producing a structured representation for the interface it defines.
func (*File) DropAST ¶
func (f *File) DropAST()
DropAST can be used to remove the AST nodes from a file, to make it easier to reproduce in tests.
func (*File) SyscallsEnumeration ¶
func (f *File) SyscallsEnumeration() *Enumeration
SyscallsEnumeration returns a synthetic enumeration (with no AST data) describing the set of syscalls. This can be used to iterate over the set of syscalls in a target language.
type Group ¶
type Group struct { Name Name Node *ast.List Docs Docs List []*ItemReference }
Group represents a group of logically related items.
type ItemReference ¶
ItemReference is like Reference, but it names the type of item in Underlying.
type Name ¶
type Name []string
Name represents a name defined in a Plan source file.
func (Name) PascalCase ¶
PascalCase returns the name in 'Pascal case', such as "PascalCase".
func (Name) ScreamCase ¶
ScreamCase returns the name in 'scream case', such as "SCREAM_CASE".
type NewInteger ¶
NewInteger represents a new type that has been defined, with an underlying integer type.
func (*NewInteger) Alignment ¶
func (i *NewInteger) Alignment(a Arch) int
func (*NewInteger) End ¶
func (i *NewInteger) End() token.Position
func (*NewInteger) Parameter ¶
func (i *NewInteger) Parameter(a Arch) bool
func (*NewInteger) Pos ¶
func (i *NewInteger) Pos() token.Position
func (*NewInteger) Size ¶
func (i *NewInteger) Size(a Arch) int
func (*NewInteger) String ¶
func (i *NewInteger) String() string
type Newline ¶
type Newline struct{}
Newline represents a line break in the text of a set of documentation.
type Padding ¶
type Padding uint16
Padding represents unused space that is included after a field in a structure to ensure the fields and structure remain correctly aligned.
type Parameter ¶
Parameter represents a single argument or result in a function call.
func (*Parameter) Enumeration ¶
func (p *Parameter) Enumeration() *Enumeration
type Parameters ¶
type Parameters []*Parameter
Parameters is an ordered set of function parameters, such as its arguments or results.
type Reference ¶
Reference represents a name used to reference a type that has already been defined elsewhere.
type ReferenceText ¶
type ReferenceText struct {
Type
}
ReferenceText represents plain text that refers to a type defined in the Plan document.
This will normally be turned into a link to the relevant type definition when rendered in documentation.
type Syscall ¶
type Syscall struct { Name Name Node *ast.List Docs Docs Groups []Name Args Parameters Results Parameters }
Syscall describes a system call, including its parameters and results.
type SyscallReference ¶
type SyscallReference struct {
Name Name
}
SyscallReference can be used in documentation references to link to a system call and is used internally to prevent syscalls and types clashing in the name space.
func (*SyscallReference) Alignment ¶
func (r *SyscallReference) Alignment(a Arch) int
func (*SyscallReference) Parameter ¶
func (r *SyscallReference) Parameter(a Arch) bool
func (*SyscallReference) Size ¶
func (r *SyscallReference) Size(a Arch) int
func (*SyscallReference) String ¶
func (r *SyscallReference) String() string
type Type ¶
type Type interface { // Alignment returns the memory alignment // of the type on the specified architecture. // // That is, the offset in bytes into a // structure at which a field of this type // appears must be an exact multiple of its // alignment. For example, if type `A` has // an alignment of 8, then any structure // fields of type `A` must have an offset // into the structure that is a multiple of // 8. // // Alignment values must be larger than // 0, and must be an exact power of 2. Alignment(Arch) int // Size returns the number of bytes that // a value of the type will consume in // memory. // // Size values must be an exact multiple // of the type's alignment, and must be // non-negative. Size(Arch) int // Parameter returns whether the type // can be passed in a syscall parameter. Parameter(Arch) bool // String returns a brief textual // representation for the type. String() string }
Type represents any type that can be referenced in a Plan document, including complex structure types.
func Underlying ¶
Underlying returns the base type, dereferencing any References if necessary.