Documentation
¶
Overview ¶
Package runtime implements the Vibescript execution engine — the Engine, Script, Execution, environment, memory accounting, module loader, and built-in registration. It is hidden from external embedders behind the vibes facade.
Index ¶
- Constants
- func AssignDestructure(target *DestructureTarget, value Value, assign func(Expression, Value) error) error
- func MemberCompletionNames() map[string][]string
- type AliasStmt
- type ArrayLiteral
- type AssignStmt
- type BinaryExpr
- type Block
- type BlockLiteral
- type BoolLiteral
- type BreakStmt
- type Builtin
- type BuiltinFunc
- type CallExpr
- type CallOptions
- type CapabilityAdapter
- func MustNewContextCapability(name string, resolver ContextCapabilityResolver) CapabilityAdapter
- func MustNewDBCapability(name string, impl Database) CapabilityAdapter
- func MustNewEventsCapability(name string, publisher EventPublisher) CapabilityAdapter
- func MustNewJobQueueCapability(name string, impl JobQueue) CapabilityAdapter
- func NewContextCapability(name string, resolver ContextCapabilityResolver) (CapabilityAdapter, error)
- func NewDBCapability(name string, impl Database) (CapabilityAdapter, error)
- func NewEventsCapability(name string, publisher EventPublisher) (CapabilityAdapter, error)
- func NewJobQueueCapability(name string, impl JobQueue) (CapabilityAdapter, error)
- type CapabilityBinding
- type CapabilityContractProvider
- type CapabilityMethodContract
- type CaseExpr
- type CaseWhenClause
- type CheckWarning
- type ClassDef
- type ClassStmt
- type ClassVarExpr
- type ConditionalExpr
- type Config
- type ContextCapabilityResolver
- type DBEachRequest
- type DBFindRequest
- type DBQueryRequest
- type DBSumRequest
- type DBUpdateRequest
- type Database
- type DatabaseReader
- type DatabaseWriter
- type DestructureElement
- type DestructureTarget
- type Duration
- type Engine
- func (e *Engine) Builtins() map[string]Value
- func (e *Engine) ClearModuleCache() int
- func (e *Engine) Compile(source string) (*Script, error)
- func (e *Engine) CompileSnippet(source, entrypoint string) (*Script, error)
- func (e *Engine) ConfigSummary() string
- func (e *Engine) Execute(ctx context.Context, script string) error
- func (e *Engine) MaxSourceBytes() int
- func (e *Engine) RegisterBuiltin(name string, fn BuiltinFunc)
- func (e *Engine) RegisterZeroArgBuiltin(name string, fn BuiltinFunc)
- type EnumDef
- type EnumMemberStmt
- type EnumStmt
- type EnumValueDef
- type Env
- func (e *Env) Assign(name string, val Value) bool
- func (e *Env) CloneShallow() *Env
- func (e *Env) Define(name string, val Value)
- func (e *Env) DefineStatic(name string, val Value)
- func (e *Env) Get(name string) (Value, bool)
- func (e *Env) PredeclareAssignmentLocal(name string)
- func (e *Env) PredeclareLocal(name string)
- type EqualityContext
- type EventPublishRequest
- type EventPublisher
- type Execution
- type ExprStmt
- type Expression
- type FloatLiteral
- type ForStmt
- type FunctionStmt
- type HashEntry
- type HashLiteral
- type HashLookupKey
- type HashPair
- type Identifier
- type IfExpr
- type IfExprBranch
- type IfStmt
- type IndexExpr
- type Instance
- type IntegerLiteral
- type InterpolatedString
- type InterpolatedSymbol
- type IvarExpr
- type JobQueue
- type JobQueueEnqueueOptions
- type JobQueueJob
- type JobQueueRetryRequest
- type JobQueueWithRetry
- type KeywordArg
- type LogicalStmt
- type MemberExpr
- type Money
- type NextStmt
- type NilLiteral
- type Node
- type Param
- type ParamKind
- type ParseIssue
- type Position
- type Program
- type PropertyDecl
- type RaiseStmt
- type Range
- type RangeExpr
- type RegexLiteral
- type RescueClause
- type RescueExpr
- type RetryStmt
- type ReturnStmt
- type RuntimeError
- type ScopeExpr
- type Script
- func (s *Script) Call(ctx context.Context, name string, args []Value, opts CallOptions) (Value, error)
- func (s *Script) CheckOrderIndependentWarnings() []CheckWarning
- func (s *Script) CheckWarnings() []CheckWarning
- func (s *Script) CheckWarningsForCall(name string, args []Value, opts CallOptions) []CheckWarning
- func (s *Script) CheckWarningsForFunction(name string) []CheckWarning
- func (s *Script) CheckWarningsForFunctionWithOptions(name string, opts CallOptions) []CheckWarning
- func (s *Script) CheckWarningsWithOptions(opts CallOptions) []CheckWarning
- func (s *Script) Classes() []*ClassDef
- func (s *Script) Enums() []*EnumDef
- func (s *Script) Function(name string) (*ScriptFunction, bool)
- func (s *Script) Functions() []*ScriptFunction
- type ScriptFunction
- type SplatArg
- type StackFrame
- type Statement
- type StringExpr
- type StringLiteral
- type StringPart
- type StringText
- type SymbolLiteral
- type Token
- type TokenType
- type TryStmt
- type TypeExpr
- type TypeKind
- type TypedHashEntry
- type UnaryExpr
- type UntilStmt
- type Value
- func NewArray(a []Value) Value
- func NewAutoBuiltin(name string, fn BuiltinFunc) Value
- func NewBlock(params []Param, body []Statement, env *Env) Value
- func NewBool(b bool) Value
- func NewBuiltin(name string, fn BuiltinFunc) Value
- func NewCapturingBuiltin(name string, fn BuiltinFunc, captured ...Value) Value
- func NewClass(def *ClassDef) Value
- func NewDuration(d Duration) Value
- func NewEnum(def *EnumDef) Value
- func NewEnumValue(def *EnumValueDef) Value
- func NewFloat(f float64) Value
- func NewFunction(fn *ScriptFunction) Value
- func NewHash(h map[string]Value) Value
- func NewHashWithDefault(h map[string]Value, defaultValue, defaultProc Value) Value
- func NewInstance(inst *Instance) Value
- func NewInt(i int64) Value
- func NewMoney(m Money) Value
- func NewNil() Value
- func NewObject(attrs map[string]Value) Value
- func NewRange(r Range) Value
- func NewRegex(r value.Regex) Value
- func NewString(s string) Value
- func NewSymbol(name string) Value
- func NewTime(t time.Time) Value
- func NewTypedHash(capacity int) Value
- type ValueKind
- type WhileStmt
- type YieldExpr
Constants ¶
const ( ParamNormal = ast.ParamNormal ParamKeyword = ast.ParamKeyword ParamRest = ast.ParamRest ParamKeywordRest = ast.ParamKeywordRest ParamBlock = ast.ParamBlock )
const ( TypeAny = ast.TypeAny TypeInt = ast.TypeInt TypeFloat = ast.TypeFloat TypeNumber = ast.TypeNumber TypeString = ast.TypeString TypeBool = ast.TypeBool TypeNil = ast.TypeNil TypeDuration = ast.TypeDuration TypeTime = ast.TypeTime TypeMoney = ast.TypeMoney TypeArray = ast.TypeArray TypeHash = ast.TypeHash TypeRange = ast.TypeRange TypeSymbol = ast.TypeSymbol TypeFunction = ast.TypeFunction TypeShape = ast.TypeShape TypeUnion = ast.TypeUnion TypeEnum = ast.TypeEnum TypeUnknown = ast.TypeUnknown )
const ( KindNil = value.KindNil KindBool = value.KindBool KindInt = value.KindInt KindFloat = value.KindFloat KindString = value.KindString KindArray = value.KindArray KindHash = value.KindHash KindFunction = value.KindFunction KindBuiltin = value.KindBuiltin KindMoney = value.KindMoney KindDuration = value.KindDuration KindTime = value.KindTime KindSymbol = value.KindSymbol KindObject = value.KindObject KindRange = value.KindRange KindBlock = value.KindBlock KindEnum = value.KindEnum KindEnumValue = value.KindEnumValue KindClass = value.KindClass KindInstance = value.KindInstance KindRegex = value.KindRegex )
Variables ¶
This section is empty.
Functions ¶
func AssignDestructure ¶ added in v0.60.0
func AssignDestructure(target *DestructureTarget, value Value, assign func(Expression, Value) error) error
AssignDestructure applies Vibescript's destructuring assignment rules and invokes assign for each concrete leaf target. It is the host-facing entry point used by tools that walk destructuring targets without a sandboxed Execution (such as the REPL extracting bound names from a result); it never charges memory because those callers run outside a quota. Sandboxed evaluation goes through Execution.assignDestructure, which charges every fresh slot array (the right-hand-side snapshot and any named rest window) against the memory quota before it is allocated.
func MemberCompletionNames ¶ added in v0.50.0
MemberCompletionNames returns the builtin member-method names per receiver type, for editor tooling such as LSP completion. The slices are copies; callers may sort or mutate them freely. Each type's list includes the universal Object-level helpers (itself, nil?, eql?, equal?, tap, yield_self) and the introspection predicates (respond_to?, is_a?, kind_of?, instance_of?), which resolve on every value through resolveMember's fallback even though they live outside the per-kind dispatch switches.
Types ¶
type ArrayLiteral ¶
type ArrayLiteral = ast.ArrayLiteral
type AssignStmt ¶
type AssignStmt = ast.AssignStmt
type BinaryExpr ¶
type BinaryExpr = ast.BinaryExpr
type Block ¶
type Block struct {
Params []Param
ImplicitParams []string
Body []Statement
Env *Env
// contains filtered or unexported fields
}
Block represents a closure passed to a function at runtime. It stays in the vibes package because its fields reference parser AST and the runtime Env/Script types.
func (*Block) ValueBlockMarker ¶
func (*Block) ValueBlockMarker()
type BlockLiteral ¶
type BlockLiteral = ast.BlockLiteral
type BoolLiteral ¶
type BoolLiteral = ast.BoolLiteral
type Builtin ¶
type Builtin struct {
Name string
Fn BuiltinFunc
AutoInvoke bool
// OptionsHashTarget receives a collapsed keyword options hash for builtin
// wrappers around script functions (method, constructor, and function-call
// alias callers).
OptionsHashTarget *ScriptFunction
// DirectCallAlias marks a builtin that invokes a function value directly,
// such as the `call` member exposed on function values. Direct-call aliases
// follow plain function-call semantics, so they collapse a parenthesized
// keyword options hash just like `fn(...)`. Method and constructor wrappers
// leave this false to keep parenthesized keyword binding strict.
DirectCallAlias bool
// DirectCallAliasPos is the source position attached to the member access
// that created a direct-call alias. Rebinding an escaped alias rebuilds its
// closure around the live callable and preserves this position for diagnostics.
DirectCallAliasPos Position
// CapturedValues holds runtime values the builtin's Fn closes over and keeps
// alive for as long as the builtin is reachable. The memory estimator charges
// their payloads so a stored bound builtin (for example `probe = big.eql?`,
// which captures its receiver) cannot retain arbitrarily large structures
// outside the runtime memory quota. Builtins that close over no runtime values
// leave this nil and stay free, as before.
CapturedValues []Value
// BoundReceiver, when non-nil, marks the builtin a receiver-bound predicate (a
// bound eql?/equal?) and exposes a two-phase clone. The universal predicates
// read the value they were resolved from through a mutable cell, so a plain
// clone of the Fn keeps comparing against the pre-clone receiver. When
// Script.Call host-clones a returned graph (or re-roots an inbound one) that
// holds both a receiver and a predicate bound to it, the clone walk reserves an
// empty clone, registers it, recurses to clone the receiver, then installs the
// cloned receiver via this hook. Reserving before recursing keeps a receiver
// graph that reaches the predicate bound to it (for example `[p, a]` where `a`
// stores `p = a.eql?`) deduplicated to one clone, so a re-entering
// `probe(clonedReceiver)` still reports identity. Builtins with no bound
// receiver leave this nil.
BoundReceiver *boundReceiverClone
// Capability marks a builtin a capability adapter exposed for a single
// Script.Call. Capability grants are per call: when a closure that captured
// one (for example a `Hash.new { ... }` default proc copying a capability
// into a local) escapes and re-enters a later call, the inbound rebinder
// revokes the captured grant so a missing-key lookup cannot invoke a
// capability the re-entering call never granted.
Capability bool
}
Builtin represents a built-in function callable from Vibescript. It remains defined in the vibes package because BuiltinFunc references the runtime *Execution type.
func (*Builtin) ValueBuiltinMarker ¶
func (*Builtin) ValueBuiltinMarker()
type BuiltinFunc ¶
type BuiltinFunc func(exec *Execution, receiver Value, args []Value, kwargs map[string]Value, block Value) (Value, error)
BuiltinFunc is the Go function signature for built-in Vibescript functions.
type CallOptions ¶
type CallOptions struct {
Globals map[string]Value
Capabilities []CapabilityAdapter
AllowRequire bool
Keywords map[string]Value
}
CallOptions configures globals, capabilities, and other settings for a script invocation.
type CapabilityAdapter ¶
type CapabilityAdapter interface {
Bind(binding CapabilityBinding) (map[string]Value, error)
}
CapabilityAdapter binds host capabilities into a script invocation.
func MustNewContextCapability ¶
func MustNewContextCapability(name string, resolver ContextCapabilityResolver) CapabilityAdapter
MustNewContextCapability is the panicking variant of NewContextCapability.
func MustNewDBCapability ¶
func MustNewDBCapability(name string, impl Database) CapabilityAdapter
MustNewDBCapability is the panicking variant of NewDBCapability.
func MustNewEventsCapability ¶
func MustNewEventsCapability(name string, publisher EventPublisher) CapabilityAdapter
MustNewEventsCapability is the panicking variant of NewEventsCapability.
func MustNewJobQueueCapability ¶
func MustNewJobQueueCapability(name string, impl JobQueue) CapabilityAdapter
MustNewJobQueueCapability is the panicking variant of NewJobQueueCapability.
func NewContextCapability ¶
func NewContextCapability(name string, resolver ContextCapabilityResolver) (CapabilityAdapter, error)
NewContextCapability constructs a data-only context capability adapter that bridges a contextcap.Resolver into the runtime CapabilityAdapter interface. The vibes facade re-exports this entry point under the same name.
func NewDBCapability ¶
func NewDBCapability(name string, impl Database) (CapabilityAdapter, error)
NewDBCapability constructs a database capability adapter bound to the provided script-facing name. The vibes facade re-exports this entry point under the same name.
func NewEventsCapability ¶
func NewEventsCapability(name string, publisher EventPublisher) (CapabilityAdapter, error)
NewEventsCapability constructs a CapabilityAdapter that delegates to a *events.Capability. The vibes facade re-exports this entry point under the same name.
func NewJobQueueCapability ¶
func NewJobQueueCapability(name string, impl JobQueue) (CapabilityAdapter, error)
NewJobQueueCapability constructs a CapabilityAdapter that delegates to a *jobqueue.Capability. It is the runtime-facing entry point used by the vibes facade.
type CapabilityBinding ¶
CapabilityBinding provides execution context for adapters during binding.
type CapabilityContractProvider ¶
type CapabilityContractProvider interface {
CapabilityContracts() map[string]CapabilityMethodContract
}
CapabilityContractProvider exposes per-method contracts for capability adapters. Contract keys must match builtin method names exposed to scripts (for example "jobs.enqueue").
type CapabilityMethodContract ¶
type CapabilityMethodContract struct {
ValidateArgs func(args []Value, kwargs map[string]Value, block Value) error
// ReturnValidatedByBuiltin means the builtin returns a script-safe value
// that has already been validated and isolated from host-owned state.
ReturnValidatedByBuiltin bool
ValidateReturn func(result Value) error
}
CapabilityMethodContract validates capability method calls at the boundary. These contracts run before and after a capability builtin executes.
type CaseWhenClause ¶
type CaseWhenClause = ast.CaseWhenClause
type CheckWarning ¶ added in v0.60.0
CheckWarning describes a statically checkable contract issue.
type ClassDef ¶
type ClassDef struct {
Name string
IsModule bool
Methods map[string]*ScriptFunction
ClassMethods map[string]*ScriptFunction
ClassVars map[string]Value
// NestedModules lists the short names of module declarations nested in
// this definition's body. The compiled definitions are registered under
// the qualified name (Name + "::" + short) and linked into ClassVars per
// call so Outer::Inner resolves like any other scoped constant.
NestedModules []string
// IncludedModules lists the qualified names of modules mixed in with
// include — the full transitive closure, so a module reached through
// another include is listed too — in precedence order from lowest to
// highest (earlier include directives before later ones; within one
// directive, later arguments before earlier ones; a module's own
// includes before the module itself, matching Ruby's ancestor
// ordering). Their constants are adopted into ClassVars in this order
// before the class body runs, and is_a? reports instances as belonging
// to them.
IncludedModules []string
Body []Statement
// contains filtered or unexported fields
}
ClassDef represents a user-defined class or module with its methods and class-level state. Module declarations (`module Name ... end`) compile to a ClassDef with IsModule set: Methods holds instance-style methods that include copies into classes, ClassMethods holds `def self.` module functions (`Billing.code`), and ClassVars holds module constants (`Billing::LIMIT`). Modules cannot be instantiated.
func ClassOf ¶
ClassOf returns the *ClassDef stored in v, or nil if v is not a class value. It is the typed companion to v.Class(), which returns the value.ClassPayload interface for cycle-free reach from outside vibes.
func (*ClassDef) ValueClassMarker ¶
func (*ClassDef) ValueClassMarker()
type ClassVarExpr ¶
type ClassVarExpr = ast.ClassVarExpr
type ConditionalExpr ¶ added in v0.60.0
type ConditionalExpr = ast.ConditionalExpr
type Config ¶
type Config struct {
StepQuota int
MemoryQuotaBytes int
StrictEffects bool
RecursionLimit int
ModulePaths []string
ModuleAllowList []string
ModuleDenyList []string
RandomReader io.Reader
RandomReadFunc func(context.Context, []byte) (int, error)
OutputWriter io.Writer
ErrorWriter io.Writer
MaxCachedModules int
MaxSourceBytes int
DefaultTaskConcurrency int
MaxTaskConcurrency int
}
Config controls interpreter execution bounds and enforcement modes.
type ContextCapabilityResolver ¶
type ContextCapabilityResolver = contextcap.Resolver
ContextCapabilityResolver is an internal alias for contextcap.Resolver so runtime code (and tests) can keep using the short name that matches the public vibes facade.
type DBEachRequest ¶
type DBEachRequest = db.DBEachRequest
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DBFindRequest ¶
type DBFindRequest = db.DBFindRequest
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DBQueryRequest ¶
type DBQueryRequest = db.DBQueryRequest
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DBSumRequest ¶
type DBSumRequest = db.DBSumRequest
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DBUpdateRequest ¶
type DBUpdateRequest = db.DBUpdateRequest
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type Database ¶
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DatabaseReader ¶
type DatabaseReader = db.DatabaseReader
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DatabaseWriter ¶
type DatabaseWriter = db.DatabaseWriter
Internal aliases for db capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type DestructureElement ¶ added in v0.60.0
type DestructureElement = ast.DestructureElement
type DestructureTarget ¶ added in v0.60.0
type DestructureTarget = ast.DestructureTarget
type Duration ¶
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine executes Vibescript programs with deterministic limits.
func MustNewEngine ¶
MustNewEngine constructs an Engine or panics if the config is invalid.
func (*Engine) ClearModuleCache ¶
ClearModuleCache drops all cached modules and returns the number of entries removed. Long-running hosts can call this between script runs to force fresh module reloads.
func (*Engine) CompileSnippet ¶ added in v0.60.0
CompileSnippet compiles source as an inline snippet. Top-level declarations remain top-level, while executable top-level statements are moved into a synthetic entrypoint function so callers can invoke the snippet through the same Script.Call contract as ordinary scripts.
func (*Engine) ConfigSummary ¶
ConfigSummary provides a human-readable description of the interpreter limits.
func (*Engine) Execute ¶
Execute compiles the provided source ensuring it is valid under current config.
func (*Engine) MaxSourceBytes ¶ added in v0.60.0
MaxSourceBytes reports the effective source-size limit, in bytes, applied before parsing. The value reflects the configured limit after defaults are resolved, so callers can reject oversized inputs before reading them.
func (*Engine) RegisterBuiltin ¶
func (e *Engine) RegisterBuiltin(name string, fn BuiltinFunc)
RegisterBuiltin registers a callable global available to scripts.
func (*Engine) RegisterZeroArgBuiltin ¶
func (e *Engine) RegisterZeroArgBuiltin(name string, fn BuiltinFunc)
RegisterZeroArgBuiltin registers a builtin that can be invoked without arguments or parentheses.
type EnumDef ¶
type EnumDef struct {
Name string
Members map[string]*EnumValueDef
MembersByKey map[string]*EnumValueDef
Order []string
// contains filtered or unexported fields
}
EnumDef represents a user-defined enumeration with named members.
func (*EnumDef) ValueEnumMarker ¶
func (*EnumDef) ValueEnumMarker()
type EnumMemberStmt ¶
type EnumMemberStmt = ast.EnumMemberStmt
type EnumValueDef ¶
EnumValueDef represents a single member within an EnumDef.
func EnumValueOf ¶
func EnumValueOf(v Value) *EnumValueDef
EnumValueOf returns the *EnumValueDef stored in v, or nil.
func (*EnumValueDef) ValueEnumValueMarker ¶
func (*EnumValueDef) ValueEnumValueMarker()
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env represents a lexical scope that maps variable names to values.
Bindings live in two stores: inline holds small normal script scopes without a map allocation, values holds larger normal script scopes, and statics holds bindings whose deep size never changes after definition (builtins, per-call function clones). Statics are stored separately so memory-quota estimation can account for them in O(1) through the staticBytes counter instead of re-walking every binding on each check -- the root env's builtin set dominated estimation cost otherwise.
func (*Env) Assign ¶
Assign updates an existing variable in the nearest enclosing scope. Names not bound anywhere are defined in the outermost mutable scope, and names found in a frozen scope rebind in the nearest mutable scope below it, so engine-shared bindings are never written.
func (*Env) CloneShallow ¶
CloneShallow returns a copy of the environment with the same parent and a shallow copy of its bindings.
func (*Env) DefineStatic ¶ added in v0.40.0
DefineStatic binds a variable whose deep size is fixed at definition time, keeping it out of the per-check estimation walk.
func (*Env) PredeclareAssignmentLocal ¶ added in v0.60.0
func (*Env) PredeclareLocal ¶ added in v0.60.0
type EqualityContext ¶ added in v0.60.0
type EqualityContext = value.EqualityContext
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type EventPublishRequest ¶
type EventPublishRequest = events.PublishRequest
Internal aliases for events capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type EventPublisher ¶
Internal aliases for events capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type Execution ¶
type Execution struct {
// contains filtered or unexported fields
}
Execution holds the runtime state for a single script evaluation.
func (*Execution) CallBlock ¶
CallBlock invokes a block value with the provided arguments. This is the public entry point for capability adapters that need to call user-supplied blocks (e.g. db.each, db.tx).
func (*Execution) Context ¶
Context returns the execution's bound context. Capability adapters that have been carved into sibling packages (vibes/capability/...) rely on it to forward cancellation and request-scoped values to host callbacks without reaching into unexported runtime fields.
type Expression ¶
type Expression = ast.Expression
type FloatLiteral ¶
type FloatLiteral = ast.FloatLiteral
type FunctionStmt ¶
type FunctionStmt = ast.FunctionStmt
type HashEntry ¶ added in v0.60.0
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type HashLiteral ¶
type HashLiteral = ast.HashLiteral
type HashLookupKey ¶
type HashLookupKey = value.HashLookupKey
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type Identifier ¶
type Identifier = ast.Identifier
type IfExprBranch ¶ added in v0.60.0
type IfExprBranch = ast.IfExprBranch
type Instance ¶
Instance represents a runtime instance of a ClassDef with its own instance variables.
func InstanceOf ¶
InstanceOf returns the *Instance stored in v, or nil.
func (*Instance) ValueInstanceMarker ¶
func (*Instance) ValueInstanceMarker()
type IntegerLiteral ¶
type IntegerLiteral = ast.IntegerLiteral
type InterpolatedString ¶
type InterpolatedString = ast.InterpolatedString
type InterpolatedSymbol ¶ added in v0.60.0
type InterpolatedSymbol = ast.InterpolatedSymbol
type JobQueue ¶
Internal aliases for jobqueue capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type JobQueueEnqueueOptions ¶
type JobQueueEnqueueOptions = jobqueue.JobQueueEnqueueOptions
Internal aliases for jobqueue capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type JobQueueJob ¶
type JobQueueJob = jobqueue.JobQueueJob
Internal aliases for jobqueue capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type JobQueueRetryRequest ¶
type JobQueueRetryRequest = jobqueue.JobQueueRetryRequest
Internal aliases for jobqueue capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type JobQueueWithRetry ¶
type JobQueueWithRetry = jobqueue.JobQueueWithRetry
Internal aliases for jobqueue capability types so runtime code (and tests) can keep referring to short names that match the public vibes facade.
type KeywordArg ¶
type KeywordArg = ast.KeywordArg
type LogicalStmt ¶
type LogicalStmt = ast.LogicalStmt
type MemberExpr ¶
type MemberExpr = ast.MemberExpr
type Money ¶
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type NilLiteral ¶
type NilLiteral = ast.NilLiteral
type ParseIssue ¶ added in v0.50.0
ParseIssue is one structured parse failure extracted from a Compile error. Pos is the 1-indexed position where the issue starts; End is the exclusive end of the offending token, or the zero Position when the parser could not determine a span. Message carries the bare error text without the position prefix or rendered code frame.
func ParseIssues ¶ added in v0.50.0
func ParseIssues(err error) []ParseIssue
ParseIssues extracts the structured parse failures carried by a Compile error, in source order. It returns nil for nil errors and for errors that carry no parse positions (such as size-limit or duplicate top-level name failures).
type Position ¶
Position is an internal alias for source.Position so runtime code can use the short name. AST and other internal aliases below mirror the vibes facade re-exports.
type PropertyDecl ¶
type PropertyDecl = ast.PropertyDecl
type Range ¶
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type RegexLiteral ¶ added in v0.60.0
type RegexLiteral = ast.RegexLiteral
type RescueClause ¶ added in v0.60.0
type RescueClause = ast.RescueClause
type RescueExpr ¶ added in v0.60.0
type RescueExpr = ast.RescueExpr
type ReturnStmt ¶
type ReturnStmt = ast.ReturnStmt
type RuntimeError ¶
type RuntimeError struct {
Type string
Message string
CodeFrame string
Frames []StackFrame
}
RuntimeError represents a Vibescript runtime error with a call stack and source context.
func (*RuntimeError) Error ¶
func (re *RuntimeError) Error() string
Error returns the error message with a code frame and formatted stack trace.
func (*RuntimeError) Unwrap ¶
func (re *RuntimeError) Unwrap() error
Unwrap returns nil to satisfy the error unwrapping interface. RuntimeError is a terminal error that wraps the original error message but not the error itself.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script represents a parsed Vibescript module ready for execution.
func CompileSnippetWithProgram ¶ added in v0.60.0
func CompileSnippetWithProgram(e *Engine, source, entrypoint string) (*Script, *ast.Program, []error, error)
CompileSnippetWithProgram compiles source as an inline snippet and returns the parsed program from the same parser pass. The returned program reflects the user's source; only the compiled script receives the synthetic entrypoint.
func CompileWithProgram ¶ added in v0.60.0
CompileWithProgram compiles source and returns the parsed program from the same parser pass. It is intended for internal tooling paths that need both diagnostics and navigation data without reparsing clean source.
func (*Script) CheckOrderIndependentWarnings ¶ added in v0.60.0
func (s *Script) CheckOrderIndependentWarnings() []CheckWarning
CheckOrderIndependentWarnings returns the whole-script check warnings that hold regardless of which function runs first or what state earlier calls established: undefined value/function names and typed block parameters contradicted by literal receivers. vibes run -check -e uses it to cover snippet functions the entrypoint never calls, where state-sensitive warnings (for example a type annotation that resolves only after a require in the entrypoint runs) would misfire.
The pass checks against empty CallOptions, so hosts that inject Globals or Capabilities should prefer CheckWarningsWithOptions with their real options: free names that only those options bind are reported here.
func (*Script) CheckWarnings ¶ added in v0.60.0
func (s *Script) CheckWarnings() []CheckWarning
CheckWarnings returns statically checkable contract issues for the compiled script. It reports only facts that are known from the AST and compiled script metadata; dynamic calls remain runtime-checked.
func (*Script) CheckWarningsForCall ¶ added in v0.60.0
func (s *Script) CheckWarningsForCall(name string, args []Value, opts CallOptions) []CheckWarning
CheckWarningsForCall returns statically checkable contract issues for a single function call, including host-supplied arguments and keywords.
func (*Script) CheckWarningsForFunction ¶ added in v0.60.0
func (s *Script) CheckWarningsForFunction(name string) []CheckWarning
CheckWarningsForFunction returns statically checkable contract issues for the execution path of a single function call.
func (*Script) CheckWarningsForFunctionWithOptions ¶ added in v0.60.0
func (s *Script) CheckWarningsForFunctionWithOptions(name string, opts CallOptions) []CheckWarning
CheckWarningsForFunctionWithOptions returns statically checkable contract issues for a single function call using the same host globals that Call would receive.
func (*Script) CheckWarningsWithOptions ¶ added in v0.60.0
func (s *Script) CheckWarningsWithOptions(opts CallOptions) []CheckWarning
CheckWarningsWithOptions returns statically checkable contract issues using the same host globals that a later Call would receive.
func (*Script) Function ¶
func (s *Script) Function(name string) (*ScriptFunction, bool)
Function looks up a compiled function by name.
func (*Script) Functions ¶
func (s *Script) Functions() []*ScriptFunction
Functions returns compiled functions in deterministic name order.
type ScriptFunction ¶
type ScriptFunction struct {
Name string
Params []Param
ReturnTy *TypeExpr
Body []Statement
Pos Position
Env *Env
Exported bool
Private bool
Protected bool
Accessor functionAccessorKind
AccessorName string
// contains filtered or unexported fields
}
ScriptFunction represents a user-defined function within a Vibescript module.
func FunctionOf ¶
func FunctionOf(v Value) *ScriptFunction
FunctionOf returns the *ScriptFunction stored in v, or nil.
func (*ScriptFunction) ValueFunctionMarker ¶
func (*ScriptFunction) ValueFunctionMarker()
type StackFrame ¶
type StackFrame struct {
Function string
Pos Position
// Source is the module path for module-backed frames. It is empty for
// root scripts compiled directly by an embedder.
Source string
}
StackFrame represents a single entry in a runtime error's call stack.
type StringExpr ¶
type StringExpr = ast.StringExpr
type StringLiteral ¶
type StringLiteral = ast.StringLiteral
type StringPart ¶
type StringPart = ast.StringPart
type StringText ¶
type StringText = ast.StringText
type SymbolLiteral ¶
type SymbolLiteral = ast.SymbolLiteral
type TypedHashEntry ¶
type TypedHashEntry = value.TypedHashEntry
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
type Value ¶
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
func NewAutoBuiltin ¶
func NewAutoBuiltin(name string, fn BuiltinFunc) Value
NewAutoBuiltin returns a builtin function Value that auto-invokes without parentheses.
func NewBuiltin ¶
func NewBuiltin(name string, fn BuiltinFunc) Value
NewBuiltin returns a builtin function Value.
func NewCapturingBuiltin ¶ added in v0.60.0
func NewCapturingBuiltin(name string, fn BuiltinFunc, captured ...Value) Value
NewCapturingBuiltin returns a builtin function Value whose Fn closes over the given runtime values. The captured values are recorded on the builtin so the memory estimator charges their payloads while the builtin is reachable, keeping closures such as a bound predicate's receiver inside the memory quota.
func NewEnumValue ¶
func NewEnumValue(def *EnumValueDef) Value
NewEnumValue returns an enum member Value.
func NewFunction ¶
func NewFunction(fn *ScriptFunction) Value
NewFunction returns a script-defined function Value.
func NewHashWithDefault ¶
NewHashWithDefault returns a hash Value carrying Ruby-style default metadata (a default value and/or a default proc consulted on missing-key lookup).
func NewInstance ¶
NewInstance returns a class instance Value.
func NewTypedHash ¶
NewTypedHash returns a typed-key hash without eagerly materializing the legacy string-key compatibility map.
type ValueKind ¶
Internal aliases for the value package types so runtime code can keep referring to short names (Value, Money, KindInt, NewNil, etc.) without repeating the value. prefix everywhere. These mirror the public re-exports in vibes/value_alias.go and exist purely to keep the runtime sources readable after the move out of package vibes.
Source Files
¶
- aliases.go
- block_forwarding.go
- builtins.go
- call.go
- capabilities.go
- capability_adapters.go
- check.go
- check_names.go
- compile.go
- doc.go
- engine.go
- env.go
- errors.go
- eval.go
- execution.go
- inbound_data_copy.go
- json.go
- limits.go
- match_data.go
- math.go
- member_cache.go
- members.go
- members_array.go
- members_hash.go
- members_inspect.go
- members_introspect.go
- members_numeric.go
- members_range.go
- members_scalar.go
- members_string.go
- members_symbol.go
- members_temporal.go
- members_universal.go
- memory.go
- modules.go
- modules_open_unix.go
- nonlocal_return.go
- parse_issues.go
- regex_cache.go
- regex_replace.go
- regex_value.go
- rounding.go
- script.go
- sizeclass.go
- strftime.go
- suggest.go
- symbol_literals.go
- tasks.go
- types.go
- types_normalize.go
- types_user.go
- value_sets.go
- values.go