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 ¶
- Constants
- func Token(tok htok.Token) vtok.Token
- func Transpile(opts *config.Huloc, vfs vfs.VFS, basePath string) (map[string]string, error)
- type ClassSymbol
- type DependencyResolver
- type EnumSymbol
- type EnumValue
- type ExportInfo
- type ExportKind
- type ImportInfo
- type ImportKind
- type Module
- type ModuleManager
- type Scope
- type ScopeStack
- type ScopeType
- type StringPart
- type Symbol
- type SymbolTable
- func (st *SymbolTable) AddClass(name string, class *ClassSymbol)
- func (st *SymbolTable) AddConstant(name string, node hast.Node)
- func (st *SymbolTable) AddEnum(name string, values []*EnumValue)
- func (st *SymbolTable) AddFunction(name string, node hast.Node)
- func (st *SymbolTable) AddSymbol(symbol *Symbol)
- func (st *SymbolTable) AddVariable(name string, node hast.Node)
- func (st *SymbolTable) AllocVariableName(originalName string, scope *Scope) string
- func (st *SymbolTable) CurrentScope() *Scope
- func (st *SymbolTable) GetClass(name string) (*ClassSymbol, bool)
- func (st *SymbolTable) GetEnum(name string) (*EnumSymbol, bool)
- func (st *SymbolTable) HasClass(name string) bool
- func (st *SymbolTable) HasConstant(name string) bool
- func (st *SymbolTable) HasEnum(name string) bool
- func (st *SymbolTable) HasEnumValue(enumName, valueName string) bool
- func (st *SymbolTable) HasFunction(name string) bool
- func (st *SymbolTable) HasVariable(name string) bool
- func (st *SymbolTable) LookupSymbol(name string) *Symbol
- func (st *SymbolTable) PopScope()
- func (st *SymbolTable) PushScope(scopeType ScopeType, module *Module, id ...string) *Scope
- type SymbolType
- type VBScriptTranspiler
- func (v *VBScriptTranspiler) Convert(node hast.Node) vast.Node
- func (v *VBScriptTranspiler) ConvertArrayLiteral(node *hast.ArrayLiteralExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertAssignStmt(node *hast.AssignStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertBlock(node *hast.BlockStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertCallExpr(node *hast.CallExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertClassDecl(node *hast.ClassDecl) vast.Node
- func (v *VBScriptTranspiler) ConvertCmdExpr(node *hast.CmdExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertDeclareDecl(node *hast.DeclareDecl) vast.Node
- func (v *VBScriptTranspiler) ConvertEnumDecl(node *hast.EnumDecl) vast.Node
- func (v *VBScriptTranspiler) ConvertExternDecl(node *hast.ExternDecl) vast.Node
- func (v *VBScriptTranspiler) ConvertFile(node *hast.File) vast.Node
- func (v *VBScriptTranspiler) ConvertForStmt(node *hast.ForStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertForeachStmt(node *hast.ForeachStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertFuncDecl(node *hast.FuncDecl) vast.Node
- func (v *VBScriptTranspiler) ConvertIfStmt(node *hast.IfStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertImport(node *hast.Import) vast.Node
- func (v *VBScriptTranspiler) ConvertIncDecExpr(node *hast.IncDecExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertMatchStmt(node *hast.MatchStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertModAccessExpr(node *hast.ModAccessExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertObjectLiteral(node *hast.ObjectLiteralExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertParameter(node *hast.Parameter) vast.Node
- func (v *VBScriptTranspiler) ConvertReturnStmt(node *hast.ReturnStmt) vast.Node
- func (v *VBScriptTranspiler) ConvertSelectExpr(node *hast.SelectExpr) vast.Node
- func (v *VBScriptTranspiler) ConvertStringLiteral(node *hast.StringLiteral) vast.Node
- func (v *VBScriptTranspiler) ConvertUnsafeStmt(node *hast.UnsafeStmt) vast.Node
- func (v *VBScriptTranspiler) Emit(n ...vast.Stmt)
- func (v *VBScriptTranspiler) Flush() []vast.Stmt
- func (b *VBScriptTranspiler) Transpile(mainFile string) (map[string]string, error)
Constants ¶
const WILDCARD = "_"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClassSymbol ¶
ClassSymbol 表示类的符号表信息
type DependencyResolver ¶
type DependencyResolver struct {
// contains filtered or unexported fields
}
type EnumSymbol ¶
EnumSymbol 表示枚举的符号表信息
type EnumValue ¶
type EnumValue struct { Name string // 枚举值名 Value string // 实际值 Type string // 值类型:number, string, boolean }
EnumValue 表示枚举值的信息
type ExportInfo ¶
type ExportInfo struct { Name string Value hast.Node Kind ExportKind Public bool }
type ExportKind ¶
type ExportKind int
Function, Class, Constant, etc.
const ( ExportFunction ExportKind = iota ExportClass ExportConstant ExportVariable )
type ImportInfo ¶
type ImportInfo struct { ModulePath string SymbolName []string Alias string Kind ImportKind }
type ImportKind ¶
type ImportKind int
Named, All, Default
const ( ImportSingle ImportKind = iota ImportMulti ImportAll )
type Module ¶
type Module struct { Name string Path string AST *hast.File Exports map[string]*ExportInfo Imports []*ImportInfo Dependencies []string Transpiled *vast.File Symbols *SymbolTable }
type ModuleManager ¶
type ModuleManager struct {
// contains filtered or unexported fields
}
func (*ModuleManager) GetModule ¶
func (mm *ModuleManager) GetModule(path string) *Module
func (*ModuleManager) ResolveAllDependencies ¶
func (mm *ModuleManager) ResolveAllDependencies(mainFile string) ([]*Module, error)
type ScopeStack ¶
type ScopeStack struct {
// contains filtered or unexported fields
}
func (*ScopeStack) Current ¶
func (ss *ScopeStack) Current() *Scope
func (*ScopeStack) Pop ¶
func (ss *ScopeStack) Pop()
func (*ScopeStack) Push ¶
func (ss *ScopeStack) Push(scope *Scope)
type StringPart ¶
func ParseStringInterpolation ¶
func ParseStringInterpolation(s string) []StringPart
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
func NewSymbolTable ¶
func NewSymbolTable(moduleName string, enableMangle bool) *SymbolTable
NewSymbolTable 创建新的符号表
func (*SymbolTable) AddClass ¶
func (st *SymbolTable) AddClass(name string, class *ClassSymbol)
AddClass 添加类
func (*SymbolTable) AddConstant ¶
func (st *SymbolTable) AddConstant(name string, node hast.Node)
AddConstant 添加常量
func (*SymbolTable) AddEnum ¶
func (st *SymbolTable) AddEnum(name string, values []*EnumValue)
func (*SymbolTable) AddFunction ¶
func (st *SymbolTable) AddFunction(name string, node hast.Node)
AddFunction 添加函数
func (*SymbolTable) AddVariable ¶
func (st *SymbolTable) AddVariable(name string, node hast.Node)
AddVariable 添加变量
func (*SymbolTable) AllocVariableName ¶
func (st *SymbolTable) AllocVariableName(originalName string, scope *Scope) string
变量分配策略
func (*SymbolTable) CurrentScope ¶
func (st *SymbolTable) CurrentScope() *Scope
func (*SymbolTable) GetClass ¶
func (st *SymbolTable) GetClass(name string) (*ClassSymbol, bool)
func (*SymbolTable) GetEnum ¶
func (st *SymbolTable) GetEnum(name string) (*EnumSymbol, bool)
func (*SymbolTable) HasConstant ¶
func (st *SymbolTable) HasConstant(name string) bool
HasConstant 检查是否包含常量
func (*SymbolTable) HasEnum ¶
func (st *SymbolTable) HasEnum(name string) bool
func (*SymbolTable) HasEnumValue ¶
func (st *SymbolTable) HasEnumValue(enumName, valueName string) bool
func (*SymbolTable) HasFunction ¶
func (st *SymbolTable) HasFunction(name string) bool
HasFunction 检查是否包含函数
func (*SymbolTable) HasVariable ¶
func (st *SymbolTable) HasVariable(name string) bool
HasVariable 检查是否包含变量
func (*SymbolTable) PopScope ¶
func (st *SymbolTable) PopScope()
type SymbolType ¶
type SymbolType int
const ( SymbolVariable SymbolType = iota SymbolFunction SymbolClass SymbolConstant SymbolArray SymbolObject )
type VBScriptTranspiler ¶
type VBScriptTranspiler struct {
// contains filtered or unexported fields
}
func NewVBScriptTranspiler ¶
func NewVBScriptTranspiler(opts *config.Huloc, vfs vfs.VFS) *VBScriptTranspiler
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) ConvertCmdExpr ¶
func (v *VBScriptTranspiler) ConvertCmdExpr(node *hast.CmdExpr) 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