Documentation
¶
Overview ¶
Package machine implements the Scheme virtual machine, compiler, and macro expander.
The machine package is the core execution engine for Wile, providing:
Compilation Pipeline ¶
Scheme source undergoes three phases:
- Expansion: macro-expand via ExpanderTimeContinuation
- Compilation: generate bytecode via CompileTimeContinuation
- Execution: run bytecode via MachineContext
Virtual Machine ¶
The VM is a stack-based interpreter with:
- MachineContext: execution state (value stack, environment, PC)
- MachineContext.Run: main interpreter loop
- NativeTemplate: compiled bytecode container
- MachineClosure: first-class procedure representation
Continuations ¶
- MachineContinuation: captured continuation state for call/cc
- ComposableContinuation: delimited continuations for prompts
- dynamic-wind support via wind/unwind stacks
Macro System ¶
Implements R7RS hygienic macros with Flatt's "sets of scopes" model:
- ExpanderTimeContinuation: macro expansion driver
- syntax-rules pattern matching via internal/match
- syntax-case with fenders and procedural macros
Foreign Functions ¶
Go functions are exposed as ForeignFunction implementations:
type ForeignFunction func(context.Context, *MachineContext) error
The [ForeignClosure] type wraps these for the VM.
Index ¶
- Constants
- Variables
- func AllFeatures() []string
- func CopyLibraryBindingsToEnv(lib *CompiledLibrary, bindings map[string]string, ...) error
- func CopyLibraryBindingsToEnvAtPhase(lib *CompiledLibrary, bindings map[string]string, ...) error
- func FindCommonWindingPrefix(current, target WindingStack) int
- func GraftContinuation(segment, target *MachineContinuation)
- func IsFeatureSupported(feature string) bool
- func LookupPhaseBinding[T any](phaseEnv *environment.EnvironmentFrame, sym *values.Symbol, ...) T
- func RegisterPhaseBindings[F any](env *environment.EnvironmentFrame, ...) error
- func RegisterPrimitiveExpanders(env *environment.EnvironmentFrame) error
- func RegisterSyntaxCompilers(env *environment.EnvironmentFrame) error
- type Breakpoint
- type BreakpointID
- type CaseLambdaClause
- type CaseLambdaClosure
- type CompileTimeCallContext
- type CompileTimeContinuation
- func (p *CompileTimeContinuation) AppendOperations(ops ...Operation)
- func (p *CompileTimeContinuation) CompileBeginForSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileCondExpand(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileDefineForSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileDefineLibrary(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileDefineSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileEvalWhen(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileExport(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileExpression(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileImport(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileInclude(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileIncludeCi(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileMeta(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompilePrimitiveOrProcedureCall(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileProcedureCall(ctctx CompileTimeCallContext, initial syntax.SyntaxValue, ...) error
- func (p *CompileTimeContinuation) CompileQuasisyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileSelfEvaluating(_ CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileSymbol(ctctx CompileTimeCallContext, expr *syntax.SyntaxSymbol) error
- func (p *CompileTimeContinuation) CompileSyntax(_ CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileSyntaxCase(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileSyntaxPrimitive(ctctx CompileTimeCallContext, sym *syntax.SyntaxSymbol, ...) (bool, error)
- func (p *CompileTimeContinuation) CompileUnquote(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileUnquoteSplicing(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileUnsyntax(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileUnsyntaxSplicing(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) CompileValidatedBegin(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedBegin) error
- func (p *CompileTimeContinuation) CompileValidatedCaseLambda(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedCaseLambda) error
- func (p *CompileTimeContinuation) CompileValidatedDefine(ctctx CompileTimeCallContext, formName string, v *validate.ValidatedDefine) error
- func (p *CompileTimeContinuation) CompileValidatedDefineFn(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedDefine) error
- func (p *CompileTimeContinuation) CompileValidatedDynamicWind(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedDynamicWind) error
- func (p *CompileTimeContinuation) CompileValidatedIf(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedIf) error
- func (p *CompileTimeContinuation) CompileValidatedLambda(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedLambda) error
- func (p *CompileTimeContinuation) CompileValidatedQuasiquote(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedQuasiquote) error
- func (p *CompileTimeContinuation) CompileValidatedQuote(_ CompileTimeCallContext, _ string, v *validate.ValidatedQuote) error
- func (p *CompileTimeContinuation) CompileValidatedSetBang(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedSetBang) error
- func (p *CompileTimeContinuation) CompileWithSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
- func (p *CompileTimeContinuation) SetLibraryCallback(cb func(*CompiledLibrary))
- type CompiledLibrary
- type ComposableContinuation
- func (p *ComposableContinuation) Cont() *MachineContinuation
- func (p *ComposableContinuation) EqualTo(o values.Value) bool
- func (p *ComposableContinuation) IsVoid() bool
- func (p *ComposableContinuation) SchemeString() string
- func (p *ComposableContinuation) ThreadID() uint64
- func (p *ComposableContinuation) WindingStack() WindingStack
- type Debugger
- func (p *Debugger) Breakpoints() []*Breakpoint
- func (p *Debugger) CheckBreakpoint(mc *MachineContext) *Breakpoint
- func (p *Debugger) Continue()
- func (p *Debugger) DisableBreakpoint(id BreakpointID) bool
- func (p *Debugger) EnableBreakpoint(id BreakpointID) bool
- func (p *Debugger) IsStepping() bool
- func (p *Debugger) OnBreak(fn func(mc *MachineContext, bp *Breakpoint))
- func (p *Debugger) RemoveBreakpoint(id BreakpointID) bool
- func (p *Debugger) SetBreakpoint(file string, line, column int) BreakpointID
- func (p *Debugger) ShouldStep(mc *MachineContext) bool
- func (p *Debugger) StepInto()
- func (p *Debugger) StepOut(mc *MachineContext)
- func (p *Debugger) StepOver(mc *MachineContext)
- func (p *Debugger) TriggerBreak(mc *MachineContext, bp *Breakpoint)
- type DynamicWindFrame
- type ErrContinuationEscape
- type ErrExceptionEscape
- type ErrPromptAbort
- type ExceptionHandler
- type ExpandTimeCallContext
- type ExpanderContext
- func (p *ExpanderContext) Env() *environment.EnvironmentFrame
- func (p *ExpanderContext) Expand(stx syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderContext) ExpandOnce(stx syntax.SyntaxValue) (syntax.SyntaxValue, bool, error)
- func (p *ExpanderContext) IntroductionScope() *syntax.Scope
- func (p *ExpanderContext) SetIntroductionScope(scope *syntax.Scope)
- func (p *ExpanderContext) SetUseSiteScope(scope *syntax.Scope)
- func (p *ExpanderContext) UseSiteScope() *syntax.Scope
- type ExpanderTimeContinuation
- func (p *ExpanderTimeContinuation) ExpandBodyWithDefineSyntax(ectx ExpandTimeCallContext, forms []syntax.SyntaxValue) ([]syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandExpression(ectx ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandOnce(ectx ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, bool, error)
- func (p *ExpanderTimeContinuation) ExpandPrimitiveForm(ectx ExpandTimeCallContext, primName string, sym *syntax.SyntaxSymbol, ...) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandQuasiquote(_ ExpandTimeCallContext, _ syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandQuote(_ ExpandTimeCallContext, _ syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandSelfEvaluating(_ ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandSymbol(_ ExpandTimeCallContext, expr *syntax.SyntaxSymbol) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandSyntaxArgumentList(ccnt ExpandTimeCallContext, args *syntax.SyntaxPair) (*syntax.SyntaxPair, error)
- func (p *ExpanderTimeContinuation) ExpandSyntaxExpression(ectx ExpandTimeCallContext, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
- func (p *ExpanderTimeContinuation) ExpandSyntaxOrProcedureCall(ectx ExpandTimeCallContext, car syntax.SyntaxValue, cdr *syntax.SyntaxPair) (syntax.SyntaxValue, error)
- type FeatureRequirement
- func NewAndRequirement(reqs ...FeatureRequirement) FeatureRequirement
- func NewElseRequirement() FeatureRequirement
- func NewFeatureIdentifier(name string) FeatureRequirement
- func NewLibraryRequirement(name LibraryName) FeatureRequirement
- func NewNotRequirement(req FeatureRequirement) FeatureRequirement
- func NewOrRequirement(reqs ...FeatureRequirement) FeatureRequirement
- type ForeignFunction
- type FreeIdResolution
- type ImportSet
- type LibraryName
- type LibraryRegistry
- func (p *LibraryRegistry) AddSearchPath(path string)
- func (p *LibraryRegistry) FindLibraryFile(name LibraryName) (string, error)
- func (p *LibraryRegistry) FinishLoading(name LibraryName)
- func (p *LibraryRegistry) GetSearchPaths() []string
- func (p *LibraryRegistry) IsLoading(name LibraryName) bool
- func (p *LibraryRegistry) Lookup(name LibraryName) *CompiledLibrary
- func (p *LibraryRegistry) Register(lib *CompiledLibrary) error
- func (p *LibraryRegistry) SetSearchPaths(paths []string)
- func (p *LibraryRegistry) StartLoading(name LibraryName)
- type LiteralIndex
- type MachineClosure
- func CompileSyntaxRules(ctx context.Context, env *environment.EnvironmentFrame, ...) (*MachineClosure, error)
- func NewClosureWithTemplate(tpl *NativeTemplate, env *environment.EnvironmentFrame) *MachineClosure
- func NewForeignClosure(env *environment.EnvironmentFrame, pcnt int, vardiac bool, fn ForeignFunction) *MachineClosure
- type MachineContext
- func (p *MachineContext) Apply(mcls *MachineClosure, vs ...values.Value) (*MachineContext, error)
- func (p *MachineContext) ApplyCaseLambda(clcls *CaseLambdaClosure, vs ...values.Value) (*MachineContext, error)
- func (p *MachineContext) Arg(index int) values.Value
- func (p *MachineContext) CallDepth() int
- func (p *MachineContext) CaptureStackTrace(maxDepth int) StackTrace
- func (p *MachineContext) Context() context.Context
- func (p *MachineContext) Counters() VMCounters
- func (p *MachineContext) CurrentContinuation() *MachineContinuation
- func (p *MachineContext) CurrentSource() *syntax.SourceContext
- func (p *MachineContext) Debugger() *Debugger
- func (p *MachineContext) EnvironmentFrame() *environment.EnvironmentFrame
- func (p *MachineContext) Error(msg string) *SchemeError
- func (p *MachineContext) EscapeCont() *MachineContinuation
- func (p *MachineContext) ExceptionHandler() *ExceptionHandler
- func (p *MachineContext) ExpanderContext() *ExpanderContext
- func (p *MachineContext) FindPrompt(tag *PromptTag) (*MachineContinuation, bool)
- func (p *MachineContext) GetValue() values.Value
- func (p *MachineContext) GetValues() MultipleValues
- func (p *MachineContext) NewSubContext() *MachineContext
- func (p *MachineContext) PC() int
- func (p *MachineContext) Parent() *MachineContinuation
- func (p *MachineContext) ParentMC() *MachineContext
- func (p *MachineContext) PopContinuation() *MachineContinuation
- func (p *MachineContext) PopExceptionHandler() *ExceptionHandler
- func (p *MachineContext) PopWindingFrame() *DynamicWindFrame
- func (p *MachineContext) PromptTag() *PromptTag
- func (p *MachineContext) PushExceptionHandler(handler values.Value)
- func (p *MachineContext) PushWindingFrame(frame *DynamicWindFrame)
- func (p *MachineContext) Restore(cont *MachineContinuation)
- func (p *MachineContext) RestoreWithWinding(cont *MachineContinuation, targetStack WindingStack) error
- func (p *MachineContext) RestoreWithWindingFrom(cont *MachineContinuation, sourceStack, targetStack WindingStack) error
- func (p *MachineContext) RewindTo(target WindingStack, commonDepth int) error
- func (p *MachineContext) Run() error
- func (p *MachineContext) RunWithEscapeHandling() error
- func (p *MachineContext) SaveContinuation(off int)
- func (p *MachineContext) SetContext(ctx context.Context)
- func (p *MachineContext) SetDebugger(d *Debugger)
- func (p *MachineContext) SetEscapeCont(cont *MachineContinuation)
- func (p *MachineContext) SetExceptionHandler(h *ExceptionHandler)
- func (p *MachineContext) SetExpanderContext(ctx *ExpanderContext)
- func (p *MachineContext) SetPC(v int)
- func (p *MachineContext) SetPromptTag(tag *PromptTag)
- func (p *MachineContext) SetThread(t *values.Thread)
- func (p *MachineContext) SetValue(v values.Value)
- func (p *MachineContext) SetValues(vs ...values.Value)
- func (p *MachineContext) SetWindingStack(stack WindingStack)
- func (p *MachineContext) SliceContinuationAt(prompt *MachineContinuation) *MachineContinuation
- func (p *MachineContext) Template() *NativeTemplate
- func (p *MachineContext) Thread() *values.Thread
- func (p *MachineContext) ThreadID() uint64
- func (p *MachineContext) UnwindTo(commonDepth int) error
- func (p *MachineContext) WindingStack() WindingStack
- func (p *MachineContext) WrapError(err error, msg string) *SchemeError
- type MachineContinuation
- func NewMachineContinuation(parent *MachineContinuation, tpl *NativeTemplate, ...) *MachineContinuation
- func NewMachineContinuationFromMachineContext(mc *MachineContext, off int) *MachineContinuation
- func NewMachineContinuationWithPrompt(parent *MachineContinuation, tpl *NativeTemplate, ...) *MachineContinuation
- func (p *MachineContinuation) CallDepth() int
- func (p *MachineContinuation) Copy() *MachineContinuation
- func (p *MachineContinuation) DeepCopy() *MachineContinuation
- func (p *MachineContinuation) EnvironmentFrame() *environment.EnvironmentFrame
- func (p *MachineContinuation) EqualTo(o values.Value) bool
- func (p *MachineContinuation) IsVoid() bool
- func (p *MachineContinuation) PC() int
- func (p *MachineContinuation) Parent() *MachineContinuation
- func (p *MachineContinuation) PromptHandler() *MachineClosure
- func (p *MachineContinuation) PromptTag() *PromptTag
- func (p *MachineContinuation) PushValues(v ...values.Value)
- func (p *MachineContinuation) SchemeString() string
- func (p *MachineContinuation) SetPC(v int)
- func (p *MachineContinuation) SetPromptHandler(h *MachineClosure)
- func (p *MachineContinuation) SetPromptTag(t *PromptTag)
- func (p *MachineContinuation) Template() *NativeTemplate
- func (p *MachineContinuation) ThreadID() uint64
- type MultipleValues
- type NativeTemplate
- func (p *NativeTemplate) AppendOperations(ops ...Operation)
- func (p *NativeTemplate) Copy() *NativeTemplate
- func (p *NativeTemplate) DeduplicateLiteral(v values.Value) values.Value
- func (p *NativeTemplate) EqualTo(o values.Value) bool
- func (p *NativeTemplate) IsVariadic() bool
- func (p *NativeTemplate) IsVoid() bool
- func (p *NativeTemplate) MaybeAppendLiteral(v values.Value) LiteralIndex
- func (p *NativeTemplate) Name() string
- func (p *NativeTemplate) Operations() Operations
- func (p *NativeTemplate) ParameterCount() int
- func (p *NativeTemplate) SchemeString() string
- func (p *NativeTemplate) SetName(name string)
- func (p *NativeTemplate) SourceAt(pc int) *syntax.SourceContext
- func (p *NativeTemplate) ValueCount() int
- type Operation
- type OperationApply
- type OperationBindPatternVars
- func (p *OperationBindPatternVars) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationBindPatternVars) EqualTo(other values.Value) bool
- func (p *OperationBindPatternVars) IsVoid() bool
- func (p *OperationBindPatternVars) SchemeString() string
- func (p *OperationBindPatternVars) String() string
- type OperationBranchOffsetImmediate
- func (p *OperationBranchOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationBranchOffsetImmediate) EqualTo(o values.Value) bool
- func (p *OperationBranchOffsetImmediate) IsVoid() bool
- func (p *OperationBranchOffsetImmediate) SchemeString() string
- type OperationBranchOnFalseOffsetImmediate
- func (p *OperationBranchOnFalseOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationBranchOnFalseOffsetImmediate) EqualTo(o values.Value) bool
- func (p *OperationBranchOnFalseOffsetImmediate) IsVoid() bool
- func (p *OperationBranchOnFalseOffsetImmediate) SchemeString() string
- type OperationBranchOnNotFalseOffsetImmediate
- func (p *OperationBranchOnNotFalseOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationBranchOnNotFalseOffsetImmediate) EqualTo(o values.Value) bool
- func (p *OperationBranchOnNotFalseOffsetImmediate) IsVoid() bool
- func (p *OperationBranchOnNotFalseOffsetImmediate) SchemeString() string
- type OperationBrk
- type OperationBuildSyntaxList
- func (p *OperationBuildSyntaxList) Apply(_ context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationBuildSyntaxList) EqualTo(other values.Value) bool
- func (p *OperationBuildSyntaxList) IsVoid() bool
- func (p *OperationBuildSyntaxList) SchemeString() string
- func (p *OperationBuildSyntaxList) String() string
- type OperationClearSyntaxCaseInput
- func (p *OperationClearSyntaxCaseInput) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationClearSyntaxCaseInput) EqualTo(other values.Value) bool
- func (p *OperationClearSyntaxCaseInput) IsVoid() bool
- func (p *OperationClearSyntaxCaseInput) SchemeString() string
- func (p *OperationClearSyntaxCaseInput) String() string
- type OperationDrop
- type OperationForeignFunctionCall
- func (p *OperationForeignFunctionCall) Apply(ctx context.Context, mc *MachineContext) (rmc *MachineContext, rerr error)
- func (p *OperationForeignFunctionCall) EqualTo(o values.Value) bool
- func (p *OperationForeignFunctionCall) IsVoid() bool
- func (p *OperationForeignFunctionCall) SchemeString() string
- type OperationLoadGlobalByGlobalIndexLiteralIndexImmediate
- func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) EqualTo(o values.Value) bool
- func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) IsVoid() bool
- func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) SchemeString() string
- type OperationLoadLiteralByLiteralIndexImmediate
- func (p *OperationLoadLiteralByLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationLoadLiteralByLiteralIndexImmediate) EqualTo(o values.Value) bool
- func (p *OperationLoadLiteralByLiteralIndexImmediate) IsVoid() bool
- func (p *OperationLoadLiteralByLiteralIndexImmediate) SchemeString() string
- type OperationLoadLiteralInteger
- type OperationLoadLocalByLocalIndexImmediate
- func (p *OperationLoadLocalByLocalIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationLoadLocalByLocalIndexImmediate) EqualTo(o values.Value) bool
- func (p *OperationLoadLocalByLocalIndexImmediate) IsVoid() bool
- func (p *OperationLoadLocalByLocalIndexImmediate) SchemeString() string
- type OperationLoadVoid
- type OperationMakeCaseLambdaClosure
- func (p *OperationMakeCaseLambdaClosure) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationMakeCaseLambdaClosure) EqualTo(o values.Value) bool
- func (p *OperationMakeCaseLambdaClosure) IsVoid() bool
- func (p *OperationMakeCaseLambdaClosure) SchemeString() string
- type OperationMakeClosure
- type OperationPeekK
- type OperationPop
- type OperationPopAll
- type OperationPopEnv
- type OperationPopWind
- type OperationPull
- type OperationPush
- type OperationPushWind
- type OperationRestoreContinuation
- type OperationSaveContinuationOffsetImmediate
- func (p *OperationSaveContinuationOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationSaveContinuationOffsetImmediate) EqualTo(o values.Value) bool
- func (p *OperationSaveContinuationOffsetImmediate) IsVoid() bool
- func (p *OperationSaveContinuationOffsetImmediate) SchemeString() string
- type OperationStoreGlobalByGlobalIndexLiteralIndexImmediate
- func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) EqualTo(o values.Value) bool
- func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) IsVoid() bool
- func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) SchemeString() string
- type OperationStoreLocalByLocalIndexImmediate
- func (p *OperationStoreLocalByLocalIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
- func (p *OperationStoreLocalByLocalIndexImmediate) EqualTo(o values.Value) bool
- func (p *OperationStoreLocalByLocalIndexImmediate) IsVoid() bool
- func (p *OperationStoreLocalByLocalIndexImmediate) SchemeString() string
- type OperationStoreSyntaxCaseInput
- func (p *OperationStoreSyntaxCaseInput) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationStoreSyntaxCaseInput) EqualTo(other values.Value) bool
- func (p *OperationStoreSyntaxCaseInput) IsVoid() bool
- func (p *OperationStoreSyntaxCaseInput) SchemeString() string
- func (p *OperationStoreSyntaxCaseInput) String() string
- type OperationSyntaxCaseMatch
- func (p *OperationSyntaxCaseMatch) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationSyntaxCaseMatch) EqualTo(other values.Value) bool
- func (p *OperationSyntaxCaseMatch) IsVoid() bool
- func (p *OperationSyntaxCaseMatch) SchemeString() string
- func (p *OperationSyntaxCaseMatch) String() string
- type OperationSyntaxCaseNoMatch
- func (p *OperationSyntaxCaseNoMatch) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationSyntaxCaseNoMatch) EqualTo(other values.Value) bool
- func (p *OperationSyntaxCaseNoMatch) IsVoid() bool
- func (p *OperationSyntaxCaseNoMatch) SchemeString() string
- func (p *OperationSyntaxCaseNoMatch) String() string
- type OperationSyntaxRulesTransform
- func (p *OperationSyntaxRulesTransform) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationSyntaxRulesTransform) EqualTo(other values.Value) bool
- func (p *OperationSyntaxRulesTransform) IsVoid() bool
- func (p *OperationSyntaxRulesTransform) SchemeString() string
- func (p *OperationSyntaxRulesTransform) String() string
- type OperationSyntaxTemplateExpand
- func (p *OperationSyntaxTemplateExpand) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
- func (p *OperationSyntaxTemplateExpand) EqualTo(other values.Value) bool
- func (p *OperationSyntaxTemplateExpand) IsVoid() bool
- func (p *OperationSyntaxTemplateExpand) SchemeString() string
- func (p *OperationSyntaxTemplateExpand) String() string
- type Operations
- type Parameter
- type PhaseEntry
- type PrimitiveExpander
- func (p *PrimitiveExpander) EqualTo(other values.Value) bool
- func (p *PrimitiveExpander) Expand(etc *ExpanderTimeContinuation, ectx ExpandTimeCallContext, ...) (syntax.SyntaxValue, error)
- func (p *PrimitiveExpander) IsVoid() bool
- func (p *PrimitiveExpander) Name() string
- func (p *PrimitiveExpander) SchemeString() string
- type PrimitiveExpanderFunc
- type PromptTag
- type SchemeError
- type Stack
- func (p Stack) AsList() values.Tuple
- func (p *Stack) Clear()
- func (p Stack) Copy() *Stack
- func (p Stack) IsVoid() bool
- func (p Stack) Len() int
- func (p Stack) PeekK(i int) values.Value
- func (p *Stack) Pop() values.Value
- func (p *Stack) PopAll() []values.Value
- func (p *Stack) Pull() values.Value
- func (p *Stack) Push(v values.Value)
- func (p *Stack) PushAll(vs []values.Value)
- func (p Stack) SchemeString() string
- func (p Stack) String() string
- type StackFrame
- type StackTrace
- type StepMode
- type SyntaxCompiler
- type SyntaxCompilerFunc
- type SyntaxRulesClause
- type VMCounters
- type WindingStack
Constants ¶
const ImplementationName = "wile"
ImplementationName is the name of this Scheme implementation.
const (
// SchemeIncludePathEnv is the environment variable name for the Scheme include path
SchemeIncludePathEnv = "SCHEME_INCLUDE_PATH"
)
Variables ¶
var ( ErrMachineHalt = values.NewStaticError("machine halt: no more operations to run") ErrMachineDoNotAdvancePC = values.NewStaticError("machine do not advance PC: operation did not advance program counter") )
var DefaultLibraryPaths = []string{
".",
"./lib",
}
DefaultLibraryPaths are the default directories to search for libraries.
var DefaultPromptTag = NewPromptTag("default")
DefaultPromptTag is the default prompt tag installed at the top of execution.
var LibraryEnvFactory func(ctx context.Context, callerEnv *environment.EnvironmentFrame) (*environment.EnvironmentFrame, error)
LibraryEnvFactory is a function that creates a new environment for a library. This avoids import cycles between machine and runtime packages. The function should return a fresh environment with primitives registered, but MUST share the TopLevelEnvironment with callerEnv to ensure symbol identity. R7RS §6.5: (eq? 'bindSymbolWithScopes (string->symbol "bindSymbolWithScopes")) must be #t.
Functions ¶
func AllFeatures ¶
func AllFeatures() []string
AllFeatures returns all supported feature identifiers.
func CopyLibraryBindingsToEnv ¶
func CopyLibraryBindingsToEnv(lib *CompiledLibrary, bindings map[string]string, targetEnv *environment.EnvironmentFrame) error
CopyLibraryBindingsToEnv copies exported bindings from a library to an environment. bindings is the map from localName -> externalName produced by ApplyToExports. Both runtime and syntax bindings are copied. This is a convenience wrapper that imports to phase 0 (runtime).
func CopyLibraryBindingsToEnvAtPhase ¶
func CopyLibraryBindingsToEnvAtPhase(lib *CompiledLibrary, bindings map[string]string, targetEnv *environment.EnvironmentFrame, targetPhase int) error
CopyLibraryBindingsToEnvAtPhase copies exported bindings from a library to a specific phase. bindings is the map from localName -> externalName produced by ApplyToExports.
Phase semantics:
- targetPhase == 0: Runtime import (default). Runtime bindings go to phase 0, syntax bindings go to both phase 0 (for export) and phase 1 (for use in macros).
- targetPhase > 0: For-syntax import. Bindings are shifted to the target phase. Runtime bindings become available during macro expansion at targetPhase. Syntax bindings go to targetPhase and targetPhase+1.
- targetPhase < 0: For-template import. Bindings shifted to negative phase (used for generating code that will run at a lower phase).
func FindCommonWindingPrefix ¶
func FindCommonWindingPrefix(current, target WindingStack) int
FindCommonPrefix finds the longest common prefix of two winding stacks. Returns the index where they diverge (0 means no common frames).
func GraftContinuation ¶
func GraftContinuation(segment, target *MachineContinuation)
GraftContinuation walks the segment chain to its bottom frame and sets its parent to target, effectively splicing the segment onto the target chain.
func IsFeatureSupported ¶
IsFeatureSupported checks if a feature identifier is supported.
func LookupPhaseBinding ¶
func LookupPhaseBinding[T any]( phaseEnv *environment.EnvironmentFrame, sym *values.Symbol, scopes []*syntax.Scope, ) T
LookupPhaseBinding looks up a binding by symbol in the target phase environment. Returns the value cast to type T if found, or the zero value if not found or if the value is not of type T.
This function handles hygiene by using scoped lookup - it will only match bindings whose scopes are a subset of the symbol's scopes.
func RegisterPhaseBindings ¶
func RegisterPhaseBindings[F any]( env *environment.EnvironmentFrame, phaseEnv func() *environment.EnvironmentFrame, entries []PhaseEntry[F], wrapper func(name string, fn F) values.Value, ) error
RegisterPhaseBindings binds all entries in the target phase environment. This is a generic helper for registering primitives in expand or compile phases.
Parameters:
- env: The top-level environment
- phaseEnv: Accessor for the target phase (e.g., env.Expand or env.Compile)
- entries: Slice of (name, function) pairs to register
- wrapper: Creates the values.Value wrapper from name and function
func RegisterPrimitiveExpanders ¶
func RegisterPrimitiveExpanders(env *environment.EnvironmentFrame) error
RegisterPrimitiveExpanders binds all primitive expanders in the expand-time environment (env.Expand()). These are looked up by ExpandPrimitiveForm() when the expander encounters a special form.
Each primitive has different expansion behavior:
- quote, define-syntax, quasiquote: return unchanged (no expansion)
- if: expand test, consequent, alternative separately
- begin: expand all subexpressions
- set!: expand only the value expression
- define: expand value if simple define
- lambda, case-lambda: expand body expressions
- syntax-case, cond-expand: return unchanged (compile-time forms)
func RegisterSyntaxCompilers ¶
func RegisterSyntaxCompilers(env *environment.EnvironmentFrame) error
RegisterSyntaxCompilers binds all syntax compilers in the compile-time environment (env.Compile()). These are looked up by CompileSyntaxPrimitive() when the compiler encounters a special form.
The compiler uses a two-tier dispatch system:
Tier 1 (Validated Forms): Core forms like if, define, lambda, set!, quote, quasiquote, begin go through the validation layer which produces type-safe ValidatedExpr types, then compile via compileValidated* methods. These are NOT registered here.
Tier 2 (Registry Forms): Extension forms like syntax-case, import, define-syntax pass through validation as ValidatedLiteral, then are dispatched via this registry. This is the single source of truth for these forms.
The syntax compilers are bound with BindingTypePrimitive to distinguish them from syntax transformers (BindingTypeSyntax) and regular variables.
Types ¶
type Breakpoint ¶
type Breakpoint struct {
ID BreakpointID
File string
Line int
Column int // 0 = any column on line
Enabled bool
HitCount int
}
Breakpoint represents a source-level breakpoint.
type CaseLambdaClause ¶
type CaseLambdaClause struct {
// contains filtered or unexported fields
}
CaseLambdaClause represents a single clause in a case-lambda. Each clause has its own template and environment for parameter bindings.
type CaseLambdaClosure ¶
type CaseLambdaClosure struct {
// contains filtered or unexported fields
}
func NewCaseLambdaClosure ¶
func NewCaseLambdaClosure(closures []*MachineClosure) *CaseLambdaClosure
func (*CaseLambdaClosure) Clauses ¶
func (p *CaseLambdaClosure) Clauses() []*CaseLambdaClause
func (*CaseLambdaClosure) FindMatchingClause ¶
func (p *CaseLambdaClosure) FindMatchingClause(argCount int) (*MachineClosure, bool)
FindMatchingClause finds the first clause that matches the given argument count. Returns the matching closure and a boolean indicating success.
func (*CaseLambdaClosure) IsVoid ¶
func (p *CaseLambdaClosure) IsVoid() bool
func (*CaseLambdaClosure) SchemeString ¶
func (p *CaseLambdaClosure) SchemeString() string
type CompileTimeCallContext ¶
type CompileTimeCallContext struct {
// contains filtered or unexported fields
}
CompileTimeCallContext carries contextual information through the compilation process. It tracks properties that affect code generation, particularly for tail call optimization and distinguishing definition contexts from expression contexts.
This structure is passed by value (not pointer) through the compiler, allowing each compilation step to create modified copies without affecting the caller's context.
Tail Call Optimization ¶
The inTail flag tracks whether an expression is in tail position. An expression is in tail position if its value will be the final result of the enclosing procedure. When inTail is true, the compiler can generate a tail call that reuses the current stack frame instead of creating a new one, preventing stack overflow in recursive procedures.
Per R7RS Section 3.5, these positions are tail positions:
- The body of a lambda expression
- The last expression in a begin sequence (if the begin is in tail position)
- The consequent and alternative of an if expression (if the if is in tail position)
- The body of a let/let*/letrec (if the let is in tail position)
These are NOT tail positions (use NotInTail()):
- Function arguments: (f (g x)) - the call to g is not in tail position
- Condition of if: (if (pred x) ...) - pred is not in tail position
- Definitions: (define x (expr)) - expr is not in tail position
- Non-final expressions in begin: (begin (a) (b) (c)) - only c is in tail position
Definition vs Expression Context ¶
The inExpression flag distinguishes between definition contexts (top-level or internal definitions) and expression contexts. This affects how certain forms are compiled:
- In definition context: define creates bindings
- In expression context: define may be an error or treated differently
Use NotInExpression() when entering a definition-only context (e.g., library body).
func NewCompileTimeCallContext ¶
func NewCompileTimeCallContext(ctx context.Context, inTail, inExpression bool, env *environment.EnvironmentFrame) CompileTimeCallContext
NewCompileTimeCallContext creates a new compile-time context with the given flags. Parameters:
- inTail: true if compiling an expression in tail position
- inExpression: true if compiling an expression (vs. a definition)
- env: the environment frame for variable resolution during compilation
func (CompileTimeCallContext) NotInExpression ¶
func (p CompileTimeCallContext) NotInExpression() CompileTimeCallContext
NotInExpression returns a copy of the context with inExpression set to false. Use this when entering a definition-only context where expressions are not allowed at the current level (e.g., library declaration bodies before begin).
func (CompileTimeCallContext) NotInTail ¶
func (p CompileTimeCallContext) NotInTail() CompileTimeCallContext
NotInTail returns a copy of the context with inTail set to false. Use this when compiling sub-expressions that are not in tail position:
- Function arguments
- Condition expressions in if
- Initial values in define/let bindings
- Non-final expressions in begin
Example:
// Compiling (f (g x)) - the call to g is not in tail position err := p.CompileExpression(ctctx.NotInTail(), argExpr)
type CompileTimeContinuation ¶
type CompileTimeContinuation struct {
// contains filtered or unexported fields
}
CompileTimeContinuation is a continuation used during the compilation phase
func NewCompiletimeContinuation ¶
func NewCompiletimeContinuation(tpl *NativeTemplate, env *environment.EnvironmentFrame) *CompileTimeContinuation
NewCompiletimeContinuation creates a new CompileTimeContinuation
func (*CompileTimeContinuation) AppendOperations ¶
func (p *CompileTimeContinuation) AppendOperations(ops ...Operation)
AppendOperations appends operations tagged with the current source from the source stack. This routes through the template's source-aware append so every emitted op automatically gets the innermost source context.
func (*CompileTimeContinuation) CompileBeginForSyntax ¶
func (p *CompileTimeContinuation) CompileBeginForSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileBeginForSyntax handles (begin-for-syntax expr ...).
This form evaluates a sequence of expressions at compile time in the expand phase environment. It is useful for setting up compile-time state like hash tables or registries that macros can access.
Each expression is compiled and executed at compile time. The expressions can use define-for-syntax bindings and runtime primitives. The result of the last expression is discarded (begin-for-syntax is used for side effects).
func (*CompileTimeContinuation) CompileCondExpand ¶
func (p *CompileTimeContinuation) CompileCondExpand(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileCondExpand compiles a cond-expand expression. cond-expand is evaluated at compile-time and expands to the body of the first clause whose feature requirement is satisfied.
Syntax: (cond-expand <clause> ...) where <clause> is (<feature-requirement> <expression> ...)
Example:
(cond-expand (r7rs (display "R7RS")) (else (display "other")))
func (*CompileTimeContinuation) CompileDefineForSyntax ¶
func (p *CompileTimeContinuation) CompileDefineForSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileDefineForSyntax handles (define-for-syntax name expr) or (define-for-syntax (name args...) body...).
This form defines a binding in the expand phase environment that is available during macro expansion. The expression is compiled and evaluated at compile time, and the result is stored in env.Expand().
Unlike define-syntax (which stores macro transformers), define-for-syntax stores regular values with BindingTypeVariable.
func (*CompileTimeContinuation) CompileDefineLibrary ¶
func (p *CompileTimeContinuation) CompileDefineLibrary(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileDefineLibrary handles (define-library (lib-name) <library-declaration> ...).
R7RS library syntax:
(define-library <library-name> <library-declaration> ...) <library-declaration> = | (export <export-spec> ...) | (import <import-set> ...) | (begin <command-or-definition> ...) | (include <filename> ...) | (include-ci <filename> ...)
This creates an isolated environment for the library, processes declarations in order, and registers the compiled library in the registry.
func (*CompileTimeContinuation) CompileDefineSyntax ¶
func (p *CompileTimeContinuation) CompileDefineSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileDefineSyntax handles (define-syntax keyword transformer-expr).
This is the compile-time handler for R7RS define-syntax. Unlike most definitions, define-syntax is processed entirely at compile time:
- Parse the form: (define-syntax keyword (syntax-rules ...))
- Compile the syntax-rules transformer to a MachineClosure
- Store the closure in the environment with BindingTypeSyntax
- Emit NO runtime operations (the binding is already established)
The BindingTypeSyntax marker is crucial: when the expander encounters a symbol, it checks if that symbol is bound to a syntax transformer. If so, it invokes the transformer closure to expand the macro.
This is how derived expressions like 'let' work: they're defined as macros using define-syntax, and expand to lambda expressions:
(define-syntax let
(syntax-rules ()
((let ((name val) ...) body)
((lambda (name ...) body) val ...))))
Reference: R7RS Section 5.4 (Syntax definitions)
func (*CompileTimeContinuation) CompileEvalWhen ¶
func (p *CompileTimeContinuation) CompileEvalWhen(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileEvalWhen handles (eval-when (phase ...) body ...).
This form controls when code is evaluated based on phase specifiers. Phase names follow Chez Scheme's eval-when (Dybvig, TSPL §12.10):
- expand: evaluate during macro expansion (at compile time)
- compile: evaluate during compilation (currently same as expand)
- run: evaluate at runtime (generate code for normal execution)
Multiple phases can be specified. If both expand and run are specified, the body is evaluated at compile time AND code is generated for runtime.
eval-when is not part of R7RS-small; it is a Wile extension.
Examples:
(eval-when (expand) (display "at expansion time")) (eval-when (run) (display "at runtime")) (eval-when (expand run) (display "both times"))
func (*CompileTimeContinuation) CompileExport ¶
func (p *CompileTimeContinuation) CompileExport(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
CompileExport handles top-level (export <export-spec> ...).
This is only valid within a library definition. At top-level, it's an error.
func (*CompileTimeContinuation) CompileExpression ¶
func (p *CompileTimeContinuation) CompileExpression(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileExpression compiles a general expression. Pushes the expression's source context onto the source stack so that all operations emitted during compilation (including infrastructure ops like Branch and Push) are tagged with the source location.
func (*CompileTimeContinuation) CompileImport ¶
func (p *CompileTimeContinuation) CompileImport(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileImport handles top-level (import <import-set> ...).
This is for top-level imports outside of a library definition. It loads the specified libraries and binds their exports in the current environment.
Supports Racket-style phased imports:
- (import (scheme base)) ; Phase 0 (runtime)
- (import (for-syntax (scheme base))) ; Phase 1 (expand)
- (import (for-template (scheme base))) ; Phase -1
- (import (for-meta 2 (scheme base))) ; Phase 2
func (*CompileTimeContinuation) CompileInclude ¶
func (p *CompileTimeContinuation) CompileInclude(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileInclude compiles an include expression. It reads and compiles all forms from the specified files in order. Each form is expanded and compiled in the current environment.
func (*CompileTimeContinuation) CompileIncludeCi ¶
func (p *CompileTimeContinuation) CompileIncludeCi(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileIncludeCi compiles an include-ci expression. It reads and compiles all forms from the specified files in order, treating symbols as case-insensitive (folded to lowercase).
func (*CompileTimeContinuation) CompileMeta ¶
func (p *CompileTimeContinuation) CompileMeta(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileMeta compiles a meta expression.
func (*CompileTimeContinuation) CompilePrimitiveOrProcedureCall ¶
func (p *CompileTimeContinuation) CompilePrimitiveOrProcedureCall(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompilePrimitiveOrProcedureCall compiles either a primitive or a procedure call. It first checks if the initial element is a syntax symbol that corresponds to a primitive. If so, it compiles the primitive. If not, it treats it as a procedure call.
func (*CompileTimeContinuation) CompileProcedureCall ¶
func (p *CompileTimeContinuation) CompileProcedureCall(ctctx CompileTimeCallContext, initial syntax.SyntaxValue, expr syntax.SyntaxValue) error
CompileProcedureCall compiles a procedure call expression. It assumes that the initial element is not a primitive and compiles it as a procedure call. The compiled code will leave the result of the procedure call on the stack.
Tail Call Optimization: When ctctx.inTail is true, we skip SaveContinuation. This allows the called function's RestoreContinuation to return directly to our caller's continuation, implementing proper tail call optimization per R7RS Section 3.5.
func (*CompileTimeContinuation) CompileQuasisyntax ¶
func (p *CompileTimeContinuation) CompileQuasisyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileQuasisyntax compiles the (quasisyntax template) form.
quasisyntax is like quasiquote but for syntax objects. It supports:
- (unsyntax expr) - evaluate expr and splice result at depth 1
- (unsyntax-splicing expr) - evaluate and splice list at depth 1
- nested quasisyntax increases depth
Like quasiquote, unsyntax only evaluates when depth reaches 0. The result is a syntax object, not a raw datum.
func (*CompileTimeContinuation) CompileSelfEvaluating ¶
func (p *CompileTimeContinuation) CompileSelfEvaluating(_ CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileSelfEvaluating compiles a self-evaluating expression (literal).
func (*CompileTimeContinuation) CompileSymbol ¶
func (p *CompileTimeContinuation) CompileSymbol(ctctx CompileTimeCallContext, expr *syntax.SyntaxSymbol) error
CompileSymbol compiles a syntax symbol expression.
func (*CompileTimeContinuation) CompileSyntax ¶
func (p *CompileTimeContinuation) CompileSyntax(_ CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileSyntax compiles the (syntax template) form.
Unlike quote which unwraps syntax to raw values, syntax preserves the syntax structure. When used inside syntax-case, pattern variables in the template are substituted with their matched values.
For templates containing ellipsis (...), runtime expansion is used because ellipsis patterns capture variable-length lists that must be expanded dynamically.
(syntax template) -> syntax-object
func (*CompileTimeContinuation) CompileSyntaxCase ¶
func (p *CompileTimeContinuation) CompileSyntaxCase(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileSyntaxCase compiles the (syntax-case expr (literal ...) clause ...) form.
R6RS syntax-case is a pattern matching form that provides procedural macro facilities. Unlike syntax-rules which expands to templates, syntax-case evaluates arbitrary Scheme code in the body, with pattern variables bound as local variables.
Syntax:
(syntax-case expr (literal ...) (pattern body) (pattern fender body) ...)
Compilation strategy:
- Compile expr to get the input syntax object
- For each clause, generate pattern matching and body code
- Pattern variables are bound as local variables in the body's scope
- If fender exists, it's evaluated as a guard condition
func (*CompileTimeContinuation) CompileSyntaxPrimitive ¶
func (p *CompileTimeContinuation) CompileSyntaxPrimitive(ctctx CompileTimeCallContext, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue) (bool, error)
CompileSyntaxPrimitive compiles a syntax primitive if sym corresponds to one.
func (*CompileTimeContinuation) CompileUnquote ¶
func (p *CompileTimeContinuation) CompileUnquote(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
CompileUnquote errors - unquote outside of quasiquote
func (*CompileTimeContinuation) CompileUnquoteSplicing ¶
func (p *CompileTimeContinuation) CompileUnquoteSplicing(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
CompileUnquoteSplicing errors - unquote-splicing outside of quasiquote
func (*CompileTimeContinuation) CompileUnsyntax ¶
func (p *CompileTimeContinuation) CompileUnsyntax(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
CompileUnsyntax errors - unsyntax outside of quasisyntax
func (*CompileTimeContinuation) CompileUnsyntaxSplicing ¶
func (p *CompileTimeContinuation) CompileUnsyntaxSplicing(_ CompileTimeCallContext, _ syntax.SyntaxValue) error
CompileUnsyntaxSplicing errors - unsyntax-splicing outside of quasisyntax
func (*CompileTimeContinuation) CompileValidatedBegin ¶
func (p *CompileTimeContinuation) CompileValidatedBegin(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedBegin) error
CompileValidatedBegin compiles a validated (begin expr...) form.
begin (R7RS 4.2.3) sequences expressions for side effects. All expressions are evaluated left-to-right; the value of the last expression becomes the value of the entire begin form.
R7RS §5.3.2: Internal definitions use letrec* semantics - all defined names are visible throughout the body, enabling forward references between defines.
Example: (begin (display "hello") (newline) 42) => 42 (after printing)
func (*CompileTimeContinuation) CompileValidatedCaseLambda ¶
func (p *CompileTimeContinuation) CompileValidatedCaseLambda(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedCaseLambda) error
CompileValidatedCaseLambda compiles a validated (case-lambda [clause] ...) form.
case-lambda (R7RS 4.2.9) creates a procedure that dispatches to different implementations based on the number of arguments. For example:
(case-lambda ((x) (* x x)) ; 1 arg: square ((x y) (* x y)) ; 2 args: multiply ((x y . rest) (apply + x y rest))) ; 2+ args: sum all
At runtime, the VM selects the first clause whose arity matches the call.
func (*CompileTimeContinuation) CompileValidatedDefine ¶
func (p *CompileTimeContinuation) CompileValidatedDefine(ctctx CompileTimeCallContext, formName string, v *validate.ValidatedDefine) error
CompileValidatedDefine compiles a validated define form.
func (*CompileTimeContinuation) CompileValidatedDefineFn ¶
func (p *CompileTimeContinuation) CompileValidatedDefineFn(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedDefine) error
CompileValidatedDefineFn compiles the function shorthand form of define.
Usage: (define (name param ...) body ...)
(define (name param ... . rest) body ...)
This is syntactic sugar equivalent to:
(define name (lambda (param ...) body ...))
Examples:
(define (square x) (* x x)) ; fixed arity (define (sum . args) (apply + args)) ; variadic (all args) (define (sum x . rest) (apply + x rest)) ; variadic (1+ args)
The function name is bound before compiling the body to enable self-recursion:
(define (fact n) (if (<= n 1) 1 (* n (fact (- n 1)))))
func (*CompileTimeContinuation) CompileValidatedDynamicWind ¶
func (p *CompileTimeContinuation) CompileValidatedDynamicWind(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedDynamicWind) error
CompileValidatedDynamicWind compiles a validated (dynamic-wind before thunk after) form.
R7RS §6.10: dynamic-wind calls thunk without arguments, returning the result(s). Before is called whenever execution enters the dynamic extent of the call to thunk, and after is called whenever it exits.
The key insight is that by compiling to bytecode, the cleanup code (calling after) is in the bytecode stream. When a continuation is captured inside the thunk and later restored, the cleanup code will run on normal completion.
Bytecode structure:
<compile before> PUSH <compile thunk> PUSH <compile after> PUSH ; Stack: [before, thunk, after] PEEK_K 2 ; value = before SAVE_CONTINUATION →after_before APPLY ; call before() after_before: ; Stack: [before, thunk, after] OP_PUSH_WIND ; create winding frame PEEK_K 1 ; value = thunk SAVE_CONTINUATION →after_thunk APPLY ; call thunk() after_thunk: ; Stack: [before, thunk, after] PUSH ; save thunk result, Stack: [before, thunk, after, result] OP_POP_WIND ; pop winding frame PEEK_K 1 ; value = after SAVE_CONTINUATION →after_after APPLY ; call after() after_after: ; Stack: [before, thunk, after, result] PEEK_K 0 ; value = result (thunk's return value) DROP DROP DROP DROP ; clean up stack
func (*CompileTimeContinuation) CompileValidatedIf ¶
func (p *CompileTimeContinuation) CompileValidatedIf(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedIf) error
CompileValidatedIf compiles a validated (if test conseq [alt]) form. The structure is guaranteed to be valid by the validator.
func (*CompileTimeContinuation) CompileValidatedLambda ¶
func (p *CompileTimeContinuation) CompileValidatedLambda(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedLambda) error
CompileValidatedLambda compiles a validated (lambda params body...) form.
func (*CompileTimeContinuation) CompileValidatedQuasiquote ¶
func (p *CompileTimeContinuation) CompileValidatedQuasiquote(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedQuasiquote) error
CompileValidatedQuasiquote compiles a validated (quasiquote template) form. Quasiquote has complex runtime semantics, so we delegate to the existing compiler.
func (*CompileTimeContinuation) CompileValidatedQuote ¶
func (p *CompileTimeContinuation) CompileValidatedQuote(_ CompileTimeCallContext, _ string, v *validate.ValidatedQuote) error
CompileValidatedQuote compiles a validated (quote datum) form.
func (*CompileTimeContinuation) CompileValidatedSetBang ¶
func (p *CompileTimeContinuation) CompileValidatedSetBang(ctctx CompileTimeCallContext, _ string, v *validate.ValidatedSetBang) error
CompileValidatedSetBang compiles a validated (set! name expr) form.
func (*CompileTimeContinuation) CompileWithSyntax ¶
func (p *CompileTimeContinuation) CompileWithSyntax(ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
CompileWithSyntax compiles the (with-syntax ((pattern expr) ...) body ...) form.
with-syntax is a convenience form for binding pattern variables from expressions. It's equivalent to:
(syntax-case (list expr ...) () ((pattern ...) (let () body ...)))
For now, this implements a simple transformation approach.
func (*CompileTimeContinuation) SetLibraryCallback ¶
func (p *CompileTimeContinuation) SetLibraryCallback(cb func(*CompiledLibrary))
SetLibraryCallback sets a callback function that will be called when a library is compiled via CompileDefineLibrary. This is used by LoadLibrary to capture the compiled library.
type CompiledLibrary ¶
type CompiledLibrary struct {
Name LibraryName // Library name
Env *environment.EnvironmentFrame // Library's private environment
Exports map[string]string // external-name -> internal-name
SourceFile string // Path to .sld file (for error messages)
Template *NativeTemplate // Compiled bytecode (for execution)
}
CompiledLibrary holds a loaded and compiled library.
func LoadLibrary ¶
func LoadLibrary(ctx context.Context, name LibraryName, env *environment.EnvironmentFrame) (*CompiledLibrary, error)
LoadLibrary loads a library by name, compiling and executing it if not already loaded. Returns the CompiledLibrary which can be used to import bindings.
The function: 1. Checks if already loaded (returns cached library) 2. Checks for circular dependencies 3. Finds the library file on the search path 4. Parses and compiles the define-library form 5. Executes the library to create runtime bindings 6. Registers the library in the registry
func NewCompiledLibrary ¶
func NewCompiledLibrary(name LibraryName, env *environment.EnvironmentFrame) *CompiledLibrary
NewCompiledLibrary creates a new compiled library.
func (*CompiledLibrary) AddExport ¶
func (p *CompiledLibrary) AddExport(externalName, internalName string)
AddExport adds an export to the library. If internalName is empty, it defaults to externalName (no rename).
func (*CompiledLibrary) GetInternalName ¶
func (p *CompiledLibrary) GetInternalName(externalName string) string
GetInternalName returns the internal name for an exported external name. Returns empty string if not exported.
func (*CompiledLibrary) IsExported ¶
func (p *CompiledLibrary) IsExported(externalName string) bool
IsExported returns true if the given external name is exported.
type ComposableContinuation ¶
type ComposableContinuation struct {
// contains filtered or unexported fields
}
ComposableContinuation is a callable value wrapping a delimited continuation segment (a chain of MachineContinuation frames) plus the captured winding stack. When applied, it splices its frames onto the current continuation, effectively composing the captured computation with the current one.
This implements Racket-style composable continuations as described in Flatt, Yu, Findler, Felleisen "Adding Delimited and Composable Control to a Production Programming Environment" (ICFP 2007).
func NewComposableContinuation ¶
func NewComposableContinuation(cont *MachineContinuation, windingStack WindingStack, threadID uint64) *ComposableContinuation
NewComposableContinuation creates a composable continuation from a continuation chain segment and the winding stack captured at the point of capture.
func (*ComposableContinuation) Cont ¶
func (p *ComposableContinuation) Cont() *MachineContinuation
func (*ComposableContinuation) EqualTo ¶
func (p *ComposableContinuation) EqualTo(o values.Value) bool
func (*ComposableContinuation) IsVoid ¶
func (p *ComposableContinuation) IsVoid() bool
func (*ComposableContinuation) SchemeString ¶
func (p *ComposableContinuation) SchemeString() string
func (*ComposableContinuation) ThreadID ¶ added in v1.1.0
func (p *ComposableContinuation) ThreadID() uint64
func (*ComposableContinuation) WindingStack ¶
func (p *ComposableContinuation) WindingStack() WindingStack
type Debugger ¶
type Debugger struct {
// contains filtered or unexported fields
}
Debugger manages breakpoints and stepping.
func (*Debugger) Breakpoints ¶
func (p *Debugger) Breakpoints() []*Breakpoint
Breakpoints returns all breakpoints.
func (*Debugger) CheckBreakpoint ¶
func (p *Debugger) CheckBreakpoint(mc *MachineContext) *Breakpoint
CheckBreakpoint checks if execution should break at current location.
func (*Debugger) DisableBreakpoint ¶
func (p *Debugger) DisableBreakpoint(id BreakpointID) bool
DisableBreakpoint disables a breakpoint.
func (*Debugger) EnableBreakpoint ¶
func (p *Debugger) EnableBreakpoint(id BreakpointID) bool
EnableBreakpoint enables a breakpoint.
func (*Debugger) IsStepping ¶
IsStepping returns whether the debugger is in stepping mode.
func (*Debugger) OnBreak ¶
func (p *Debugger) OnBreak(fn func(mc *MachineContext, bp *Breakpoint))
OnBreak sets the callback for when a breakpoint is hit.
func (*Debugger) RemoveBreakpoint ¶
func (p *Debugger) RemoveBreakpoint(id BreakpointID) bool
RemoveBreakpoint removes a breakpoint.
func (*Debugger) SetBreakpoint ¶
func (p *Debugger) SetBreakpoint(file string, line, column int) BreakpointID
SetBreakpoint adds a breakpoint at the given source location.
func (*Debugger) ShouldStep ¶
func (p *Debugger) ShouldStep(mc *MachineContext) bool
ShouldStep checks if we should break due to stepping.
func (*Debugger) StepOut ¶
func (p *Debugger) StepOut(mc *MachineContext)
StepOut enables step-out mode.
func (*Debugger) StepOver ¶
func (p *Debugger) StepOver(mc *MachineContext)
StepOver enables step-over mode.
func (*Debugger) TriggerBreak ¶
func (p *Debugger) TriggerBreak(mc *MachineContext, bp *Breakpoint)
TriggerBreak calls the break callback if set.
type DynamicWindFrame ¶
type DynamicWindFrame struct {
Before *MachineClosure // Called when entering this extent
After *MachineClosure // Called when exiting this extent
ID uint64 // Unique identifier for extent matching
}
DynamicWindFrame represents a single dynamic-wind extent. Each frame tracks the before/after thunks for one dynamic-wind call.
R7RS §6.10: dynamic-wind establishes a dynamic extent during which the before and after thunks are called whenever control enters or exits.
func NewDynamicWindFrame ¶
func NewDynamicWindFrame(before, after *MachineClosure) *DynamicWindFrame
NewDynamicWindFrame creates a new winding frame with a unique ID.
type ErrContinuationEscape ¶
type ErrContinuationEscape struct {
Continuation *MachineContinuation // Where to resume (inside sub-context for call/cc in dynamic-wind)
Value values.Value
Handled bool // Set to true after the escape has been handled and mc has been restored
WindingStack WindingStack // Target winding stack for proper dynamic-wind handling
EscapeCont *MachineContinuation // Outer continuation to restore after Continuation completes (for sub-context escapes)
}
ErrContinuationEscape is used to signal that a continuation was invoked from within a sub-context. This allows the escape to propagate up through nested foreign function calls.
func (*ErrContinuationEscape) Error ¶
func (p *ErrContinuationEscape) Error() string
type ErrExceptionEscape ¶
type ErrExceptionEscape struct {
Condition values.Value // The raised condition/object
Continuable bool // Whether handler can return
Continuation *MachineContinuation // Return point for continuable exceptions
Handled bool // Set true after handler processes it
WindingStack WindingStack // Winding stack at raise point (for proper unwinding)
Source *syntax.SourceContext // Source location where exception was raised
StackTrace StackTrace // VM stack trace at raise point
}
ErrExceptionEscape signals an exception being raised through the call stack. It is used by raise and raise-continuable to propagate exceptions to handlers.
func (*ErrExceptionEscape) Error ¶
func (p *ErrExceptionEscape) Error() string
Error implements the error interface.
When Source is present and the condition is a NativeError, produces clean human-readable output like "file:5:3: error: division by zero". For non-NativeError conditions with Source, produces "file:5:3: exception: foo". When no Source is set, falls back to the original format for backward compat.
type ErrPromptAbort ¶
ErrPromptAbort signals an abort to the nearest continuation prompt matching the given tag. This parallels ErrContinuationEscape: it propagates up through Run() and is caught by RunWithEscapeHandling().
When caught, the handler finds the matching prompt frame, unwinds dynamic-wind extents, and invokes the prompt's handler with the abort values.
func (*ErrPromptAbort) Error ¶
func (p *ErrPromptAbort) Error() string
type ExceptionHandler ¶
type ExceptionHandler struct {
// contains filtered or unexported fields
}
ExceptionHandler represents an installed exception handler. Handlers form a linked list (stack) for dynamic exception handling. When an exception is raised, handlers are invoked in reverse order of installation (most recent first).
func NewExceptionHandler ¶
func NewExceptionHandler(handler values.Value, parent *ExceptionHandler) *ExceptionHandler
NewExceptionHandler creates a new exception handler with the given handler procedure and parent handler.
func (*ExceptionHandler) Handler ¶
func (p *ExceptionHandler) Handler() values.Value
Handler returns the handler procedure.
func (*ExceptionHandler) Parent ¶
func (p *ExceptionHandler) Parent() *ExceptionHandler
Parent returns the previous handler in the chain.
type ExpandTimeCallContext ¶
type ExpandTimeCallContext struct {
// contains filtered or unexported fields
}
func NewExpandTimeCallContext ¶
func NewExpandTimeCallContext(ctx context.Context) ExpandTimeCallContext
type ExpanderContext ¶
type ExpanderContext struct {
// contains filtered or unexported fields
}
ExpanderContext provides access to the macro expander from within Scheme code during macro expansion. It is set on MachineContext when invoking macro transformers, enabling syntax-local-* primitives.
func NewExpanderContext ¶
func NewExpanderContext( env *environment.EnvironmentFrame, expander *ExpanderTimeContinuation, ectx ExpandTimeCallContext, ) *ExpanderContext
NewExpanderContext creates a new ExpanderContext.
func (*ExpanderContext) Env ¶
func (p *ExpanderContext) Env() *environment.EnvironmentFrame
Env returns the environment frame associated with this context.
func (*ExpanderContext) Expand ¶
func (p *ExpanderContext) Expand(stx syntax.SyntaxValue) (syntax.SyntaxValue, error)
Expand fully expands a syntax object.
func (*ExpanderContext) ExpandOnce ¶
func (p *ExpanderContext) ExpandOnce(stx syntax.SyntaxValue) (syntax.SyntaxValue, bool, error)
ExpandOnce performs a single step of macro expansion. Returns (expanded-syntax, did-expand, error). If the input is a macro call, it expands it once and returns (result, true, nil). If the input is not a macro call, it returns (input, false, nil).
func (*ExpanderContext) IntroductionScope ¶
func (p *ExpanderContext) IntroductionScope() *syntax.Scope
IntroductionScope returns the introduction scope for the current macro expansion. This scope is added to identifiers introduced by a macro and can be flipped using syntax-local-introduce.
func (*ExpanderContext) SetIntroductionScope ¶
func (p *ExpanderContext) SetIntroductionScope(scope *syntax.Scope)
SetIntroductionScope sets the introduction scope for the current macro expansion.
func (*ExpanderContext) SetUseSiteScope ¶
func (p *ExpanderContext) SetUseSiteScope(scope *syntax.Scope)
SetUseSiteScope sets the use-site scope for binding forms.
func (*ExpanderContext) UseSiteScope ¶
func (p *ExpanderContext) UseSiteScope() *syntax.Scope
UseSiteScope returns the use-site scope for binding forms. This scope is used by syntax-local-identifier-as-binding to mark identifiers as binding sites.
type ExpanderTimeContinuation ¶
type ExpanderTimeContinuation struct {
// contains filtered or unexported fields
}
ExpanderTimeContinuation is a continuation used during the expansion phase.
It walks the syntax tree, detecting and expanding macro invocations. The env field provides access to macro definitions (BindingTypeSyntax bindings).
func NewExpanderTimeContinuation ¶
func NewExpanderTimeContinuation(env *environment.EnvironmentFrame) *ExpanderTimeContinuation
NewExpanderTimeContinuation creates a new ExpanderTimeContinuation.
func (*ExpanderTimeContinuation) ExpandBodyWithDefineSyntax ¶
func (p *ExpanderTimeContinuation) ExpandBodyWithDefineSyntax( ectx ExpandTimeCallContext, forms []syntax.SyntaxValue, ) ([]syntax.SyntaxValue, error)
ExpandBodyWithDefineSyntax expands a sequence of body forms, compiling define-syntax forms as encountered so subsequent forms can use the macros.
This unifies the expansion pattern used by: - Lambda bodies (internal define-syntax) - Library bodies (top-level define-syntax) - Include files (top-level define-syntax)
R7RS §5.3: Internal define-syntax forms must be processed before expanding subsequent body expressions so that locally-defined macros are visible.
R7RS §5.3.2: Bodies use letrec* semantics where all defined names are visible to all initializers. This enables forward references within macros - a macro can reference a definition that appears later in the same body.
func (*ExpanderTimeContinuation) ExpandExpression ¶
func (p *ExpanderTimeContinuation) ExpandExpression(ectx ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandExpression expands a syntax expression.
func (*ExpanderTimeContinuation) ExpandOnce ¶
func (p *ExpanderTimeContinuation) ExpandOnce(ectx ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, bool, error)
ExpandOnce performs a single step of macro expansion. Returns (expanded-syntax, did-expand, error). If the input is a macro call, it expands it once and returns (result, true, nil). If the input is not a macro call, it returns (input, false, nil). Unlike ExpandExpression, this does NOT recursively expand the result.
func (*ExpanderTimeContinuation) ExpandPrimitiveForm ¶
func (p *ExpanderTimeContinuation) ExpandPrimitiveForm(ectx ExpandTimeCallContext, primName string, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandPrimitiveForm handles expansion within primitive forms like if, begin, lambda, define, etc. Some primitives need their subexpressions expanded (like if, begin) while others should be left unchanged (like quote, define-syntax).
This function looks up the primitive expander in the expand environment registry. If found, it invokes the expander; otherwise returns the form unchanged.
func (*ExpanderTimeContinuation) ExpandQuasiquote ¶
func (p *ExpanderTimeContinuation) ExpandQuasiquote(_ ExpandTimeCallContext, _ syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandQuasiquote handles the expansion of quasiquoted expressions.
func (*ExpanderTimeContinuation) ExpandQuote ¶
func (p *ExpanderTimeContinuation) ExpandQuote(_ ExpandTimeCallContext, _ syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandQuote handles the expansion of quoted expressions.
func (*ExpanderTimeContinuation) ExpandSelfEvaluating ¶
func (p *ExpanderTimeContinuation) ExpandSelfEvaluating(_ ExpandTimeCallContext, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandSelfEvaluating handles self-evaluating expressions.
func (*ExpanderTimeContinuation) ExpandSymbol ¶
func (p *ExpanderTimeContinuation) ExpandSymbol(_ ExpandTimeCallContext, expr *syntax.SyntaxSymbol) (syntax.SyntaxValue, error)
ExpandSymbol handles a symbol expression.
func (*ExpanderTimeContinuation) ExpandSyntaxArgumentList ¶
func (p *ExpanderTimeContinuation) ExpandSyntaxArgumentList(ccnt ExpandTimeCallContext, args *syntax.SyntaxPair) (*syntax.SyntaxPair, error)
ExpandSyntaxArgumentList expands each argument in the argument list. It returns a new syntax list with the expanded arguments.
func (*ExpanderTimeContinuation) ExpandSyntaxExpression ¶
func (p *ExpanderTimeContinuation) ExpandSyntaxExpression(ectx ExpandTimeCallContext, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue) (syntax.SyntaxValue, error)
ExpandSyntaxExpression checks if sym is a macro and expands it, or returns the expression as a procedure call if not.
This is where macro invocation happens:
- Look up the symbol in the expand environment
- If bound with BindingTypeSyntax, it's a macro - invoke the transformer
- If it's a primitive (like quote, if, define-syntax), don't expand args
- Otherwise, treat as procedure call and expand arguments
The transformer closure (MachineClosure from CompileSyntaxRules) is invoked by creating a MachineContext and running it. The transformer:
- Receives the full macro invocation form on the eval stack
- Pattern matches against its clauses (OperationSyntaxRulesTransform)
- Expands the matching template with captured bindings
- Adds an intro scope to the expansion for hygiene
- Returns the expanded syntax in the value register
The expanded result may itself contain macro invocations, so the caller should recursively expand it.
func (*ExpanderTimeContinuation) ExpandSyntaxOrProcedureCall ¶
func (p *ExpanderTimeContinuation) ExpandSyntaxOrProcedureCall(ectx ExpandTimeCallContext, car syntax.SyntaxValue, cdr *syntax.SyntaxPair) (syntax.SyntaxValue, error)
ExpandSyntaxOrProcedureCall handles a list expression. The car may be a symbol (possibly a macro), a nested pair (computed procedure), or a self-evaluating value (like in quoted data or malformed expressions).
type FeatureRequirement ¶
type FeatureRequirement interface {
// IsSatisfied returns true if this requirement is satisfied.
// The registry parameter is used to check library availability.
IsSatisfied(registry *LibraryRegistry) bool
}
FeatureRequirement represents a parsed cond-expand feature requirement. Feature requirements can be:
- A symbol (feature identifier)
- (library <library-name>) - check if library is available
- (and <req> ...) - all requirements must be satisfied
- (or <req> ...) - at least one requirement must be satisfied
- (not <req>) - requirement must NOT be satisfied
func NewAndRequirement ¶
func NewAndRequirement(reqs ...FeatureRequirement) FeatureRequirement
NewAndRequirement creates an and requirement.
func NewElseRequirement ¶
func NewElseRequirement() FeatureRequirement
NewElseRequirement creates an else requirement (always satisfied).
func NewFeatureIdentifier ¶
func NewFeatureIdentifier(name string) FeatureRequirement
NewFeatureIdentifier creates a feature identifier requirement.
func NewLibraryRequirement ¶
func NewLibraryRequirement(name LibraryName) FeatureRequirement
NewLibraryRequirement creates a library requirement.
func NewNotRequirement ¶
func NewNotRequirement(req FeatureRequirement) FeatureRequirement
NewNotRequirement creates a not requirement.
func NewOrRequirement ¶
func NewOrRequirement(reqs ...FeatureRequirement) FeatureRequirement
NewOrRequirement creates an or requirement.
type ForeignFunction ¶
type ForeignFunction func(ctx context.Context, mc *MachineContext) error
type FreeIdResolution ¶
type FreeIdResolution struct {
// Global is set if the free identifier refers to a global binding.
// This enables cross-library macro hygiene by pre-resolving the binding.
Global *environment.GlobalIndex
// LocalScopes is set if the free identifier refers to a local binding.
// These are the scopes of the binding at macro definition time.
// During expansion, the free identifier gets these scopes, ensuring
// it resolves to the definition-time binding (not a shadowing binding).
LocalScopes []*syntax.Scope
// HasLocalBinding is true if a local binding was found at macro definition time,
// even if the binding has no scopes. This distinguishes "local binding with empty
// scopes" from "no binding at all" - the former should NOT get intro scope added
// during expansion, while the latter might (for special forms).
HasLocalBinding bool
}
FreeIdResolution stores the resolution info for a free identifier in a macro template. Free identifiers can be resolved to either global bindings (via GlobalIndex) or local bindings (via their scope set at macro definition time).
This type implements the localScopesProvider, globalBindingProvider, and hasLocalBindingProvider interfaces used by the match package's expansion functions to handle hygiene without circular imports.
func (*FreeIdResolution) GetGlobal ¶
func (p *FreeIdResolution) GetGlobal() *environment.GlobalIndex
GetGlobal returns the global binding's index, or nil if this is a local binding. Implements the globalBindingProvider interface for match package hygiene.
func (*FreeIdResolution) GetHasLocalBinding ¶
func (p *FreeIdResolution) GetHasLocalBinding() bool
GetHasLocalBinding returns true if a local binding was found at macro definition time. This is used to distinguish "local binding with empty scopes" from "no binding at all". Implements the hasLocalBindingProvider interface.
func (*FreeIdResolution) GetLocalScopes ¶
func (p *FreeIdResolution) GetLocalScopes() []*syntax.Scope
GetLocalScopes returns the local binding's scopes, or nil if this is a global binding. Implements the localScopesProvider interface for match package hygiene.
type ImportSet ¶
type ImportSet struct {
LibraryName LibraryName // Base library to import from
Only []string // If non-nil, only import these names
Except []string // If non-nil, import all except these
Prefix string // If non-empty, add this prefix to all names
Renames map[string]string // old-name -> new-name
PhaseShift int // Phase offset: 0=runtime, 1=for-syntax, -1=for-template
}
ImportSet represents a parsed import specification. It can be a simple library reference or include modifiers.
PhaseShift supports Racket-style phased imports:
- (import (scheme base)) ; Phase 0 (runtime) - default
- (import (for-syntax (scheme base))) ; Phase +1 (expand)
- (import (for-template (scheme base))) ; Phase -1
- (import (for-meta 2 (scheme base))) ; Phase +2
- (import (for-meta -1 (scheme base))) ; Phase -1 (same as for-template)
Phase shifts compose additively: (for-syntax (for-syntax lib)) = phase +2
func NewImportSet ¶
func NewImportSet(name LibraryName) *ImportSet
NewImportSet creates a new import set for a library.
func ParseImportSetFromDatum ¶
ParseImportSetFromDatum parses an import set from a datum value. This is for runtime use by the 'environment' procedure. Import sets can be:
- (<library-name>) : import all exports
- (only <import-set> <id> ...) : import only specified identifiers
- (except <import-set> <id> ...): import all except specified
- (prefix <import-set> <prefix>): add prefix to all imported names
- (rename <import-set> (<old> <new>) ...): rename specific imports
- (for-syntax <import-set>) : import at phase +1 (macro expansion)
- (for-template <import-set>) : import at phase -1
- (for-meta <n> <import-set>) : import at phase +n
func (*ImportSet) ApplyToExports ¶
func (p *ImportSet) ApplyToExports(lib *CompiledLibrary) (map[string]string, error)
ApplyToExports applies the import modifiers and returns the final bindings. Returns a map of local-name -> external-name (the name in the library).
type LibraryName ¶
type LibraryName struct {
Parts []string // e.g., ["scheme", "base"]
}
LibraryName represents an R7RS library name like (scheme base) or (my lib). Library names are lists of identifiers used to uniquely identify a library.
func NewLibraryName ¶
func NewLibraryName(parts ...string) LibraryName
NewLibraryName creates a LibraryName from a list of string parts.
func ParseLibraryNameFromDatum ¶
ParseLibraryNameFromDatum extracts a LibraryName from a datum list like (scheme base). This is for runtime use by the 'environment' procedure.
func (LibraryName) Key ¶
func (p LibraryName) Key() string
Key returns a unique string key for map lookups.
func (LibraryName) SchemeString ¶
func (p LibraryName) SchemeString() string
SchemeString returns the Scheme representation like "(scheme base)".
func (LibraryName) String ¶
func (p LibraryName) String() string
String returns a human-readable representation like "scheme/base".
func (LibraryName) ToFilePath ¶
func (p LibraryName) ToFilePath() string
ToFilePath converts a library name to a file path. (scheme base) -> "scheme/base.sld"
type LibraryRegistry ¶
type LibraryRegistry struct {
// contains filtered or unexported fields
}
LibraryRegistry manages loaded libraries and handles library loading.
func NewLibraryRegistry ¶
func NewLibraryRegistry() *LibraryRegistry
NewLibraryRegistry creates a new library registry with default search paths.
func (*LibraryRegistry) AddSearchPath ¶
func (p *LibraryRegistry) AddSearchPath(path string)
AddSearchPath adds a path to the beginning of the search path list.
func (*LibraryRegistry) FindLibraryFile ¶
func (p *LibraryRegistry) FindLibraryFile(name LibraryName) (string, error)
FindLibraryFile searches for a library file in the search paths. Returns the full path to the file, or an error if not found.
func (*LibraryRegistry) FinishLoading ¶
func (p *LibraryRegistry) FinishLoading(name LibraryName)
FinishLoading marks a library as finished loading.
func (*LibraryRegistry) GetSearchPaths ¶
func (p *LibraryRegistry) GetSearchPaths() []string
GetSearchPaths returns the current library search paths.
func (*LibraryRegistry) IsLoading ¶
func (p *LibraryRegistry) IsLoading(name LibraryName) bool
IsLoading returns true if the library is currently being loaded. Used to detect circular dependencies.
func (*LibraryRegistry) Lookup ¶
func (p *LibraryRegistry) Lookup(name LibraryName) *CompiledLibrary
Lookup returns a library by name, or nil if not found.
func (*LibraryRegistry) Register ¶
func (p *LibraryRegistry) Register(lib *CompiledLibrary) error
Register adds a compiled library to the registry.
func (*LibraryRegistry) SetSearchPaths ¶
func (p *LibraryRegistry) SetSearchPaths(paths []string)
SetSearchPaths sets the library search paths.
func (*LibraryRegistry) StartLoading ¶
func (p *LibraryRegistry) StartLoading(name LibraryName)
StartLoading marks a library as being loaded.
type LiteralIndex ¶
type LiteralIndex int
type MachineClosure ¶
type MachineClosure struct {
// contains filtered or unexported fields
}
func CompileSyntaxRules ¶
func CompileSyntaxRules(ctx context.Context, env *environment.EnvironmentFrame, syntaxRulesForm syntax.SyntaxValue) (*MachineClosure, error)
CompileSyntaxRules compiles a syntax-rules form into a transformer procedure.
R7RS Forms:
(syntax-rules (literal ...) (pattern template) ...) (syntax-rules <ellipsis> (literal ...) (pattern template) ...) ; custom ellipsis
The compilation process:
- Parse optional custom ellipsis identifier
- Parse the literals list - these symbols are matched literally, not as variables
- For each clause, identify pattern variables (symbols not in literals list)
- Compile each pattern to bytecode (see match/syntax_compiler.go)
- Create a MachineClosure that, when invoked: - Tries each pattern in order against the input form - On first match, expands the template with captured bindings - Adds an "intro scope" to the expansion for hygiene
The returned closure is stored in the environment with BindingTypeSyntax, allowing the expander to recognize it as a macro transformer.
func NewClosureWithTemplate ¶
func NewClosureWithTemplate(tpl *NativeTemplate, env *environment.EnvironmentFrame) *MachineClosure
func NewForeignClosure ¶
func NewForeignClosure(env *environment.EnvironmentFrame, pcnt int, vardiac bool, fn ForeignFunction) *MachineClosure
func (*MachineClosure) Copy ¶
func (p *MachineClosure) Copy() *MachineClosure
func (*MachineClosure) IsVoid ¶
func (p *MachineClosure) IsVoid() bool
func (*MachineClosure) SchemeString ¶
func (p *MachineClosure) SchemeString() string
func (*MachineClosure) Template ¶
func (p *MachineClosure) Template() *NativeTemplate
type MachineContext ¶
type MachineContext struct {
// contains filtered or unexported fields
}
MachineContext represents the execution context of a virtual machine. It holds the current environment, values, evaluation stack, continuation, and program counter. It is created from a MachineContinuation and can be modified during execution.
func NewMachineContext ¶
func NewMachineContext(ctx context.Context, cont *MachineContinuation) *MachineContext
NewMachineContext creates a new machine context with the given context and continuation. The context enables cancellation/timeout support in the VM loop. For callers that don't need cancellation, pass context.Background().
func NewMachineContextFromMachineClosure ¶
func NewMachineContextFromMachineClosure(ctx context.Context, cls *MachineClosure) *MachineContext
func (*MachineContext) Apply ¶
func (p *MachineContext) Apply(mcls *MachineClosure, vs ...values.Value) (*MachineContext, error)
FIXME: needs unit tests FIXME: not symmetric with Apply of MachineClosure FIXME: variadic parameters but no return values
func (*MachineContext) ApplyCaseLambda ¶
func (p *MachineContext) ApplyCaseLambda(clcls *CaseLambdaClosure, vs ...values.Value) (*MachineContext, error)
ApplyCaseLambda applies a case-lambda closure by finding the matching clause.
func (*MachineContext) CallDepth ¶
func (p *MachineContext) CallDepth() int
CallDepth returns the depth of the current continuation stack.
func (*MachineContext) CaptureStackTrace ¶
func (p *MachineContext) CaptureStackTrace(maxDepth int) StackTrace
CaptureStackTrace walks the continuation chain and builds a stack trace.
func (*MachineContext) Context ¶
func (p *MachineContext) Context() context.Context
Context returns the context for this machine context.
func (*MachineContext) Counters ¶ added in v1.1.0
func (p *MachineContext) Counters() VMCounters
Counters returns a snapshot of the performance counters for this context.
func (*MachineContext) CurrentContinuation ¶
func (p *MachineContext) CurrentContinuation() *MachineContinuation
func (*MachineContext) CurrentSource ¶
func (p *MachineContext) CurrentSource() *syntax.SourceContext
CurrentSource returns the source location for the current execution point. When the current template has no source (e.g., inside a foreign function), walks up the continuation chain to find the nearest call site with source info. Continuation PCs are return addresses (one past the call), so pc-1 gives the call site.
func (*MachineContext) Debugger ¶
func (p *MachineContext) Debugger() *Debugger
Debugger returns the attached debugger, or nil if none.
func (*MachineContext) EnvironmentFrame ¶
func (p *MachineContext) EnvironmentFrame() *environment.EnvironmentFrame
func (*MachineContext) Error ¶
func (p *MachineContext) Error(msg string) *SchemeError
Error creates a SchemeError with the current source location and stack trace.
func (*MachineContext) EscapeCont ¶
func (p *MachineContext) EscapeCont() *MachineContinuation
EscapeCont returns the escape continuation for this context. This is set by foreign functions (like dynamic-wind) that need call/cc inside their sub-contexts to know where to continue after completion.
func (*MachineContext) ExceptionHandler ¶
func (p *MachineContext) ExceptionHandler() *ExceptionHandler
ExceptionHandler returns the current exception handler chain.
func (*MachineContext) ExpanderContext ¶
func (p *MachineContext) ExpanderContext() *ExpanderContext
ExpanderContext returns the expander context, or nil if not in expansion context.
func (*MachineContext) FindPrompt ¶
func (p *MachineContext) FindPrompt(tag *PromptTag) (*MachineContinuation, bool)
FindPrompt walks the continuation chain to find the nearest frame with a matching prompt tag. Also checks the context's own prompt tag (set by call-with-continuation-prompt on sub-contexts). Returns the matching frame and true, or nil and false.
When the prompt is on the context itself (not a continuation frame), returns nil and true — the caller should treat this as "prompt at the boundary of this sub-context" and slice the entire continuation chain.
func (*MachineContext) GetValue ¶
func (p *MachineContext) GetValue() values.Value
func (*MachineContext) GetValues ¶
func (p *MachineContext) GetValues() MultipleValues
func (*MachineContext) NewSubContext ¶
func (p *MachineContext) NewSubContext() *MachineContext
NewSubContext creates a new MachineContext for running sub-calls (e.g., apply, map, for-each). The sub-context shares the global environment but has a fresh call stack, eval stack, and value register. This allows foreign functions to call Scheme closures without corrupting the parent context's state.
Note: Sub-contexts have isolated continuation chains (cont = nil). When call/cc captures a continuation inside a sub-context, it captures mc.Parent() which refers to the sub-context's chain (nil). For continuations to escape back to the outer context, the escape error propagates up through the call stack and is handled by RunWithEscapeHandling at the top level.
The parentMC field tracks the parent context, allowing call/cc to find an outer continuation for proper R7RS continuation semantics when captured inside sub-contexts.
The escapeCont field is inherited, allowing nested sub-contexts to know where execution should continue after their completion (set by dynamic-wind and similar constructs).
func (*MachineContext) PC ¶
func (p *MachineContext) PC() int
func (*MachineContext) Parent ¶
func (p *MachineContext) Parent() *MachineContinuation
func (*MachineContext) ParentMC ¶
func (p *MachineContext) ParentMC() *MachineContext
ParentMC returns the parent machine context (for sub-contexts), or nil for top-level contexts.
func (*MachineContext) PopContinuation ¶
func (p *MachineContext) PopContinuation() *MachineContinuation
PopContinuation pops the current continuation from the machine context and returns it. It restores the machine context to the state saved in the popped continuation.
Note: Unlike Restore(), we do NOT copy evals here because PopContinuation is used for normal function return where the continuation is consumed once. Restore() is used for continuation re-entry (call/cc) where the same continuation may be invoked multiple times, requiring the copy to prevent stack corruption.
func (*MachineContext) PopExceptionHandler ¶
func (p *MachineContext) PopExceptionHandler() *ExceptionHandler
PopExceptionHandler pops the current exception handler from the stack and returns it. Returns nil if no handler is installed.
func (*MachineContext) PopWindingFrame ¶
func (p *MachineContext) PopWindingFrame() *DynamicWindFrame
PopWindingFrame removes the innermost frame from the winding stack.
func (*MachineContext) PromptTag ¶
func (p *MachineContext) PromptTag() *PromptTag
PromptTag returns the prompt tag for this context, or nil.
func (*MachineContext) PushExceptionHandler ¶
func (p *MachineContext) PushExceptionHandler(handler values.Value)
PushExceptionHandler pushes a new exception handler onto the handler stack.
func (*MachineContext) PushWindingFrame ¶
func (p *MachineContext) PushWindingFrame(frame *DynamicWindFrame)
PushWindingFrame adds a frame to the winding stack.
func (*MachineContext) Restore ¶
func (p *MachineContext) Restore(cont *MachineContinuation)
func (*MachineContext) RestoreWithWinding ¶
func (p *MachineContext) RestoreWithWinding(cont *MachineContinuation, targetStack WindingStack) error
RestoreWithWinding restores a continuation with proper dynamic-wind handling. It unwinds from the current dynamic extent, rewinds to the target extent, then restores the machine state.
If cont is nil (continuation captured in a sub-context), we still perform the winding operations but don't restore machine state - the caller should handle continued execution appropriately.
func (*MachineContext) RestoreWithWindingFrom ¶
func (p *MachineContext) RestoreWithWindingFrom(cont *MachineContinuation, sourceStack, targetStack WindingStack) error
RestoreWithWindingFrom restores a continuation with proper dynamic-wind handling, using an explicit source winding stack instead of the current context's stack.
This is needed when the escape originated from a sub-context that has a different winding stack than the context where RestoreWithWinding is called. For example, when call/cc captures inside a sub-context and the escape propagates up, the source winding stack (where the escape happened) may have frames that the top-level context doesn't know about.
Parameters:
- cont: The continuation to restore to
- sourceStack: The winding stack where the escape originated (for unwinding)
- targetStack: The winding stack to restore to (for rewinding)
func (*MachineContext) RewindTo ¶
func (p *MachineContext) RewindTo(target WindingStack, commonDepth int) error
RewindTo runs before thunks from common ancestor to target depth. Returns error if any before thunk fails.
func (*MachineContext) Run ¶
func (p *MachineContext) Run() error
Run executes the VM loop starting from the current pc. The pc is NOT reset here - callers are responsible for ensuring the correct initial pc:
- NewMachineContext copies pc from the continuation (typically 0 for fresh execution)
- Apply sets pc = 0 for fresh closure invocation
- Restore sets pc from the saved continuation for resumption
This design allows continuation resumption (e.g., raise-continuable) to work correctly by preserving the pc set by Restore rather than unconditionally resetting to 0.
Context cancellation: The loop checks p.ctx.Done() on each iteration, allowing preemption via context.WithTimeout or context.WithCancel. This enables:
- Test timeouts that actually stop execution
- REPL interrupt support (Ctrl+C)
- Resource management for long-running computations
Set the context via SetContext() before calling Run().
func (*MachineContext) RunWithEscapeHandling ¶
func (p *MachineContext) RunWithEscapeHandling() error
RunWithEscapeHandling runs the VM loop, handling continuation escapes that weren't caught by an enclosing call/cc. This is used at the top level (REPL and file execution) to catch continuations invoked outside their original dynamic extent.
When a continuation captured inside a foreign function (like dynamic-wind's thunk) is invoked from outside, the escape error propagates up. This method catches it and restores the continuation with proper dynamic-wind handling.
For continuations captured inside sub-contexts (like dynamic-wind thunks):
- Continuation: the inner state (inside the thunk)
- EscapeCont: the outer continuation (after the original sub-context would have completed)
After the inner execution completes and unwinds, if there's a pending escape continuation, execution continues from there.
When execution completes (either normally or via ErrMachineHalt), any remaining frames on the winding stack are unwound (after thunks are called).
func (*MachineContext) SaveContinuation ¶
func (p *MachineContext) SaveContinuation(off int)
SaveContinuation pushes a new continuation onto the machine context with the given offset to the current program counter.
func (*MachineContext) SetContext ¶
func (p *MachineContext) SetContext(ctx context.Context)
SetContext sets the context for this machine context. This should be called before Run() to enable context cancellation/timeout.
func (*MachineContext) SetDebugger ¶
func (p *MachineContext) SetDebugger(d *Debugger)
SetDebugger attaches a debugger to this context.
func (*MachineContext) SetEscapeCont ¶
func (p *MachineContext) SetEscapeCont(cont *MachineContinuation)
SetEscapeCont sets the escape continuation for this context.
func (*MachineContext) SetExceptionHandler ¶
func (p *MachineContext) SetExceptionHandler(h *ExceptionHandler)
SetExceptionHandler sets the exception handler chain.
func (*MachineContext) SetExpanderContext ¶
func (p *MachineContext) SetExpanderContext(ctx *ExpanderContext)
SetExpanderContext sets the expander context for this machine context. This is called when invoking macro transformers to enable syntax-local-* primitives.
func (*MachineContext) SetPC ¶
func (p *MachineContext) SetPC(v int)
SetPC sets the program counter. Used by PrimCallCC for inline lambda execution.
func (*MachineContext) SetPromptTag ¶
func (p *MachineContext) SetPromptTag(tag *PromptTag)
SetPromptTag sets the prompt tag on this context. Used by call-with-continuation-prompt to mark sub-contexts as prompt boundaries.
func (*MachineContext) SetThread ¶ added in v1.1.0
func (p *MachineContext) SetThread(t *values.Thread)
SetThread sets the SRFI-18 thread identity on this context. Both the thread object and its ID are stored for efficient comparison.
func (*MachineContext) SetValue ¶
func (p *MachineContext) SetValue(v values.Value)
func (*MachineContext) SetValues ¶
func (p *MachineContext) SetValues(vs ...values.Value)
func (*MachineContext) SetWindingStack ¶
func (p *MachineContext) SetWindingStack(stack WindingStack)
SetWindingStack sets the winding stack (used by sub-contexts).
func (*MachineContext) SliceContinuationAt ¶
func (p *MachineContext) SliceContinuationAt(prompt *MachineContinuation) *MachineContinuation
SliceContinuationAt deep-copies the continuation chain segment from p.cont down to (but not including) the prompt frame. The returned chain's bottom frame has parent = nil, making it a standalone segment suitable for composable continuation capture.
func (*MachineContext) Template ¶
func (p *MachineContext) Template() *NativeTemplate
func (*MachineContext) Thread ¶ added in v1.1.0
func (p *MachineContext) Thread() *values.Thread
Thread returns the SRFI-18 thread object for this context, or nil for the primordial thread.
func (*MachineContext) ThreadID ¶ added in v1.1.0
func (p *MachineContext) ThreadID() uint64
ThreadID returns the SRFI-18 thread ID for this context. 0 means the primordial thread (main goroutine).
func (*MachineContext) UnwindTo ¶
func (p *MachineContext) UnwindTo(commonDepth int) error
UnwindTo runs after thunks from innermost to the common ancestor. Returns error if any after thunk fails.
func (*MachineContext) WindingStack ¶
func (p *MachineContext) WindingStack() WindingStack
WindingStack returns the current winding stack.
func (*MachineContext) WrapError ¶
func (p *MachineContext) WrapError(err error, msg string) *SchemeError
WrapError wraps an existing error with the current source location and stack trace.
type MachineContinuation ¶
type MachineContinuation struct {
// contains filtered or unexported fields
}
func NewMachineContinuation ¶
func NewMachineContinuation(parent *MachineContinuation, tpl *NativeTemplate, env *environment.EnvironmentFrame) *MachineContinuation
NewMachineContinuation creates a new machine continuation with the given parent, template, environment frame, and initial values.
func NewMachineContinuationFromMachineContext ¶
func NewMachineContinuationFromMachineContext(mc *MachineContext, off int) *MachineContinuation
NewMachineContinuationFromMachineContext creates a new machine continuation from the given machine context and an offset to the program counter. The new continuation inherits the environment, template, and evaluation stack from the machine context.
func NewMachineContinuationWithPrompt ¶
func NewMachineContinuationWithPrompt(parent *MachineContinuation, tpl *NativeTemplate, env *environment.EnvironmentFrame, tag *PromptTag, handler *MachineClosure) *MachineContinuation
NewMachineContinuationWithPrompt creates a continuation frame that acts as a continuation prompt. The tag identifies the prompt for abort/capture, and the handler is invoked when an abort reaches this prompt.
func (*MachineContinuation) CallDepth ¶
func (p *MachineContinuation) CallDepth() int
CallDepth returns the depth of the continuation stack.
func (*MachineContinuation) Copy ¶
func (p *MachineContinuation) Copy() *MachineContinuation
func (*MachineContinuation) DeepCopy ¶
func (p *MachineContinuation) DeepCopy() *MachineContinuation
DeepCopy creates a deep copy of the entire continuation chain. Each frame in the chain is copied, with parent pointers updated to point to the copied frames. This is needed for composable continuations which must be safely re-invoked multiple times.
func (*MachineContinuation) EnvironmentFrame ¶
func (p *MachineContinuation) EnvironmentFrame() *environment.EnvironmentFrame
func (*MachineContinuation) IsVoid ¶
func (p *MachineContinuation) IsVoid() bool
func (*MachineContinuation) PC ¶
func (p *MachineContinuation) PC() int
func (*MachineContinuation) Parent ¶
func (p *MachineContinuation) Parent() *MachineContinuation
func (*MachineContinuation) PromptHandler ¶
func (p *MachineContinuation) PromptHandler() *MachineClosure
func (*MachineContinuation) PromptTag ¶
func (p *MachineContinuation) PromptTag() *PromptTag
func (*MachineContinuation) PushValues ¶
func (p *MachineContinuation) PushValues(v ...values.Value)
func (*MachineContinuation) SchemeString ¶
func (p *MachineContinuation) SchemeString() string
func (*MachineContinuation) SetPC ¶
func (p *MachineContinuation) SetPC(v int)
func (*MachineContinuation) SetPromptHandler ¶
func (p *MachineContinuation) SetPromptHandler(h *MachineClosure)
func (*MachineContinuation) SetPromptTag ¶
func (p *MachineContinuation) SetPromptTag(t *PromptTag)
func (*MachineContinuation) Template ¶
func (p *MachineContinuation) Template() *NativeTemplate
func (*MachineContinuation) ThreadID ¶ added in v1.1.0
func (p *MachineContinuation) ThreadID() uint64
type MultipleValues ¶
MultipleValues represents multiple return values from a function.
func NewMultipleValues ¶
func NewMultipleValues(values ...values.Value) MultipleValues
NewMultipleValues creates a new MultipleValues from the given values.
func (MultipleValues) Copy ¶
func (p MultipleValues) Copy() MultipleValues
Copy creates a copy of the MultipleValues.
func (MultipleValues) EqualTo ¶
func (p MultipleValues) EqualTo(o values.Value) bool
EqualTo checks if the MultipleValues is equal to another value.
func (MultipleValues) IsVoid ¶
func (p MultipleValues) IsVoid() bool
IsVoid returns true if the MultipleValues represents 'void' - either
func (MultipleValues) Len ¶
func (p MultipleValues) Len() int
Len returns the number of values in the MultipleValues.
func (MultipleValues) SchemeString ¶
func (p MultipleValues) SchemeString() string
SchemeString returns the Scheme representation of the MultipleValues.
type NativeTemplate ¶
type NativeTemplate struct {
// contains filtered or unexported fields
}
func NewNativeTemplate ¶
func NewNativeTemplate(pcnt int, vcnt int, vd bool, operations ...Operation) *NativeTemplate
func (*NativeTemplate) AppendOperations ¶
func (p *NativeTemplate) AppendOperations(ops ...Operation)
AppendOperations appends operations with no source attribution (index 0 = nil). This is the fallback for direct template calls outside the compiler.
func (*NativeTemplate) Copy ¶
func (p *NativeTemplate) Copy() *NativeTemplate
func (*NativeTemplate) DeduplicateLiteral ¶
func (p *NativeTemplate) DeduplicateLiteral(v values.Value) values.Value
DeduplicateLiteral deduplicates the given value using the template's literal pool. For composite values (pairs and vectors), all elements are deduplicated recursively. Returns the deduplicated value.
func (*NativeTemplate) IsVariadic ¶
func (p *NativeTemplate) IsVariadic() bool
func (*NativeTemplate) IsVoid ¶
func (p *NativeTemplate) IsVoid() bool
func (*NativeTemplate) MaybeAppendLiteral ¶
func (p *NativeTemplate) MaybeAppendLiteral(v values.Value) LiteralIndex
func (*NativeTemplate) Name ¶
func (p *NativeTemplate) Name() string
func (*NativeTemplate) Operations ¶
func (p *NativeTemplate) Operations() Operations
func (*NativeTemplate) ParameterCount ¶
func (p *NativeTemplate) ParameterCount() int
func (*NativeTemplate) SchemeString ¶
func (p *NativeTemplate) SchemeString() string
func (*NativeTemplate) SetName ¶
func (p *NativeTemplate) SetName(name string)
func (*NativeTemplate) SourceAt ¶
func (p *NativeTemplate) SourceAt(pc int) *syntax.SourceContext
SourceAt returns the source location for the operation at pc. Returns nil if pc is out of bounds or no source was recorded. O(1) lookup via the parallel sourceRefs array.
func (*NativeTemplate) ValueCount ¶
func (p *NativeTemplate) ValueCount() int
type Operation ¶
type Operation interface {
values.Value
Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
}
type OperationApply ¶
type OperationApply struct{}
OperationApply is the bytecode operation that dispatches procedure calls. It is the single point where all Scheme procedure application converges at runtime. The compiler emits OperationApply after pushing arguments onto the eval stack and placing the callee in the value register.
The type switch inside Apply is exhaustive over the four callable value types in the VM. Each type reaches this point through different Scheme-level syntax but all share the same calling convention: callee in value[0], arguments popped from the eval stack.
func NewOperationApply ¶
func NewOperationApply() *OperationApply
NewOperationApply returns a new apply operation.
func (*OperationApply) Apply ¶
func (p *OperationApply) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
Apply dispatches a procedure call to the appropriate handler based on the callee's concrete type. The eval stack holds the arguments (pushed by the compiler-generated Push/Pull sequence); PopAll retrieves them.
The type switch covers every callable type in the VM:
MachineClosure: standard Scheme lambda. Created by OperationMakeClosure from compiled NativeTemplates. This is the common case — nearly all user-defined and built-in procedures are MachineClosure values.
CaseLambdaClosure: R7RS case-lambda (§4.2.9). Wraps multiple MachineClosure clauses, each with a different arity. ApplyCaseLambda selects the clause whose parameter count matches the argument count.
Parameter: R7RS make-parameter (§4.2.6). A callable object that acts as a mutable cell: zero arguments returns the current value, one argument sets it (after an optional converter). Parameters must manage their own continuation restore because they don't use NativeTemplate bytecode — they execute Go code directly and must explicitly return control.
ComposableContinuation: delimited continuation captured by call-with-composable-continuation. Invoking it splices the captured continuation frames onto the current chain, rewinding/unwinding dynamic-wind extents as needed. See Flatt et al. ICFP 2007.
Any other value in the callee position is a type error — Scheme attempted to call a non-procedure.
func (*OperationApply) EqualTo ¶
func (p *OperationApply) EqualTo(o values.Value) bool
EqualTo returns true if o is also an OperationApply (identity by type).
func (*OperationApply) IsVoid ¶
func (p *OperationApply) IsVoid() bool
IsVoid returns true if the receiver is nil (satisfies values.Value).
func (*OperationApply) SchemeString ¶
func (p *OperationApply) SchemeString() string
SchemeString returns the external representation for debugging.
type OperationBindPatternVars ¶
type OperationBindPatternVars struct {
PatternVars []string // Ordered list for consistent indexing
}
OperationBindPatternVars binds pattern variables from the last match into a new local environment frame that is pushed onto the current environment.
This operation creates a new environment frame with local slots for each pattern variable, binds the matched values, and makes this the current environment.
func NewOperationBindPatternVars ¶
func NewOperationBindPatternVars(patternVars map[string]struct{}) *OperationBindPatternVars
func (*OperationBindPatternVars) Apply ¶
func (p *OperationBindPatternVars) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationBindPatternVars) EqualTo ¶
func (p *OperationBindPatternVars) EqualTo(other values.Value) bool
func (*OperationBindPatternVars) IsVoid ¶
func (p *OperationBindPatternVars) IsVoid() bool
func (*OperationBindPatternVars) SchemeString ¶
func (p *OperationBindPatternVars) SchemeString() string
func (*OperationBindPatternVars) String ¶
func (p *OperationBindPatternVars) String() string
type OperationBranchOffsetImmediate ¶
type OperationBranchOffsetImmediate struct {
Offset int
}
func NewOperationBranchOffsetImmediate ¶
func NewOperationBranchOffsetImmediate(offset int) *OperationBranchOffsetImmediate
func (*OperationBranchOffsetImmediate) Apply ¶
func (p *OperationBranchOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationBranchOffsetImmediate) EqualTo ¶
func (p *OperationBranchOffsetImmediate) EqualTo(o values.Value) bool
func (*OperationBranchOffsetImmediate) IsVoid ¶
func (p *OperationBranchOffsetImmediate) IsVoid() bool
func (*OperationBranchOffsetImmediate) SchemeString ¶
func (p *OperationBranchOffsetImmediate) SchemeString() string
type OperationBranchOnFalseOffsetImmediate ¶
type OperationBranchOnFalseOffsetImmediate struct {
Offset int
}
func NewOperationBranchOnFalseOffsetImmediate ¶
func NewOperationBranchOnFalseOffsetImmediate(offset int) *OperationBranchOnFalseOffsetImmediate
func (*OperationBranchOnFalseOffsetImmediate) Apply ¶
func (p *OperationBranchOnFalseOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationBranchOnFalseOffsetImmediate) EqualTo ¶
func (p *OperationBranchOnFalseOffsetImmediate) EqualTo(o values.Value) bool
func (*OperationBranchOnFalseOffsetImmediate) IsVoid ¶
func (p *OperationBranchOnFalseOffsetImmediate) IsVoid() bool
func (*OperationBranchOnFalseOffsetImmediate) SchemeString ¶
func (p *OperationBranchOnFalseOffsetImmediate) SchemeString() string
type OperationBranchOnNotFalseOffsetImmediate ¶
type OperationBranchOnNotFalseOffsetImmediate struct {
Offset int
}
func NewOperationBranchOnNotFalseOffsetImmediate ¶
func NewOperationBranchOnNotFalseOffsetImmediate(offset int) *OperationBranchOnNotFalseOffsetImmediate
func (*OperationBranchOnNotFalseOffsetImmediate) Apply ¶
func (p *OperationBranchOnNotFalseOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationBranchOnNotFalseOffsetImmediate) EqualTo ¶
func (p *OperationBranchOnNotFalseOffsetImmediate) EqualTo(o values.Value) bool
func (*OperationBranchOnNotFalseOffsetImmediate) IsVoid ¶
func (p *OperationBranchOnNotFalseOffsetImmediate) IsVoid() bool
func (*OperationBranchOnNotFalseOffsetImmediate) SchemeString ¶
func (p *OperationBranchOnNotFalseOffsetImmediate) SchemeString() string
type OperationBrk ¶
type OperationBrk struct {
Fn func(context.Context, *MachineContext) error
}
func NewOperationBrk ¶
func NewOperationBrk(fn func(context.Context, *MachineContext) error) *OperationBrk
func (*OperationBrk) Apply ¶
func (p *OperationBrk) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationBrk) IsVoid ¶
func (p *OperationBrk) IsVoid() bool
func (*OperationBrk) SchemeString ¶
func (p *OperationBrk) SchemeString() string
type OperationBuildSyntaxList ¶
type OperationBuildSyntaxList struct {
Count int
}
OperationBuildSyntaxList builds a syntax list from elements on the eval stack. n elements are popped from the stack (in reverse order) and consed into a list.
func NewOperationBuildSyntaxList ¶
func NewOperationBuildSyntaxList(count int) *OperationBuildSyntaxList
NewOperationBuildSyntaxList creates a new OperationBuildSyntaxList.
func (*OperationBuildSyntaxList) Apply ¶
func (p *OperationBuildSyntaxList) Apply(_ context.Context, mctx *MachineContext) (*MachineContext, error)
Apply implements the Operation interface.
func (*OperationBuildSyntaxList) EqualTo ¶
func (p *OperationBuildSyntaxList) EqualTo(other values.Value) bool
func (*OperationBuildSyntaxList) IsVoid ¶
func (p *OperationBuildSyntaxList) IsVoid() bool
func (*OperationBuildSyntaxList) SchemeString ¶
func (p *OperationBuildSyntaxList) SchemeString() string
func (*OperationBuildSyntaxList) String ¶
func (p *OperationBuildSyntaxList) String() string
type OperationClearSyntaxCaseInput ¶
type OperationClearSyntaxCaseInput struct{}
OperationClearSyntaxCaseInput clears the global syntax-case input. This is called at the end of a syntax-case form.
func NewOperationClearSyntaxCaseInput ¶
func NewOperationClearSyntaxCaseInput() *OperationClearSyntaxCaseInput
func (*OperationClearSyntaxCaseInput) Apply ¶
func (p *OperationClearSyntaxCaseInput) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationClearSyntaxCaseInput) EqualTo ¶
func (p *OperationClearSyntaxCaseInput) EqualTo(other values.Value) bool
func (*OperationClearSyntaxCaseInput) IsVoid ¶
func (p *OperationClearSyntaxCaseInput) IsVoid() bool
func (*OperationClearSyntaxCaseInput) SchemeString ¶
func (p *OperationClearSyntaxCaseInput) SchemeString() string
func (*OperationClearSyntaxCaseInput) String ¶
func (p *OperationClearSyntaxCaseInput) String() string
type OperationDrop ¶
type OperationDrop struct{}
OperationDrop removes the top value from the eval stack without affecting the value register. This is used when we need to clean up the stack but preserve the current result.
func NewOperationDrop ¶
func NewOperationDrop() *OperationDrop
func (*OperationDrop) Apply ¶
func (*OperationDrop) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationDrop) IsVoid ¶
func (p *OperationDrop) IsVoid() bool
func (*OperationDrop) SchemeString ¶
func (p *OperationDrop) SchemeString() string
type OperationForeignFunctionCall ¶
type OperationForeignFunctionCall struct {
Function ForeignFunction
}
func NewOperationForeignFunctionCall ¶
func NewOperationForeignFunctionCall(ffn ForeignFunction) *OperationForeignFunctionCall
func (*OperationForeignFunctionCall) Apply ¶
func (p *OperationForeignFunctionCall) Apply(ctx context.Context, mc *MachineContext) (rmc *MachineContext, rerr error)
func (*OperationForeignFunctionCall) EqualTo ¶
func (p *OperationForeignFunctionCall) EqualTo(o values.Value) bool
func (*OperationForeignFunctionCall) IsVoid ¶
func (p *OperationForeignFunctionCall) IsVoid() bool
func (*OperationForeignFunctionCall) SchemeString ¶
func (p *OperationForeignFunctionCall) SchemeString() string
type OperationLoadGlobalByGlobalIndexLiteralIndexImmediate ¶
type OperationLoadGlobalByGlobalIndexLiteralIndexImmediate struct {
LiteralIndex LiteralIndex
}
OperationLoadGlobalByGlobalIndexLiteralIndexImmediate loads a global variable using an index from the literals pool.
func NewOperationLoadGlobalByGlobalIndexLiteralIndexImmediate ¶
func NewOperationLoadGlobalByGlobalIndexLiteralIndexImmediate(li LiteralIndex) *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate
NewOperationLoadGlobalByGlobalIndexLiteralIndexImmediate creates a new global load operation.
func (*OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) Apply ¶
func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
Apply executes the operation, loading the global variable's value.
func (*OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) EqualTo ¶
func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) EqualTo(o values.Value) bool
EqualTo returns true if both operations have the same literal index.
func (*OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) IsVoid ¶
func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) IsVoid() bool
IsVoid returns true if the operation is nil.
func (*OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) SchemeString ¶
func (p *OperationLoadGlobalByGlobalIndexLiteralIndexImmediate) SchemeString() string
SchemeString returns the Scheme representation of the operation.
type OperationLoadLiteralByLiteralIndexImmediate ¶
type OperationLoadLiteralByLiteralIndexImmediate struct {
LiteralIndex LiteralIndex
}
OperationLoadLiteralByLiteralIndexImmediate loads a literal value from the literals pool.
func NewOperationLoadLiteralByLiteralIndexImmediate ¶
func NewOperationLoadLiteralByLiteralIndexImmediate(li LiteralIndex) *OperationLoadLiteralByLiteralIndexImmediate
NewOperationLoadLiteralByLiteralIndexImmediate creates a new literal load operation.
func (*OperationLoadLiteralByLiteralIndexImmediate) Apply ¶
func (p *OperationLoadLiteralByLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
Apply executes the operation, loading the literal value.
func (*OperationLoadLiteralByLiteralIndexImmediate) EqualTo ¶
func (p *OperationLoadLiteralByLiteralIndexImmediate) EqualTo(o values.Value) bool
EqualTo returns true if both operations have the same literal index.
func (*OperationLoadLiteralByLiteralIndexImmediate) IsVoid ¶
func (p *OperationLoadLiteralByLiteralIndexImmediate) IsVoid() bool
IsVoid returns true if the operation is nil.
func (*OperationLoadLiteralByLiteralIndexImmediate) SchemeString ¶
func (p *OperationLoadLiteralByLiteralIndexImmediate) SchemeString() string
SchemeString returns the Scheme representation of the operation.
type OperationLoadLiteralInteger ¶
type OperationLoadLiteralInteger struct {
Value int64
}
func NewOperationLoadLiteralInteger ¶
func NewOperationLoadLiteralInteger(v int64) *OperationLoadLiteralInteger
func (*OperationLoadLiteralInteger) Apply ¶
func (p *OperationLoadLiteralInteger) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationLoadLiteralInteger) EqualTo ¶
func (p *OperationLoadLiteralInteger) EqualTo(o values.Value) bool
func (*OperationLoadLiteralInteger) IsVoid ¶
func (p *OperationLoadLiteralInteger) IsVoid() bool
func (*OperationLoadLiteralInteger) SchemeString ¶
func (p *OperationLoadLiteralInteger) SchemeString() string
type OperationLoadLocalByLocalIndexImmediate ¶
type OperationLoadLocalByLocalIndexImmediate struct {
LocalIndex *environment.LocalIndex
}
func NewOperationLoadLocalByLocalIndexImmediate ¶
func NewOperationLoadLocalByLocalIndexImmediate(li *environment.LocalIndex) *OperationLoadLocalByLocalIndexImmediate
func (*OperationLoadLocalByLocalIndexImmediate) Apply ¶
func (p *OperationLoadLocalByLocalIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationLoadLocalByLocalIndexImmediate) EqualTo ¶
func (p *OperationLoadLocalByLocalIndexImmediate) EqualTo(o values.Value) bool
func (*OperationLoadLocalByLocalIndexImmediate) IsVoid ¶
func (p *OperationLoadLocalByLocalIndexImmediate) IsVoid() bool
func (*OperationLoadLocalByLocalIndexImmediate) SchemeString ¶
func (p *OperationLoadLocalByLocalIndexImmediate) SchemeString() string
type OperationLoadVoid ¶
type OperationLoadVoid struct{}
func NewOperationLoadVoid ¶
func NewOperationLoadVoid() *OperationLoadVoid
func (*OperationLoadVoid) Apply ¶
func (p *OperationLoadVoid) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationLoadVoid) IsVoid ¶
func (p *OperationLoadVoid) IsVoid() bool
func (*OperationLoadVoid) SchemeString ¶
func (p *OperationLoadVoid) SchemeString() string
type OperationMakeCaseLambdaClosure ¶
type OperationMakeCaseLambdaClosure struct {
// contains filtered or unexported fields
}
OperationMakeCaseLambdaClosure creates a case-lambda closure from multiple closures. Stack layout (top to bottom): closure_n, closure_n-1, ..., closure_1 The closureCount immediate specifies how many closures to pop.
func NewOperationMakeCaseLambdaClosure ¶
func NewOperationMakeCaseLambdaClosure(closureCount int) *OperationMakeCaseLambdaClosure
func (*OperationMakeCaseLambdaClosure) Apply ¶
func (p *OperationMakeCaseLambdaClosure) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationMakeCaseLambdaClosure) EqualTo ¶
func (p *OperationMakeCaseLambdaClosure) EqualTo(o values.Value) bool
func (*OperationMakeCaseLambdaClosure) IsVoid ¶
func (p *OperationMakeCaseLambdaClosure) IsVoid() bool
func (*OperationMakeCaseLambdaClosure) SchemeString ¶
func (p *OperationMakeCaseLambdaClosure) SchemeString() string
type OperationMakeClosure ¶
type OperationMakeClosure struct{}
func NewOperationMakeClosure ¶
func NewOperationMakeClosure() *OperationMakeClosure
func (*OperationMakeClosure) Apply ¶
func (p *OperationMakeClosure) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationMakeClosure) IsVoid ¶
func (p *OperationMakeClosure) IsVoid() bool
func (*OperationMakeClosure) SchemeString ¶
func (p *OperationMakeClosure) SchemeString() string
type OperationPeekK ¶
type OperationPeekK struct {
Depth int
}
func NewOperationPeekK ¶
func NewOperationPeekK(depth int) *OperationPeekK
func (*OperationPeekK) Apply ¶
func (p *OperationPeekK) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPeekK) IsVoid ¶
func (p *OperationPeekK) IsVoid() bool
func (*OperationPeekK) SchemeString ¶
func (p *OperationPeekK) SchemeString() string
type OperationPop ¶
type OperationPop struct{}
func NewOperationPop ¶
func NewOperationPop() *OperationPop
func (*OperationPop) Apply ¶
func (*OperationPop) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPop) IsVoid ¶
func (p *OperationPop) IsVoid() bool
func (*OperationPop) SchemeString ¶
func (p *OperationPop) SchemeString() string
type OperationPopAll ¶
type OperationPopAll struct{}
func NewOperationPopAll ¶
func NewOperationPopAll() *OperationPopAll
func (*OperationPopAll) Apply ¶
func (*OperationPopAll) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPopAll) IsVoid ¶
func (p *OperationPopAll) IsVoid() bool
func (*OperationPopAll) SchemeString ¶
func (p *OperationPopAll) SchemeString() string
type OperationPopEnv ¶
type OperationPopEnv struct{}
OperationPopEnv unconditionally restores the parent environment. It pops one level from the environment chain (restoring the parent environment).
This is used in syntax-case fender evaluation to restore the environment when the fender returns false, before branching to the next clause.
func NewOperationPopEnv ¶
func NewOperationPopEnv() *OperationPopEnv
func (*OperationPopEnv) Apply ¶
func (p *OperationPopEnv) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationPopEnv) IsVoid ¶
func (p *OperationPopEnv) IsVoid() bool
func (*OperationPopEnv) SchemeString ¶
func (p *OperationPopEnv) SchemeString() string
func (*OperationPopEnv) String ¶
func (p *OperationPopEnv) String() string
type OperationPopWind ¶
type OperationPopWind struct{}
OperationPopWind pops the innermost dynamic-wind frame from the winding stack. This operation does NOT call the after thunk - that is done explicitly in the bytecode stream to ensure proper continuation semantics.
The frame is simply removed from the winding stack. If a continuation captured inside the dynamic extent is later restored, the RestoreWithWinding mechanism will handle running the appropriate before/after thunks.
R7RS §6.10: dynamic-wind establishes a dynamic extent during which the before and after thunks are called whenever control enters or exits.
func NewOperationPopWind ¶
func NewOperationPopWind() *OperationPopWind
func (*OperationPopWind) Apply ¶
func (*OperationPopWind) Apply(_ context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPopWind) IsVoid ¶
func (p *OperationPopWind) IsVoid() bool
func (*OperationPopWind) SchemeString ¶
func (*OperationPopWind) SchemeString() string
type OperationPull ¶
type OperationPull struct{}
func NewOperationPull ¶
func NewOperationPull() *OperationPull
func (*OperationPull) Apply ¶
func (*OperationPull) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPull) IsVoid ¶
func (p *OperationPull) IsVoid() bool
func (*OperationPull) SchemeString ¶
func (p *OperationPull) SchemeString() string
type OperationPush ¶
type OperationPush struct{}
func NewOperationPush ¶
func NewOperationPush() *OperationPush
func (*OperationPush) Apply ¶
func (*OperationPush) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPush) IsVoid ¶
func (p *OperationPush) IsVoid() bool
func (*OperationPush) SchemeString ¶
func (p *OperationPush) SchemeString() string
type OperationPushWind ¶
type OperationPushWind struct{}
OperationPushWind creates a dynamic-wind frame and pushes it onto the winding stack. It expects the stack to contain [before, thunk, after] where:
- before is at PeekK(2) - the before thunk
- thunk is at PeekK(1) - the main thunk (not used by this operation)
- after is at PeekK(0) - the after thunk
The frame is created from the before and after closures and pushed onto the winding stack. The stack is not modified.
R7RS §6.10: dynamic-wind establishes a dynamic extent during which the before and after thunks are called whenever control enters or exits.
func NewOperationPushWind ¶
func NewOperationPushWind() *OperationPushWind
func (*OperationPushWind) Apply ¶
func (*OperationPushWind) Apply(_ context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationPushWind) IsVoid ¶
func (p *OperationPushWind) IsVoid() bool
func (*OperationPushWind) SchemeString ¶
func (*OperationPushWind) SchemeString() string
type OperationRestoreContinuation ¶
type OperationRestoreContinuation struct{}
func NewOperationRestoreContinuation ¶
func NewOperationRestoreContinuation() *OperationRestoreContinuation
func (*OperationRestoreContinuation) Apply ¶
func (p *OperationRestoreContinuation) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationRestoreContinuation) EqualTo ¶
func (p *OperationRestoreContinuation) EqualTo(o values.Value) bool
func (*OperationRestoreContinuation) IsVoid ¶
func (p *OperationRestoreContinuation) IsVoid() bool
func (*OperationRestoreContinuation) SchemeString ¶
func (p *OperationRestoreContinuation) SchemeString() string
type OperationSaveContinuationOffsetImmediate ¶
type OperationSaveContinuationOffsetImmediate struct {
Offset int
}
func NewOperationSaveContinuationOffsetImmediate ¶
func NewOperationSaveContinuationOffsetImmediate(off int) *OperationSaveContinuationOffsetImmediate
func (*OperationSaveContinuationOffsetImmediate) Apply ¶
func (p *OperationSaveContinuationOffsetImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationSaveContinuationOffsetImmediate) EqualTo ¶
func (p *OperationSaveContinuationOffsetImmediate) EqualTo(o values.Value) bool
func (*OperationSaveContinuationOffsetImmediate) IsVoid ¶
func (p *OperationSaveContinuationOffsetImmediate) IsVoid() bool
func (*OperationSaveContinuationOffsetImmediate) SchemeString ¶
func (p *OperationSaveContinuationOffsetImmediate) SchemeString() string
type OperationStoreGlobalByGlobalIndexLiteralIndexImmediate ¶
type OperationStoreGlobalByGlobalIndexLiteralIndexImmediate struct {
LiteralIndex LiteralIndex
}
OperationStoreGlobalByGlobalIndexLiteralIndexImmediate stores a value to a global variable using an index from the literals pool.
func NewOperationStoreGlobalByGlobalIndexLiteralIndexImmediate ¶
func NewOperationStoreGlobalByGlobalIndexLiteralIndexImmediate(liti LiteralIndex) *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate
NewOperationStoreGlobalByGlobalIndexLiteralIndexImmediate creates a new global store operation.
func (*OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) Apply ¶
func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) EqualTo ¶
func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) EqualTo(o values.Value) bool
func (*OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) IsVoid ¶
func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) IsVoid() bool
func (*OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) SchemeString ¶
func (p *OperationStoreGlobalByGlobalIndexLiteralIndexImmediate) SchemeString() string
SchemeString returns the Scheme representation of the operation.
type OperationStoreLocalByLocalIndexImmediate ¶
type OperationStoreLocalByLocalIndexImmediate struct {
LocalIndex *environment.LocalIndex
}
func NewOperationStoreLocalByLocalIndexImmediate ¶
func NewOperationStoreLocalByLocalIndexImmediate(li *environment.LocalIndex) *OperationStoreLocalByLocalIndexImmediate
func (*OperationStoreLocalByLocalIndexImmediate) Apply ¶
func (p *OperationStoreLocalByLocalIndexImmediate) Apply(ctx context.Context, mc *MachineContext) (*MachineContext, error)
func (*OperationStoreLocalByLocalIndexImmediate) EqualTo ¶
func (p *OperationStoreLocalByLocalIndexImmediate) EqualTo(o values.Value) bool
func (*OperationStoreLocalByLocalIndexImmediate) IsVoid ¶
func (p *OperationStoreLocalByLocalIndexImmediate) IsVoid() bool
func (*OperationStoreLocalByLocalIndexImmediate) SchemeString ¶
func (p *OperationStoreLocalByLocalIndexImmediate) SchemeString() string
type OperationStoreSyntaxCaseInput ¶
type OperationStoreSyntaxCaseInput struct{}
OperationStoreSyntaxCaseInput stores the value register into the global currentSyntaxCaseInput for use by OperationSyntaxCaseMatch.
func NewOperationStoreSyntaxCaseInput ¶
func NewOperationStoreSyntaxCaseInput() *OperationStoreSyntaxCaseInput
func (*OperationStoreSyntaxCaseInput) Apply ¶
func (p *OperationStoreSyntaxCaseInput) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationStoreSyntaxCaseInput) EqualTo ¶
func (p *OperationStoreSyntaxCaseInput) EqualTo(other values.Value) bool
func (*OperationStoreSyntaxCaseInput) IsVoid ¶
func (p *OperationStoreSyntaxCaseInput) IsVoid() bool
func (*OperationStoreSyntaxCaseInput) SchemeString ¶
func (p *OperationStoreSyntaxCaseInput) SchemeString() string
func (*OperationStoreSyntaxCaseInput) String ¶
func (p *OperationStoreSyntaxCaseInput) String() string
type OperationSyntaxCaseMatch ¶
type OperationSyntaxCaseMatch struct{}
OperationSyntaxCaseMatch performs pattern matching for syntax-case.
Expects:
- wrt register: syntaxCaseClause with compiled pattern
- Top of eval stack: input syntax object
Results:
- If match succeeds: value register = #t, pattern bindings stored in context
- If match fails: value register = #f
func NewOperationSyntaxCaseMatch ¶
func NewOperationSyntaxCaseMatch() *OperationSyntaxCaseMatch
func (*OperationSyntaxCaseMatch) Apply ¶
func (p *OperationSyntaxCaseMatch) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationSyntaxCaseMatch) EqualTo ¶
func (p *OperationSyntaxCaseMatch) EqualTo(other values.Value) bool
func (*OperationSyntaxCaseMatch) IsVoid ¶
func (p *OperationSyntaxCaseMatch) IsVoid() bool
func (*OperationSyntaxCaseMatch) SchemeString ¶
func (p *OperationSyntaxCaseMatch) SchemeString() string
func (*OperationSyntaxCaseMatch) String ¶
func (p *OperationSyntaxCaseMatch) String() string
type OperationSyntaxCaseNoMatch ¶
type OperationSyntaxCaseNoMatch struct{}
OperationSyntaxCaseNoMatch is emitted at the end of syntax-case when no clause matches.
func NewOperationSyntaxCaseNoMatch ¶
func NewOperationSyntaxCaseNoMatch() *OperationSyntaxCaseNoMatch
func (*OperationSyntaxCaseNoMatch) Apply ¶
func (p *OperationSyntaxCaseNoMatch) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationSyntaxCaseNoMatch) EqualTo ¶
func (p *OperationSyntaxCaseNoMatch) EqualTo(other values.Value) bool
func (*OperationSyntaxCaseNoMatch) IsVoid ¶
func (p *OperationSyntaxCaseNoMatch) IsVoid() bool
func (*OperationSyntaxCaseNoMatch) SchemeString ¶
func (p *OperationSyntaxCaseNoMatch) SchemeString() string
func (*OperationSyntaxCaseNoMatch) String ¶
func (p *OperationSyntaxCaseNoMatch) String() string
type OperationSyntaxRulesTransform ¶
type OperationSyntaxRulesTransform struct{}
OperationSyntaxRulesTransform is a VM operation that performs macro expansion.
Execution context:
- wrt register: contains clausesWrapper with compiled pattern/template pairs
- Local parameter 0: contains the input form (the macro invocation)
The operation is part of the transformer closure created by CompileSyntaxRules.
func NewOperationSyntaxRulesTransform ¶
func NewOperationSyntaxRulesTransform() *OperationSyntaxRulesTransform
func (*OperationSyntaxRulesTransform) Apply ¶
func (p *OperationSyntaxRulesTransform) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationSyntaxRulesTransform) EqualTo ¶
func (p *OperationSyntaxRulesTransform) EqualTo(other values.Value) bool
func (*OperationSyntaxRulesTransform) IsVoid ¶
func (p *OperationSyntaxRulesTransform) IsVoid() bool
func (*OperationSyntaxRulesTransform) SchemeString ¶
func (p *OperationSyntaxRulesTransform) SchemeString() string
func (*OperationSyntaxRulesTransform) String ¶
func (p *OperationSyntaxRulesTransform) String() string
type OperationSyntaxTemplateExpand ¶
type OperationSyntaxTemplateExpand struct{}
OperationSyntaxTemplateExpand expands a syntax template using the current pattern variable bindings. This is used for templates containing ellipsis, which require runtime expansion rather than compile-time code generation.
The template is stored in the value register (loaded from literals). The result is the expanded syntax object, left in the value register.
func NewOperationSyntaxTemplateExpand ¶
func NewOperationSyntaxTemplateExpand() *OperationSyntaxTemplateExpand
func (*OperationSyntaxTemplateExpand) Apply ¶
func (p *OperationSyntaxTemplateExpand) Apply(ctx context.Context, mctx *MachineContext) (*MachineContext, error)
func (*OperationSyntaxTemplateExpand) EqualTo ¶
func (p *OperationSyntaxTemplateExpand) EqualTo(other values.Value) bool
func (*OperationSyntaxTemplateExpand) IsVoid ¶
func (p *OperationSyntaxTemplateExpand) IsVoid() bool
func (*OperationSyntaxTemplateExpand) SchemeString ¶
func (p *OperationSyntaxTemplateExpand) SchemeString() string
func (*OperationSyntaxTemplateExpand) String ¶
func (p *OperationSyntaxTemplateExpand) String() string
type Operations ¶
type Operations []Operation
func NewOperations ¶
func NewOperations(ops ...Operation) Operations
func (Operations) AsList ¶
func (p Operations) AsList() values.Tuple
func (Operations) Copy ¶
func (p Operations) Copy() Operations
func (Operations) IsVoid ¶
func (p Operations) IsVoid() bool
func (Operations) Len ¶
func (p Operations) Len() int
func (Operations) SchemeString ¶
func (p Operations) SchemeString() string
type Parameter ¶
type Parameter struct {
// contains filtered or unexported fields
}
Parameter represents an R7RS parameter object. Parameters are dynamically-scoped variables that can be temporarily rebound using parameterize. They act as procedures:
- (param) returns the current value
- (param val) sets the current value (after applying converter if present)
func NewParameter ¶
func NewParameter(init values.Value, converter *MachineClosure) *Parameter
NewParameter creates a new parameter with the given initial value and optional converter. The converter should be a procedure that takes one argument and returns the converted value. Pass nil for converter if no conversion is needed.
func (*Parameter) Converter ¶
func (p *Parameter) Converter() *MachineClosure
Converter returns the converter procedure, or nil if none.
func (*Parameter) EqualTo ¶
EqualTo uses identity comparison for parameters. Two parameters are equal only if they are the same object.
func (*Parameter) HasConverter ¶
HasConverter returns true if the parameter has a converter procedure.
func (*Parameter) SchemeString ¶
SchemeString returns the Scheme representation of the parameter.
type PhaseEntry ¶
PhaseEntry represents a named item to register in a phase environment.
type PrimitiveExpander ¶
type PrimitiveExpander struct {
// contains filtered or unexported fields
}
PrimitiveExpander wraps a PrimitiveExpanderFunc as a values.Value so it can be stored in the environment.
func LookupPrimitiveExpander ¶
func LookupPrimitiveExpander(env *environment.EnvironmentFrame, sym *values.Symbol, scopes []*syntax.Scope) *PrimitiveExpander
LookupPrimitiveExpander looks up a primitive expander by symbol in the expand environment. Returns the PrimitiveExpander if found, or nil if the symbol does not name a primitive expander.
This function handles hygiene by using scoped lookup - it will only match bindings whose scopes are a subset of the symbol's scopes.
func NewPrimitiveExpander ¶
func NewPrimitiveExpander(name string, fn PrimitiveExpanderFunc) *PrimitiveExpander
NewPrimitiveExpander creates a new primitive expander.
func (*PrimitiveExpander) EqualTo ¶
func (p *PrimitiveExpander) EqualTo(other values.Value) bool
EqualTo implements values.Value interface.
func (*PrimitiveExpander) Expand ¶
func (p *PrimitiveExpander) Expand( etc *ExpanderTimeContinuation, ectx ExpandTimeCallContext, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue, ) (syntax.SyntaxValue, error)
Expand invokes the primitive expander function.
func (*PrimitiveExpander) IsVoid ¶
func (p *PrimitiveExpander) IsVoid() bool
IsVoid implements values.Value interface.
func (*PrimitiveExpander) Name ¶
func (p *PrimitiveExpander) Name() string
Name returns the name of this primitive expander.
func (*PrimitiveExpander) SchemeString ¶
func (p *PrimitiveExpander) SchemeString() string
SchemeString implements values.Value interface.
type PrimitiveExpanderFunc ¶
type PrimitiveExpanderFunc func( etc *ExpanderTimeContinuation, ectx ExpandTimeCallContext, sym *syntax.SyntaxSymbol, expr syntax.SyntaxValue, ) (syntax.SyntaxValue, error)
PrimitiveExpanderFunc is the type for expand-time special form handlers. These functions handle macro expansion of primitive forms like `if`, `lambda`, `define`, `quote`, etc.
Parameters:
- etc: The expander-time continuation (expander state)
- ectx: The expand-time call context
- sym: The keyword symbol (e.g., 'if', 'lambda')
- expr: The expression arguments (everything after the keyword)
Returns the expanded syntax value.
type PromptTag ¶
type PromptTag struct {
// contains filtered or unexported fields
}
PromptTag is an opaque identity value for delimited continuation prompts. Equality is pointer identity (each tag is unique). Follows the Racket model of continuation prompt tags.
See: Flatt, Yu, Findler, Felleisen "Adding Delimited and Composable Control to a Production Programming Environment" (ICFP 2007).
func NewPromptTag ¶
NewPromptTag creates a new prompt tag with an optional name for debugging.
func (*PromptTag) SchemeString ¶
type SchemeError ¶
type SchemeError struct {
Message string
Source *syntax.SourceContext // Where error occurred
StackTrace string // Formatted stack trace
Cause error // Underlying error (if any)
}
SchemeError is a runtime error with Scheme-level stack trace.
func NewSchemeError ¶
func NewSchemeError(msg string, source *syntax.SourceContext, stackTrace string) *SchemeError
func NewSchemeErrorWithCause ¶
func NewSchemeErrorWithCause(msg string, source *syntax.SourceContext, stackTrace string, cause error) *SchemeError
func (*SchemeError) EqualTo ¶
func (p *SchemeError) EqualTo(o values.Value) bool
EqualTo compares for equality.
func (*SchemeError) Error ¶
func (p *SchemeError) Error() string
func (*SchemeError) IsVoid ¶
func (p *SchemeError) IsVoid() bool
IsVoid returns false (errors are not void).
func (*SchemeError) SchemeString ¶
func (p *SchemeError) SchemeString() string
SchemeString returns the Scheme representation.
func (*SchemeError) Unwrap ¶
func (p *SchemeError) Unwrap() error
type Stack ¶
func (Stack) AsList ¶
AsList converts the stack to a Scheme list (values.Tuple). The list is in stack order (first pushed = first element).
func (Stack) PeekK ¶
PeekK returns the kth value from the top of the stack without removing it. `K` is zero-based, so PeekK(0) returns the top value. `K` is used for methods that need a numeric index.
func (Stack) SchemeString ¶
SchemeString returns a Scheme-like string representation of the stack.
type StackFrame ¶
type StackFrame struct {
FunctionName string // Function name (or "<anonymous>")
CallSite *syntax.SourceContext // Where the call was made
CurrentLoc *syntax.SourceContext // Current execution point
}
StackFrame represents one frame in a Scheme stack trace.
func (*StackFrame) String ¶
func (p *StackFrame) String() string
String formats the frame for display.
type StackTrace ¶
type StackTrace []StackFrame
StackTrace is a list of stack frames.
func (StackTrace) String ¶
func (p StackTrace) String() string
String formats the entire stack trace.
type SyntaxCompiler ¶
type SyntaxCompiler struct {
// contains filtered or unexported fields
}
SyntaxCompiler wraps a SyntaxCompilerFunc as a values.Value so it can be stored in the environment.
func LookupSyntaxCompiler ¶
func LookupSyntaxCompiler(env *environment.EnvironmentFrame, sym *values.Symbol, scopes []*syntax.Scope) *SyntaxCompiler
LookupSyntaxCompiler looks up a syntax compiler by symbol in the compile environment. Returns the SyntaxCompiler if found, or nil if the symbol does not name a syntax compiler.
This function handles hygiene by using scoped lookup - it will only match bindings whose scopes are a subset of the symbol's scopes.
func NewSyntaxCompiler ¶
func NewSyntaxCompiler(name string, fn SyntaxCompilerFunc) *SyntaxCompiler
NewSyntaxCompiler creates a new syntax compiler.
func (*SyntaxCompiler) Compile ¶
func (p *SyntaxCompiler) Compile(ctc *CompileTimeContinuation, ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
Compile invokes the syntax compiler function.
func (*SyntaxCompiler) EqualTo ¶
func (p *SyntaxCompiler) EqualTo(other values.Value) bool
EqualTo implements values.Value interface.
func (*SyntaxCompiler) IsVoid ¶
func (p *SyntaxCompiler) IsVoid() bool
IsVoid implements values.Value interface.
func (*SyntaxCompiler) Name ¶
func (p *SyntaxCompiler) Name() string
Name returns the name of this syntax compiler.
func (*SyntaxCompiler) SchemeString ¶
func (p *SyntaxCompiler) SchemeString() string
SchemeString implements values.Value interface.
type SyntaxCompilerFunc ¶
type SyntaxCompilerFunc func(ctc *CompileTimeContinuation, ctctx CompileTimeCallContext, expr syntax.SyntaxValue) error
SyntaxCompilerFunc is the type for compile-time special form handlers. These functions handle syntax-directed compilation of special forms like `define`, `lambda`, `if`, `quote`, etc.
Parameters:
- ctc: The compile-time continuation (compiler state)
- ctctx: The compile-time call context (tail position info, etc.)
- expr: The expression arguments (everything after the keyword)
The function should emit operations to ctc.template and return nil on success.
type SyntaxRulesClause ¶
type SyntaxRulesClause struct {
// contains filtered or unexported fields
}
SyntaxRulesClause represents a single pattern-template pair in syntax-rules.
Per R7RS, a syntax-rules form contains:
(syntax-rules (literal ...) clause ...) (syntax-rules <ellipsis> (literal ...) clause ...) ; with custom ellipsis
where each clause is (pattern template).
The pattern is compiled to bytecode for efficient matching. The template is stored as-is and expanded by substituting captured pattern variables.
The macroScope field supports hygiene: when the transformer runs, it creates a fresh "intro scope" that marks all identifiers introduced by the macro. This prevents variable capture between the macro and its use site.
type VMCounters ¶ added in v1.1.0
type VMCounters struct {
OpsExecuted uint64
ClosuresApplied uint64
EnvsCopied uint64
BindingsCopied uint64
ContinuationsSaved uint64
ContinuationsRestored uint64
StackPopAlls uint64
StackElementsCopied uint64
ForeignCalls uint64
SubContextsCreated uint64
}
VMCounters holds performance counters for a single MachineContext execution. All counters are plain uint64 — no atomics needed because each MachineContext is single-goroutine. Sub-contexts have their own counters (not aggregated into the parent).
func (VMCounters) String ¶ added in v1.1.0
func (c VMCounters) String() string
String returns a tabular summary of all counters.
type WindingStack ¶
type WindingStack []*DynamicWindFrame
WindingStack tracks the current dynamic-wind context. It's a slice of frames from outermost to innermost.
func (WindingStack) Copy ¶
func (p WindingStack) Copy() WindingStack
Copy creates a shallow copy of the winding stack.
func (WindingStack) Depth ¶
func (p WindingStack) Depth() int
Depth returns the number of active dynamic-wind frames.
func (*WindingStack) Pop ¶
func (p *WindingStack) Pop() *DynamicWindFrame
Pop removes the innermost frame from the winding stack.
func (*WindingStack) Push ¶
func (p *WindingStack) Push(frame *DynamicWindFrame)
Push adds a frame to the winding stack.
Source Files
¶
- case_lambda_closure.go
- compile_begin_for_syntax.go
- compile_define_for_syntax.go
- compile_eval_when.go
- compile_quasisyntax.go
- compile_syntax_case.go
- compile_syntax_form.go
- compile_syntax_rules.go
- compile_time_call_context.go
- compile_time_continuation.go
- compile_transformer.go
- compile_validated.go
- compile_with_syntax.go
- composable_continuation.go
- counters.go
- debugger.go
- doc.go
- dynamic_wind.go
- exception_escape.go
- exception_handler.go
- expand_time_call_context.go
- expander_context.go
- expander_time_continuation.go
- features.go
- import_set_datum.go
- library.go
- library_loader.go
- machine_closure.go
- machine_context.go
- machine_continuation.go
- multiple_values.go
- native_template.go
- operation.go
- operation_apply.go
- operation_branch_offset_immediate.go
- operation_branch_on_false_offset_immediate.go
- operation_branch_on_not_false_offset_immediate.go
- operation_brk.go
- operation_build_syntax.go
- operation_drop.go
- operation_foreign_function_call.go
- operation_helpers.go
- operation_load_global_by_global_index_literal_index_immediate.go
- operation_load_literal_by_literal_index_immediate.go
- operation_load_literal_integer.go
- operation_load_local_by_local_index_immediate.go
- operation_load_void.go
- operation_make_case_lambda_closure.go
- operation_make_closure.go
- operation_peek_m.go
- operation_pop.go
- operation_pop_all.go
- operation_pop_env.go
- operation_pop_wind.go
- operation_pull.go
- operation_push.go
- operation_push_wind.go
- operation_restore_continuation.go
- operation_save_continuation_offset_immediate.go
- operation_store_global_by_global_index_literal_index_immediate.go
- operation_store_local_by_local_index_immediate.go
- operation_syntax_case.go
- operation_syntax_rules_transform.go
- operations.go
- parameter.go
- phase_registry.go
- primitive_expander.go
- primitive_expanders_registry.go
- prompt_abort.go
- prompt_tag.go
- register.go
- scheme_error.go
- stack.go
- stack_frame.go
- syntax_compiler.go
- syntax_compilers_registry.go
- util.go