srcobj

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReturnOK   = Raw("return true, nil")
	ReturnFail = Raw("return false, nil")
)
View Source
const Break = Raw("break")

Break represents break operator

View Source
const False = Raw("false")

False ...

View Source
const Semicolon = Raw(";")

Semicolon ...

Variables

View Source
var Found = OperatorGE(Raw("pos"), Raw("0"))

Found is `pos >= 0`

View Source
var OK = Raw("ok")

Functions

func Decode

func Decode(dest string, decoding Call, fail Source) (res hardToAccessDecodingStuff)

Decode decoding generator

func Go2ResultType

func Go2ResultType(extTypes map[string]types.TypeRegistration, useString bool, goType string) (hardToAccessResultType, error)

func LookupByteLong

func LookupByteLong(useString bool, v string, src Source, needle Source) lookupByteLong

LookupByteLong creates new lookup

func LookupStringLong

func LookupStringLong(useString bool, v string, src Source, needle Source) lookupStringLong

LookupStringLong creates new lookup

func LookupStringShort

func LookupStringShort(useString bool, v string, src, needle Source) lookupStringShort

LookupStringShort creates private lookupStringShort for external consumption

func PrefixString

func PrefixString(useString bool, src, needle Source) prefixString

PrefixString creates private prefixString for external consumption

func RightPkg

func RightPkg(useString bool) string

func RightType

func RightType(useString bool) string

func String

func String(s Source) string

Types

type Body

type Body struct {
	// contains filtered or unexported fields
}

Body describes LDE generated listing of program elements

func NewBody

func NewBody(pieces ...Source) *Body

func (*Body) Append

func (l *Body) Append(item Source)

Append appends new program element

func (*Body) Dump

func (l *Body) Dump(w io.Writer) error

Dump implementation

type Call

type Call struct {
	Name   string
	Params []Source
}

Call function call representation

func NewCall

func NewCall(name string, params ...Source) Call

func (Call) Dump

func (c Call) Dump(w io.Writer) error

Dump ...

type Define

type Define struct {
	Receiver Source
	Expr     Source
}

Define represents variable definition

func (Define) Dump

func (d Define) Dump(w io.Writer) error

Dump ...

type DrawChar

type DrawChar string

DrawChar draws char 'a' as "'a'" in Go code

func (DrawChar) Dump

func (dc DrawChar) Dump(w io.Writer) error

Dump to implement Source

type ExtractorResult

type ExtractorResult struct{}

ExtractorResult

func (ExtractorResult) ResultType

func (e ExtractorResult) ResultType() string

type FieldDef

type FieldDef struct {
	Comment []string
	Name    string
	Type    FieldType
}

FieldDef describes LDE generated field definition

type FieldType

type FieldType interface {
	TypeString() string
}

FieldType represents LDE generated struct's field

type File

type File struct {
	// contains filtered or unexported fields
}

File represents LDE generated Go source file

func NewFile

func NewFile(useString bool) *File

NewFile constructor

func (*File) AddAccessor

func (f *File) AddAccessor(typeName, name string, resultType hardToAccessResultType) *Method

AddAccessor adds accessor method for an extractor

func (*File) AddConst

func (f *File) AddConst(name, value string) string

AddConst adds text constant and returns its name

func (*File) AddExtract

func (f *File) AddExtract(typeName string) *Method

AddExtract adds extraction method for an extractor

func (*File) AddExtractor

func (f *File) AddExtractor(comment []string, typeName string, g generator.Generator) *Strct

AddExtractor adds new extractor struct type definition and returns struct body

func (*File) AddNamedImport

func (f *File) AddNamedImport(access, path string) error

AddNamedImport adds new import item with specific access name

func (*File) Append

func (f *File) Append(src Source)

Append appends to file body

func (*File) Dump

func (f *File) Dump(w io.Writer) error

Dump ...

func (*File) PkgName

func (f *File) PkgName(name string)

PkgName sets package name

type For

type For struct {
	I          string
	Value      string
	Container  Source
	Body       Source
	DontAssign bool
}

For range representation

func (For) Dump

func (f For) Dump(w io.Writer) error

Dump ...

type If

type If struct {
	Expr Source
	Then Source
	Else Source
}

If structure

func (If) Dump

func (i If) Dump(w io.Writer) error

type Index

type Index struct {
	Src   Source
	Index Source
}

Index generates indexing access

func (Index) Dump

func (i Index) Dump(w io.Writer) error

Dump ...

type LineAssign

type LineAssign struct {
	Receiver string
	Expr     Source
}

LineAssign represents assignment operation

func (LineAssign) Dump

func (a LineAssign) Dump(w io.Writer) error

Dump ...

type LookupByteShort

type LookupByteShort struct {
	Var    string
	Src    Source
	Needle Source
}

LookupByteShort represents short byte lookups

func (LookupByteShort) Dump

func (l LookupByteShort) Dump(w io.Writer) error

Dump ...

type Method

type Method struct {
	// contains filtered or unexported fields
}

Method describes LDE generated method of extractor

func NewAccessor

func NewAccessor(objType, name string, resType hardToAccessResultType) *Method

NewAccessor creates accessor definition

func NewExtractor

func NewExtractor(useString bool, objType string) *Method

NewExtractor creates extractor definition

func (*Method) Body

func (m *Method) Body() *Body

Body returns method body

func (*Method) Dump

func (m *Method) Dump(w io.Writer) error

Dump implementation of source

type PrefixByte

type PrefixByte struct {
	Var    string
	Src    Source
	Needle Source
}

PrefixByte for prefix byte check code generation

func (PrefixByte) Dump

func (p PrefixByte) Dump(w io.Writer) error

Dump ...

type Raw

type Raw string

Raw just puts text directly into the generated code

func (Raw) Dump

func (r Raw) Dump(w io.Writer) error

Dump ...

type ResultType

type ResultType interface {
	ResultType() string
}

type Source

type Source interface {
	Dump(w io.Writer) error
}

Source is an abstraction over

func Assign

func Assign(receiver string, src Source) Source

func Comment

func Comment(comment string) Source

Comment generate comment

func Deref

func Deref(operand Source) Source

func Error

func Error(format string, params ...Source) Source

func Goto

func Goto(label string) Source

Goto generate goto <label>

func HexU64

func HexU64(data uint64) Source

HexU64 generates hexadecimal representation of uint64 fed

func Literal

func Literal(data interface{}) Source

Literal generates literal representation of object fed

func OperatorAdd

func OperatorAdd(op1, op2 Source) Source

func OperatorAnd

func OperatorAnd(op1, op2 Source) Source

func OperatorAssign

func OperatorAssign(op1, op2 Source) Source

OperatorAssign generate assignment

func OperatorBitAnd

func OperatorBitAnd(op1, op2 Source) Source

func OperatorColon

func OperatorColon(op1, op2 Source) Source

func OperatorComma

func OperatorComma(op1, op2 Source) Source

func OperatorDot

func OperatorDot(op1, op2 Source) Source

func OperatorEq

func OperatorEq(op1, op2 Source) Source

OperatorEq generate equality check

func OperatorGE

func OperatorGE(op1, op2 Source) Source

OperatorGE generate Greater or Equal comparison

func OperatorGT

func OperatorGT(op1, op2 Source) Source

OperatorGT generate Greater or Equal comparison

func OperatorInc

func OperatorInc(op1, op2 Source) Source

func OperatorLE

func OperatorLE(op1, op2 Source) Source

OperatorLE generate Greater or Equal comparison

func OperatorLT

func OperatorLT(op1, op2 Source) Source

OperatorLT generate Greater or Equal comparison

func OperatorNEq

func OperatorNEq(op1, op2 Source) Source

OperatorNEq generate equality check

func OperatorNot

func OperatorNot(operand Source) Source

func OperatorOr

func OperatorOr(op1, op2 Source) Source

func OperatorSemicolon

func OperatorSemicolon(op1, op2 Source) Source

func OperatorSub

func OperatorSub(op1, op2 Source) Source

func Ref

func Ref(operand Source) Source

func ReturnError

func ReturnError(format string, params ...Source) Source

ReturnError ...

func Slice

func Slice(expr, from, to Source) Source

func SliceFrom

func SliceFrom(expr, from Source) Source

SliceFrom generates {rest}[index:] expression

func SliceTo

func SliceTo(expr, to Source) Source

SliceTo generates {rest}[:index] expression

func Stringify

func Stringify(src Source) Source

Stringify cast to string code generator

func Trim

func Trim(s Source) Source

Trim trims generated code from new line characters and semicolons

type Strct

type Strct struct {
	// contains filtered or unexported fields
}

Strct represents LDE generated struct

func Struct

func Struct(useString bool, g generator.Generator) *Strct

Struct creates Strct for external consumption

func (*Strct) AddBool added in v0.1.1

func (s *Strct) AddBool(comment []string, name string)

AddBool adds bool field

func (*Strct) AddCustomType added in v0.1.0

func (s *Strct) AddCustomType(comment []string, name string, fieldType types.TypeRegistration)

AddCustomType add custom type

func (*Strct) AddDec128

func (s *Strct) AddDec128(comment []string, name string)

AddDec128 adds a couple of two elements in a structure emulating uint128 type

func (*Strct) AddFloat32

func (s *Strct) AddFloat32(comment []string, name string)

AddFloat32 adds float32 field

func (*Strct) AddFloat64

func (s *Strct) AddFloat64(comment []string, name string)

AddFloat64 adds float64 field

func (*Strct) AddInt

func (s *Strct) AddInt(comment []string, name string)

AddInt8 adds int field

func (*Strct) AddInt16

func (s *Strct) AddInt16(comment []string, name string)

AddInt16 adds int16 field

func (*Strct) AddInt32

func (s *Strct) AddInt32(comment []string, name string)

AddInt32 adds int32 field

func (*Strct) AddInt64

func (s *Strct) AddInt64(comment []string, name string)

AddInt64 adds int64 field

func (*Strct) AddInt8

func (s *Strct) AddInt8(comment []string, name string)

AddInt8 adds int8 field

func (*Strct) AddStr

func (s *Strct) AddStr(comment []string, name string)

AddStr adds native string field

func (*Strct) AddString

func (s *Strct) AddString(comment []string, name string)

AddString adds string field

func (*Strct) AddSubstruct

func (s *Strct) AddSubstruct(comment []string, name string) *Strct

AddSubstruct add substruct and returns it

func (*Strct) AddUint

func (s *Strct) AddUint(comment []string, name string)

AddUint adds uint field

func (*Strct) AddUint16

func (s *Strct) AddUint16(comment []string, name string)

AddUint16 adds uint16 field

func (*Strct) AddUint32

func (s *Strct) AddUint32(comment []string, name string)

AddUint32 adds uint32 field

func (*Strct) AddUint64

func (s *Strct) AddUint64(comment []string, name string)

AddUint64 adds uint64 field

func (*Strct) AddUint8

func (s *Strct) AddUint8(comment []string, name string)

AddUint8 adds uint8 field

func (*Strct) TypeString

func (s *Strct) TypeString() string

TypeString implementation to satisfy FieldType

type Vars

type Vars struct {
	// contains filtered or unexported fields
}

Vars for in-func variable declarations

func NewVars

func NewVars() *Vars

NewVars constructor

func (*Vars) Declare

func (v *Vars) Declare(varName, varType string) error

func (*Vars) Dump

func (v *Vars) Dump(w io.Writer) error

Dump implementation

func (*Vars) Pos

func (v *Vars) Pos()

Pos declare `var pos int` variable

Jump to

Keyboard shortcuts

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