lang: interfaces, ast: Add debug methods for graphing scope
This can occasionally help in our debugging of the scope graph. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
@@ -134,6 +134,15 @@ type Expr interface {
|
||||
Value() (types.Value, error)
|
||||
}
|
||||
|
||||
// ScopeGrapher adds a method to turn an AST (Expr or Stmt) into a graph so that
|
||||
// we can debug the SetScope compilation phase.
|
||||
type ScopeGrapher interface {
|
||||
Node
|
||||
|
||||
// ScopeGraph adds nodes and vertices to the supplied graph.
|
||||
ScopeGraph(g *pgraph.Graph)
|
||||
}
|
||||
|
||||
// Data provides some data to the node that could be useful during its lifetime.
|
||||
type Data struct {
|
||||
// Fs represents a handle to the filesystem that we're running on. This
|
||||
|
||||
@@ -187,3 +187,8 @@ func (obj *ExprAny) Value() (types.Value, error) {
|
||||
}
|
||||
return obj.V, nil
|
||||
}
|
||||
|
||||
// ScopeGraph adds nodes and vertices to the supplied graph.
|
||||
func (obj *ExprAny) ScopeGraph(g *pgraph.Graph) {
|
||||
g.AddVertex(obj)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user