diff options
Diffstat (limited to 'vendor/modernc.org/ccgo')
-rw-r--r-- | vendor/modernc.org/ccgo/v3/lib/go.go | 30 | ||||
-rw-r--r-- | vendor/modernc.org/ccgo/v3/lib/init.go | 4 |
2 files changed, 21 insertions, 13 deletions
diff --git a/vendor/modernc.org/ccgo/v3/lib/go.go b/vendor/modernc.org/ccgo/v3/lib/go.go index fc869395..45ffc6e7 100644 --- a/vendor/modernc.org/ccgo/v3/lib/go.go +++ b/vendor/modernc.org/ccgo/v3/lib/go.go @@ -1012,6 +1012,8 @@ func (p *project) isArray(f *function, n declarator, t cc.Type) (r bool) { return p.detectArray(f, n.(cc.Node), false, true, nil) } +var home = os.Getenv("HOME") + // Return n's position with path reduced to baseName(path) unless // p.task.fullPathComments is true. func (p *project) pos(n cc.Node) (r token.Position) { @@ -1019,9 +1021,15 @@ func (p *project) pos(n cc.Node) (r token.Position) { return r } - r = token.Position(n.Position()) - if r.IsValid() && !p.task.fullPathComments { - r.Filename = filepath.Base(r.Filename) + if r = token.Position(n.Position()); r.IsValid() { + switch { + case p.task.fullPathComments: + if strings.HasPrefix(r.Filename, home) { + r.Filename = "$HOME" + r.Filename[len(home):] + } + default: + r.Filename = filepath.Base(r.Filename) + } } return r } @@ -1491,7 +1499,7 @@ func (p *project) layoutDefines() error { } name = p.scope.take(cc.String(name)) p.defines[nm] = define{name, val} - p.defineLines = append(p.defineLines, fmt.Sprintf("%s = %s", name, src)) + p.defineLines = append(p.defineLines, fmt.Sprintf("%s = %s // %v:", name, src, p.pos(m))) } } return nil @@ -3929,9 +3937,9 @@ func (p *project) convertToUint128(n cc.Node, op cc.Operand, to cc.Type, flags f func (p *project) convertNil(n cc.Node, to cc.Type, flags flags) string { switch to.Kind() { case cc.Int128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) case cc.UInt128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) } p.w("%s(", p.typ(n, to)) @@ -4025,15 +4033,15 @@ func (p *project) convertInt(n cc.Node, op cc.Operand, to cc.Type, flags flags) from := op.Type() switch from.Kind() { case cc.Int128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) case cc.UInt128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) } switch to.Kind() { case cc.Int128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) case cc.UInt128: - panic(todo("", pos(n))) + panic(todo("", p.pos(n))) } force := flags&fForceConv != 0 @@ -12048,7 +12056,7 @@ func (p *project) intConst(n cc.Node, src string, op cc.Operand, to cc.Type, fla defer p.w(")") // ok default: - panic(todo("%v: %v -> %v", pos(n), op.Type(), to)) + panic(todo("%v: %v -> %v", p.pos(n), op.Type(), to)) } src = strings.TrimRight(src, "luLU") diff --git a/vendor/modernc.org/ccgo/v3/lib/init.go b/vendor/modernc.org/ccgo/v3/lib/init.go index db3ad913..75bdc668 100644 --- a/vendor/modernc.org/ccgo/v3/lib/init.go +++ b/vendor/modernc.org/ccgo/v3/lib/init.go @@ -326,7 +326,7 @@ func (p *project) containingStructField(part *cc.Initializer, off uintptr, t cc. } } - panic(todo("%v: internal error", pos(part))) + panic(todo("%v: internal error", p.pos(part))) } func (p *project) initializerUnion(tag string, off uintptr, f *function, s []*cc.Initializer, t cc.Type, sc cc.StorageClass, tld *tld, lm, tm map[*cc.Initializer][]cc.StringID) { @@ -376,7 +376,7 @@ func (p *project) initializerUnion(tag string, off uintptr, f *function, s []*cc } continue default: - panic(todo("%v: %v <- %T", pos(part), et, x)) + panic(todo("%v: %v <- %T", p.pos(part), et, x)) } case p.isWCharType(et): panic(todo("")) |