expression

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: BSD-3-Clause Imports: 5 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Blank = VariableVal("_")
View Source
var Nil = VariableVal("nil")

Functions

This section is empty.

Types

type ArrayType added in v0.0.2

type ArrayType struct {
	Len astgen.ASTExpr
	Elt Type
}

func (*ArrayType) ASTExpr added in v0.0.2

func (a *ArrayType) ASTExpr() ast.Expr

type Binary

type Binary struct {
	LHS astgen.ASTExpr
	Op  token.Token
	RHS astgen.ASTExpr
}

func NewBinary

func NewBinary(lhs astgen.ASTExpr, op token.Token, rhs astgen.ASTExpr) *Binary

func (*Binary) ASTExpr

func (b *Binary) ASTExpr() ast.Expr

type BuiltIn

type BuiltIn string
const (
	AppendBuiltIn BuiltIn = "append"
	CopyBuiltIn   BuiltIn = "copy"
	LenBuiltIn    BuiltIn = "len"
	MakeBuiltIn   BuiltIn = "make"
	NewBuiltIn    BuiltIn = "new"
	PanicBuiltIn  BuiltIn = "panic"
)

func (BuiltIn) ASTExpr

func (c BuiltIn) ASTExpr() ast.Expr

type CallExpression

type CallExpression struct {
	Function astgen.ASTExpr
	Args     []astgen.ASTExpr
}

func NewCallExpression

func NewCallExpression(function astgen.ASTExpr, args ...astgen.ASTExpr) *CallExpression

func NewCallFunction

func NewCallFunction(receiver, function string, args ...astgen.ASTExpr) *CallExpression

func (*CallExpression) ASTExpr

func (c *CallExpression) ASTExpr() ast.Expr

type CompositeLit

type CompositeLit struct {
	Type     astgen.ASTExpr
	Elements []astgen.ASTExpr
}

func NewCompositeLit

func NewCompositeLit(typ astgen.ASTExpr, elems ...astgen.ASTExpr) *CompositeLit

func (*CompositeLit) ASTExpr

func (c *CompositeLit) ASTExpr() ast.Expr

type Ellipsis added in v0.0.2

type Ellipsis struct{}

func (Ellipsis) ASTExpr added in v0.0.2

func (Ellipsis) ASTExpr() ast.Expr

type FuncLit

type FuncLit struct {
	Type FuncType
	Body []astgen.ASTStmt
}

func NewFuncLit

func NewFuncLit(typ FuncType, body ...astgen.ASTStmt) *FuncLit

func (*FuncLit) ASTExpr

func (f *FuncLit) ASTExpr() ast.Expr

type FuncParam

type FuncParam struct {
	Names []string
	Type  Type
}

func NewFuncParam

func NewFuncParam(name string, t Type) *FuncParam

func (*FuncParam) ToASTField

func (f *FuncParam) ToASTField() *ast.Field

type FuncParams

type FuncParams []*FuncParam

func (FuncParams) ToFieldList

func (f FuncParams) ToFieldList() *ast.FieldList

type FuncType

type FuncType struct {
	Params      FuncParams
	ReturnTypes Types
}

func (*FuncType) ASTExpr

func (f *FuncType) ASTExpr() ast.Expr

type Index

type Index struct {
	Receiver astgen.ASTExpr
	Index    astgen.ASTExpr
}

Index represents accessing an array or map by index, e.g. `myMap["myKey"]` or `myArr[0]`

func NewIndex

func NewIndex(receiver astgen.ASTExpr, index astgen.ASTExpr) *Index

func (*Index) ASTExpr

func (i *Index) ASTExpr() ast.Expr

type IntVal

type IntVal int

func (IntVal) ASTExpr

func (i IntVal) ASTExpr() ast.Expr

type InterfaceFunctionDecl

type InterfaceFunctionDecl struct {
	Name        string
	Params      FuncParams
	ReturnTypes Types
	Comment     string
}

func (*InterfaceFunctionDecl) ToASTField

func (i *InterfaceFunctionDecl) ToASTField() *ast.Field

type InterfaceFunctionDecls

type InterfaceFunctionDecls []*InterfaceFunctionDecl

func (InterfaceFunctionDecls) ToFieldList

func (i InterfaceFunctionDecls) ToFieldList() *ast.FieldList

type InterfaceType

type InterfaceType struct {
	Functions InterfaceFunctionDecls
}

func NewInterfaceType

func NewInterfaceType(functions ...*InterfaceFunctionDecl) *InterfaceType

func (*InterfaceType) ASTExpr

func (i *InterfaceType) ASTExpr() ast.Expr

type KeyValue

type KeyValue struct {
	Key   astgen.ASTExpr
	Value astgen.ASTExpr
}

func NewKeyValue

func NewKeyValue(key string, value astgen.ASTExpr) *KeyValue

func (*KeyValue) ASTExpr

func (k *KeyValue) ASTExpr() ast.Expr

type Paren

type Paren struct {
	Expression astgen.ASTExpr
}

func NewParen

func NewParen(expr astgen.ASTExpr) *Paren

func (*Paren) ASTExpr

func (p *Paren) ASTExpr() ast.Expr

type Selector

type Selector struct {
	Receiver astgen.ASTExpr
	Selector string
}

func NewSelector

func NewSelector(receiver astgen.ASTExpr, selector string) *Selector

func (*Selector) ASTExpr

func (s *Selector) ASTExpr() ast.Expr

type Star

type Star struct {
	Expression astgen.ASTExpr
}

func NewStar

func NewStar(expr astgen.ASTExpr) *Star

func (*Star) ASTExpr

func (s *Star) ASTExpr() ast.Expr

type StringVal

type StringVal string

func (StringVal) ASTExpr

func (s StringVal) ASTExpr() ast.Expr

type StructField

type StructField struct {
	Name    string
	Type    Type
	Tag     string
	Comment string
}

func (*StructField) ToASTField

func (f *StructField) ToASTField() *ast.Field

type StructFields

type StructFields []*StructField

func (StructFields) ToFieldList

func (s StructFields) ToFieldList() *ast.FieldList

type StructType

type StructType struct {
	Fields StructFields
}

func NewStructType

func NewStructType(fields ...*StructField) *StructType

func (*StructType) ASTExpr

func (s *StructType) ASTExpr() ast.Expr

type Type

type Type string
const (
	BoolType           Type = "bool"
	StringType         Type = "string"
	IntType            Type = "int"
	ErrorType          Type = "error"
	EmptyInterfaceType Type = "interface{}"
	ByteSliceType      Type = "[]byte"
)

func (Type) ASTExpr

func (t Type) ASTExpr() ast.Expr

func (Type) Pointer

func (t Type) Pointer() Type

Pointer returns a new type that is a pointer to the current type (prepends a "*").

func (Type) ToIdent

func (t Type) ToIdent() *ast.Ident

type TypeAssert

type TypeAssert struct {
	Receiver astgen.ASTExpr
	Type     astgen.ASTExpr
}

func NewTypeAssert

func NewTypeAssert(receiver astgen.ASTExpr, typ astgen.ASTExpr) *TypeAssert

func (*TypeAssert) ASTExpr

func (t *TypeAssert) ASTExpr() ast.Expr

type Types

type Types []Type

func (Types) ToFieldList

func (t Types) ToFieldList() *ast.FieldList

type Unary

type Unary struct {
	Op       token.Token
	Receiver astgen.ASTExpr
}

func NewUnary

func NewUnary(op token.Token, receiver astgen.ASTExpr) *Unary

func (*Unary) ASTExpr

func (u *Unary) ASTExpr() ast.Expr

type VariableVal

type VariableVal string

func (VariableVal) ASTExpr

func (v VariableVal) ASTExpr() ast.Expr

Jump to

Keyboard shortcuts

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