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 "io" 9 "os" 10 "path/filepath" 11 ) 12 13 // WalkInsts calls visit function for each XED instruction found at $xedPath/all-dec-instructions.txt. 14 func WalkInsts(xedPath string, visit func(*Inst)) error { 15 f, err := os.Open(filepath.Join(xedPath, "all-dec-instructions.txt")) 16 if err != nil { 17 return err 18 } 19 r := NewReader(f) 20 for { 21 o, err := r.Read() 22 if err == io.EOF { 23 return nil 24 } 25 if err != nil { 26 return err 27 } 28 for _, inst := range o.Insts { 29 visit(inst) 30 } 31 } 32 } 33