transpiler

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const FunctionArgumentPrefix = `@funcArg_`
View Source
const FunctionReturnVariable = `@return`
View Source
const FunctionTrampolinePrefix = `@funcTramp_`

Variables

This section is empty.

Functions

func GolangToMLOG

func GolangToMLOG(input string, options Options) (string, error)

func GolangToMLOGBytes

func GolangToMLOGBytes(input []byte, options Options) (string, error)

func GolangToMLOGFile

func GolangToMLOGFile(fileName string, options Options) (string, error)

func MLOGToString

func MLOGToString(ctx context.Context, statements [][]Resolvable, statement MLOGAble, lineNumber int, source string) [][]string

func RegisterFuncTranslation

func RegisterFuncTranslation(name string, translator Translator)

func RegisterInlineTranslation added in v0.0.20

func RegisterInlineTranslation(name string, translator InlineTranslator)

func RegisterSelector

func RegisterSelector(name string, selector string)

func RegisterValidImport added in v0.0.9

func RegisterValidImport(path string)

Types

type ContextBlock added in v0.0.8

type ContextBlock struct {
	Statements []MLOGStatement
	Extra      []MLOGStatement
}

type ContextKey added in v0.0.23

type ContextKey string

type ContextualError added in v0.0.8

type ContextualError struct {
	Context context.Context
	Pos     *ast.Node
	// contains filtered or unexported fields
}

func Err added in v0.0.8

func Err(ctx context.Context, err string) ContextualError

func ErrPos added in v0.0.13

func ErrPos(ctx context.Context, pos ast.Node, err string) ContextualError

func (ContextualError) Error added in v0.0.8

func (e ContextualError) Error() string

type DynamicVariable

type DynamicVariable struct {
	Name string
}

func (*DynamicVariable) GetValue

func (m *DynamicVariable) GetValue() string

func (*DynamicVariable) PostProcess

func (m *DynamicVariable) PostProcess(context.Context, *Global, *Function) error

func (*DynamicVariable) PreProcess added in v0.0.10

func (m *DynamicVariable) PreProcess(_ context.Context, _ *Global, function *Function) error

type Function

type Function struct {
	Name                 string
	Called               bool
	Declaration          *ast.FuncDecl
	Statements           []MLOGStatement
	ArgumentCount        int
	VariableCounter      int
	ScopeVariableCounter map[string]int
	RootVariables        []*VarReference
}

type FunctionJumpTarget

type FunctionJumpTarget struct {
	Statement    WithPosition
	FunctionName string
	SourcePos    ast.Node
}

func (*FunctionJumpTarget) GetPosition

func (m *FunctionJumpTarget) GetPosition() int

func (*FunctionJumpTarget) PostProcess

func (m *FunctionJumpTarget) PostProcess(context.Context, *Global, *Function) error

func (*FunctionJumpTarget) PreProcess added in v0.0.10

func (m *FunctionJumpTarget) PreProcess(ctx context.Context, global *Global, _ *Function) error

func (*FunctionJumpTarget) Size added in v0.0.7

func (m *FunctionJumpTarget) Size() int

type Global

type Global struct {
	Functions []*Function
	Constants map[string]bool
}

type InlineTranslator added in v0.0.20

type InlineTranslator func(args []Resolvable) (Resolvable, error)

type InlineVariable added in v0.0.26

type InlineVariable struct {
	Value Resolvable
}

func (*InlineVariable) GetValue added in v0.0.26

func (m *InlineVariable) GetValue() string

func (*InlineVariable) PostProcess added in v0.0.26

func (m *InlineVariable) PostProcess(ctx context.Context, g *Global, function *Function) error

func (*InlineVariable) PreProcess added in v0.0.26

func (m *InlineVariable) PreProcess(ctx context.Context, g *Global, function *Function) error

type JumpTarget

type JumpTarget interface {
	Processable
	WithPosition
}

type MLOG

type MLOG struct {
	Statement [][]Resolvable
	Position  int
	Comment   string
	SourcePos ast.Node
}

func (*MLOG) GetComment

func (m *MLOG) GetComment(int) string

func (*MLOG) GetPosition

func (m *MLOG) GetPosition() int

func (*MLOG) GetSourcePos added in v0.0.12

func (m *MLOG) GetSourcePos(int) ast.Node

func (*MLOG) PostProcess

func (m *MLOG) PostProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOG) PreProcess added in v0.0.10

func (m *MLOG) PreProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOG) SetPosition

func (m *MLOG) SetPosition(position int) int

func (*MLOG) SetSourcePos added in v0.0.12

func (m *MLOG) SetSourcePos(pos ast.Node)

func (*MLOG) Size added in v0.0.7

func (m *MLOG) Size() int

func (*MLOG) ToMLOG

func (m *MLOG) ToMLOG() [][]Resolvable

type MLOGAble

type MLOGAble interface {
	ToMLOG() [][]Resolvable
	GetComment(int) string
	SetSourcePos(ast.Node)
	GetSourcePos(int) ast.Node
}

type MLOGBranch added in v0.0.10

type MLOGBranch struct {
	MLOG
	Block *ContextBlock
	Token token.Token
}

func (*MLOGBranch) GetComment added in v0.0.10

func (m *MLOGBranch) GetComment(int) string

func (*MLOGBranch) Size added in v0.0.10

func (m *MLOGBranch) Size() int

func (*MLOGBranch) ToMLOG added in v0.0.10

func (m *MLOGBranch) ToMLOG() [][]Resolvable

type MLOGCustomFunction added in v0.0.11

type MLOGCustomFunction struct {
	Position        int
	Arguments       []ast.Expr
	Variables       []Resolvable
	Unresolved      []MLOGStatement
	FunctionName    string
	Comments        map[int]string
	SourcePositions map[int]ast.Node
	SourcePos       ast.Node
	Context         context.Context
}

func (*MLOGCustomFunction) GetComment added in v0.0.11

func (m *MLOGCustomFunction) GetComment(pos int) string

func (*MLOGCustomFunction) GetPosition added in v0.0.11

func (m *MLOGCustomFunction) GetPosition() int

func (*MLOGCustomFunction) GetSourcePos added in v0.0.12

func (m *MLOGCustomFunction) GetSourcePos(pos int) ast.Node

func (*MLOGCustomFunction) PostProcess added in v0.0.11

func (m *MLOGCustomFunction) PostProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGCustomFunction) PreProcess added in v0.0.11

func (m *MLOGCustomFunction) PreProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGCustomFunction) SetPosition added in v0.0.11

func (m *MLOGCustomFunction) SetPosition(position int) int

func (*MLOGCustomFunction) SetSourcePos added in v0.0.12

func (m *MLOGCustomFunction) SetSourcePos(pos ast.Node)

func (*MLOGCustomFunction) Size added in v0.0.11

func (m *MLOGCustomFunction) Size() int

func (*MLOGCustomFunction) ToMLOG added in v0.0.11

func (m *MLOGCustomFunction) ToMLOG() [][]Resolvable

type MLOGFunc

type MLOGFunc struct {
	Position   int
	Function   Translator
	Arguments  []Resolvable
	Variables  []Resolvable
	Unresolved []MLOGStatement
	SourcePos  ast.Node
}

func (*MLOGFunc) GetComment

func (m *MLOGFunc) GetComment(int) string

func (*MLOGFunc) GetPosition

func (m *MLOGFunc) GetPosition() int

func (*MLOGFunc) GetSourcePos added in v0.0.12

func (m *MLOGFunc) GetSourcePos(int) ast.Node

func (*MLOGFunc) PostProcess

func (m *MLOGFunc) PostProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGFunc) PreProcess added in v0.0.10

func (m *MLOGFunc) PreProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGFunc) SetPosition

func (m *MLOGFunc) SetPosition(position int) int

func (*MLOGFunc) SetSourcePos added in v0.0.12

func (m *MLOGFunc) SetSourcePos(pos ast.Node)

func (*MLOGFunc) Size added in v0.0.7

func (m *MLOGFunc) Size() int

func (*MLOGFunc) ToMLOG

func (m *MLOGFunc) ToMLOG() [][]Resolvable

type MLOGJump

type MLOGJump struct {
	MLOG
	Condition  []Resolvable
	JumpTarget JumpTarget
}

func (*MLOGJump) GetComment

func (m *MLOGJump) GetComment(int) string

func (*MLOGJump) PostProcess

func (m *MLOGJump) PostProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGJump) PreProcess added in v0.0.10

func (m *MLOGJump) PreProcess(ctx context.Context, global *Global, function *Function) error

func (*MLOGJump) Size added in v0.0.7

func (m *MLOGJump) Size() int

func (*MLOGJump) ToMLOG

func (m *MLOGJump) ToMLOG() [][]Resolvable

type MLOGLabel added in v0.0.23

type MLOGLabel struct {
	MLOG
	Name string
}

func (*MLOGLabel) GetComment added in v0.0.23

func (m *MLOGLabel) GetComment(int) string

func (*MLOGLabel) Size added in v0.0.23

func (m *MLOGLabel) Size() int

func (*MLOGLabel) ToMLOG added in v0.0.23

func (m *MLOGLabel) ToMLOG() [][]Resolvable

type MLOGStackWriter

type MLOGStackWriter struct {
	MLOG
	Action string
	Extra  int
}

func (*MLOGStackWriter) GetComment

func (m *MLOGStackWriter) GetComment(int) string

func (*MLOGStackWriter) Size added in v0.0.23

func (m *MLOGStackWriter) Size() int

func (*MLOGStackWriter) ToMLOG

func (m *MLOGStackWriter) ToMLOG() [][]Resolvable

type MLOGStatement

type MLOGStatement interface {
	MLOGAble
	WithPosition
	MutablePosition
	Processable
}

type MLOGTrampoline

type MLOGTrampoline struct {
	MLOG
	Variable string
	Extra    int
	Stacked  string
	Function string
}

func (*MLOGTrampoline) GetComment

func (m *MLOGTrampoline) GetComment(int) string

func (*MLOGTrampoline) Size added in v0.0.23

func (m *MLOGTrampoline) Size() int

func (*MLOGTrampoline) ToMLOG

func (m *MLOGTrampoline) ToMLOG() [][]Resolvable

type MLOGTrampolineBack

type MLOGTrampolineBack struct {
	MLOG
	Stacked  string
	Function string
}

func (*MLOGTrampolineBack) GetComment

func (m *MLOGTrampolineBack) GetComment(int) string

func (*MLOGTrampolineBack) PreProcess added in v0.0.12

func (m *MLOGTrampolineBack) PreProcess(ctx context.Context, global *Global, function *Function) error

type MutablePosition

type MutablePosition interface {
	SetPosition(int) int
}

type NormalVariable

type NormalVariable struct {
	Name           string
	CalculatedName string
}

func (*NormalVariable) GetValue

func (m *NormalVariable) GetValue() string

func (*NormalVariable) PostProcess

func (m *NormalVariable) PostProcess(context.Context, *Global, *Function) error

func (*NormalVariable) PreProcess added in v0.0.10

func (m *NormalVariable) PreProcess(_ context.Context, global *Global, function *Function) error

type Options

type Options struct {
	Numbers       bool
	Comments      bool
	CommentOffset int
	NoStartup     bool
	Stacked       string
	Source        bool
}

type Processable

type Processable interface {
	PreProcess(context.Context, *Global, *Function) error
	PostProcess(context.Context, *Global, *Function) error
}

type Resolvable

type Resolvable interface {
	Processable
	GetValue() string
}

type StatementJumpTarget

type StatementJumpTarget struct {
	Statement WithPosition
	After     bool
}

func (*StatementJumpTarget) GetPosition

func (m *StatementJumpTarget) GetPosition() int

func (*StatementJumpTarget) PostProcess

func (*StatementJumpTarget) PreProcess added in v0.0.10

func (*StatementJumpTarget) Size added in v0.0.7

func (m *StatementJumpTarget) Size() int

type TranslateFunc added in v0.0.23

type TranslateFunc func(args []Resolvable, vars []Resolvable) ([]MLOGStatement, error)

type Translator

type Translator struct {
	Count     func(args []Resolvable, vars []Resolvable) int
	Variables int

	Translate TranslateFunc
}

type Value

type Value struct {
	Value string
}

func (*Value) GetValue

func (m *Value) GetValue() string

func (*Value) PostProcess

func (m *Value) PostProcess(context.Context, *Global, *Function) error

func (*Value) PreProcess added in v0.0.10

func (m *Value) PreProcess(context.Context, *Global, *Function) error

func (*Value) String

func (m *Value) String() string

type VarReference added in v0.0.26

type VarReference struct {
	Name     string
	Identity Resolvable
}

type WithPosition

type WithPosition interface {
	GetPosition() int
	Size() int
}

Jump to

Keyboard shortcuts

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