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.
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.
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.
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) GetScope(name string) (token.Token, bool)
- func (e *Environment) GetValue(name string) (object.Value, 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
- type ReturnValue
- type Variable
- type VariableInfo
- type WarpValue
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) GetScope ¶
func (e *Environment) GetScope(name string) (token.Token, bool)
GetScope 获取变量的作用域
func (*Environment) GetValue ¶ added in v0.3.0
func (e *Environment) GetValue(name string) (object.Value, bool)
GetValue 获取变量值,按优先级查找:const -> let -> var
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(env *Environment) *Interpreter
type ReturnValue ¶ added in v0.3.0
func (*ReturnValue) Interface ¶ added in v0.3.0
func (r *ReturnValue) Interface() any
func (*ReturnValue) Text ¶ added in v0.3.0
func (r *ReturnValue) Text() string
func (*ReturnValue) Type ¶ added in v0.3.0
func (r *ReturnValue) Type() object.Type
type Variable ¶
type VariableInfo ¶
type VariableInfo struct { Value object.Value Scope token.Token // CONST, VAR, LET ReadOnly bool // 是否为只读(const 变量) }
VariableInfo 存储变量的详细信息