internal/load: doc exported symbols (#9)
This commit is contained in:
@@ -12,11 +12,13 @@ import (
|
|||||||
"github.com/mmcloughlin/avo/internal/opcodesxml"
|
"github.com/mmcloughlin/avo/internal/opcodesxml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Expected data source filenames.
|
||||||
const (
|
const (
|
||||||
defaultCSVName = "x86.v0.2.csv"
|
DefaultCSVName = "x86.v0.2.csv"
|
||||||
defaultOpcodesXMLName = "x86_64.xml"
|
DefaultOpcodesXMLName = "x86_64.xml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Loader builds an instruction database from underlying datasources.
|
||||||
type Loader struct {
|
type Loader struct {
|
||||||
X86CSVPath string
|
X86CSVPath string
|
||||||
OpcodesXMLPath string
|
OpcodesXMLPath string
|
||||||
@@ -25,13 +27,17 @@ type Loader struct {
|
|||||||
order map[string]opcodescsv.OperandOrder
|
order map[string]opcodescsv.OperandOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewLoaderFromDataDir constructs an instruction loader from datafiles in the
|
||||||
|
// given directory. The files themselves are expected to have the standard
|
||||||
|
// names: see Default*Name constants.
|
||||||
func NewLoaderFromDataDir(dir string) *Loader {
|
func NewLoaderFromDataDir(dir string) *Loader {
|
||||||
return &Loader{
|
return &Loader{
|
||||||
X86CSVPath: filepath.Join(dir, defaultCSVName),
|
X86CSVPath: filepath.Join(dir, DefaultCSVName),
|
||||||
OpcodesXMLPath: filepath.Join(dir, defaultOpcodesXMLName),
|
OpcodesXMLPath: filepath.Join(dir, DefaultOpcodesXMLName),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load performs instruction loading.
|
||||||
func (l *Loader) Load() ([]inst.Instruction, error) {
|
func (l *Loader) Load() ([]inst.Instruction, error) {
|
||||||
if err := l.init(); err != nil {
|
if err := l.init(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user