Documentation
¶
Overview ¶
Package xc provides cross language compiler support/utility stuff.
Index ¶
- Variables
- type Dictionary
- type FileCentral
- type MemDB
- type Once
- type Report
- func (c *Report) ClearErrors() error
- func (c *Report) Err(pos token.Pos, format string, arg ...interface{})
- func (c *Report) ErrChar(ch lex.Char, format string, arg ...interface{})
- func (c *Report) ErrPosition(position token.Position, format string, arg ...interface{})
- func (c *Report) ErrTok(tok Token, format string, arg ...interface{})
- func (c *Report) Errors(sorted bool) error
- type Token
- type Val
Constants ¶
This section is empty.
Variables ¶
var ( // DB keeps parser/compiler data shared between stages. See also *MemDB // methods. DB = NewMemDB() // Dict collects unique []byte values using the global DB variable. // See also *Dictionary methods. Dict = NewDictionary() // FileSet represents a set of source files. FileSet = token.NewFileSet() // Files is a ready to use FileCentral. Files = NewFileCentral() // PrintHooks define default strutil.PrettyPrintHooks. PrintHooks = strutil.PrettyPrintHooks{ reflect.TypeOf(lex.Char{}): func(f strutil.Formatter, v interface{}, prefix, suffix string) { c := v.(lex.Char) suffix = strings.Replace(suffix, "%", "%%", -1) f.Format("%s%v: %q"+suffix, prefix, FileSet.Position(c.Pos()), string(c.Rune)) }, reflect.TypeOf(token.Pos(0)): func(f strutil.Formatter, v interface{}, prefix, suffix string) { p := v.(token.Pos) suffix = strings.Replace(suffix, "%", "%%", -1) f.Format("%s%v"+suffix, prefix, FileSet.Position(p)) }, reflect.TypeOf(Val(0)): func(f strutil.Formatter, v interface{}, prefix, suffix string) { suffix = strings.Replace(suffix, "%", "%%", -1) f.Format("%s%s"+suffix, prefix, Dict.S(int(v.(Val)))) }, } )
Functions ¶
This section is empty.
Types ¶
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is a bijection of a set of byte slice values and their associated numeric identifiers. A zero length byte slice is guaranteed to have zero ID. Dictionary uses the global DB variable.
func NewDictionary ¶
func NewDictionary() *Dictionary
NewDictionary returns a newly created *Dictionary.
func (*Dictionary) ID ¶
func (d *Dictionary) ID(s []byte) int
ID returns the identifier associated with s. If len(s) is 0, ID returns zero.
func (*Dictionary) S ¶
func (d *Dictionary) S(id int) []byte
S returns the byte slice associated with id.
NOTE: The result refers to the dictionary backing storage directly without copying and is thus strictly R/O.
func (*Dictionary) SID ¶
func (d *Dictionary) SID(s string) int
SID is like ID but accepts a string instead of a byte slice.
type FileCentral ¶
type FileCentral struct {
// contains filtered or unexported fields
}
FileCentral provides centralized source file handling. Methods of FileCentral are synchonized; multiple goroutines may invoke them concurrently.
func NewFileCentral ¶
func NewFileCentral() *FileCentral
NewFileCentral returns a newly created FileCentral.
func (*FileCentral) Map ¶
func (f *FileCentral) Map(fn func(string, *Once) bool)
Map calls fn for every pair of path and its associated Once in f, in random order. f is locked through the execution of Map.
If fn returns false, the iteration of f is aborted.
func (*FileCentral) Once ¶
func (f *FileCentral) Once(id string, set func() interface{}) *Once
Once returns the *Once associated with id, which must be an absolute path. If the value of the returned object needs to be set, Once starts the set function in a new goroutine to obtain the value. Once will panic is the set function returns nil.
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
MemDB stores data accessible using a numeric identifier.
type Once ¶
type Once struct {
// contains filtered or unexported fields
}
Once manages a single value instantiated only once.
type Report ¶
type Report struct { // ErrLimit limits the number of calls to the error reporting methods. // After the limit is reached, all errors are reported using log.Print // and then log.Fatal() is called with a message about too many errors. // To disable error limit set ErrLimit to value less or equal zero. // Default value is 10. ErrLimit int // IgnoreErrors is a testing hook allowing to ignore errors. IgnoreErrors bool // PanicOnError is a testing hook allowing to fast fail by panicking on // first call to any of the error reporting methods. PanicOnError bool // TraceErrors enable printing errors to stderr as they come, which // means they may not be sorted. Intended for testing. TraceErrors bool // contains filtered or unexported fields }
Report provides centralized error collecting. Methods of Report are synchonized; multiple goroutines may invoke them concurrently.
func (*Report) ClearErrors ¶
ClearErrors clears any errors already reported to c and returnes them.
func (*Report) ErrChar ¶
ErrChar reports an error for char ch. ErrChar is safe for concurrent use by multiple goroutines.
func (*Report) ErrPosition ¶
ErrPosition reports an error at position.