GoToSPGen

package module
v0.0.0-...-eeb70d5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header string = "" /* 235-byte string literal not displayed */

	GENFLAG_NEWLINE   = 1
	GENFLAG_SEMICOLON = 2
)

Variables

View Source
var (
	FuncNames = map[string]string{
		"len":  "sizeof",
		"main": "OnPluginStart",
	}

	IdenNames = map[string]string{
		"nil": "null",
	}
)

Functions

func GeneratePluginFile

func GeneratePluginFile(file *ast.File) string

func GetExprString

func GetExprString(e ast.Expr) string

func GetTypeString

func GetTypeString(expr ast.Expr, name string, param bool) string

*

  • SP params -> [const] TypeName ([]... | &) VarName ([N]...)
  • SP vars -> TypeName VarName ([(N)]...)
  • SP ret -> TypeName ([])

func InsertStr

func InsertStr(a []string, index int, value string) []string

func IsSameType

func IsSameType(a ast.Expr, b []ast.Expr, param bool) bool

func MakeConstSpec

func MakeConstSpec(const_spec *ast.ValueSpec, tabs uint) string

func MakeVarSpec

func MakeVarSpec(var_spec *ast.ValueSpec, tabs uint) string

func ReplaceName

func ReplaceName(s *string, typ, rep string) bool

func WriteParams

func WriteParams(flist *ast.FieldList) []string

func WriteStructMembs

func WriteStructMembs(flist *ast.FieldList) []string

func WriteTabStr

func WriteTabStr(count uint) string

Types

type EStruct

type EStruct struct {
	Methods []FuncBlock
	Fields  []string
}

type FuncBlock

type FuncBlock struct {
	Body                   strings.Builder
	Tabs                   uint
	Params                 []string
	Storage, RetType, Name string
}

func (*FuncBlock) MakeStmt

func (cb *FuncBlock) MakeStmt(stmt ast.Stmt, flags int)

func (*FuncBlock) MakeStmts

func (cb *FuncBlock) MakeStmts(stmts []ast.Stmt, flags int)

type MethodMap

type MethodMap struct {
	Methods, Props []FuncBlock
	Name           string
}

type SMPlugin

type SMPlugin struct {
	Includes, Globals []string
	Structs           map[string]EStruct
	//MethodMaps []MethodMap
	Funcs []FuncBlock
}

func (*SMPlugin) MakeFuncDecl

func (plugin *SMPlugin) MakeFuncDecl(f *ast.FuncDecl)

func (*SMPlugin) MakeTypeSpec

func (plugin *SMPlugin) MakeTypeSpec(type_spec *ast.TypeSpec)

type TypeString

type TypeString struct {
	TypeName, LhsBracks, Name, RhsBracks string
}

func (TypeString) Join

func (ts TypeString) Join(param, is_ref, is_array bool) string

Jump to

Keyboard shortcuts

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