gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

line.go (1021B)


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