dep

package
v0.0.0-...-f54e8e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DEBUG_GRAPH = false

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstDeps

type ConstDeps struct {
	Type      ast.Expr
	TypeDeps  []string
	Values    []ast.Expr
	ValueDeps [][]string
}

for consts that inherit type and initializers from a previous *ast.ValueSpec

type Decl

type Decl struct {
	Kind  Kind
	Name  string
	Node  ast.Node // nil for multiple const or var declarations in a single *ast.ValueSpec - in such case, see Extra
	Deps  []string // names of types, constants and variables used in Node's declaration
	Pos   token.Pos
	Extra *Extra
}

func NewDecl

func NewDecl(kind Kind, name string, node ast.Node, pos token.Pos, deps []string) *Decl

func NewDeclExpr

func NewDeclExpr(node ast.Expr, counter *int) *Decl

func NewDeclFunc

func NewDeclFunc(kind Kind, name string, node *ast.FuncDecl, deps []string) *Decl

func NewDeclImport

func NewDeclImport(spec ast.Spec, counter *int) *Decl

func NewDeclPackage

func NewDeclPackage(spec ast.Spec, counter *int) *Decl

func NewDeclStmt

func NewDeclStmt(node ast.Stmt, counter *int) *Decl

func NewDeclType

func NewDeclType(node *ast.TypeSpec, deps []string) *Decl

func NewDeclVar

func NewDeclVar(ident *ast.Ident, node ast.Spec, typ ast.Expr, value ast.Expr, deps []string) *Decl

func NewDeclVarMulti

func NewDeclVarMulti(ident *ast.Ident, node *ast.ValueSpec, deps []string) *Decl

func (*Decl) Fprint

func (decl *Decl) Fprint(out io.Writer)

func (*Decl) Print

func (decl *Decl) Print()

func (*Decl) RemoveUnresolvableDeps

func (decl *Decl) RemoveUnresolvableDeps(m DeclMap)

remove all dependencies that cannot be resolved, i.e. not present among m

func (*Decl) String

func (decl *Decl) String() string

type DeclList

type DeclList []*Decl

func (DeclList) Map

func (list DeclList) Map() DeclMap

func (DeclList) Print

func (list DeclList) Print()

func (DeclList) Reverse

func (list DeclList) Reverse() DeclList

func (DeclList) SortByPos

func (list DeclList) SortByPos() DeclList

func (DeclList) String

func (l DeclList) String() string

type DeclMap

type DeclMap map[string]DeclList

func (DeclMap) Dup

func (m DeclMap) Dup() DeclMap

func (DeclMap) List

func (m DeclMap) List() DeclList

func (DeclMap) Print

func (m DeclMap) Print()

func (DeclMap) RemoveUnresolvableDeps

func (m DeclMap) RemoveUnresolvableDeps()

remove all dependencies that cannot be resolved, i.e. not present among m

type Extra

type Extra struct {
	Ident *ast.Ident
	Type  ast.Expr
	Value ast.Expr
	Iota  int // for constants, value of iota to use
}

for multiple const or var declarations in a single *ast.ValueSpec

func (*Extra) Spec

func (extra *Extra) Spec() *ast.ValueSpec

convert *Extra to ast.Spec

type Kind

type Kind int
const (
	Unknown Kind = iota
	Const
	Expr
	Func
	Import
	Macro
	Method
	Package
	Stmt
	Type
	TypeFwd
	Var
	VarMulti
)

func (Kind) String

func (k Kind) String() string

type Scope

type Scope struct {
	Decls  DeclMap
	Outer  *Scope
	Gensym int
}

func NewScope

func NewScope(outer *Scope) *Scope

func (*Scope) Ast

func (s *Scope) Ast(form ast2.Ast) []string

func (*Scope) AstExpr

func (s *Scope) AstExpr(in ast2.Ast) []string

func (*Scope) Const

func (s *Scope) Const(ident *ast.Ident, node ast.Spec, iota int, typ ast.Expr, value ast.Expr, deps []string) *Decl

constant

func (*Scope) Consts

func (s *Scope) Consts(node ast.Spec, iota int, defaults *ConstDeps) []string

constants

func (*Scope) Decl

func (s *Scope) Decl(node ast.Node) []string

func (*Scope) Expr

func (s *Scope) Expr(node ast.Node) []string

func (*Scope) Exprs

func (s *Scope) Exprs(list []ast.Expr) [][]string

func (*Scope) File

func (s *Scope) File(node *ast.File) []string

func (*Scope) Func

func (s *Scope) Func(node *ast.FuncDecl) []string

function or method

func (*Scope) GenDecl

func (s *Scope) GenDecl(node *ast.GenDecl) []string

func (*Scope) Import

func (s *Scope) Import(node ast.Spec)

import

func (*Scope) Node

func (s *Scope) Node(node ast.Node) []string

func (*Scope) Nodes

func (s *Scope) Nodes(nodes []ast.Node)

func (*Scope) Package

func (s *Scope) Package(node ast.Spec)

package

func (*Scope) Type

func (s *Scope) Type(node ast.Spec) []string

type

func (*Scope) Var

func (s *Scope) Var(ident *ast.Ident, node ast.Spec, typ ast.Expr, value ast.Expr, deps []string) *Decl

variable

func (*Scope) Vars

func (s *Scope) Vars(node ast.Spec) []string

variables

type Sorter

type Sorter struct {
	// contains filtered or unexported fields
}

func NewSorter

func NewSorter() *Sorter

func (*Sorter) All

func (s *Sorter) All() DeclList

func (*Sorter) LoadAst

func (s *Sorter) LoadAst(form ast2.Ast)

func (*Sorter) LoadNode

func (s *Sorter) LoadNode(node ast.Node)

func (*Sorter) LoadNodes

func (s *Sorter) LoadNodes(nodes []ast.Node)

func (*Sorter) Some

func (s *Sorter) Some() DeclList

return one of: * a list of imports * a list of declarations * a list of expressions and statements

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL