yockp

package
v0.0.0-...-9853328 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StmtAssign = iota
	StmtLocalAssign
	StmtFuncCall
	StmtDoBlock
	StmtWhile
	StmtRepeat
	StmtIf
	StmtNumbderFor
	StmtGenericFor
	StmtFuncDef
	StmtReturn
	StmtBreak
	StmtLabel
	StmtGoto

	ExprTrue
	ExprFalse
	ExprNil
	ExprNumber
	ExprString
	ExprComma3
	ExprIdent
	ExprAttrGet
	ExprTable
	ExprFuncCall
	ExprLogicalOp
	ExprRelationalOp
	ExprStringConcatOp
	ExprArithmeticOp
	ExprUnaryMinus
	ExprUnaryNotOp
	ExprUnaryLenOp
	ExprFunciton

	HandleDefault
)

Variables

This section is empty.

Functions

func NewLuaDependencyAnalyzer

func NewLuaDependencyAnalyzer() *luaDependencyAnalyzer

Types

type ArithmeticOpExpr

type ArithmeticOpExpr = *ast.ArithmeticOpExpr

type AssignStmt

type AssignStmt = *ast.AssignStmt

type AttrGetExpr

type AttrGetExpr = *ast.AttrGetExpr

type BreakStmt

type BreakStmt = *ast.BreakStmt

type Comma3Expr

type Comma3Expr = *ast.Comma3Expr

type CompileOpt

type CompileOpt struct {
	DisableAnalyse bool
	VM             yocki.YockRuntime
}

type DecomposeOpt

type DecomposeOpt struct {
	// file to be decomposed
	File string
	// divide file into modes to be specified
	Modes []string
	// template file, is used to generate control script.
	Tpl    string
	Prefix string
}

DecomposeOpt indicates configuration of Decompose

type DoBlockStmt

type DoBlockStmt = *ast.DoBlockStmt

type FalseExpr

type FalseExpr = *ast.FalseExpr

type FuncCallExpr

type FuncCallExpr = *ast.FuncCallExpr

type FuncCallStmt

type FuncCallStmt = *ast.FuncCallStmt

type FuncDefStmt

type FuncDefStmt = *ast.FuncDefStmt

type FunctionExpr

type FunctionExpr = *ast.FunctionExpr

type GenericForStmt

type GenericForStmt = *ast.GenericForStmt

type GotoStmt

type GotoStmt = *ast.GotoStmt

type IdentExpr

type IdentExpr = *ast.IdentExpr

type IfStmt

type IfStmt = *ast.IfStmt

type LabelStmt

type LabelStmt = *ast.LabelStmt

type LocalAssignStmt

type LocalAssignStmt = *ast.LocalAssignStmt

type LogicalOpExpr

type LogicalOpExpr = *ast.LogicalOpExpr

type LuaMethod

type LuaMethod struct {
	// Argc indicates the number of parameters
	Argc int `json:"argc"`
	// Argv collects the name of each parameter
	Argv []string `json:"argv"`
	// Pkg indicates the scope for current driver.
	// Generally speaking, it is the file name,
	// and the way pkg is introduced for standard library functions and strings is g(global).
	Pkg string `json:"pkg"`
}

LuaMethod stores the metadata of the driver

type NilExpr

type NilExpr = *ast.NilExpr

type NilFrame

type NilFrame struct{}

type NumberExpr

type NumberExpr = *ast.NumberExpr

type NumberForStmt

type NumberForStmt = *ast.NumberForStmt

type RelationalOpExpr

type RelationalOpExpr = *ast.RelationalOpExpr

type RepeatStmt

type RepeatStmt = *ast.RepeatStmt

type ReturnStmt

type ReturnStmt = *ast.ReturnStmt

type StringConcatOpExpr

type StringConcatOpExpr = *ast.StringConcatOpExpr

type StringExpr

type StringExpr = *ast.StringExpr

type TableExpr

type TableExpr = *ast.TableExpr

type TrueExpr

type TrueExpr = *ast.TrueExpr

type UnaryLenOpExpr

type UnaryLenOpExpr = *ast.UnaryLenOpExpr

type UnaryMinusOpExpr

type UnaryMinusOpExpr = *ast.UnaryMinusOpExpr

type UnaryNotOpExpr

type UnaryNotOpExpr = *ast.UnaryNotOpExpr

type VisitExprHandle

type VisitExprHandle[T any] map[uint8]func(idx int, expr yockExpr, frame T)

type VisitStmtHandle

type VisitStmtHandle[T any] map[uint8]func(idx int, stmt yockStmt, frame T)

type WhileStmt

type WhileStmt = *ast.WhileStmt

type YockPack

type YockPack[T any] struct{}

YockPack serves as yock's preprocessing tool for decomposing Lua source code and for dependency analysis when YPM is not introduced.

func New

func New() YockPack[NilFrame]

func (*YockPack[T]) BuildScript

func (*YockPack[T]) BuildScript(stmts []ast.Stmt, filter map[int]bool) string

BuildScript restores a given lua statement to source code

func (*YockPack[T]) CC

func (yockp *YockPack[T]) CC(entry string, main string)

! try to build virtual file system

func (*YockPack[T]) Compile

func (yockpack *YockPack[T]) Compile(opt CompileOpt, file string) *lua.LFunction

Compile compiles the contents of the given file into functions that can be executed by the virtual machine.

func (*YockPack[T]) Decompose

func (yockpack *YockPack[T]) Decompose(opt DecomposeOpt, stmts []ast.Stmt)

func (*YockPack[T]) DumpFile

func (yockpack *YockPack[T]) DumpFile(file string) string

DumpFile prints out a syntax tree based on the given file

func (*YockPack[T]) DumpStr

func (yockpack *YockPack[T]) DumpStr(str string) string

DumpStr prints out a syntax tree based on the given source code string

func (*YockPack[T]) ParseFile

func (*YockPack[T]) ParseFile(file string) []ast.Stmt

ParseFile parses the given file content into a lua statement structure

func (*YockPack[T]) ParseStr

func (*YockPack[T]) ParseStr(str string) []ast.Stmt

ParseStr parses the given string into a lua statement structure

func (*YockPack[T]) VisitExpr

func (yockpack *YockPack[T]) VisitExpr(exprs []ast.Expr, frame T, handle VisitExprHandle[T])

VisitExpr recursively traverses the lua expression, and you can pass a callback function to handle the incoming expression.

func (*YockPack[T]) VisitFile

func (yockpack *YockPack[T]) VisitFile(file string, frame T, handle VisitStmtHandle[T])

func (*YockPack[T]) VisitStmt

func (yockpack *YockPack[T]) VisitStmt(stmts []ast.Stmt, frame T, handle VisitStmtHandle[T])

VisitStmt recursively traverses the lua statement, and you can pass a callback function to handle the incoming statement.

func (*YockPack[T]) VisitStr

func (yockpack *YockPack[T]) VisitStr(str string, frame T, handle VisitStmtHandle[T])

Jump to

Keyboard shortcuts

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