line.go 1021 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2009 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. package obj
  5. import (
  6. "github.com/twitchyliquid64/golang-asm/goobj"
  7. "github.com/twitchyliquid64/golang-asm/src"
  8. )
  9. // AddImport adds a package to the list of imported packages.
  10. func (ctxt *Link) AddImport(pkg string, fingerprint goobj.FingerprintType) {
  11. ctxt.Imports = append(ctxt.Imports, goobj.ImportedPkg{Pkg: pkg, Fingerprint: fingerprint})
  12. }
  13. func linkgetlineFromPos(ctxt *Link, xpos src.XPos) (f string, l int32) {
  14. pos := ctxt.PosTable.Pos(xpos)
  15. if !pos.IsKnown() {
  16. pos = src.Pos{}
  17. }
  18. // TODO(gri) Should this use relative or absolute line number?
  19. return pos.SymFilename(), int32(pos.RelLine())
  20. }
  21. // getFileIndexAndLine returns the file index (local to the CU), and the line number for a position.
  22. func getFileIndexAndLine(ctxt *Link, xpos src.XPos) (int, int32) {
  23. f, l := linkgetlineFromPos(ctxt, xpos)
  24. return ctxt.PosTable.FileIndex(f), l
  25. }