X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/compile/internal/noder
opt
/
golang
/
1.19.4
/
src
/
cmd
/
compile
/
internal
/
noder
/
📁
..
📄
codes.go
(1.27 KB)
📄
decl.go
(10.83 KB)
📄
export.go
(800 B)
📄
expr.go
(14.16 KB)
📄
func.go
(1.9 KB)
📄
helpers.go
(5.96 KB)
📄
import.go
(10.31 KB)
📄
irgen.go
(11.3 KB)
📄
lex.go
(5.06 KB)
📄
lex_test.go
(3.64 KB)
📄
linker.go
(7.05 KB)
📄
noder.go
(13.33 KB)
📄
object.go
(5.56 KB)
📄
posmap.go
(2.02 KB)
📄
quirks.go
(1.8 KB)
📄
reader.go
(58.09 KB)
📄
scopes.go
(1.49 KB)
📄
sizes.go
(4.04 KB)
📄
stencil.go
(79.07 KB)
📄
stmt.go
(8.67 KB)
📄
transform.go
(28.22 KB)
📄
types.go
(16.72 KB)
📄
unified.go
(9.09 KB)
📄
validate.go
(3.09 KB)
📄
writer.go
(41.38 KB)
Editing: scopes.go
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package noder import ( "strings" "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/syntax" "cmd/compile/internal/types2" ) // recordScopes populates fn.Parents and fn.Marks based on the scoping // information provided by types2. func (g *irgen) recordScopes(fn *ir.Func, sig *syntax.FuncType) { scope, ok := g.info.Scopes[sig] if !ok { base.FatalfAt(fn.Pos(), "missing scope for %v", fn) } for i, n := 0, scope.NumChildren(); i < n; i++ { g.walkScope(scope.Child(i)) } g.marker.WriteTo(fn) } func (g *irgen) walkScope(scope *types2.Scope) bool { // types2 doesn't provide a proper API for determining the // lexical element a scope represents, so we have to resort to // string matching. Conveniently though, this allows us to // skip both function types and function literals, neither of // which are interesting to us here. if strings.HasPrefix(scope.String(), "function scope ") { return false } g.marker.Push(g.pos(scope)) haveVars := false for _, name := range scope.Names() { if obj, ok := scope.Lookup(name).(*types2.Var); ok && obj.Name() != "_" { haveVars = true break } } for i, n := 0, scope.NumChildren(); i < n; i++ { if g.walkScope(scope.Child(i)) { haveVars = true } } if haveVars { g.marker.Pop(g.end(scope)) } else { g.marker.Unpush() } return haveVars }
Upload File
Create Folder