mod

package
v0.0.0-...-9cd5b15 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: BSD-2-Clause Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = errors.New("mod file not found")
View Source
var Export = &importSpec{impl("<form@export mods:<tupl|exp|alt str tag|str> none>"), true}
View Source
var Import = &importSpec{impl("<form@import mods:<tupl|exp|alt str tag|str> none>"), false}
View Source
var Module = &moduleSpec{impl("<form@module name:sym tags?:tupl|exp none>")}
View Source
var Registry = new(SysMods)

Registry provides a central global module registry for convenience.

Functions

This section is empty.

Types

type FSMods

type FSMods struct {
	Roots []*PathFS
	Ext   []string
	Index []string

	Log func(root, path string)
	// contains filtered or unexported fields
}

func FileMods

func FileMods(roots ...string) *FSMods

func (*FSMods) LoadSrc

func (fm *FSMods) LoadSrc(raw, base *Loc) (*Src, error)

type File

type File = exp.File

type Loader

type Loader interface {
	LoadSrc(path, base *Loc) (*Src, error)
}

Loader caches and loads module sources.

type LoaderEnv

type LoaderEnv struct {
	Par     exp.Env
	Loaders []Loader
}

LoaderEnv adds module awareness to a program environment. It provides the mod and use forms and holds the module loaders.

func FindLoaderEnv

func FindLoaderEnv(env exp.Env) *LoaderEnv

func NewLoaderEnv

func NewLoaderEnv(par exp.Env, ls ...Loader) *LoaderEnv

NewLoaderEnv create a new module loader environment with the given parent env and loader. The parent env should be used as basis for external module loads.

func (*LoaderEnv) LoadFile

func (le *LoaderEnv) LoadFile(prog *exp.Prog, loc *Loc) (f *File, err error)

func (*LoaderEnv) Lookup

func (le *LoaderEnv) Lookup(s *exp.Sym, p cor.Path, eval bool) (lit.Val, error)

func (*LoaderEnv) Parent

func (le *LoaderEnv) Parent() exp.Env

type Loc

type Loc struct {
	URL string
	// contains filtered or unexported fields
}

func ParseLoc

func ParseLoc(url string) *Loc

func (*Loc) Frag

func (l *Loc) Frag() string

func (*Loc) Path

func (l *Loc) Path() string

func (*Loc) Proto

func (l *Loc) Proto() string

func (Loc) String

func (l Loc) String() string

type Mod

type Mod = exp.Mod

type ModEnv

type ModEnv struct {
	Par exp.Env
	Mod *Mod
}

ModEnv encapsulates a module environment.

func FindModEnv

func FindModEnv(env exp.Env) *ModEnv

func NewModEnv

func NewModEnv(par exp.Env, file *File) *ModEnv

func (*ModEnv) AddDecl

func (e *ModEnv) AddDecl(name string, v lit.Val) error

func (*ModEnv) Lookup

func (e *ModEnv) Lookup(s *exp.Sym, path cor.Path, eval bool) (lit.Val, error)

func (*ModEnv) Parent

func (e *ModEnv) Parent() exp.Env

func (*ModEnv) Publish

func (e *ModEnv) Publish() error

Publish checks and publishes the module to the file or returns an error. It must be called once at the end of module setup or evaluation.

func (*ModEnv) SetName

func (e *ModEnv) SetName(name string)

type ModRef

type ModRef = exp.ModRef

type PathFS

type PathFS struct {
	Path string
	FS   fs.FS
	Rel  string
	// contains filtered or unexported fields
}

type Src

type Src struct {
	Rel string
	Loc
	Raw   []ast.Ast
	Setup func(*exp.Prog, *Src) (*File, error)
}

Src is the raw and program independent module source for a location. The input is represented either as an abstract syntax tree or as program specific setup hook.

type SysMods

type SysMods struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SysMods is a thread-safe module registry that implements the module loader interface.

func (*SysMods) LoadSrc

func (sm *SysMods) LoadSrc(raw, base *Loc) (*Src, error)

func (*SysMods) Register

func (sm *SysMods) Register(src *Src) *Src

Jump to

Keyboard shortcuts

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