...

Source file src/cmd/internal/obj/line.go

Documentation: cmd/internal/obj

     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  	"cmd/internal/goobj"
     9  	"cmd/internal/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  // getFileIndexAndLine returns the relative file index (local to the CU), and
    18  // the relative line number for a position (i.e., as adjusted by a //line
    19  // directive). This is the file/line visible in the final binary (pcfile, pcln,
    20  // etc).
    21  func (ctxt *Link) getFileIndexAndLine(xpos src.XPos) (int, int32) {
    22  	pos := ctxt.InnermostPos(xpos)
    23  	if !pos.IsKnown() {
    24  		pos = src.Pos{}
    25  	}
    26  	return pos.FileIndex(), int32(pos.RelLine())
    27  }
    28  

View as plain text