rt

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 56 Imported by: 0

Documentation

Overview

This file carries no bootstrap build constraint on purpose: BootCore must exist in every build so a downstream caller compiles, and under -tags bootstrap the embedded core (CoreCompiledLGB) is empty, making LoadCoreBundle return the documented error instead of an undefined-symbol failure.

Code generated by `lginterop -packages github.com/nooga/let-go/pkg/glplat`. DO NOT EDIT.

Code generated by `lginterop -packages github.com/zeebo/xxh3 -opaque-structs -build-tags '!tinygo'`. DO NOT EDIT.

Index

Constants

View Source
const NameCoreNS = "core"
View Source
const NameLetGoCoreNS = "let-go.core"

NameLetGoCoreNS is the home for lg-specific extras that are not part of the portable Clojure surface (clojure ∪ bb) — e.g. gt/lt/ge/le. It is auto-refer'd alongside clojure.core so unqualified use keeps resolving, while clojure.core itself stays a faithful Clojure surface. See openspec/changes/purify-clojure-core.

View Source
const NameLetGoTypesNS = "let-go.types"

NameLetGoTypesNS is a focused namespace for lg-specific type predicates (array?, bigint?, range?, …) that are not part of the portable Clojure surface but should stay visible. Auto-refer'd as a baseline like let-go.core.

Variables

View Source
var (
	ReadableProto *vm.Protocol // method: -make-reader [x] → reader
	WritableProto *vm.Protocol // method: -make-writer [x] → writer
)

IReadable and IWritable are the IO coercion protocols. Extending these allows user-defined types to participate in the IO system.

View Source
var (
	Version = "dev"
	Commit  = "none"
)

Version and Commit are set by lg.go from goreleaser ldflags at startup.

View Source
var CoreCompiledLGB []byte
View Source
var CoreNS *vm.Namespace
View Source
var CoreSrc string
View Source
var CurrentNS *vm.Var
View Source
var GoASTType *theGoASTType = &theGoASTType{}

Functions

func AddValue added in v1.9.0

func AddValue(a, b vm.Value) vm.Value

func AllNSes

func AllNSes() map[string]*vm.Namespace

func AllNativeModules added in v1.10.0

func AllNativeModules() map[string][]*NativeModule

AllNativeModules returns a snapshot of the entire registry. Useful for tools that need the full view — the IR pipeline at codegen time, a REPL `(rt/native-modules)` inspector, parity diff scripts.

func ApplyGoOverrides added in v1.10.0

func ApplyGoOverrides(ns *vm.Namespace)

ApplyGoOverrides drains any pending overrides for ns and Defs them onto the namespace, replacing whatever bytecode or source replay produced. No-op if nothing is pending.

func ApplyVarMeta added in v1.11.0

func ApplyVarMeta(v *vm.Var, meta vm.Value)

ApplyVarMeta applies def metadata to v exactly as the bytecode defCompiler does: it sets the var's meta map, then mirrors the :dynamic / :private flags onto the Var. Shared by build-time def lowering (the apply-def-meta! builtin) and gogen-lowered `def` forms so both paths reproduce defCompiler's var setup (docstrings, type hints, ^:dynamic / ^:private). A nil/NIL meta is a no-op.

func AuditGeneratedPrimitives added in v1.13.0

func AuditGeneratedPrimitives() []string

AuditGeneratedPrimitives verifies that every recorded generated primitive is actually bound in its canonical namespace, and returns one human-readable line per primitive that is NOT — including where the name IS bound instead, if anywhere. It never panics and never stops at the first problem: it is the non-terminating diagnostic run around the bootstrap core.lg compile, so a batch of newly hoisted //lg:native primitives surfaces ALL its registration failures at once (`+ registered under "clojure.core", not canonical "core"`) rather than the compile dying on the first `Can't resolve X`. Empty slice = every generated primitive resolves in its canonical namespace.

func BindGeneratedPrimitive added in v1.13.0

func BindGeneratedPrimitive(nsName, name string, adapter vm.Value)

BindGeneratedPrimitive is the exported binding entry point for own-mode registrars generated into OTHER packages (which cannot call the unexported defGeneratedPrimitive). It resolves/creates the target namespace and binds the adapter as the var's guarded canonical root, recording it for reapply. pkg/rt's own generated registrar keeps calling defGeneratedPrimitive directly.

func BitAndNotValue added in v1.12.0

func BitAndNotValue(a, b vm.Value) vm.Value

func BitAndValue added in v1.12.0

func BitAndValue(a, b vm.Value) vm.Value

func BitNotValue added in v1.12.0

func BitNotValue(a vm.Value) vm.Value

func BitOrValue added in v1.12.0

func BitOrValue(a, b vm.Value) vm.Value

func BitShiftLeftValue added in v1.12.0

func BitShiftLeftValue(a, b vm.Value) vm.Value

func BitShiftRightValue added in v1.12.0

func BitShiftRightValue(a, b vm.Value) vm.Value

func BitXorValue added in v1.12.0

func BitXorValue(a, b vm.Value) vm.Value

func BootCore added in v1.12.0

func BootCore() (*vm.ExecContext, error)

BootCore decodes and runs the embedded precompiled clojure.core bundle so a program that links only pkg/rt + pkg/vm — with no compiler — can resolve and invoke the full clojure.core surface plus the lg baseline and hybrid namespaces. It returns a fresh ExecContext ready to Invoke.

The motivating case is an AOT-lowered binary (scripts/lg-compile output): its generated funcs call core via ec.Invoke(rt.CachedVarFn(..., "clojure.core", name), ...), which needs those vars bound. Programs that touch only NATIVE core fns (str, +, vector, …) already work from a bare vm.NewExecContext(), because installers register those at package init; BootCore is what additionally binds the .lg-DEFINED core (and let-go.core / let-go.types).

Call once at startup. It shares the compiler-free boot spine with LoadCore and compiler.loadPrecompiledBundle via LoadCoreBundle; the eager hybrid replay is what BootCore needs over LoadCore, since it returns straight to the caller with no namespace loader installed.

func BoxNativeFn added in v1.9.0

func BoxNativeFn(fn any) vm.Value

BoxNativeFn wraps a Go function literal as a let-go callable. Lowered Go closures use this at the runtime boundary after capturing outer Go locals directly.

func BoxRestArgs added in v1.9.0

func BoxRestArgs(args []vm.Value) vm.Value

BoxRestArgs boxes a variadic rest-args slice into a vm.Value list. Used by the Go lowering when lowering :load-arg for the rest arg of a variadic function (where the Go param is ...vm.Value).

func CachedVarFn added in v1.10.0

func CachedVarFn(ptr **vm.Var, nsName, symName string) vm.Fn

CachedVarFn lazily resolves a cross-namespace Var ONCE — memoizing it through the caller-supplied package-level pointer — then returns that var's CURRENT fn root for invocation. The lowered Go calls it as

rt.CachedVarFn(&__v_ns_name, "ns", "name").Invoke(args)

The *Var (not the fn) is what's cached, and its root is re-read on every call, so the var stays the override seam (^:dynamic / ^:redef / alter-var-root still work). Resolution is lazy (first call), not at package init(): blank-imported lowered packages run init() before the bundle replay loads namespaces, where LookupVar would return nil. The .(vm.Fn) assertion matches the trampoline's contract — every callable vm value implements vm.Fn.

func ClearNSNeedsLoad added in v1.12.0

func ClearNSNeedsLoad(name string)

ClearNSNeedsLoad removes the needs-load flag — used after a namespace's precompiled chunk has been executed eagerly (hybrid native+bundled namespaces; see compiler.loadPrecompiledBundle).

func ClearTaps added in v1.9.0

func ClearTaps()

ClearTaps drops every registered tap fn. `add-tap` appends to a process-global slice with no automatic removal, so a test that taps without `remove-tap` (e.g. clojure-test-suite's taps.cljc) leaks its tap closure — and, because all of a compile pass's fns share one vm.Consts, the closure pins that whole constant pool. Re-running the suite in a loop (BenchmarkClojureTestSuite) thus accumulates ~one Consts pool per iteration. The bench calls this between iterations to keep that from growing unboundedly.

func Conj added in v1.12.0

func Conj(args ...vm.Value) (vm.Value, error)

Conj adds elements to a collection (front for lists/seqs, back for vectors, key/val for maps). Mirrors clojure.core/conj — `(conj coll x y …)`.

func CoreAbs added in v1.13.0

func CoreAbs(vs ...vm.Value) (vm.Value, error)

func CoreAclonef added in v1.13.0

func CoreAclonef(vs ...vm.Value) (vm.Value, error)

func CoreAddTap added in v1.13.0

func CoreAddTap(vs ...vm.Value) (vm.Value, error)

func CoreAddWatch added in v1.13.0

func CoreAddWatch(vs ...vm.Value) (vm.Value, error)

func CoreAgetf added in v1.13.0

func CoreAgetf(vs ...vm.Value) (vm.Value, error)

func CoreAlengthf added in v1.13.0

func CoreAlengthf(vs ...vm.Value) (vm.Value, error)

func CoreAliasf added in v1.13.0

func CoreAliasf(vs ...vm.Value) (vm.Value, error)

func CoreAllNs added in v1.13.0

func CoreAllNs(vs ...vm.Value) (vm.Value, error)

func CoreAnyp added in v1.13.0

func CoreAnyp(vs ...vm.Value) (vm.Value, error)

func CoreApplyDefMetaf added in v1.13.0

func CoreApplyDefMetaf(vs ...vm.Value) (vm.Value, error)

func CoreArrayMap added in v1.13.0

func CoreArrayMap(vs ...vm.Value) (vm.Value, error)

func CoreAsetf added in v1.13.0

func CoreAsetf(vs ...vm.Value) (vm.Value, error)

func CoreAssoc added in v1.13.0

func CoreAssoc(vs ...vm.Value) (vm.Value, error)

func CoreAssocBang added in v1.13.0

func CoreAssocBang(vs ...vm.Value) (vm.Value, error)

func CoreAtom added in v1.13.0

func CoreAtom(vs ...vm.Value) (vm.Value, error)

func CoreBigdecf added in v1.13.0

func CoreBigdecf(vs ...vm.Value) (vm.Value, error)

func CoreBigintf added in v1.13.0

func CoreBigintf(vs ...vm.Value) (vm.Value, error)

func CoreBitAnd added in v1.13.0

func CoreBitAnd(vs ...vm.Value) (vm.Value, error)

func CoreBitAndNot added in v1.13.0

func CoreBitAndNot(vs ...vm.Value) (vm.Value, error)

func CoreBitClear added in v1.13.0

func CoreBitClear(vs ...vm.Value) (vm.Value, error)

func CoreBitFlip added in v1.13.0

func CoreBitFlip(vs ...vm.Value) (vm.Value, error)

func CoreBitNot added in v1.13.0

func CoreBitNot(vs ...vm.Value) (vm.Value, error)

func CoreBitOr added in v1.13.0

func CoreBitOr(vs ...vm.Value) (vm.Value, error)

func CoreBitSet added in v1.13.0

func CoreBitSet(vs ...vm.Value) (vm.Value, error)

func CoreBitShiftLeft added in v1.13.0

func CoreBitShiftLeft(vs ...vm.Value) (vm.Value, error)

func CoreBitShiftRight added in v1.13.0

func CoreBitShiftRight(vs ...vm.Value) (vm.Value, error)

func CoreBitTest added in v1.13.0

func CoreBitTest(vs ...vm.Value) (vm.Value, error)

func CoreBitXor added in v1.13.0

func CoreBitXor(vs ...vm.Value) (vm.Value, error)

func CoreBoundQ added in v1.13.0

func CoreBoundQ(vs ...vm.Value) (vm.Value, error)

func CoreByteArrayf added in v1.13.0

func CoreByteArrayf(vs ...vm.Value) (vm.Value, error)

func CoreBytesP added in v1.13.0

func CoreBytesP(vs ...vm.Value) (vm.Value, error)

func CoreBytesf added in v1.13.0

func CoreBytesf(vs ...vm.Value) (vm.Value, error)

func CoreChanf added in v1.13.0

func CoreChanf(vs ...vm.Value) (vm.Value, error)

func CoreChar added in v1.13.0

func CoreChar(vs ...vm.Value) (vm.Value, error)

func CoreChunkAppendF added in v1.13.0

func CoreChunkAppendF(vs ...vm.Value) (vm.Value, error)

func CoreChunkBufferF added in v1.13.0

func CoreChunkBufferF(vs ...vm.Value) (vm.Value, error)

func CoreChunkConsF added in v1.13.0

func CoreChunkConsF(vs ...vm.Value) (vm.Value, error)

func CoreChunkF added in v1.13.0

func CoreChunkF(vs ...vm.Value) (vm.Value, error)

func CoreChunkFirst added in v1.13.0

func CoreChunkFirst(vs ...vm.Value) (vm.Value, error)

func CoreChunkNext added in v1.13.0

func CoreChunkNext(vs ...vm.Value) (vm.Value, error)

func CoreChunkRest added in v1.13.0

func CoreChunkRest(vs ...vm.Value) (vm.Value, error)

func CoreChunkToFnFn added in v1.13.0

func CoreChunkToFnFn(vs ...vm.Value) (vm.Value, error)

func CoreChunkedSeqP added in v1.13.0

func CoreChunkedSeqP(vs ...vm.Value) (vm.Value, error)

func CoreCompareAndSet added in v1.13.0

func CoreCompareAndSet(vs ...vm.Value) (vm.Value, error)

func CoreComplement added in v1.13.0

func CoreComplement(vs ...vm.Value) (vm.Value, error)

func CoreConcat added in v1.13.0

func CoreConcat(vs ...vm.Value) (vm.Value, error)

func CoreConjBang added in v1.13.0

func CoreConjBang(vs ...vm.Value) (vm.Value, error)

func CoreCons added in v1.13.0

func CoreCons(vs ...vm.Value) (vm.Value, error)

func CoreContains added in v1.13.0

func CoreContains(vs ...vm.Value) (vm.Value, error)

func CoreCopyFormSource added in v1.13.0

func CoreCopyFormSource(vs ...vm.Value) (vm.Value, error)

func CoreCount added in v1.13.0

func CoreCount(vs ...vm.Value) (vm.Value, error)

func CoreCreateNsf added in v1.13.0

func CoreCreateNsf(vs ...vm.Value) (vm.Value, error)

func CoreDefMethod added in v1.13.0

func CoreDefMethod(vs ...vm.Value) (vm.Value, error)

func CoreDefMulti added in v1.13.0

func CoreDefMulti(vs ...vm.Value) (vm.Value, error)

func CoreDefProtocol added in v1.13.0

func CoreDefProtocol(vs ...vm.Value) (vm.Value, error)

func CoreDelayStar added in v1.13.0

func CoreDelayStar(vs ...vm.Value) (vm.Value, error)

func CoreDeliver added in v1.13.0

func CoreDeliver(vs ...vm.Value) (vm.Value, error)

func CoreDenominatorf added in v1.13.0

func CoreDenominatorf(vs ...vm.Value) (vm.Value, error)

func CoreDisj added in v1.13.0

func CoreDisj(vs ...vm.Value) (vm.Value, error)

func CoreDisjBang added in v1.13.0

func CoreDisjBang(vs ...vm.Value) (vm.Value, error)

func CoreDissoc added in v1.13.0

func CoreDissoc(vs ...vm.Value) (vm.Value, error)

func CoreDissocBang added in v1.13.0

func CoreDissocBang(vs ...vm.Value) (vm.Value, error)

func CoreDiv added in v1.13.0

func CoreDiv(vs ...vm.Value) (vm.Value, error)

func CoreDoublef added in v1.13.0

func CoreDoublef(vs ...vm.Value) (vm.Value, error)

func CoreDoublesf added in v1.13.0

func CoreDoublesf(vs ...vm.Value) (vm.Value, error)

func CoreEmpty added in v1.13.0

func CoreEmpty(vs ...vm.Value) (vm.Value, error)

func CoreEnsureReduced added in v1.13.0

func CoreEnsureReduced(vs ...vm.Value) (vm.Value, error)

func CoreEnumerationSeq added in v1.13.0

func CoreEnumerationSeq(vs ...vm.Value) (vm.Value, error)

func CoreExCause added in v1.13.0

func CoreExCause(vs ...vm.Value) (vm.Value, error)

func CoreExData added in v1.13.0

func CoreExData(vs ...vm.Value) (vm.Value, error)

func CoreExInfo added in v1.13.0

func CoreExInfo(vs ...vm.Value) (vm.Value, error)

func CoreExMessage added in v1.13.0

func CoreExMessage(vs ...vm.Value) (vm.Value, error)

func CoreExcludeInCurrentNs added in v1.13.0

func CoreExcludeInCurrentNs(vs ...vm.Value) (vm.Value, error)

func CoreExtendType added in v1.13.0

func CoreExtendType(vs ...vm.Value) (vm.Value, error)

func CoreFindNs added in v1.13.0

func CoreFindNs(vs ...vm.Value) (vm.Value, error)

func CoreFindVar added in v1.13.0

func CoreFindVar(vs ...vm.Value) (vm.Value, error)

func CoreFloatf added in v1.13.0

func CoreFloatf(vs ...vm.Value) (vm.Value, error)

func CoreForce added in v1.13.0

func CoreForce(vs ...vm.Value) (vm.Value, error)

func CoreFormatf added in v1.13.0

func CoreFormatf(vs ...vm.Value) (vm.Value, error)

func CoreGensym added in v1.13.0

func CoreGensym(vs ...vm.Value) (vm.Value, error)

func CoreGetMethod added in v1.13.0

func CoreGetMethod(vs ...vm.Value) (vm.Value, error)

func CoreGetValidator added in v1.13.0

func CoreGetValidator(vs ...vm.Value) (vm.Value, error)

func CoreHashMap added in v1.13.0

func CoreHashMap(vs ...vm.Value) (vm.Value, error)

func CoreHashf added in v1.13.0

func CoreHashf(vs ...vm.Value) (vm.Value, error)

func CoreIdentical added in v1.13.0

func CoreIdentical(vs ...vm.Value) (vm.Value, error)

func CoreInstancep added in v1.13.0

func CoreInstancep(vs ...vm.Value) (vm.Value, error)

func CoreInternf added in v1.13.0

func CoreInternf(vs ...vm.Value) (vm.Value, error)

func CoreIsBool added in v1.13.0

func CoreIsBool(vs ...vm.Value) (vm.Value, error)

func CoreIsChar added in v1.13.0

func CoreIsChar(vs ...vm.Value) (vm.Value, error)

func CoreIsDecimal added in v1.13.0

func CoreIsDecimal(vs ...vm.Value) (vm.Value, error)

func CoreIsDelay added in v1.13.0

func CoreIsDelay(vs ...vm.Value) (vm.Value, error)

func CoreIsDouble added in v1.13.0

func CoreIsDouble(vs ...vm.Value) (vm.Value, error)

func CoreIsFloat added in v1.13.0

func CoreIsFloat(vs ...vm.Value) (vm.Value, error)

func CoreIsIFn added in v1.13.0

func CoreIsIFn(vs ...vm.Value) (vm.Value, error)

func CoreIsInfinite added in v1.13.0

func CoreIsInfinite(vs ...vm.Value) (vm.Value, error)

func CoreIsInst added in v1.13.0

func CoreIsInst(vs ...vm.Value) (vm.Value, error)

func CoreIsInt added in v1.13.0

func CoreIsInt(vs ...vm.Value) (vm.Value, error)

func CoreIsLazySeq added in v1.13.0

func CoreIsLazySeq(vs ...vm.Value) (vm.Value, error)

func CoreIsList added in v1.13.0

func CoreIsList(vs ...vm.Value) (vm.Value, error)

func CoreIsMap added in v1.13.0

func CoreIsMap(vs ...vm.Value) (vm.Value, error)

func CoreIsMapEntry added in v1.13.0

func CoreIsMapEntry(vs ...vm.Value) (vm.Value, error)

func CoreIsNaN added in v1.13.0

func CoreIsNaN(vs ...vm.Value) (vm.Value, error)

func CoreIsNumber added in v1.13.0

func CoreIsNumber(vs ...vm.Value) (vm.Value, error)

func CoreIsRatio added in v1.13.0

func CoreIsRatio(vs ...vm.Value) (vm.Value, error)

func CoreIsRealized added in v1.13.0

func CoreIsRealized(vs ...vm.Value) (vm.Value, error)

func CoreIsRecord added in v1.13.0

func CoreIsRecord(vs ...vm.Value) (vm.Value, error)

func CoreIsReducedf added in v1.13.0

func CoreIsReducedf(vs ...vm.Value) (vm.Value, error)

func CoreIsReversible added in v1.13.0

func CoreIsReversible(vs ...vm.Value) (vm.Value, error)

func CoreIsSet added in v1.13.0

func CoreIsSet(vs ...vm.Value) (vm.Value, error)

func CoreIsSorted added in v1.13.0

func CoreIsSorted(vs ...vm.Value) (vm.Value, error)

func CoreIsUUID added in v1.13.0

func CoreIsUUID(vs ...vm.Value) (vm.Value, error)

func CoreIsVar added in v1.13.0

func CoreIsVar(vs ...vm.Value) (vm.Value, error)

func CoreIterate added in v1.13.0

func CoreIterate(vs ...vm.Value) (vm.Value, error)

func CoreKeyf added in v1.13.0

func CoreKeyf(vs ...vm.Value) (vm.Value, error)

func CoreKeyword added in v1.13.0

func CoreKeyword(vs ...vm.Value) (vm.Value, error)

func CoreLazySeq added in v1.13.0

func CoreLazySeq(vs ...vm.Value) (vm.Value, error)

func CoreLongf added in v1.13.0

func CoreLongf(vs ...vm.Value) (vm.Value, error)

func CoreMakeArrayf added in v1.13.0

func CoreMakeArrayf(vs ...vm.Value) (vm.Value, error)

func CoreMakeDType added in v1.13.0

func CoreMakeDType(vs ...vm.Value) (vm.Value, error)

func CoreMakeDTypeInstance added in v1.13.0

func CoreMakeDTypeInstance(vs ...vm.Value) (vm.Value, error)

func CoreMakeMultiArityFn added in v1.13.0

func CoreMakeMultiArityFn(vs ...vm.Value) (vm.Value, error)

func CoreMakeProtocolFn added in v1.13.0

func CoreMakeProtocolFn(vs ...vm.Value) (vm.Value, error)

func CoreMakeRecord added in v1.13.0

func CoreMakeRecord(vs ...vm.Value) (vm.Value, error)

func CoreMakeRecordType added in v1.13.0

func CoreMakeRecordType(vs ...vm.Value) (vm.Value, error)

func CoreMax added in v1.13.0

func CoreMax(vs ...vm.Value) (vm.Value, error)

func CoreMethodInvoke added in v1.13.0

func CoreMethodInvoke(vs ...vm.Value) (vm.Value, error)

func CoreMin added in v1.13.0

func CoreMin(vs ...vm.Value) (vm.Value, error)

func CoreMod added in v1.13.0

func CoreMod(vs ...vm.Value) (vm.Value, error)

func CoreMul added in v1.13.0

func CoreMul(vs ...vm.Value) (vm.Value, error)

func CoreMulP added in v1.13.0

func CoreMulP(vs ...vm.Value) (vm.Value, error)

func CoreNot added in v1.13.0

func CoreNot(vs ...vm.Value) (vm.Value, error)

func CoreNsAliases added in v1.13.0

func CoreNsAliases(vs ...vm.Value) (vm.Value, error)

func CoreNsInterns added in v1.13.0

func CoreNsInterns(vs ...vm.Value) (vm.Value, error)

func CoreNsMap added in v1.13.0

func CoreNsMap(vs ...vm.Value) (vm.Value, error)

func CoreNsPublics added in v1.13.0

func CoreNsPublics(vs ...vm.Value) (vm.Value, error)

func CoreNsRefers added in v1.13.0

func CoreNsRefers(vs ...vm.Value) (vm.Value, error)

func CoreNsUnmap added in v1.13.0

func CoreNsUnmap(vs ...vm.Value) (vm.Value, error)

func CoreNumeratorf added in v1.13.0

func CoreNumeratorf(vs ...vm.Value) (vm.Value, error)

func CoreNumericEq added in v1.13.0

func CoreNumericEq(vs ...vm.Value) (vm.Value, error)

func CoreObjectArrayf added in v1.13.0

func CoreObjectArrayf(vs ...vm.Value) (vm.Value, error)

func CoreParseBool added in v1.13.0

func CoreParseBool(vs ...vm.Value) (vm.Value, error)

func CoreParseDouble added in v1.13.0

func CoreParseDouble(vs ...vm.Value) (vm.Value, error)

func CoreParseUUID added in v1.13.0

func CoreParseUUID(vs ...vm.Value) (vm.Value, error)

func CorePeek added in v1.13.0

func CorePeek(vs ...vm.Value) (vm.Value, error)

func CorePersistentf added in v1.13.0

func CorePersistentf(vs ...vm.Value) (vm.Value, error)

func CorePlus added in v1.13.0

func CorePlus(vs ...vm.Value) (vm.Value, error)

func CorePlusP added in v1.13.0

func CorePlusP(vs ...vm.Value) (vm.Value, error)

func CorePop added in v1.13.0

func CorePop(vs ...vm.Value) (vm.Value, error)

func CorePopBang added in v1.13.0

func CorePopBang(vs ...vm.Value) (vm.Value, error)

func CorePrStr added in v1.13.0

func CorePrStr(vs ...vm.Value) (vm.Value, error)

func CorePrintStr added in v1.13.0

func CorePrintStr(vs ...vm.Value) (vm.Value, error)

func CorePrintlnStr added in v1.13.0

func CorePrintlnStr(vs ...vm.Value) (vm.Value, error)

func CorePrnStr added in v1.13.0

func CorePrnStr(vs ...vm.Value) (vm.Value, error)

func CorePromisef added in v1.13.0

func CorePromisef(vs ...vm.Value) (vm.Value, error)

func CoreQuotf added in v1.13.0

func CoreQuotf(vs ...vm.Value) (vm.Value, error)

func CoreRandInt added in v1.13.0

func CoreRandInt(vs ...vm.Value) (vm.Value, error)

func CoreRandNth added in v1.13.0

func CoreRandNth(vs ...vm.Value) (vm.Value, error)

func CoreRandf added in v1.13.0

func CoreRandf(vs ...vm.Value) (vm.Value, error)

func CoreRangef added in v1.13.0

func CoreRangef(vs ...vm.Value) (vm.Value, error)

func CoreRationalizef added in v1.13.0

func CoreRationalizef(vs ...vm.Value) (vm.Value, error)

func CoreReFind added in v1.13.0

func CoreReFind(vs ...vm.Value) (vm.Value, error)

func CoreReGroups added in v1.13.0

func CoreReGroups(vs ...vm.Value) (vm.Value, error)

func CoreReMatches added in v1.13.0

func CoreReMatches(vs ...vm.Value) (vm.Value, error)

func CoreReSeq added in v1.13.0

func CoreReSeq(vs ...vm.Value) (vm.Value, error)

func CoreReducedf added in v1.13.0

func CoreReducedf(vs ...vm.Value) (vm.Value, error)

func CoreRefer added in v1.13.0

func CoreRefer(vs ...vm.Value) (vm.Value, error)

func CoreReferList added in v1.13.0

func CoreReferList(vs ...vm.Value) (vm.Value, error)

func CoreRegex added in v1.13.0

func CoreRegex(vs ...vm.Value) (vm.Value, error)

func CoreRegisterHostClass added in v1.13.0

func CoreRegisterHostClass(vs ...vm.Value) (vm.Value, error)

func CoreRegisterHostMethod added in v1.13.0

func CoreRegisterHostMethod(vs ...vm.Value) (vm.Value, error)

func CoreRemf added in v1.13.0

func CoreRemf(vs ...vm.Value) (vm.Value, error)

func CoreRemoveNs added in v1.13.0

func CoreRemoveNs(vs ...vm.Value) (vm.Value, error)

func CoreRemoveTap added in v1.13.0

func CoreRemoveTap(vs ...vm.Value) (vm.Value, error)

func CoreRemoveWatch added in v1.13.0

func CoreRemoveWatch(vs ...vm.Value) (vm.Value, error)

func CoreRepeat added in v1.13.0

func CoreRepeat(vs ...vm.Value) (vm.Value, error)

func CoreRequiref added in v1.13.0

func CoreRequiref(vs ...vm.Value) (vm.Value, error)

func CoreReset added in v1.13.0

func CoreReset(vs ...vm.Value) (vm.Value, error)

func CoreResetVals added in v1.13.0

func CoreResetVals(vs ...vm.Value) (vm.Value, error)

func CoreResolvef added in v1.13.0

func CoreResolvef(vs ...vm.Value) (vm.Value, error)

func CoreRoundBigdec added in v1.13.0

func CoreRoundBigdec(vs ...vm.Value) (vm.Value, error)

func CoreRseqf added in v1.13.0

func CoreRseqf(vs ...vm.Value) (vm.Value, error)

func CoreSatisfies added in v1.13.0

func CoreSatisfies(vs ...vm.Value) (vm.Value, error)

func CoreScopeClose added in v1.13.0

func CoreScopeClose(vs ...vm.Value) (vm.Value, error)

func CoreScopeLive added in v1.13.0

func CoreScopeLive(vs ...vm.Value) (vm.Value, error)

func CoreScopeQmark added in v1.13.0

func CoreScopeQmark(vs ...vm.Value) (vm.Value, error)

func CoreSecond added in v1.13.0

func CoreSecond(vs ...vm.Value) (vm.Value, error)

func CoreSetDTypeToString added in v1.13.0

func CoreSetDTypeToString(vs ...vm.Value) (vm.Value, error)

func CoreSetDerefProtocol added in v1.13.0

func CoreSetDerefProtocol(vs ...vm.Value) (vm.Value, error)

func CoreSetField added in v1.13.0

func CoreSetField(vs ...vm.Value) (vm.Value, error)

func CoreSetInvokableProtocol added in v1.13.0

func CoreSetInvokableProtocol(vs ...vm.Value) (vm.Value, error)

func CoreSetMacro added in v1.13.0

func CoreSetMacro(vs ...vm.Value) (vm.Value, error)

func CoreSetRandSeedFn added in v1.13.0

func CoreSetRandSeedFn(vs ...vm.Value) (vm.Value, error)

func CoreShuffle added in v1.13.0

func CoreShuffle(vs ...vm.Value) (vm.Value, error)

func CoreSlurp added in v1.13.0

func CoreSlurp(vs ...vm.Value) (vm.Value, error)

func CoreSortedMap added in v1.13.0

func CoreSortedMap(vs ...vm.Value) (vm.Value, error)

func CoreSortedMapBy added in v1.13.0

func CoreSortedMapBy(vs ...vm.Value) (vm.Value, error)

func CoreSortedSet added in v1.13.0

func CoreSortedSet(vs ...vm.Value) (vm.Value, error)

func CoreSortedSetBy added in v1.13.0

func CoreSortedSetBy(vs ...vm.Value) (vm.Value, error)

func CoreSpit added in v1.13.0

func CoreSpit(vs ...vm.Value) (vm.Value, error)

func CoreStrReplace added in v1.13.0

func CoreStrReplace(vs ...vm.Value) (vm.Value, error)

func CoreSub added in v1.13.0

func CoreSub(vs ...vm.Value) (vm.Value, error)

func CoreSubP added in v1.13.0

func CoreSubP(vs ...vm.Value) (vm.Value, error)

func CoreSubvecf added in v1.13.0

func CoreSubvecf(vs ...vm.Value) (vm.Value, error)

func CoreSymbolf added in v1.13.0

func CoreSymbolf(vs ...vm.Value) (vm.Value, error)

func CoreTapBang added in v1.13.0

func CoreTapBang(vs ...vm.Value) (vm.Value, error)

func CoreTheNs added in v1.13.0

func CoreTheNs(vs ...vm.Value) (vm.Value, error)

func CoreThrowf added in v1.13.0

func CoreThrowf(vs ...vm.Value) (vm.Value, error)

func CoreTransientf added in v1.13.0

func CoreTransientf(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedAdd added in v1.13.0

func CoreUncheckedAdd(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedByte added in v1.13.0

func CoreUncheckedByte(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedChar added in v1.13.0

func CoreUncheckedChar(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedDivideInt added in v1.13.0

func CoreUncheckedDivideInt(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedDouble added in v1.13.0

func CoreUncheckedDouble(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedFloat added in v1.13.0

func CoreUncheckedFloat(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedInt added in v1.13.0

func CoreUncheckedInt(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedLong added in v1.13.0

func CoreUncheckedLong(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedMultiply added in v1.13.0

func CoreUncheckedMultiply(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedNegate added in v1.13.0

func CoreUncheckedNegate(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedShort added in v1.13.0

func CoreUncheckedShort(vs ...vm.Value) (vm.Value, error)

func CoreUncheckedSubtract added in v1.13.0

func CoreUncheckedSubtract(vs ...vm.Value) (vm.Value, error)

func CoreUnreduced added in v1.13.0

func CoreUnreduced(vs ...vm.Value) (vm.Value, error)

func CoreUnsignedBitShiftRight added in v1.13.0

func CoreUnsignedBitShiftRight(vs ...vm.Value) (vm.Value, error)

func CoreUse added in v1.13.0

func CoreUse(vs ...vm.Value) (vm.Value, error)

func CoreValf added in v1.13.0

func CoreValf(vs ...vm.Value) (vm.Value, error)

func CoreVarGet added in v1.13.0

func CoreVarGet(vs ...vm.Value) (vm.Value, error)

func CoreVector added in v1.13.0

func CoreVector(vs ...vm.Value) (vm.Value, error)

func CoreVolatilef added in v1.13.0

func CoreVolatilef(vs ...vm.Value) (vm.Value, error)

func CoreVreset added in v1.13.0

func CoreVreset(vs ...vm.Value) (vm.Value, error)

func CoreWithMeta added in v1.13.0

func CoreWithMeta(vs ...vm.Value) (vm.Value, error)

func DecodeExecUnit added in v1.12.0

func DecodeExecUnit(data []byte) (*bytecode.ExecUnit, error)

DecodeExecUnit decodes a .lgb payload (plain or bundle format), resolving var references with LGBVarResolver.

func DecodeExecUnitWithDebug added in v1.13.0

func DecodeExecUnitWithDebug(data, debugData []byte) (*bytecode.ExecUnit, error)

DecodeExecUnitWithDebug decodes a payload and attaches a verified external debug companion when the payload was produced by bytecode.SplitDebug.

func DecodeExecUnitWithDebugFile added in v1.13.0

func DecodeExecUnitWithDebugFile(data []byte, artifactPath string) (*bytecode.ExecUnit, error)

DecodeExecUnitWithDebugFile loads and decodes a companion only when the LGB header says debug information was split. Ordinary artifacts therefore pay no filesystem lookup and ignore stale sidecars.

func DecodeResourceArchive added in v1.10.0

func DecodeResourceArchive(blob []byte) (map[string][]byte, error)

DecodeResourceArchive reverses EncodeResourceArchive.

func DefNSBare added in v1.3.0

func DefNSBare(name string) *vm.Namespace

DefNSBare creates and registers a minimal namespace (with CoreNS refer) without triggering the loader. Used during bytecode decoding to create var homes for not-yet-loaded namespaces.

func Deref added in v1.12.0

func Deref(ref vm.Value) (vm.Value, error)

Deref dereferences a Reference (atom, var, delay, promise, …). Mirrors clojure.core/deref — `(deref ref)` / `@ref`.

func Deref3 added in v1.12.0

func Deref3(bref vm.Value, ms int64, timeoutVal vm.Value) (vm.Value, error)

Deref3 blocks up to ms milliseconds for a promise/future's value, else returns timeoutVal. Mirrors clojure.core/deref with 3 args — `(deref blocking-ref timeout-ms timeout-val)`.

func DivValue added in v1.11.0

func DivValue(a, b vm.Value) vm.Value

DivValue is the runtime target for the :div IR op when the operands aren't both native float64 (int/int yields a Ratio, mixed yields Float). Mirrors clojure.core// via vm.NumDiv so the lowered Go path matches the interpreter.

func DumpNamespaces

func DumpNamespaces(fileName string)

func EDNEncodeArgs added in v1.1.0

func EDNEncodeArgs(args []vm.Value) (string, error)

EDNEncodeArgs encodes args as an EDN vector string.

func EmbeddedNSNames added in v1.9.0

func EmbeddedNSNames() []string

EmbeddedNSNames returns every embedded namespace name (dotted form), derived from the embedded file tree. Used by lgbgen to discover what to precompile.

func EmbeddedSource added in v1.9.0

func EmbeddedSource(name string) (string, bool)

EmbeddedSource returns the source of an embedded namespace by its dotted ns name. Auxiliary sources (auxEmbeddedSources) are checked first, then the core/ tree.

Naming rule for the core/ tree (the source-side analog of `cmd/lgbgen.nsToGoRelDir`, which nests the lowered Go tree the same way):

  • dots are path separators: `ir.passes.dce` → `ir/passes/dce.lg`
  • in the *leaf* segment, hyphens map to underscores so the file name is a legal Go-style identifier: `ir.lower-go` → `ir/lower_go.lg`

Returns ("", false) if no matching file exists.

func EmitReflectionWarningForForm added in v1.12.0

func EmitReflectionWarningForForm(form vm.Value, kind, reason string)

EmitReflectionWarningForForm emits a warning using a compiler form's source.

func EmitVia added in v1.11.0

func EmitVia(ec *vm.ExecContext, name, dataJSON string)

EmitVia dispatches through the current *emit* binding. No-op when unbound (early boot, or a host that never installed an emitter).

func EncodeResourceArchive added in v1.10.0

func EncodeResourceArchive(files map[string][]byte) ([]byte, error)

EncodeResourceArchive serializes a name->bytes map into a gzip-compressed, self-describing archive. Entries are written in sorted name order so the output is deterministic for a given input.

func EqValue added in v1.11.0

func EqValue(a, b vm.Value) bool

EqValue implements Clojure value-equality (the = operator / OP_EQ) for the lowered Go path. Unlike Go's ==, it is safe on non-comparable dynamic types (vectors, maps, seqs) and compares by value, not interface identity. The lowerer routes = through here whenever an operand is vm.Value (it could hold a collection); concrete comparable scalars keep native Go ==.

func FuzzyNamespacedSymbolLookup

func FuzzyNamespacedSymbolLookup(currentNS *vm.Namespace, s vm.Symbol) (matches []vm.Symbol, namePrefix vm.Symbol)

FuzzyNamespacedSymbolLookup fuzzy-matches s (which may be ns-qualified) as a symbol prefix, resolving any ns segment against currentNS. Alongside the matches it returns namePrefix, the unqualified name segment of s that was actually matched against — callers that need to strip the typed prefix from a candidate (e.g. pkg/complete's REPL completer) should use this instead of independently re-splitting s, so the two derivations can't drift apart.

func GeValue added in v1.9.0

func GeValue(a, b vm.Value) bool

func Get added in v1.12.0

func Get(coll vm.Value, key vm.Value) (vm.Value, error)

Get looks up key in an associative collection, returning nil when absent or when coll is not a lookup. Mirrors clojure.core/get — `(get coll key)`.

func Get3 added in v1.12.0

func Get3(coll vm.Value, key vm.Value, notFound vm.Value) (vm.Value, error)

Get3 looks up key in coll, returning notFound when absent or when coll is not a lookup. Mirrors clojure.core/get — `(get coll key not-found)`.

func GtValue added in v1.9.0

func GtValue(a, b vm.Value) bool

func InstallHostOutputRoots added in v1.13.0

func InstallHostOutputRoots(stdout, stderr *IOHandle)

InstallHostOutputRoots replaces the process roots of *out* and *err* with the host's handles, and *test-out* too if the test namespace is already loaded. Hosts must use this instead of SetRoot on *out* directly so the two vars never disagree. Spec 10.2.

func InstallPersistentStorage added in v1.12.0

func InstallPersistentStorage(storeID string)

InstallPersistentStorage binds core/*storage* to the default file-backed store for storeID. Failure disables storage with a warning rather than aborting startup.

func Int added in v1.13.0

func Int(v vm.Value) (vm.Value, error)

Int implements (int x). Body extracted verbatim from lang.go's closure — including the int32 range guard and the per-type coercion table — rather than retyped, so the direct-call path cannot drift from the interpreter.

func InternVar added in v1.11.0

func InternVar(nsName, symName string) *vm.Var

InternVar interns (LookupOrAdd) a Var by namespace and symbol name, creating the namespace and/or the var if absent, and returns it. Used by gogen-lowered `def` forms, which must CREATE the var at runtime — unlike LookupVar, which only resolves an already-existing one (returning nil otherwise).

func InvokeProgramEntry added in v1.13.0

func InvokeProgramEntry(ec *vm.ExecContext, namespace, name string, args []vm.Value) error

InvokeProgramEntry looks up name ("-main" or "main") in the given namespace and Invokes it with args. Used by the #425 native-entry VM-fallback frame after LoadProgramNamespaces has installed defs — a bare MainChunk re-run would no-op for single-ns programs whose MainChunk is the ns chunk itself.

namespace must be the source namespace that owns the selected entry. The compiler already chose that namespace; searching CurrentNS or the global registry would let a competing entry in another namespace steal the call.

func InvokeValue added in v1.9.0

func InvokeValue(target vm.Value, args []vm.Value) (vm.Value, error)

InvokeValue applies a runtime callable using let-go's dynamic invocation path.

func InvokeValueEC added in v1.11.0

func InvokeValueEC(ec *vm.ExecContext, target vm.Value, args []vm.Value) (vm.Value, error)

InvokeValueEC is InvokeValue threaded with the caller's ExecContext, so a callable invoked from lowered code resolves dynamic vars (and propagates the scope to spawned goroutines) against the running context rather than the process root. A nil ec resolves to the root context. Values that are not vm.Fn (only the bare invoker interface) take the context-free path.

func JSONDecodeValue added in v1.1.0

func JSONDecodeValue(s string) (vm.Value, error)

JSONDecodeValue decodes a JSON string into a vm.Value.

func JSONEncodeArgs added in v1.1.0

func JSONEncodeArgs(args []vm.Value) (string, error)

JSONEncodeArgs encodes args as a plain JSON array string.

func LGBVarResolver added in v1.12.0

func LGBVarResolver(nsName, name string) *vm.Var

LGBVarResolver resolves a decoded var reference against the live registry: the var's home namespace is materialized bare (no loader trigger) and the name is interned as a stub if not yet defined. The single resolver behind every .lgb decode site.

It records var-ref hit/miss decode stats (LG_DECODE_TAG_STATS). The Note calls self-gate on bytecode.decodeStatsEnabled, so they're a no-op unless a caller has enabled stats around the decode; folding them in here — rather than a decode-site-specific resolver — makes the counter available at every canonical decode site, not just core boot where it started (#356).

func LeValue added in v1.9.0

func LeValue(a, b vm.Value) bool

func LgBaselineNSNames added in v1.12.0

func LgBaselineNSNames() []string

LgBaselineNSNames lists the lg baseline namespace names (auto-refer'd extras). The boot loader runs their bundle chunks eagerly — they are never explicitly required, so on-demand loading would never fire.

func LoadCore added in v1.12.0

func LoadCore() error

LoadCore boots the runtime from the embedded core .lgb: decode it, replay core + the lg baseline namespaces, then register the remaining namespace chunks for on-demand loading via bytecodeNSLoader. It touches no compiler code, so it can boot a build where pkg/compiler is not linked (see cmd/lg-runtime).

Hybrid namespaces (native fns + a bundled lg chunk, e.g. async) are left for the on-demand loader — EagerHybrids is false — safe today because async's bundled content is macro-only and macros are fully expanded before a .lgb exists. LoadCore's whole reason for existing over BootCore is that it installs a namespace loader (UseBytecodeNSLoader), so it doesn't need the eager pass; a future hybrid bundling runtime fns would flip this to true.

func LoadCoreBundle added in v1.12.0

func LoadCoreBundle(opts CoreLoadOptions) (*bytecode.ExecUnit, error)

LoadCoreBundle is the single compiler-free core-boot path: decode the embedded clojure.core bundle (CoreCompiledLGB) and replay it onto the live registry — core's main chunk (all of core's def/defn/defmacro), then the lg baseline namespaces (let-go.core, let-go.types) which are auto-refer'd everywhere but never explicitly required, then optionally the hybrid namespace chunks. Non-core/non-baseline namespaces are marked NeedsLoad so a configured loader picks them up on (require ...). Returns the decoded unit so a caller can read its const pool or chunk map.

It is the one implementation behind compiler.loadPrecompiledBundle, rt.LoadCore, and rt.BootCore. Two invariants hold here:

  • for every caller, *ns* is saved before the replay and restored after. Each chunk runs its (ns …) form under a frame with no ExecContext, so in-ns falls through to CurrentNS.SetRoot and mutates the global root; unrestored, a caller that returns straight to user code (BootCore) would deref a *ns* left pointing at whichever chunk ran last.
  • under EagerHybrids, the hybrid loop iterates unit.NSOrder (dependency order), not the NSChunks map, so replay order is deterministic, and calls ReapplyGeneratedPrimitives after each chunk — the chunk's bootstrap defs overwrite the native adapters #438 Def'd at init, so without the reapply a bundle that eager-re-Defs one would strand its callers on the trampoline and lose the direct-call fast path.

func LoadDebugCompanion added in v1.13.0

func LoadDebugCompanion(artifactPath string) ([]byte, error)

LoadDebugCompanion reads debug information for artifactPath. LG_DEBUG_FILE, when set, selects an explicit file (or disables loading when empty); otherwise the conventional <artifact>.debug sibling is optional.

func LoadProgramNamespaces added in v1.13.0

func LoadProgramNamespaces(unit *bytecode.ExecUnit) error

LoadProgramNamespaces replays every namespace chunk in unit.NSOrder, draining ApplyGoOverrides after each so gogen_ir NativeFn overrides land on the Vars the bytecode just installed. This is the program-half of an AOT native-entry frame (#425): BootCore already owns core boot+reapply; the generated main.go owns this load, then the main-chunk replay, then the entry — directly when it lowered, else through InvokeProgramEntry.

Unlike the historical RunExecUnit loop, this does NOT skip MainChunk — for a single-ns program the ns chunk IS MainChunk, and the native entry still needs those Vars (non-lowered callees, override targets) installed before the direct Go call. RunProgramMainChunk then no-ops when MainChunk was already covered here.

func LookupCoreVar added in v1.11.0

func LookupCoreVar(varName string) *vm.Var

LookupCoreVar returns the *Var for a name in the core namespace, or nil if not installed. Exported for packages (e.g. nrepl) that need to PushBinding/PopBinding on the core I/O vars to implement scoped capture.

func LookupHostClass added in v1.10.0

func LookupHostClass(name string) (vm.Value, bool)

LookupHostClass resolves a registered host-class name.

func LookupNS added in v1.3.0

func LookupNS(name string) *vm.Namespace

func LookupOrRegisterNS

func LookupOrRegisterNS(name string) *vm.Namespace

func LookupOrRegisterNSNoLoad

func LookupOrRegisterNSNoLoad(name string) *vm.Namespace

func LookupVar added in v1.9.0

func LookupVar(nsName, symName string) *vm.Var

LookupVar resolves a runtime Var by namespace and symbol name.

func LtValue added in v1.9.0

func LtValue(a, b vm.Value) bool

func MakeNativeMultiArity added in v1.9.0

func MakeNativeMultiArity(fns []vm.Value) vm.Value

MakeNativeMultiArity combines native-lowered function branches into a runtime multi-arity callable.

func MarkNSNeedsLoad added in v1.3.0

func MarkNSNeedsLoad(name string)

MarkNSNeedsLoad flags a namespace as needing on-demand loading even though it already exists in the registry (created during bytecode decoding).

func MulValue added in v1.9.0

func MulValue(a, b vm.Value) vm.Value

func MultiFnNativeFrozen added in v1.11.0

func MultiFnNativeFrozen(ptr **vm.Var, nsName, symName string) bool

MultiFnNativeFrozen reports whether the multimethod var still holds its native baseline — the frozen *MultiFn captured at namespace-load completion. Generated native dispatch (the type-switch with baked _mm_* arms) calls this first and only takes the native arms when it returns true; otherwise it falls back to runtime dispatch through the var, which sees any late defmethod.

Resolution is lazy + memoized like CachedVarFn (the var pointer is filled on first call). A nil var, a non-MultiFn value, or an unfrozen MultiFn all return false — the safe default that routes through runtime dispatch.

func NS

func NS(name string) *vm.Namespace

func Name added in v1.12.0

func Name(v vm.Value) (string, error)

Name returns the name of a value as a string. For Symbols and Keywords, returns the name part after the namespace separator. For Strings, returns the string itself. Mirrors clojure.core/name — `(name x)`.

func Namespace added in v1.13.0

func Namespace(v vm.Value) (vm.Value, error)

Namespace implements (namespace x) for Named values.

func NativePrimsIntact added in v1.12.0

func NativePrimsIntact() bool

NativePrimsIntact reports that no native-primitive var root is currently overridden (with-redefs / alter-var-root / re-def). Lowered Go call sites emitted for native-module callees consult this before taking the baked direct call; on false they fall back to the var-dispatch trampoline so the override is observed across lowered function boundaries.

func NormalizeResourceName added in v1.10.0

func NormalizeResourceName(name string) (string, bool)

NormalizeResourceName canonicalizes a resource lookup name into a slash-separated path relative to a resource root. It strips a leading "/" or "./", collapses "." and in-root ".." segments, and reports ok=false for empty names or names that try to escape the root via "..".

func Nth added in v1.12.0

func Nth(coll vm.Value, i int64) (vm.Value, error)

Nth returns the element at index in a collection. For Indexed (vectors, strings, arrays, etc.), returns the element at that index. For seqs, walks linearly to find the element at that index. Mirrors clojure.core/nth with 2 arguments — `(nth coll i)`.

func Nth3 added in v1.12.0

func Nth3(coll vm.Value, i int64, notFound vm.Value) (vm.Value, error)

Nth3 returns the element at index in a collection, or notFound if out of bounds. For Indexed (vectors, strings, arrays, etc.), returns the element at that index. For seqs, walks linearly to find the element at that index. Mirrors clojure.core/nth with 3 arguments — `(nth coll i not-found)`.

func PopBinding added in v1.13.0

func PopBinding(ec *vm.ExecContext, v vm.Value) (vm.Value, error)

PopBinding implements (pop-binding! v).

func PresentVia added in v1.13.0

func PresentVia(ec *vm.ExecContext, rgba []byte, w, h int)

PresentVia dispatches through the current *surface* binding. No-op when unbound (early boot, or a host that never installed a surface). A panicking sink drops the frame instead of unwinding into the guest: frames are fire-and-forget, so silent drop is the correct failure mode — this is what keeps a throwing JS callback (via HostSurface) or a faulty embedder Surface from taking down the runtime.

func PushBinding added in v1.13.0

func PushBinding(ec *vm.ExecContext, v vm.Value, val vm.Value) (vm.Value, error)

PushBinding implements (push-binding! v val) — the dynamic-binding lifecycle, so it needs the ExecContext holding the binding stack.

func QuotValue added in v1.9.0

func QuotValue(a, b vm.Value) vm.Value

func ReapplyGeneratedPrimitives added in v1.12.0

func ReapplyGeneratedPrimitives(name string)

ReapplyGeneratedPrimitives restores the recorded native adapters on a namespace after one of its chunks executed outside the on-demand loader — the compiler's eager hybrid-namespace pass (loadPrecompiledBundle) runs chunks directly, and those re-Def bootstrap closures over the adapters just like a lazy load does. No-op for namespaces without generated primitives or that don't exist.

func Reduce added in v1.12.0

func Reduce(ec *vm.ExecContext, f vm.Value, coll vm.Value) (vm.Value, error)

Reduce implements (reduce f coll): the accumulator seeds from the first element of coll, and an empty/nil coll invokes f with no arguments. Mirrors clojure.core/reduce with 2 arguments.

func Reduce3 added in v1.12.0

func Reduce3(ec *vm.ExecContext, f vm.Value, init vm.Value, coll vm.Value) (vm.Value, error)

Reduce3 implements (reduce f init coll): the accumulator seeds from init, and a nil coll returns init unchanged without calling f. Mirrors clojure.core/reduce with 3 arguments.

func RegisterGeneratedPrimitives added in v1.12.0

func RegisterGeneratedPrimitives()

func RegisterGoOverrides added in v1.10.0

func RegisterGoOverrides(nsName string, defs map[string]vm.Value)

RegisterGoOverrides queues a set of name → NativeFn bindings. If the target namespace already exists in the registry, the defs are applied immediately (the host has already finished bundle replay); otherwise they sit in pendingGoOverrides until ApplyGoOverrides drains them.

Init-order hazard this guards against: pkg/compiler's init() replays the core bundle and calls ApplyGoOverrides(coreNS) BEFORE the blank- imported lowered packages in main get to run their own init(). Without the immediate-apply path here, every override registered after that point would sit in the queue forever — the queue would be drained once when empty, then filled and never re-drained. Symptom is the dispatch counters reporting zero and `(reduce + (range 1000))` going through bytecode dispatch even with -tags gogen_ir + all the blank imports wired up.

func RegisterHostClass added in v1.10.0

func RegisterHostClass(name string, v vm.Value)

RegisterHostClass maps a bare class name to a let-go value.

func RegisterHostMethod added in v1.10.0

func RegisterHostMethod(t vm.ValueType, name vm.Symbol, fn vm.Fn)

RegisterHostMethod registers fn as the handler for `.name` on values whose type is t. The handler is invoked with the receiver as its first argument.

func RegisterInstaller added in v1.9.0

func RegisterInstaller(fn func())

RegisterInstaller queues fn to be called from lang.go's init(). Call this from your file's init() — it is not safe to call after init has run.

func RegisterNS

func RegisterNS(namespace *vm.Namespace) *vm.Namespace

func RegisterNativeModule added in v1.10.0

func RegisterNativeModule(m *NativeModule)

RegisterNativeModule self-registers a Go package as a contributor to a let-go namespace. Safe to call from init(); merges into the global registry without overwriting prior contributions to the same namespace.

If the same (ns, name) is registered twice, the latest wins — this matches the var rebinding semantics on the let-go side and lets a downstream package selectively override a builtin.

func RegisterNativeMultiFns added in v1.11.0

func RegisterNativeMultiFns(nsName string, names []string)

RegisterNativeMultiFns queues multimethod names whose native dispatch arms must be frozen for ns. If ns has already finished loading, the multifns are frozen immediately (the immediate-apply path RegisterGoOverrides also uses); otherwise they wait for ApplyGoOverrides.

func RegisterTestOut added in v1.13.0

func RegisterTestOut(v *vm.Var)

RegisterTestOut records test/*test-out* and seeds its root: the host stdout if one is installed, else the current root of *out*. Called by test.lg immediately after the var is interned, so either load order works.

func RemoveNS added in v1.12.0

func RemoveNS(name string)

RemoveNS drops a namespace from the registry so a subsequent require/def materializes a FRESH Namespace (and fresh Vars). Test-isolation helper: vars are interned process-globally, so anything attached to them (e.g. watches added by a test) survives re-running a suite in the same process unless its namespaces are removed between runs.

func RequireNS added in v1.9.0

func RequireNS(name string) (*vm.Namespace, error)

RequireNS loads/materializes a namespace and reports an error if a loader is configured but the namespace could not be loaded. Returns nil namespace on error (no half-initialized placeholder is leaked).

func ResetReflectionWarnings added in v1.12.0

func ResetReflectionWarnings()

ResetReflectionWarnings clears the once-per-source-site deduplication set.

func RunExecUnit added in v1.12.0

func RunExecUnit(unit *bytecode.ExecUnit) error

RunExecUnit replays a decoded unit: namespace chunks in dependency order first, then the main chunk (when it is not already one of those namespaces).

func RunExitHooks added in v1.11.0

func RunExitHooks()

func RunProgramMainChunk added in v1.13.0

func RunProgramMainChunk(unit *bytecode.ExecUnit) error

RunProgramMainChunk runs unit.MainChunk on the VM when it was not already replayed by LoadProgramNamespaces (i.e. when MainChunk is not one of the NSOrder namespaces). The AOT native-entry VM-fallback path (#425 Finding 2) uses this after LoadProgramNamespaces when the recognized main/-main form did not lower.

func SetCommandLineArgs added in v1.12.0

func SetCommandLineArgs(args []string)

SetCommandLineArgs publishes the user's CLI args — the positionals after the script — to core/*command-line-args*: nil when there are none, else a seq of strings. The entry point is the only layer that knows authoritatively where the script ends and the user's args begin, so it computes them once and every consumer reads the var instead of slicing os/args by hand.

func SetEvalInNS added in v1.1.0

func SetEvalInNS(fn func(string, *vm.Namespace) (vm.Value, error))

SetEvalInNS sets the namespace-aware eval function.

func SetNSLoader

func SetNSLoader(loader NSLoader)

func SetReadEDN added in v1.1.0

func SetReadEDN(fn func(string) (vm.Value, error))

SetReadEDN sets the EDN reader function (called by compiler package).

func SetReflectionWarningWriter added in v1.12.0

func SetReflectionWarningWriter(writer io.Writer) func()

SetReflectionWarningWriter replaces the warning sink and returns a restore function. It is primarily useful to embedders and tests.

func SetResourceProvider added in v1.10.0

func SetResourceProvider(p ResourceProvider)

SetResourceProvider installs the provider consulted by io/resource.

func ShadowedHandRegistrations added in v1.13.0

func ShadowedHandRegistrations() []string

ShadowedHandRegistrations lists "<ns>/<name>" for every generated primitive that landed on top of an existing hand-written registration. Diagnostic: each entry is a duplicate implementation where only the generated one runs.

func ShutdownAllPods added in v1.1.0

func ShutdownAllPods()

ShutdownAllPods gracefully shuts down all loaded pods.

func Some added in v1.13.0

func Some(ec *vm.ExecContext, pred vm.Value, coll vm.Value) (vm.Value, error)

Some implements (some pred coll). Body extracted verbatim from lang.go's closure (including the chunked fast path) rather than retyped, so the direct-call path cannot drift from the interpreter path. Needs the ExecContext to invoke the predicate.

func StorageIDFrom added in v1.11.0

func StorageIDFrom(flagID, script, cwd, exePath string) string

StorageIDFrom derives the logical storage store id from already-resolved inputs and does no I/O of its own — the caller passes the working directory and executable path so the policy stays unit-testable. Precedence:

  • an explicit flag id, when set;
  • for a named script, its basename with the extension trimmed;
  • for a named script whose basename says nothing about the app (".", "main", or "init"), the working-directory basename;
  • the executable's basename. This is the bundle case: the script argument is empty, so cwd is not consulted and bundles key by exe name (stable regardless of the launch directory);
  • "default".

cwd or exePath may be empty when the caller's lookup failed; an empty input is skipped rather than producing a "." or empty id.

func Str added in v1.12.0

func Str(args ...vm.Value) (string, error)

Str concatenates the string representation of its arguments. Mirrors clojure.core/str — `(str a b c)`.

func SubValue added in v1.9.0

func SubValue(a, b vm.Value) vm.Value

func Subs added in v1.12.0

func Subs(s string, start int64) (string, error)

Subs returns a substring from index start to the end. Mirrors clojure.core/subs with 2 arguments — `(subs s start)`.

func Subs3 added in v1.12.0

func Subs3(s string, start, end int64) (string, error)

Subs3 returns a substring from index start to end (exclusive). Mirrors clojure.core/subs with 3 arguments — `(subs s start end)`.

func SurfaceAvailableVia added in v1.13.0

func SurfaceAvailableVia(ec *vm.ExecContext) bool

SurfaceAvailableVia reports the current *surface* binding's availability. False when unbound or bound to a nop.

func TransitDecodeValue added in v1.1.0

func TransitDecodeValue(s string) (vm.Value, error)

TransitDecodeValue decodes a transit+json payload string.

func TransitEncodeArgs added in v1.1.0

func TransitEncodeArgs(args []vm.Value) (string, error)

TransitEncodeArgs encodes a list of args for pod invocation.

func UncheckedAddValue added in v1.13.0

func UncheckedAddValue(a, b vm.Value) vm.Value

UncheckedAddValue / UncheckedSubValue / UncheckedMulValue back the IR's :unchecked-add/-sub/-mul when an operand is not a proven int. They call the same vm.NumUnchecked* implementation as the opcode and the core fn, so they coerce and wrap identically, and panic (like AddValue) on what ToInt rejects.

func UncheckedMulValue added in v1.13.0

func UncheckedMulValue(a, b vm.Value) vm.Value

func UncheckedSubValue added in v1.13.0

func UncheckedSubValue(a, b vm.Value) vm.Value

func UnsignedBitShiftRightValue added in v1.12.0

func UnsignedBitShiftRightValue(a, b vm.Value) vm.Value

func UpperCase added in v1.12.0

func UpperCase(v vm.Value) (string, error)

UpperCase converts a value's string rendering to uppercase. Mirrors clojure.string/upper-case — `(upper-case s)`: JVM Clojure calls .toString on the argument, so keywords/symbols coerce ((upper-case :a) → ":A") and only nil throws. Registered in clojure.string namespace.

func UseBytecodeNSLoader added in v1.12.0

func UseBytecodeNSLoader()

UseBytecodeNSLoader installs the bytecode-only loader. A runtime-only entry point calls this after LoadCore so that dynamic require resolves against the bundle and rejects source loading.

func WithFile added in v1.13.0

func WithFile(path string, fn func() error) error

WithFile binds core/*file* to path for the duration of fn. Used by every file-loading entry point (CLI file runner, require/load, test harness).

func WithinRoot added in v1.10.0

func WithinRoot(root, p string) bool

WithinRoot reports whether the resolved path p is the resolved directory root or lies inside it. Both arguments must already be absolute and symlink-resolved (see resolveReal).

func WriteToErr added in v1.11.0

func WriteToErr(ec *vm.ExecContext, s string) error

WriteToErr writes s through the current dynamic binding of *err*. Falls back to os.Stderr.

func WriteToOut added in v1.11.0

func WriteToOut(ec *vm.ExecContext, s string) error

WriteToOut writes s through the current dynamic binding of *out*. Falls back to os.Stdout if *out* isn't installed yet or doesn't resolve to a handle (early-boot conditions only).

Types

type CoreLoadOptions added in v1.12.0

type CoreLoadOptions struct {
	// EagerHybrids replays HYBRID namespace chunks (native fns + bundled lg
	// source, e.g. async) immediately after core+baseline instead of leaving
	// them to the on-demand loader. Their vars are reachable via qualified
	// symbols WITHOUT a (require ...), which bypasses the loader, so a caller
	// that returns straight to user code (the compiler boot path,
	// BootCore) must run them eagerly or those vars stay nil stubs. A caller
	// that installs a namespace loader and only reaches hybrids through it
	// (LoadCore + bytecodeNSLoader) can leave this false.
	EagerHybrids bool

	// OnPhase, if set, is called after each boot phase with the phase name and
	// the time it started, so a caller can record fine-grained boot timing
	// (the compiler path's bootMark). Phases: "decode-bundle", "run-core-chunk".
	// nil disables timing.
	OnPhase func(phase string, since time.Time)
}

CoreLoadOptions tunes the shared core-boot spine (LoadCoreBundle).

It intentionally exposes a SINGLE behavioral axis (EagerHybrids). If a future caller wants a third replay behavior, that's the signal this shared spine is turning into the wrong abstraction — split it rather than growing more flags.

type EmbeddedResourceProvider added in v1.10.0

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

EmbeddedResourceProvider serves resources from an in-memory map decoded from the archive appended to a standalone binary.

func NewEmbeddedResourceProvider added in v1.10.0

func NewEmbeddedResourceProvider(files map[string][]byte) *EmbeddedResourceProvider

NewEmbeddedResourceProvider builds a provider over a decoded archive map.

func (*EmbeddedResourceProvider) Open added in v1.10.0

Open implements ResourceProvider against the embedded map.

type Emitter added in v1.11.0

type Emitter interface {
	Emit(name, dataJSON string)
}

Emitter is a sink for guest-dispatched host events.

type FSResourceProvider added in v1.10.0

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

FSResourceProvider resolves resources against an ordered list of filesystem roots; the first root containing the name wins.

func NewFSResourceProvider added in v1.10.0

func NewFSResourceProvider(roots []string) *FSResourceProvider

NewFSResourceProvider builds a provider over the given resource roots.

func (*FSResourceProvider) Open added in v1.10.0

func (p *FSResourceProvider) Open(name string) (io.ReadCloser, bool)

Open implements ResourceProvider. Errors and non-regular files (e.g. directories) are treated as "not found", so a lookup never panics on a permission race or a name that happens to be a directory.

type FileStat

type FileStat struct {
	Name    string `letgo:"name"`
	Size    int64  `letgo:"size"`
	IsDir   bool   `letgo:"dir?"`
	ModTime string `letgo:"mod-time"`
}

FileStat is the struct behind os/stat return values.

type FileStorage added in v1.11.0

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

FileStorage persists keys as files below one host-selected root. Logical keys are encoded, never used as raw filenames, so callers can use portable string keys without learning filesystem path rules.

No in-process lock: native lg drives it from a single guest thread, and Set's atomic temp-then-rename keeps a concurrent reader from observing a torn value. Cross-process coordination is the host's responsibility.

func NewDefaultFileStorage added in v1.11.0

func NewDefaultFileStorage(storeID string) (*FileStorage, error)

func NewFileStorage added in v1.11.0

func NewFileStorage(root string) (*FileStorage, error)

func (*FileStorage) Get added in v1.11.0

func (s *FileStorage) Get(key string) (string, bool, error)

func (*FileStorage) Keys added in v1.11.0

func (s *FileStorage) Keys(prefix string) ([]string, error)

func (*FileStorage) Remove added in v1.11.0

func (s *FileStorage) Remove(key string) error

func (*FileStorage) Set added in v1.11.0

func (s *FileStorage) Set(key, value string) error

type FuncEmitter added in v1.11.0

type FuncEmitter func(name, dataJSON string)

FuncEmitter adapts a plain func into an Emitter, for api.WithEmit.

func (FuncEmitter) Emit added in v1.11.0

func (f FuncEmitter) Emit(name, dataJSON string)

Emit implements Emitter.

type HTTPRequest

type HTTPRequest struct {
	RequestMethod vm.Value `letgo:"request-method"`
	Scheme        string   `letgo:"scheme"`
	URI           string   `letgo:"uri"`
	Path          string   `letgo:"path"`
	QueryString   string   `letgo:"query-string"`
	Body          string   `letgo:"body"`
	RemoteAddr    string   `letgo:"remote-addr"`
	ServerAddr    string   `letgo:"server-addr"`
	ServerPort    string   `letgo:"server-port"`
	ContentType   string   `letgo:"content-type"`
	Headers       vm.Value `letgo:"headers"`
}

HTTPRequest is the struct behind ring-style HTTP request maps.

type HTTPResponse

type HTTPResponse struct {
	Status  int      `letgo:"status"`
	Body    vm.Value `letgo:"body"`
	Headers vm.Value `letgo:"headers"`
}

HTTPResponse is the struct behind HTTP client response maps.

type HTTPServer added in v1.13.0

type HTTPServer struct {
	Addr   string   `letgo:"addr"`
	Port   int      `letgo:"port"`
	Server vm.Value `letgo:"server"`
}

HTTPServer is the struct behind the record http/start returns. Addr and Port come from the bound listener, so a ":0" start reports the real port. Server is the boxed handle http/stop and http/wait take.

type Handler

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

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(resp http.ResponseWriter, request *http.Request)

type IOHandle

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

IOHandle is the runtime's I/O abstraction. It wraps an io.Writer and/or io.Reader so the same type backs file handles, stdin/stdout/stderr, bytes.Buffer-style captures, and embedder-supplied sinks. File-backed handles also retain the *os.File so callers that need Fd()/Sync() still have it.

func NewIOHandle

func NewIOHandle(f *os.File) *IOHandle

NewIOHandle wraps an *os.File. Preserves all existing call sites and keeps file-specific operations (Fd, Sync) available via File().

func NewReaderHandle added in v1.11.0

func NewReaderHandle(name string, r io.Reader) *IOHandle

NewReaderHandle wraps an arbitrary io.Reader. No writes.

func NewWriterHandle added in v1.11.0

func NewWriterHandle(name string, w io.Writer) *IOHandle

NewWriterHandle wraps an arbitrary io.Writer. No reads.

func (*IOHandle) Close

func (h *IOHandle) Close() error

Close closes the underlying file if file-backed, or any wrapped writer/ reader that implements io.Closer. No-op for non-closable handles like bytes.Buffer or os.Stdout.

func (*IOHandle) File

func (h *IOHandle) File() *os.File

File returns the underlying *os.File or nil when the handle wraps an arbitrary writer/reader. Callers that need Fd()/Sync() (e.g. term/raw mode) must handle nil.

func (*IOHandle) Reader

func (h *IOHandle) Reader() *bufio.Reader

Reader returns a buffered reader over the underlying io.Reader, lazily constructed on first use. Returns nil for write-only handles.

func (*IOHandle) ReaderRaw added in v1.11.0

func (h *IOHandle) ReaderRaw() io.Reader

func (*IOHandle) String

func (h *IOHandle) String() string

func (*IOHandle) Sync added in v1.11.0

func (h *IOHandle) Sync() error

Sync flushes/syncs the handle. For file-backed handles, calls File.Sync. For writers that implement a Flush() error method (e.g. bufio.Writer), calls that. Otherwise no-op (buffers are eager).

func (*IOHandle) Write added in v1.11.0

func (h *IOHandle) Write(s string) (int, error)

Write is the convenience write-string path used by the print fns and (write! handle x). Returns an error if the handle isn't writable.

func (*IOHandle) Writer added in v1.11.0

func (h *IOHandle) Writer() io.Writer

Writer / Reader are the interface-shaped accessors the print/error refactor consults.

type KeySource added in v1.11.0

type KeySource interface {
	// ReadKey blocks until a key is available, returning the key's bytes as
	// a string. Returns "" for end-of-input (the read-key nil contract).
	ReadKey() (string, error)
	// KeyPending reports whether a key is buffered and ready, without
	// consuming it — the non-blocking peer of ReadKey.
	KeyPending() bool
}

KeySource is a source of keypresses for term/read-key and key-pending?.

func NewQueuedKeySource added in v1.12.0

func NewQueuedKeySource(r io.Reader) KeySource

NewQueuedKeySource returns a KeySource that reads keys from r via a background goroutine and a buffered queue, so KeyPending is non-blocking on platforms that lack a poll/FIONREAD peek. The reader goroutine starts lazily on the first ReadKey/KeyPending, so binding this at *keys* without ever consulting it (e.g. when api.WithKeySource overrides it) reads nothing.

type LGBuffer

type LGBuffer struct {
	Buf *bytes.Buffer
}

LGBuffer wraps bytes.Buffer as a readable/writable value.

func (*LGBuffer) Read

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

func (*LGBuffer) String

func (b *LGBuffer) String() string

func (*LGBuffer) Write

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

type LGReader

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

LGReader wraps any io.Reader with optional buffering and close.

func (*LGReader) Buffered

func (r *LGReader) Buffered() *bufio.Reader

func (*LGReader) Close

func (r *LGReader) Close() error

func (*LGReader) Read

func (r *LGReader) Read(p []byte) (int, error)

func (*LGReader) String

func (r *LGReader) String() string

type LGURL

type LGURL struct {
	Scheme   string `letgo:"scheme"`
	Host     string `letgo:"host"`
	Port     string `letgo:"port"`
	Path     string `letgo:"path"`
	Query    string `letgo:"query"`
	Fragment string `letgo:"fragment"`
	UserInfo string `letgo:"user-info"`
	Raw      string `letgo:"raw"`
}

LGURL represents a parsed URL as a record.

type LGWriter

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

LGWriter wraps any io.Writer with optional buffering and close.

func (*LGWriter) Buffered

func (w *LGWriter) Buffered() *bufio.Writer

func (*LGWriter) Close

func (w *LGWriter) Close() error

func (*LGWriter) Flush

func (w *LGWriter) Flush() error

func (*LGWriter) String

func (w *LGWriter) String() string

func (*LGWriter) Write

func (w *LGWriter) Write(p []byte) (int, error)

func (*LGWriter) WriteString added in v1.10.0

func (w *LGWriter) WriteString(s string) (int, error)

WriteString writes s to the underlying writer. Gives .lg callers a string-typed write (Go's Write takes []byte); used by print-method methods.

type MemoryStorage added in v1.11.0

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

MemoryStorage is the default inert-but-honest backend and the test/embedder convenience store. It is per-instance and does not persist.

func NewMemoryStorage added in v1.11.0

func NewMemoryStorage() *MemoryStorage

func (*MemoryStorage) Get added in v1.11.0

func (s *MemoryStorage) Get(key string) (string, bool, error)

func (*MemoryStorage) Keys added in v1.11.0

func (s *MemoryStorage) Keys(prefix string) ([]string, error)

func (*MemoryStorage) Remove added in v1.11.0

func (s *MemoryStorage) Remove(key string) error

func (*MemoryStorage) Set added in v1.11.0

func (s *MemoryStorage) Set(key, value string) error

type MouseEvent added in v1.11.0

type MouseEvent struct {
	Action            string // "press" | "release"
	Button            string // "left" | "middle" | "right" | "wheel-up" | "wheel-down" | "none"
	X, Y              int    // 1-based cell coordinates
	Shift, Ctrl, Meta bool
}

MouseEvent is a decoded SGR (1006) mouse report. Click-only scope: press and release of the three buttons plus wheel up/down, with Shift/Ctrl/Meta from the button byte. Drag/motion (the 1002/1003 modes) is out of scope, so the motion bit is ignored here — those modes are never enabled.

type Mult

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

Mult broadcasts values from a source channel to multiple tap channels.

type NSLoader

type NSLoader interface {
	Load(string) *vm.Namespace
}

func GetNSLoader added in v1.5.0

func GetNSLoader() NSLoader

type NSLoaderWithError added in v1.12.0

type NSLoaderWithError interface {
	LoadWithError(string) (*vm.Namespace, error)
}

NSLoaderWithError optionally preserves loader failures for RequireNS while NSLoader retains its original Go API for embedders.

type NativeDirectFn added in v1.10.0

type NativeDirectFn struct {
	GoIdent    string   // exported Go identifier, e.g. "Seq"
	LgName     string   // let-go name without arity suffix (e.g. "nth" for both nth@2 and nth@3); used for registry key
	Arity      int      // fixed arity; -1 for variadic
	Variadic   bool     // true → final ParamSpec is the rest slice element type
	ParamSpecs []string // Go type strings, e.g. []string{"vm.Value"}
	ResultSpec string   // Go type of single result, e.g. "vm.Value"
	NeedsError bool     // result tuple is (ResultSpec, error)
	NeedsEC    bool     // true → the Go fn takes *vm.ExecContext as its first param
}

NativeDirectFn describes one direct-callable Go function. The shape matches the per-arity entry that *lowered-registry* holds for lowered Lisp defns, so the IR pipeline can treat both uniformly.

The current MVP scopes direct calls to vm.Value-only signatures with a (vm.Value, error) return. Variadic and typed-primitive params fall through to the existing rt.InvokeValue trampoline at the call site; they're representable here so future extensions can opt in.

func LookupNativeDirect added in v1.10.0

func LookupNativeDirect(ns, name string) *NativeDirectFn

LookupNativeDirect returns the descriptor for (ns, name) or nil if no module has registered it. The returned pointer is stable for the lifetime of the process.

type NativeModule added in v1.10.0

type NativeModule struct {
	GoPkg     string                    // import path, e.g. "github.com/nooga/let-go/pkg/rt/corefns"
	Namespace string                    // target let-go namespace, e.g. "clojure.core"
	Fns       map[string]NativeDirectFn // let-go name → descriptor (e.g. "seq" → {GoIdent:"Seq", ...})
}

NativeModule is one Go package's contribution to one let-go namespace. A package can register N functions; each is direct-callable from lowered Go.

func LookupNativeModule added in v1.10.0

func LookupNativeModule(ns string) []*NativeModule

LookupNativeModule returns the modules contributing to ns. Useful for inspection / debugging / codegen tools that need to walk by package.

type Pod added in v1.1.0

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

Pod represents a running babashka pod subprocess.

func (*Pod) Invoke added in v1.1.0

func (p *Pod) Invoke(varName string, args []vm.Value) (vm.Value, error)

Invoke calls a pod var and returns the result (synchronous).

func (*Pod) InvokeAsync added in v1.1.0

func (p *Pod) InvokeAsync(varName string, args []vm.Value) (vm.Chan, error)

InvokeAsync calls a pod var and sends results to a channel. The channel stays open for streaming - the pod sends multiple values with the same id.

func (*Pod) Shutdown added in v1.1.0

func (p *Pod) Shutdown()

Shutdown sends shutdown op if supported and waits for process to exit.

type PromiseChan added in v1.9.0

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

PromiseChan implements clojure.core.async's promise-chan: a channel that caches the FIRST value put to it and replays that value to every taker, forever. Subsequent puts are dropped; closing without a value makes takers receive nil; closing after a value is a no-op (the value keeps being served).

Unlike a raw vm.Chan it STORES the value rather than transferring it, which is what makes the semantics correct: with a single raw channel a taker parked before the first put could steal that put before it was cached, so later takers would never see it. Storing the value behind a latch removes that race entirely.

Dispatched to by >! / <! / close! when they receive a boxed *PromiseChan instead of a vm.Chan. Methods are unexported so the reflective method-boxing in vm.NewBoxed skips them.

type Pub

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

Pub routes values from a source channel to subscribers by topic.

type Resource added in v1.10.0

type Resource struct {
	Name string
	// contains filtered or unexported fields
}

Resource is the handle returned by io/resource. It is reader-coercible (the io namespace extends IReadable for it), so it flows through io/slurp, io/reader, and io/line-seq. It re-opens through its bound provider on each read, so a handle can be read more than once.

func NewResource added in v1.10.0

func NewResource(name string, p ResourceProvider) *Resource

NewResource builds a resource handle bound to a provider.

func (*Resource) Open added in v1.10.0

func (r *Resource) Open() (io.ReadCloser, bool)

Open returns a fresh reader over the resource, or ok=false if it has since disappeared (a dev-mode filesystem race).

func (*Resource) String added in v1.10.0

func (r *Resource) String() string

type ResourceProvider added in v1.10.0

type ResourceProvider interface {
	// Open returns a reader over the named resource, or ok=false if absent.
	Open(name string) (io.ReadCloser, bool)
}

ResourceProvider locates resource bytes by a normalized, slash-separated name. io/resource consults the currently-installed provider. There are two implementations: a filesystem provider (dev, backed by -resource-paths roots) and an embedded provider (a -b standalone binary, backed by the archive appended to the executable).

func GetResourceProvider added in v1.10.0

func GetResourceProvider() ResourceProvider

GetResourceProvider returns the currently-installed provider (may be nil).

type ShellResult

type ShellResult struct {
	Exit int    `letgo:"exit"`
	Out  string `letgo:"out"`
	Err  string `letgo:"err"`
}

ShellResult is the struct behind os/sh return values.

type SpawnResult added in v1.4.0

type SpawnResult struct {
	Pid  int    `letgo:"pid"`
	Exit int    `letgo:"exit"`
	Out  string `letgo:"out"`
	Err  string `letgo:"err"`
}

SpawnResult is the struct behind syscall/spawn return values.

type Storage added in v1.11.0

type Storage interface {
	Get(key string) (value string, ok bool, err error)
	Set(key, value string) error
	Remove(key string) error
	Keys(prefix string) ([]string, error)
}

Storage is the host seam for persistent string key/value storage. Guest code names logical keys; the host owns the physical backend and namespace. Values are strings so callers keep serialization policy.

Error contract, uniform across backends and surfaced to guest code:

  • Get of an absent key returns ok=false with a nil error, so storage/get yields nil. Get returns a non-nil error only when the backend itself fails (unreadable file, unavailable localStorage); that throws in the guest. Absence and failure are deliberately distinguishable.
  • Set and Remove return an error on backend failure (full disk, quota, private-mode localStorage), which throws. They never silently drop a write — losing a save with no signal is the failure mode to avoid.

type Surface added in v1.13.0

type Surface interface {
	// Present blits an RGBA frame (width*height*4 bytes, row-major, top-left
	// origin). Fire-and-forget: a frame with no sink attached is dropped.
	Present(rgba []byte, w, h int)
	// Available reports whether a real sink is wired (a canvas in the browser
	// shell, an embedder-supplied Surface). Lets the guest choose canvas vs
	// another render path.
	Available() bool
}

Surface is the host seam for (surface/present ...): a sink for RGBA frames the guest blits to its host. The binary dual of the *emit* Emitter — like it, fire-and-forget; unlike it, carries a buffer, not a JSON string.

type TransitDecoder added in v1.1.0

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

TransitDecoder decodes transit+json into vm.Values.

func NewTransitDecoder added in v1.1.0

func NewTransitDecoder() *TransitDecoder

NewTransitDecoder creates a new decoder with a fresh cache.

func (*TransitDecoder) Decode added in v1.1.0

func (d *TransitDecoder) Decode(s string) (vm.Value, error)

Decode parses a transit+json string into a vm.Value.

type TransitEncoder added in v1.1.0

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

TransitEncoder encodes vm.Values to transit+json.

func NewTransitEncoder added in v1.1.0

func NewTransitEncoder() *TransitEncoder

NewTransitEncoder creates a new encoder with a fresh cache.

func (*TransitEncoder) Encode added in v1.1.0

func (e *TransitEncoder) Encode(v vm.Value) (string, error)

Encode encodes a vm.Value to a transit+json string.

func (*TransitEncoder) EncodeList added in v1.1.0

func (e *TransitEncoder) EncodeList(vals []vm.Value) (string, error)

EncodeList encodes a slice of values as a transit list (used for pod args).

type UnameResult added in v1.4.0

type UnameResult struct {
	Sysname  string `letgo:"sysname"`
	Machine  string `letgo:"machine"`
	Release  string `letgo:"release"`
	Nodename string `letgo:"nodename"`
}

UnameResult is the struct behind syscall/uname return values.

type WaitResult added in v1.4.0

type WaitResult struct {
	Pid    int `letgo:"pid"`
	Status int `letgo:"status"`
	Signal int `letgo:"signal"`
}

WaitResult is the struct behind syscall/waitpid return values. Status is the exit code (0-255) for normal exits, -1 for signal deaths. Signal is the terminating signal number (0 when not signal-killed).

Directories

Path Synopsis
Package builtins is the single-source home for direct-call-eligible clojure.core builtins: context-free functions with uniform vm.Value signatures.
Package builtins is the single-source home for direct-call-eligible clojure.core builtins: context-free functions with uniform vm.Value signatures.
Package corefns is a placeholder while the lginterop-driven direct-call path is being wired up.
Package corefns is a placeholder while the lginterop-driven direct-call path is being wired up.
Package wasm holds build-time JS and HTML assets for the `lg -w` WASM bundler.
Package wasm holds build-time JS and HTML assets for the `lg -w` WASM bundler.

Jump to

Keyboard shortcuts

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