X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/compile/internal/types
opt
/
golang
/
1.19.4
/
src
/
cmd
/
compile
/
internal
/
types
/
📁
..
📄
alg.go
(3.35 KB)
📄
algkind_string.go
(1.07 KB)
📄
fmt.go
(17.79 KB)
📄
goversion.go
(2.28 KB)
📄
identity.go
(4.65 KB)
📄
kind_string.go
(1.62 KB)
📄
pkg.go
(3.85 KB)
📄
scope.go
(2.12 KB)
📄
size.go
(13.65 KB)
📄
sizeof_test.go
(1.01 KB)
📄
sort.go
(765 B)
📄
structuraltype.go
(4.74 KB)
📄
structuraltype_test.go
(3.26 KB)
📄
sym.go
(4.74 KB)
📄
sym_test.go
(1.23 KB)
📄
type.go
(53.86 KB)
📄
type_test.go
(511 B)
📄
universe.go
(4.04 KB)
📄
utils.go
(339 B)
Editing: scope.go
// Copyright 2017 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 types import ( "cmd/compile/internal/base" ) // Declaration stack & operations // A dsym stores a symbol's shadowed declaration so that it can be // restored once the block scope ends. type dsym struct { sym *Sym // sym == nil indicates stack mark def Object } // dclstack maintains a stack of shadowed symbol declarations so that // Popdcl can restore their declarations when a block scope ends. var dclstack []dsym // Pushdcl pushes the current declaration for symbol s (if any) so that // it can be shadowed by a new declaration within a nested block scope. func Pushdcl(s *Sym) { dclstack = append(dclstack, dsym{ sym: s, def: s.Def, }) } // Popdcl pops the innermost block scope and restores all symbol declarations // to their previous state. func Popdcl() { for i := len(dclstack); i > 0; i-- { d := &dclstack[i-1] s := d.sym if s == nil { // pop stack mark dclstack = dclstack[:i-1] return } s.Def = d.def // Clear dead pointer fields. d.sym = nil d.def = nil } base.Fatalf("popdcl: no stack mark") } // Markdcl records the start of a new block scope for declarations. func Markdcl() { dclstack = append(dclstack, dsym{ sym: nil, // stack mark }) } func isDclstackValid() bool { for _, d := range dclstack { if d.sym == nil { return false } } return true } // PkgDef returns the definition associated with s at package scope. func (s *Sym) PkgDef() Object { return *s.pkgDefPtr() } // SetPkgDef sets the definition associated with s at package scope. func (s *Sym) SetPkgDef(n Object) { *s.pkgDefPtr() = n } func (s *Sym) pkgDefPtr() *Object { // Look for outermost saved declaration, which must be the // package scope definition, if present. for i := range dclstack { d := &dclstack[i] if s == d.sym { return &d.def } } // Otherwise, the declaration hasn't been shadowed within a // function scope. return &s.Def } func CheckDclstack() { if !isDclstackValid() { base.Fatalf("mark left on the dclstack") } }
Upload File
Create Folder