core

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Module    Module
	Registry  Registry
	Converter Converter
	Checker   TypeChecker
	Evaluator Evaluator
	Variables map[string]Value
	Parent    *Context
}

Context 执行上下文

type Converter

type Converter interface {
	ConvertType(node ast.Node) (Type, error)
	ConvertValue(node ast.Node) (Value, error)
	ConvertModule(node *ast.File) (Module, error)
}

Converter AST转换器接口

type Evaluator

type Evaluator interface {
	Evaluate(node ast.Node) (Value, error)
	EvaluateInContext(node ast.Node, context *Context) (Value, error)
}

Evaluator 求值器接口

type FunctionEvaluator

type FunctionEvaluator interface {
	// EvaluateFunction 求值函数
	EvaluateFunction(funcDecl *ast.FuncDecl, args []any) (any, error)
}

FunctionEvaluator 函数求值器接口

type Module

type Module interface {
	Name() string
	Path() string
	GetType(name string) (Type, bool)
	GetValue(name string) (Value, bool)
	Export(name string, value interface{}) error
	Import(name string, alias string, from string) error
}

Module 模块接口

type Registry

type Registry interface {
	RegisterModule(module Module) error
	GetModule(name string) (Module, bool)
	ResolveSymbol(moduleName, symbolName string) (any, bool)
	ResolveDependencies() error
}

Registry 注册表接口

type Type

type Type interface {
	Name() string
	Kind() TypeKind
	AssignableTo(other Type) bool
	Equals(other Type) bool
}

Type 类型接口

type TypeChecker

type TypeChecker interface {
	CheckType(expr ast.Expr) (Type, error)
	InferType(expr ast.Expr) (Type, error)
	CheckAssignment(target Type, value Value) error
}

TypeChecker 类型检查器接口

type TypeKind

type TypeKind int

TypeKind 类型种类

const (
	TypePrimitive TypeKind = iota
	TypeArray
	TypeMap
	TypeSet
	TypeTuple
	TypeUnion
	TypeIntersection
	TypeNullable
	TypeFunction
	TypeGeneric
	TypeAny
	TypeVoid
	TypeNull
	TypeError
)

type Value

type Value interface {
	Type() Type
	Interface() any
	Equals(other Value) bool
}

Value 值接口

Jump to

Keyboard shortcuts

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