dynamic

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: LGPL-2.1 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindMode added in v0.1.30

type BindMode int32

BindMode 绑定模式

const (
	None   BindMode = iota // 无绑定
	Func                   // 函数
	Struct                 // 结构体
)

type CodeFS

type CodeFS struct {
	// contains filtered or unexported fields
}

CodeFS 代码文件系统

func NewCodeFS

func NewCodeFS() *CodeFS

NewCodeFS 创建代码文件系统

func (*CodeFS) Mapping

func (cfs *CodeFS) Mapping(pkgRoot, localPath string) error

Mapping 映射包路径

func (*CodeFS) Open

func (cfs *CodeFS) Open(name string) (file fs.File, err error)

Open implements fs.FS

func (*CodeFS) ReadDir

func (cfs *CodeFS) ReadDir(name string) (files []fs.DirEntry, err error)

ReadDir implements fs.ReadDirFS

func (*CodeFS) ReadFile

func (cfs *CodeFS) ReadFile(name string) ([]byte, error)

ReadFile implements fs.ReadFileFS

func (*CodeFS) Stat

func (cfs *CodeFS) Stat(name string) (fs.FileInfo, error)

Stat implements fs.StatFS

type Method

type Method struct {
	Name      string        // 方法名
	Reflected reflect.Value // 方法反射值
}

Method 方法

type MethodBinder

type MethodBinder = func(this any, method string) any

MethodBinder 成员方法绑定器

type Project

type Project struct {
	PkgRoot    string           // 包根路径
	LocalPath  string           // 本地路径
	SymbolsTab []interp.Exports // 符号表
}

Project 项目

type Script

type Script struct {
	PkgName      string       // 包名
	PkgPath      string       // 包路径
	Ident        string       // 类型标识,为空表示脚本均为全局方法
	BindMode     BindMode     // 绑定模式
	This         *This        // This类型
	Methods      []*Method    // 方法列表
	MethodBinder MethodBinder // 成员方法绑定器
}

Script 脚本

func (*Script) UniquePkgName

func (s *Script) UniquePkgName() string

UniquePkgName 获取唯一包名

type ScriptLib

type ScriptLib map[string]Scripts

ScriptLib 脚本库

func NewScriptLib

func NewScriptLib() ScriptLib

NewScriptLib 创建脚本库

func (ScriptLib) Compile

func (lib ScriptLib) Compile(i *interp.Interpreter) error

Compile 编译

func (ScriptLib) Load

func (lib ScriptLib) Load(localPath string) error

Load 加载

func (ScriptLib) Package

func (lib ScriptLib) Package(pkgPath string) Scripts

Package 包

func (ScriptLib) PushIdent

func (lib ScriptLib) PushIdent(pkgPath, ident string, bindMode BindMode, this *This) bool

PushIdent 添加类型标识

func (ScriptLib) PushMethod

func (lib ScriptLib) PushMethod(pkgPath, ident string, method string) bool

PushMethod 添加方法

func (ScriptLib) Range

func (lib ScriptLib) Range(fun generic.Func2[string, Scripts, bool])

Range 遍历

type Scripts

type Scripts map[string]*Script

Scripts 脚本集合

func (Scripts) Ident

func (scripts Scripts) Ident(ident string) *Script

Ident 标识

func (Scripts) Range

func (scripts Scripts) Range(fun generic.Func1[*Script, bool])

Range 遍历

type Solution

type Solution struct {
	// contains filtered or unexported fields
}

Solution 解决方案

func NewSolution

func NewSolution(pkgRoot string) *Solution

NewSolution 创建解决方案

func (*Solution) BindMethod

func (s *Solution) BindMethod(this reflect.Value, pkgPath, ident string, method string) any

BindMethod 绑定成员方法

func (*Solution) Eval

func (s *Solution) Eval(code string) (reflect.Value, error)

Eval 执行代码

func (*Solution) Load

func (s *Solution) Load(project *Project) error

Load 加载项目

func (*Solution) Method

func (s *Solution) Method(pkgPath, method string) reflect.Value

Method 方法

func (*Solution) Package

func (s *Solution) Package(pkgPath string) Scripts

Package 包

func (*Solution) Range

func (s *Solution) Range(fun generic.Func2[string, Scripts, bool])

Range 遍历

func (*Solution) Use

func (s *Solution) Use(symbols interp.Exports) error

Use 导入符号表

type This

type This struct {
	Name    string // 类型名称
	PkgName string // 包名
	PkgPath string // 包路径
}

This This类型

func (*This) UniquePkgName

func (this *This) UniquePkgName() string

UniquePkgName 获取唯一包名

Jump to

Keyboard shortcuts

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