MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / WriteTo

Method WriteTo

types/scope.go:214–232  ·  view source on GitHub ↗

WriteTo writes a string representation of the scope to w, with the scope elements sorted by name. The level of indentation is controlled by n >= 0, with n == 0 for no indentation. If recurse is set, it also writes nested (children) scopes.

(w io.Writer, n int, recurse bool)

Source from the content-addressed store, hash-verified

212// n == 0 for no indentation.
213// If recurse is set, it also writes nested (children) scopes.
214func (s *Scope) WriteTo(w io.Writer, n int, recurse bool) {
215 const ind = ". "
216 indn := strings.Repeat(ind, n)
217
218 fmt.Fprintf(w, "%s%s scope %p {\n", indn, s.comment, s)
219
220 indn1 := indn + ind
221 for _, name := range s.Names() {
222 fmt.Fprintf(w, "%s%s\n", indn1, s.Lookup(name))
223 }
224
225 if recurse {
226 for _, s := range s.children {
227 s.WriteTo(w, n+1, recurse)
228 }
229 }
230
231 fmt.Fprintf(w, "%s}\n", indn)
232}
233
234// String returns a string representation of the scope, for debugging.
235func (s *Scope) String() string {

Callers 10

StringMethod · 0.95
TestInitFunction · 0.45
TestPhiEliminationFunction · 0.45
optimizeBlocksFunction · 0.45
Example_buildPackageFunction · 0.45
ExampleScopeFunction · 0.45
testValueForExprFunction · 0.45
mustSanityCheckFunction · 0.45
TestBuildPackageFunction · 0.45
TestPackagesFunction · 0.45

Calls 2

NamesMethod · 0.95
LookupMethod · 0.95

Tested by 7

TestInitFunction · 0.36
TestPhiEliminationFunction · 0.36
Example_buildPackageFunction · 0.36
ExampleScopeFunction · 0.36
testValueForExprFunction · 0.36
TestBuildPackageFunction · 0.36
TestPackagesFunction · 0.36