stdlib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package stdlib provides wrappers of standard library packages to be imported natively in mvm.

Index

Constants

This section is empty.

Variables

View Source
var Values = map[string]map[string]reflect.Value{}

Values variable stores the map of stdlib values per package.

Functions

func PackagePatchers

func PackagePatchers() map[string][]PackagePatcher

PackagePatchers returns the registered patchers keyed by import path. Callers must not mutate the returned map.

func RegisterPackagePatcher

func RegisterPackagePatcher(importPath string, fn PackagePatcher)

RegisterPackagePatcher adds fn to the patcher list for importPath. Intended for init() in side-effect intercept packages such as stdlib/jsonx, so the interpreter itself needs no knowledge of them.

func SrcFS

func SrcFS() fs.FS

SrcFS returns a filesystem rooted at the embedded stdlib source tree. A package "cmp" is found at "cmp/cmp.go" and so on - matching the layout expected by goparser.Parser.ParseAll when fed an import path.

Types

type BridgeClose

type BridgeClose struct{ Fn func() error }

BridgeClose bridges the io.Closer interface method.

func (*BridgeClose) Close

func (b *BridgeClose) Close() error

Close implements io.Closer.

type BridgeError

type BridgeError struct {
	Fn  func() string
	Val any
}

BridgeError bridges the error interface method. Val holds the concrete value for non-string format verbs (%d, %x, etc.).

func (*BridgeError) Error

func (b *BridgeError) Error() string

Error implements the error interface.

func (*BridgeError) Format

func (b *BridgeError) Format(f fmt.State, verb rune)

Format implements fmt.Formatter.

type BridgeFlagValue

type BridgeFlagValue struct {
	FnString func() string
	FnSet    func(string) error
}

BridgeFlagValue bridges flag.Value (String, Set).

func (*BridgeFlagValue) Set

func (b *BridgeFlagValue) Set(s string) error

Set implements flag.Value.

func (*BridgeFlagValue) String

func (b *BridgeFlagValue) String() string

String implements flag.Value.

type BridgeGoString

type BridgeGoString struct {
	Fn  func() string
	Val any
}

BridgeGoString bridges the fmt.GoStringer interface method.

func (*BridgeGoString) Format

func (b *BridgeGoString) Format(f fmt.State, verb rune)

Format implements fmt.Formatter.

func (*BridgeGoString) GoString

func (b *BridgeGoString) GoString() string

GoString implements fmt.GoStringer.

type BridgeHeapInterface

type BridgeHeapInterface struct {
	BridgeSortInterface
	FnPush func(any)
	FnPop  func() any
}

BridgeHeapInterface bridges heap.Interface (Len, Less, Swap, Push, Pop). Embeds BridgeSortInterface for the sort.Interface methods.

func (*BridgeHeapInterface) Pop

func (b *BridgeHeapInterface) Pop() any

Pop implements heap.Interface.

func (*BridgeHeapInterface) Push

func (b *BridgeHeapInterface) Push(x any)

Push implements heap.Interface.

type BridgeMarshalJSON

type BridgeMarshalJSON struct{ Fn func() ([]byte, error) }

BridgeMarshalJSON bridges the json.Marshaler interface method.

func (*BridgeMarshalJSON) MarshalJSON

func (b *BridgeMarshalJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type BridgeRead

type BridgeRead struct{ Fn func([]byte) (int, error) }

BridgeRead bridges the io.Reader interface method.

func (*BridgeRead) Read

func (b *BridgeRead) Read(p []byte) (int, error)

Read implements io.Reader.

type BridgeReadFrom

type BridgeReadFrom struct {
	Fn func(io.Reader) (int64, error)
}

BridgeReadFrom bridges the io.ReaderFrom interface method.

func (*BridgeReadFrom) ReadFrom

func (b *BridgeReadFrom) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom.

type BridgeReaderWriterTo

type BridgeReaderWriterTo struct {
	FnRead    func([]byte) (int, error)
	FnWriteTo func(io.Writer) (int64, error)
}

BridgeReaderWriterTo is a composite bridge implementing io.Reader + io.WriterTo. Used to preserve WriterTo capability when wrapping for an io.Reader target (e.g. io.Copy).

func (*BridgeReaderWriterTo) Read

func (b *BridgeReaderWriterTo) Read(p []byte) (int, error)

func (*BridgeReaderWriterTo) WriteTo

func (b *BridgeReaderWriterTo) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo.

type BridgeSortInterface

type BridgeSortInterface struct {
	FnLen  func() int
	FnLess func(int, int) bool
	FnSwap func(int, int)
}

BridgeSortInterface bridges sort.Interface (Len, Less, Swap).

func (*BridgeSortInterface) Len

func (b *BridgeSortInterface) Len() int

func (*BridgeSortInterface) Less

func (b *BridgeSortInterface) Less(i, j int) bool

func (*BridgeSortInterface) Swap

func (b *BridgeSortInterface) Swap(i, j int)

type BridgeString

type BridgeString struct {
	Fn  func() string
	Val any
}

BridgeString bridges the fmt.Stringer interface method.

func (*BridgeString) Format

func (b *BridgeString) Format(f fmt.State, verb rune)

Format implements fmt.Formatter.

func (*BridgeString) String

func (b *BridgeString) String() string

String implements fmt.Stringer.

type BridgeUnmarshalJSON

type BridgeUnmarshalJSON struct{ Fn func([]byte) error }

BridgeUnmarshalJSON bridges the json.Unmarshaler interface method.

func (*BridgeUnmarshalJSON) UnmarshalJSON

func (b *BridgeUnmarshalJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type BridgeWrite

type BridgeWrite struct{ Fn func([]byte) (int, error) }

BridgeWrite bridges the io.Writer interface method.

func (*BridgeWrite) Write

func (b *BridgeWrite) Write(p []byte) (int, error)

Write implements io.Writer.

type BridgeWriteTo

type BridgeWriteTo struct {
	Fn func(io.Writer) (int64, error)
}

BridgeWriteTo bridges the io.WriterTo interface method.

func (*BridgeWriteTo) WriteTo

func (b *BridgeWriteTo) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo.

type BridgeWriterReaderFrom

type BridgeWriterReaderFrom struct {
	FnWrite    func([]byte) (int, error)
	FnReadFrom func(io.Reader) (int64, error)
}

BridgeWriterReaderFrom is a composite bridge implementing io.Writer + io.ReaderFrom. Used to preserve ReaderFrom capability when wrapping for an io.Writer target (e.g. io.Copy).

func (*BridgeWriterReaderFrom) ReadFrom

func (b *BridgeWriterReaderFrom) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements io.ReaderFrom.

func (*BridgeWriterReaderFrom) Write

func (b *BridgeWriterReaderFrom) Write(p []byte) (int, error)

type PackagePatcher

type PackagePatcher func(m *vm.Machine, values map[string]vm.Value)

PackagePatcher mutates a package's exported values at interpreter startup. m is the live VM; values is the package's vm.Value symbol map (the same map the interpreter resolves imports against).

Directories

Path Synopsis
Package all is the convenience aggregator for stdlib bindings: blank-import it to get the full set (core + ext + jsonx).
Package all is the convenience aggregator for stdlib bindings: blank-import it to get the full set (core + ext + jsonx).
Package core provides wrappers for core standard library packages.
Package core provides wrappers for core standard library packages.
Package jsonx is a mvm-aware replacement for the encoding/json functions that need to honour mvm-defined methods on struct types (MarshalJSON, UnmarshalJSON).
Package jsonx is a mvm-aware replacement for the encoding/json functions that need to honour mvm-defined methods on struct types (MarshalJSON, UnmarshalJSON).
src
cmp
Package cmp provides types and functions related to comparing ordered values.
Package cmp provides types and functions related to comparing ordered values.
iter
Package iter provides basic definitions related to iterators over sequences.
Package iter provides basic definitions related to iterators over sequences.
maps
Package maps defines various functions useful with maps of any type.
Package maps defines various functions useful with maps of any type.
slices
Package slices defines various functions useful with slices of any type.
Package slices defines various functions useful with slices of any type.

Jump to

Keyboard shortcuts

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