build

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 13 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.

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

Constants

View Source
const WILDCARD = "_"

Variables

This section is empty.

Functions

func Token

func Token(tok htok.Token) vtok.Token

func Transpile

func Transpile(opts *config.VBScriptOptions, mainFile string, vfs vfs.VFS, basePath string, huloPath string, popts ...parser.ParserOptions) (map[string]string, error)

Transpile 编译函数,处理依赖关系和内置函数内联

func TranspileToVBScript

func TranspileToVBScript(opts *config.VBScriptOptions, node hast.Node) (vast.Node, error)

func TranspileToVBScriptWithModules

func TranspileToVBScriptWithModules(opts *config.VBScriptOptions, node hast.Node, vfs vfs.VFS, basePath string) (vast.Node, error)

TranspileToVBScriptWithModules 支持模块导入的转换函数

Types

type BuiltinFunction

type BuiltinFunction struct {
	Name     string
	Code     string
	IsInline bool
}

BuiltinFunction 内置函数信息

type ClassSymbol

type ClassSymbol struct {
	Name   string   // 类名
	Fields []string // 字段名列表
	Public bool     // 是否为公共类
}

ClassSymbol 表示类的符号表信息

type EnumSymbol

type EnumSymbol struct {
	Name   string       // 枚举名
	Values []*EnumValue // 枚举值列表
}

EnumSymbol 表示枚举的符号表信息

type EnumValue

type EnumValue struct {
	Name  string // 枚举值名
	Value string // 实际值
	Type  string // 值类型:number, string, boolean
}

EnumValue 表示枚举值的信息

type ImportedModule

type ImportedModule struct {
	Path    string                 // 模块路径
	AST     interface{}            // 解析后的AST
	Exports map[string]interface{} // 导出的符号
	Imports []string               // 该模块的导入列表
}

ImportedModule 表示已导入的模块

type ModuleExports

type ModuleExports struct {
	Functions map[string]bool
	Classes   map[string]bool
	Constants map[string]bool
}

ModuleExports 模块导出的符号

type ModuleInfo

type ModuleInfo struct {
	Path         string
	Content      []byte
	AST          interface{}
	Transpiled   interface{} // 转换后的代码
	Dependencies []string
}

ModuleInfo 表示模块信息

type ModuleManager

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

ModuleManager 管理模块的导入和依赖

func NewModuleManager

func NewModuleManager(vfs vfs.VFS, basePath string) *ModuleManager

NewModuleManager 创建新的模块管理器

func (*ModuleManager) GetAllImportedModules

func (mm *ModuleManager) GetAllImportedModules() map[string]*ImportedModule

GetAllImportedModules 获取所有已导入的模块

func (*ModuleManager) GetModuleAST

func (mm *ModuleManager) GetModuleAST(importPath string) (interface{}, bool)

GetModuleAST 获取指定模块的AST

func (*ModuleManager) GetModuleExports

func (mm *ModuleManager) GetModuleExports(importPath string) (map[string]interface{}, bool)

GetModuleExports 获取指定模块的导出

func (*ModuleManager) ImportModule

func (mm *ModuleManager) ImportModule(importPath string) (*ImportedModule, error)

ImportModule 导入指定路径的模块

type ScopeType

type ScopeType int
const (
	GlobalScope ScopeType = iota
	ForScope
	MatchScope
	IfScope
)

type StringPart

type StringPart struct {
	Text       string
	IsVariable bool
	Expr       vast.Expr
}

func ParseStringInterpolation

func ParseStringInterpolation(s string) []StringPart

type SymbolTable

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

func (*SymbolTable) AddClass

func (st *SymbolTable) AddClass(name string, fields []string, public bool)

func (*SymbolTable) AddEnum

func (st *SymbolTable) AddEnum(name string, values []*EnumValue)

func (*SymbolTable) GetClass

func (st *SymbolTable) GetClass(name string) (*ClassSymbol, bool)

func (*SymbolTable) GetEnum

func (st *SymbolTable) GetEnum(name string) (*EnumSymbol, bool)

func (*SymbolTable) HasClass

func (st *SymbolTable) HasClass(name string) bool

func (*SymbolTable) HasEnum

func (st *SymbolTable) HasEnum(name string) bool

func (*SymbolTable) HasEnumValue

func (st *SymbolTable) HasEnumValue(enumName, valueName string) bool

type VBScriptTranspiler

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

func (*VBScriptTranspiler) Convert

func (v *VBScriptTranspiler) Convert(node hast.Node) vast.Node

func (*VBScriptTranspiler) ConvertArrayLiteral

func (v *VBScriptTranspiler) ConvertArrayLiteral(node *hast.ArrayLiteralExpr) vast.Node

ConvertArrayLiteral 将Hulo数组字面量转换为VBScript的Array函数调用

func (*VBScriptTranspiler) ConvertAssignStmt

func (v *VBScriptTranspiler) ConvertAssignStmt(node *hast.AssignStmt) vast.Node

func (*VBScriptTranspiler) ConvertBlock

func (v *VBScriptTranspiler) ConvertBlock(node *hast.BlockStmt) vast.Node

func (*VBScriptTranspiler) ConvertCallExpr

func (v *VBScriptTranspiler) ConvertCallExpr(node *hast.CallExpr) vast.Node

func (*VBScriptTranspiler) ConvertClassDecl

func (v *VBScriptTranspiler) ConvertClassDecl(node *hast.ClassDecl) vast.Node

func (*VBScriptTranspiler) ConvertDeclareDecl

func (v *VBScriptTranspiler) ConvertDeclareDecl(node *hast.DeclareDecl) vast.Node

func (*VBScriptTranspiler) ConvertEnumDecl

func (v *VBScriptTranspiler) ConvertEnumDecl(node *hast.EnumDecl) vast.Node

ConvertEnumDecl 将 Hulo 的枚举声明转换为 VBScript 的常量声明

func (*VBScriptTranspiler) ConvertExternDecl

func (v *VBScriptTranspiler) ConvertExternDecl(node *hast.ExternDecl) vast.Node

func (*VBScriptTranspiler) ConvertFile

func (v *VBScriptTranspiler) ConvertFile(node *hast.File) vast.Node

func (*VBScriptTranspiler) ConvertForStmt

func (v *VBScriptTranspiler) ConvertForStmt(node *hast.ForStmt) vast.Node

func (*VBScriptTranspiler) ConvertForeachStmt

func (v *VBScriptTranspiler) ConvertForeachStmt(node *hast.ForeachStmt) vast.Node

ConvertForeachStmt 将Hulo的foreach语句转换为VBScript的For Each语句

func (*VBScriptTranspiler) ConvertFuncDecl

func (v *VBScriptTranspiler) ConvertFuncDecl(node *hast.FuncDecl) vast.Node

func (*VBScriptTranspiler) ConvertIfStmt

func (v *VBScriptTranspiler) ConvertIfStmt(node *hast.IfStmt) vast.Node

func (*VBScriptTranspiler) ConvertImport

func (v *VBScriptTranspiler) ConvertImport(node *hast.Import) vast.Node

func (*VBScriptTranspiler) ConvertIncDecExpr

func (v *VBScriptTranspiler) ConvertIncDecExpr(node *hast.IncDecExpr) vast.Node

func (*VBScriptTranspiler) ConvertMatchStmt

func (v *VBScriptTranspiler) ConvertMatchStmt(node *hast.MatchStmt) vast.Node

ConvertMatchStmt 将 Hulo 的 match 语句转换为 VBScript 的 if-elseif-else 语句

func (*VBScriptTranspiler) ConvertModAccessExpr

func (v *VBScriptTranspiler) ConvertModAccessExpr(node *hast.ModAccessExpr) vast.Node

ConvertModAccessExpr 将模块访问表达式转换为相应的常量引用 例如:Status::Pending 转换为 0(数字枚举)或生成常量声明(字符串枚举)

func (*VBScriptTranspiler) ConvertObjectLiteral

func (v *VBScriptTranspiler) ConvertObjectLiteral(node *hast.ObjectLiteralExpr) vast.Node

ConvertObjectLiteral 将Hulo对象字面量转换为VBScript的Dictionary对象

func (*VBScriptTranspiler) ConvertParameter

func (v *VBScriptTranspiler) ConvertParameter(node *hast.Parameter) vast.Node

func (*VBScriptTranspiler) ConvertReturnStmt

func (v *VBScriptTranspiler) ConvertReturnStmt(node *hast.ReturnStmt) vast.Node

func (*VBScriptTranspiler) ConvertSelectExpr

func (v *VBScriptTranspiler) ConvertSelectExpr(node *hast.SelectExpr) vast.Node

func (*VBScriptTranspiler) ConvertStringLiteral

func (v *VBScriptTranspiler) ConvertStringLiteral(node *hast.StringLiteral) vast.Node

func (*VBScriptTranspiler) ConvertUnsafeStmt

func (v *VBScriptTranspiler) ConvertUnsafeStmt(node *hast.UnsafeStmt) vast.Node

func (*VBScriptTranspiler) Emit

func (v *VBScriptTranspiler) Emit(n ...vast.Stmt)

func (*VBScriptTranspiler) Flush

func (v *VBScriptTranspiler) Flush() []vast.Stmt

Jump to

Keyboard shortcuts

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