golang.org/x/arch@v0.17.0/x86/xeddata/xeddata.go (about)

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package xeddata
     6  
     7  import (
     8  	"os"
     9  	"path/filepath"
    10  )
    11  
    12  // WalkInsts calls visit function for each XED instruction found at $xedPath/all-dec-instructions.txt.
    13  func WalkInsts(xedPath string, visit func(*Inst)) error {
    14  	f, err := os.Open(filepath.Join(xedPath, "all-dec-instructions.txt"))
    15  	if err != nil {
    16  		return err
    17  	}
    18  	for obj, err := range readObjects(f) {
    19  		if err != nil {
    20  			return err
    21  		}
    22  		for _, inst := range obj.Insts {
    23  			visit(inst)
    24  		}
    25  	}
    26  	return nil
    27  }