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.
Index ¶
- func Transpile(opts *config.Huloc, vfs vfs.VFS, basePath string) (map[string]string, error)
- type DependencyResolver
- type ExportInfo
- type ExportKind
- type ImportInfo
- type ImportKind
- type Module
- type ModuleManager
- type PowerShellTranspiler
- func (p *PowerShellTranspiler) Convert(node hast.Node) past.Node
- func (p *PowerShellTranspiler) ConvertArrayLiteralExpr(node *hast.ArrayLiteralExpr) past.Node
- func (p *PowerShellTranspiler) ConvertAssignStmt(node *hast.AssignStmt) past.Node
- func (p *PowerShellTranspiler) ConvertBinaryExpr(node *hast.BinaryExpr) past.Node
- func (p *PowerShellTranspiler) ConvertBlockStmt(node *hast.BlockStmt) past.Node
- func (p *PowerShellTranspiler) ConvertBoolLiteral(node *hast.TrueLiteral) past.Node
- func (p *PowerShellTranspiler) ConvertBreakStmt(node *hast.BreakStmt) past.Node
- func (p *PowerShellTranspiler) ConvertCallExpr(node *hast.CallExpr) past.Node
- func (p *PowerShellTranspiler) ConvertCaseClause(node *hast.CaseClause) past.Node
- func (p *PowerShellTranspiler) ConvertCatchClause(node *hast.CatchClause) past.Node
- func (p *PowerShellTranspiler) ConvertClassDecl(node *hast.ClassDecl) past.Node
- func (p *PowerShellTranspiler) ConvertCmdExpr(node *hast.CmdExpr) past.Node
- func (p *PowerShellTranspiler) ConvertComment(node *hast.Comment) past.Node
- func (p *PowerShellTranspiler) ConvertCommentGroup(node *hast.CommentGroup) past.Node
- func (p *PowerShellTranspiler) ConvertContinueStmt(node *hast.ContinueStmt) past.Node
- func (p *PowerShellTranspiler) ConvertDoWhileStmt(node *hast.DoWhileStmt) past.Node
- func (p *PowerShellTranspiler) ConvertEnumDecl(node *hast.EnumDecl) past.Node
- func (p *PowerShellTranspiler) ConvertExprStmt(node *hast.ExprStmt) past.Node
- func (p *PowerShellTranspiler) ConvertFalseLiteral(node *hast.FalseLiteral) past.Node
- func (p *PowerShellTranspiler) ConvertFile(node *hast.File) past.Node
- func (p *PowerShellTranspiler) ConvertForStmt(node *hast.ForStmt) past.Node
- func (p *PowerShellTranspiler) ConvertForeachStmt(node *hast.ForeachStmt) past.Node
- func (p *PowerShellTranspiler) ConvertFuncDecl(node *hast.FuncDecl) past.Node
- func (p *PowerShellTranspiler) ConvertIdent(node *hast.Ident) past.Node
- func (p *PowerShellTranspiler) ConvertIfStmt(node *hast.IfStmt) past.Node
- func (p *PowerShellTranspiler) ConvertImport(node *hast.Import) past.Node
- func (p *PowerShellTranspiler) ConvertIncDecExpr(node *hast.IncDecExpr) past.Node
- func (p *PowerShellTranspiler) ConvertNumericLiteral(node *hast.NumericLiteral) past.Node
- func (p *PowerShellTranspiler) ConvertObjectLiteralExpr(node *hast.ObjectLiteralExpr) past.Node
- func (p *PowerShellTranspiler) ConvertParameter(node *hast.Parameter) past.Node
- func (p *PowerShellTranspiler) ConvertRefExpr(node *hast.RefExpr) past.Node
- func (p *PowerShellTranspiler) ConvertReturnStmt(node *hast.ReturnStmt) past.Node
- func (p *PowerShellTranspiler) ConvertSelectExpr(node *hast.SelectExpr) past.Node
- func (p *PowerShellTranspiler) ConvertStringLiteral(node *hast.StringLiteral) past.Node
- func (p *PowerShellTranspiler) ConvertSwitchStmt(node *hast.MatchStmt) past.Node
- func (p *PowerShellTranspiler) ConvertThrowStmt(node *hast.ThrowStmt) past.Node
- func (p *PowerShellTranspiler) ConvertTryStmt(node *hast.TryStmt) past.Node
- func (p *PowerShellTranspiler) ConvertWhileStmt(node *hast.WhileStmt) past.Node
- func (p *PowerShellTranspiler) Transpile(mainFile string) (map[string]string, error)
- type Scope
- type ScopeStack
- type ScopeType
- type Symbol
- type SymbolTable
- func (st *SymbolTable) AddClass(name string, node hast.Node)
- func (st *SymbolTable) AddConstant(name string, node hast.Node)
- 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) HasClass(name string) bool
- func (st *SymbolTable) HasConstant(name 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) *Scope
- type SymbolType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DependencyResolver ¶
type DependencyResolver struct {
// contains filtered or unexported fields
}
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 *past.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 PowerShellTranspiler ¶
type PowerShellTranspiler struct {
// contains filtered or unexported fields
}
func NewPowerShellTranspiler ¶
func NewPowerShellTranspiler(opts *config.Huloc, vfs vfs.VFS) *PowerShellTranspiler
func (*PowerShellTranspiler) Convert ¶
func (p *PowerShellTranspiler) Convert(node hast.Node) past.Node
func (*PowerShellTranspiler) ConvertArrayLiteralExpr ¶
func (p *PowerShellTranspiler) ConvertArrayLiteralExpr(node *hast.ArrayLiteralExpr) past.Node
func (*PowerShellTranspiler) ConvertAssignStmt ¶
func (p *PowerShellTranspiler) ConvertAssignStmt(node *hast.AssignStmt) past.Node
func (*PowerShellTranspiler) ConvertBinaryExpr ¶
func (p *PowerShellTranspiler) ConvertBinaryExpr(node *hast.BinaryExpr) past.Node
func (*PowerShellTranspiler) ConvertBlockStmt ¶
func (p *PowerShellTranspiler) ConvertBlockStmt(node *hast.BlockStmt) past.Node
func (*PowerShellTranspiler) ConvertBoolLiteral ¶
func (p *PowerShellTranspiler) ConvertBoolLiteral(node *hast.TrueLiteral) past.Node
func (*PowerShellTranspiler) ConvertBreakStmt ¶
func (p *PowerShellTranspiler) ConvertBreakStmt(node *hast.BreakStmt) past.Node
func (*PowerShellTranspiler) ConvertCallExpr ¶
func (p *PowerShellTranspiler) ConvertCallExpr(node *hast.CallExpr) past.Node
func (*PowerShellTranspiler) ConvertCaseClause ¶
func (p *PowerShellTranspiler) ConvertCaseClause(node *hast.CaseClause) past.Node
func (*PowerShellTranspiler) ConvertCatchClause ¶
func (p *PowerShellTranspiler) ConvertCatchClause(node *hast.CatchClause) past.Node
func (*PowerShellTranspiler) ConvertClassDecl ¶
func (p *PowerShellTranspiler) ConvertClassDecl(node *hast.ClassDecl) past.Node
func (*PowerShellTranspiler) ConvertCmdExpr ¶
func (p *PowerShellTranspiler) ConvertCmdExpr(node *hast.CmdExpr) past.Node
func (*PowerShellTranspiler) ConvertComment ¶
func (p *PowerShellTranspiler) ConvertComment(node *hast.Comment) past.Node
func (*PowerShellTranspiler) ConvertCommentGroup ¶
func (p *PowerShellTranspiler) ConvertCommentGroup(node *hast.CommentGroup) past.Node
func (*PowerShellTranspiler) ConvertContinueStmt ¶
func (p *PowerShellTranspiler) ConvertContinueStmt(node *hast.ContinueStmt) past.Node
func (*PowerShellTranspiler) ConvertDoWhileStmt ¶
func (p *PowerShellTranspiler) ConvertDoWhileStmt(node *hast.DoWhileStmt) past.Node
func (*PowerShellTranspiler) ConvertEnumDecl ¶
func (p *PowerShellTranspiler) ConvertEnumDecl(node *hast.EnumDecl) past.Node
func (*PowerShellTranspiler) ConvertExprStmt ¶
func (p *PowerShellTranspiler) ConvertExprStmt(node *hast.ExprStmt) past.Node
func (*PowerShellTranspiler) ConvertFalseLiteral ¶
func (p *PowerShellTranspiler) ConvertFalseLiteral(node *hast.FalseLiteral) past.Node
func (*PowerShellTranspiler) ConvertFile ¶
func (p *PowerShellTranspiler) ConvertFile(node *hast.File) past.Node
func (*PowerShellTranspiler) ConvertForStmt ¶
func (p *PowerShellTranspiler) ConvertForStmt(node *hast.ForStmt) past.Node
func (*PowerShellTranspiler) ConvertForeachStmt ¶
func (p *PowerShellTranspiler) ConvertForeachStmt(node *hast.ForeachStmt) past.Node
func (*PowerShellTranspiler) ConvertFuncDecl ¶
func (p *PowerShellTranspiler) ConvertFuncDecl(node *hast.FuncDecl) past.Node
func (*PowerShellTranspiler) ConvertIdent ¶
func (p *PowerShellTranspiler) ConvertIdent(node *hast.Ident) past.Node
func (*PowerShellTranspiler) ConvertIfStmt ¶
func (p *PowerShellTranspiler) ConvertIfStmt(node *hast.IfStmt) past.Node
func (*PowerShellTranspiler) ConvertImport ¶
func (p *PowerShellTranspiler) ConvertImport(node *hast.Import) past.Node
func (*PowerShellTranspiler) ConvertIncDecExpr ¶
func (p *PowerShellTranspiler) ConvertIncDecExpr(node *hast.IncDecExpr) past.Node
func (*PowerShellTranspiler) ConvertNumericLiteral ¶
func (p *PowerShellTranspiler) ConvertNumericLiteral(node *hast.NumericLiteral) past.Node
func (*PowerShellTranspiler) ConvertObjectLiteralExpr ¶
func (p *PowerShellTranspiler) ConvertObjectLiteralExpr(node *hast.ObjectLiteralExpr) past.Node
func (*PowerShellTranspiler) ConvertParameter ¶
func (p *PowerShellTranspiler) ConvertParameter(node *hast.Parameter) past.Node
func (*PowerShellTranspiler) ConvertRefExpr ¶
func (p *PowerShellTranspiler) ConvertRefExpr(node *hast.RefExpr) past.Node
func (*PowerShellTranspiler) ConvertReturnStmt ¶
func (p *PowerShellTranspiler) ConvertReturnStmt(node *hast.ReturnStmt) past.Node
func (*PowerShellTranspiler) ConvertSelectExpr ¶
func (p *PowerShellTranspiler) ConvertSelectExpr(node *hast.SelectExpr) past.Node
func (*PowerShellTranspiler) ConvertStringLiteral ¶
func (p *PowerShellTranspiler) ConvertStringLiteral(node *hast.StringLiteral) past.Node
func (*PowerShellTranspiler) ConvertSwitchStmt ¶
func (p *PowerShellTranspiler) ConvertSwitchStmt(node *hast.MatchStmt) past.Node
func (*PowerShellTranspiler) ConvertThrowStmt ¶
func (p *PowerShellTranspiler) ConvertThrowStmt(node *hast.ThrowStmt) past.Node
func (*PowerShellTranspiler) ConvertTryStmt ¶
func (p *PowerShellTranspiler) ConvertTryStmt(node *hast.TryStmt) past.Node
func (*PowerShellTranspiler) ConvertWhileStmt ¶
func (p *PowerShellTranspiler) ConvertWhileStmt(node *hast.WhileStmt) past.Node
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 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, node hast.Node)
AddClass 添加类
func (*SymbolTable) AddConstant ¶
func (st *SymbolTable) AddConstant(name string, node hast.Node)
AddConstant 添加常量
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) HasConstant ¶
func (st *SymbolTable) HasConstant(name string) bool
HasConstant 检查是否包含常量
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 )
Click to show internal directories.
Click to hide internal directories.