-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathssa4gub.go
69 lines (57 loc) · 2.33 KB
/
ssa4gub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2014 Rocky Bernstein
package ssa2
/*
This file contains definitions beyond ssa.go needed for the gub
debugger. This could be merged into ssa.go but we keep it separate so
as to make diff'ing our ssa.go and the unmodified ssa.go look more
alike.
*/
import (
"go/ast"
"go/token"
"github.com/rocky/go-types"
"github.com/rocky/go-loader"
)
type LocInst struct {
pos token.Pos
endP token.Pos
// Fixme: I don't know how to do a C union "Instruction" typecast
Trace *Trace
Fn *Function
}
// Scopes are attached to basic blocks. For our purposes, we need a
// types.Scope plus some sort of non-pointer-address name which we can
// repeatably derive. The name is just a preorder traversal number of
// the scope tree for a package. Scope number should be reset for each
// function, but that's more work. I, rocky, believe this really
// should be in ast.scope, but it is what it is.
type ScopeId uint
type Scope struct {
*types.Scope
scopeId ScopeId
node *ast.Node
}
type NameScope struct {
Name string
Scope *Scope
}
func (s *Alloc) EndP() token.Pos { return s.endP }
func (s *Builtin) EndP() token.Pos { return s.endP }
func (s *Const) EndP() token.Pos { return s.endP }
func (s *DebugRef) EndP() token.Pos { return s.Expr.End() }
func (s *Defer) EndP() token.Pos { return s.Call.endP }
func (s *Go) EndP() token.Pos { return s.Call.endP }
func (v *Register) EndP() token.Pos { return v.endP }
func (s *Return) EndP() token.Pos { return s.endP }
func (v *Function) EndP() token.Pos { return v.endP }
func (v *Function) Fset() *token.FileSet { return v.Prog.Fset }
func (v *Function) NamedResults() []*Alloc { return v.namedResults }
func (v *Global) EndP() token.Pos { return v.endP }
func (v *LocInst) EndP() token.Pos { return v.endP }
func (v *Parameter) EndP() token.Pos { return v.endP }
func (v *Register) setEnd(pos token.Pos) { v.endP = pos }
func (v *LocInst) Pos() token.Pos { return v.pos }
func (p *Package) Locs() []LocInst { return p.locs }
func (p *Package) Info() *loader.PackageInfo { return p.info }
func (s *Scope) ScopeId() ScopeId { return s.scopeId }
func (s *Scope) Node() *ast.Node { return s.node }