Documentation ¶
Overview ¶
Package c provides an AST for a subset of C.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayType ¶
ArrayType is an array type.
type BaseType ¶
type BaseType uint8
BaseType is a base type.
const ( Void BaseType = iota + 1 // void Char // char Short // short Int // int Long // long UChar // unsigned char UShort // unsigned short UInt // unsigned int ULong // unsigned long )
Base types.
type Block ¶
type Block struct { // Start line number (relative to the function). LineStart uint32 // End line number (relative to the function). LineEnd uint32 // Local variables. Locals []*VarDecl }
A Block encapsulates a block scope.
type EnumMember ¶
EnumMember is an enum member.
type EnumType ¶
type EnumType struct { // Enum tag. Tag string // Enum members. Members []*EnumMember }
EnumType is a enum type.
type Field ¶
type Field struct { // Offset (optional). Offset uint32 // Size in bytes (optional). Size uint32 // Underlying variable. Var }
A Field represents a field in a structure type or union type.
type FuncDecl ¶
type FuncDecl struct { // Source file. Path string // Address (optional). Addr uint32 // Size (optional). Size uint32 // Start line number. LineStart uint32 // End line number. LineEnd uint32 // Underlying function variable. Var // Scope blocks. Blocks []*Block }
A FuncDecl is a function declaration.
type FuncType ¶
type FuncType struct { // Return type. RetType Type // Function parameters. Params []*VarDecl // Variadic function. Variadic bool }
FuncType is a function type.
type PointerType ¶
type PointerType struct { // Element type. Elem Type }
PointerType is a pointer type.
func (*PointerType) Def ¶
func (t *PointerType) Def() string
Def returns the C syntax representation of the definition of the type.
func (*PointerType) String ¶
func (t *PointerType) String() string
String returns the string representation of the pointer type.
type StorageClass ¶
type StorageClass uint8
A StorageClass is a storage class.
const ( Auto StorageClass = iota + 1 // auto Extern // extern Static // static Register // register Typedef // typedef )
Base types.
func (StorageClass) String ¶
func (i StorageClass) String() string
type StructType ¶
type StructType struct { // Size in bytes (optional). Size uint32 // Structure tag. Tag string // Structure fields. Fields []Field // Struct methods. Methods []Field }
StructType is a structure type.
func (*StructType) Def ¶
func (t *StructType) Def() string
Def returns the C syntax representation of the definition of the type.
func (*StructType) String ¶
func (t *StructType) String() string
String returns the string representation of the structure type.
type Type ¶
type Type interface { fmt.Stringer // Def returns the C syntax representation of the definition of the type. Def() string }
Type is a C type.
type UnionType ¶
type UnionType struct { // Size in bytes (optional). Size uint32 // Union tag. Tag string // Union fields. Fields []Field }
UnionType is a union type.
type VarDecl ¶
type VarDecl struct { // Address, frame pointer delta, or register depending on storage class // (optional). Addr uint32 // Size (optional). Size uint32 // Storage class. Class StorageClass // Underlying variable. Var }
A VarDecl is a variable declaration.