Source file src/simd/_gen/unify/pos.go

     1  // Copyright 2025 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 unify
     6  
     7  import (
     8  	"fmt"
     9  )
    10  
    11  type Pos struct {
    12  	Path string
    13  	Line int
    14  }
    15  
    16  func (p Pos) String() string {
    17  	var b []byte
    18  	b, _ = p.AppendText(b)
    19  	return string(b)
    20  }
    21  
    22  func (p Pos) AppendText(b []byte) ([]byte, error) {
    23  	if p.Line == 0 {
    24  		if p.Path == "" {
    25  			return append(b, "?:?"...), nil
    26  		} else {
    27  			return append(b, p.Path...), nil
    28  		}
    29  	} else if p.Path == "" {
    30  		return fmt.Appendf(b, "?:%d", p.Line), nil
    31  	}
    32  	return fmt.Appendf(b, "%s:%d", p.Path, p.Line), nil
    33  }
    34  

View as plain text