Documentation
¶
Overview ¶
Copyright 2025 The Hulo Authors. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Index ¶
- func Evaluate(ctx *Context, node ast.Node) object.Value
- type Breakpoint
- type Context
- type DebugCommand
- type DebugState
- type Debugger
- type Environment
- func (e *Environment) Assign(name string, obj object.Value) error
- func (e *Environment) Declare(name string, obj object.Value, scope token.Token) error
- func (e *Environment) Fork() *Environment
- func (e *Environment) Get(name string) (object.Value, bool)
- func (e *Environment) GetScope(name string) (token.Token, bool)
- func (e *Environment) GetVariableInfo(name string) (*VariableInfo, bool)
- func (e *Environment) IsDeclared(name string) bool
- func (e *Environment) IsReadOnly(name string) bool
- func (e *Environment) Set(name string, obj object.Value) object.Value
- func (e *Environment) SetWithScope(name string, obj object.Value, scope token.Token, readOnly bool) object.Value
- type FunctionEvaluatorImpl
- type Interpreter
- func (interp *Interpreter) Eval(node ast.Node) ast.Node
- func (interp *Interpreter) EvalModule(module core.Module) error
- func (interp *Interpreter) ExecuteMain(mainFile string) error
- func (interp *Interpreter) GetEnvironment() *Environment
- func (interp *Interpreter) LoadModule(modulePath string) (core.Module, error)
- type ModuleSystem
- type Symbol
- type SymbolKind
- type Variable
- type VariableInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func DefaultContext ¶
func DefaultContext() *Context
type DebugCommand ¶
type DebugCommand struct{}
type DebugState ¶
type DebugState struct{}
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func NewEnvironment ¶
func NewEnvironment() *Environment
func (*Environment) Assign ¶
func (e *Environment) Assign(name string, obj object.Value) error
Assign 重新赋值变量
func (*Environment) Fork ¶
func (e *Environment) Fork() *Environment
func (*Environment) Get ¶
func (e *Environment) Get(name string) (object.Value, bool)
Get 获取变量值,按优先级查找:const -> let -> var
func (*Environment) GetScope ¶
func (e *Environment) GetScope(name string) (token.Token, bool)
GetScope 获取变量的作用域
func (*Environment) GetVariableInfo ¶
func (e *Environment) GetVariableInfo(name string) (*VariableInfo, bool)
GetVariableInfo 获取变量的完整信息
func (*Environment) IsDeclared ¶
func (e *Environment) IsDeclared(name string) bool
IsDeclared 检查变量是否已声明
func (*Environment) IsReadOnly ¶
func (e *Environment) IsReadOnly(name string) bool
IsReadOnly 检查变量是否为只读
type FunctionEvaluatorImpl ¶
type FunctionEvaluatorImpl struct {
// contains filtered or unexported fields
}
FunctionEvaluatorImpl 函数求值器实现
func NewFunctionEvaluator ¶
func NewFunctionEvaluator(interpreter *Interpreter) *FunctionEvaluatorImpl
NewFunctionEvaluator 创建函数求值器
func (*FunctionEvaluatorImpl) EvaluateFunction ¶
func (fe *FunctionEvaluatorImpl) EvaluateFunction(funcDecl *ast.FuncDecl, args []interface{}) (interface{}, error)
EvaluateFunction 求值函数
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter() *Interpreter
func (*Interpreter) EvalModule ¶
func (interp *Interpreter) EvalModule(module core.Module) error
EvalModule 执行模块
func (*Interpreter) ExecuteMain ¶
func (interp *Interpreter) ExecuteMain(mainFile string) error
ExecuteMain 执行主模块
func (*Interpreter) GetEnvironment ¶
func (interp *Interpreter) GetEnvironment() *Environment
GetEnvironment 获取环境
func (*Interpreter) LoadModule ¶
func (interp *Interpreter) LoadModule(modulePath string) (core.Module, error)
LoadModule 加载模块(支持缓存)
type ModuleSystem ¶
type Symbol ¶
type Symbol struct { Name string Value object.Value Type object.Type Module string // 所属模块 Kind SymbolKind }
Symbol 表示一个符号
type SymbolKind ¶
type SymbolKind int
const ( SymbolValue SymbolKind = iota SymbolType SymbolFunction SymbolModule )
Click to show internal directories.
Click to hide internal directories.