Documentation
¶
Index ¶
- type CGOTable
- type DataType
- type Table
- func (t *Table) AddDataType(sym *symbols.SymbolDef) error
- func (t *Table) AddFunction(sym *symbols.SymbolDef) error
- func (t *Table) AddVariable(sym *symbols.SymbolDef) error
- func (t *Table) Exists(name string) bool
- func (t *Table) Lookup(key string) (*symbols.SymbolDef, symbols.SymbolType, error)
- func (t *Table) LookupAllMethods(datatype string) (map[string]*symbols.SymbolDef, error)
- func (t *Table) LookupDataType(key string) (*symbols.SymbolDef, error)
- func (t *Table) LookupFunction(key string) (*symbols.SymbolDef, error)
- func (t *Table) LookupMethod(datatype, methodName string) (*symbols.SymbolDef, error)
- func (t *Table) LookupVariable(key string) (*symbols.SymbolDef, error)
- func (t *Table) LookupVariableLikeSymbol(key string) (*symbols.SymbolDef, symbols.SymbolType, error)
- func (t *Table) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CGOTable ¶
type CGOTable struct {
*Table
}
Examples
func Print(s string) { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) C.fputs(cs, (*C.FILE)(C.stdout)) }
Analysis: - C.CString is stored into allocated symbol table as gotypes.CgoSymbol{Def: "CString", Package: "C"} - cs is out gotypes.CgoSymbol{Def: "CString", Package: "C"} - unsafe.Pointer is processed as usually - C.free is stored as gotypes.CgoSymbol{Def: "free", Package: "C"} - C.stdout is stored as gotypes.CgoSymbol{Def: "stdout", Package: "C"} - C.FILE is stored as gotypes.CgoSymbol{Def: "FILE", Package: "C"} - C.fputs is stored as gotypes.CgoSymbol{Def: "fputs", Package: "C"}
Basically, if a gotypes.DataType is of gotypes.CgoSymbol type, it is interpreted based on a context. E.g. if it is a part of an expression, it is interpreted as it would have one result value E.g. it it is a part of a multi-var assignmet, each variable is of type gotypes.CgoSymbol{Def: "", Package: "C"} unless the type can be deduced
C.GoString convers C zero-terminated array of chars to Go string C.int convers Go int to C int C.CString covers Go string to C string
Or go tool cgo -godefs translates all C-like structs into G-like ones
func NewCGOTable ¶
func NewCGOTable() *CGOTable
func (*CGOTable) LoadFromFile ¶
type DataType ¶
func (*DataType) UnmarshalYAML ¶
type Table ¶
type Table struct { Symbols map[string][]*symbols.SymbolDef `json:"symbols"` PackageQID string `json:"qid"` Imports []string `json:"imports"` // contains filtered or unexported fields }