Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssertTypeMatch ¶
func NewAssertTypeMatch ¶
func NewAssertTypeMatch(value preserves.Value, m Match) *AssertTypeMatch
func (*AssertTypeMatch) Stmt ¶
func (a *AssertTypeMatch) Stmt() (stmts []ast.Stmt)
type BoolMatch ¶
type LengthRangeMatch struct { From int To int M Match } func NewLengthRangeMatch(from int, to int, m Match) *LengthRangeMatch { return &LengthRangeMatch{From: from, To: to, M: m} } func (l *LengthRangeMatch) FromPreserves(values []preserves.Value) any { if len(values) > l.From && len(values) < l.To { return l.M.FromPreserves(values) } return nil } func (l *LengthRangeMatch) Stmt() (stmts []ast.Stmt) { stmts = append(stmts, &ast.IfStmt{ Cond: &ast.BinaryExpr{ X: &ast.BinaryExpr{ X: &ast.CallExpr{ Fun: ast.NewIdent("len"), Args: []ast.Expr{ast.NewIdent("value")}}, Op: token.GTR, Y: ast.NewIdent(strconv.Itoa(l.From)), }, Op: token.LAND, Y: &ast.BinaryExpr{ X: &ast.CallExpr{ Fun: ast.NewIdent("len"), Args: []ast.Expr{ast.NewIdent("values")}}, Op: token.LSS, Y: ast.NewIdent(strconv.Itoa(l.To)), }, }, Body: &ast.BlockStmt{List: l.M.Stmt()}, }) return } type LengthExactMatch struct { L int M Match } func NewLengthExactMatch(l int, m Match) *LengthExactMatch { return &LengthExactMatch{L: l, M: m} } func (l *LengthExactMatch) FromPreserves(values preserves.Value) any { if len(values) == l.L { return l.M.FromPreserves(values) } return nil } func (l *LengthExactMatch) Stmt() (stmts []ast.Stmt) { stmts = append(stmts, &ast.IfStmt{ Cond: &ast.BinaryExpr{ X: &ast.CallExpr{ Fun: ast.NewIdent("len"), Args: []ast.Expr{ast.NewIdent("values")}}, Op: token.EQL, Y: ast.NewIdent(strconv.Itoa(l.From)), }, Body: &ast.BlockStmt{List: l.M.Stmt()}, }) return }
func (r *Rec) Matcher() Match { return NewAssertTypeMatch(&preserves.Record{}, ) }
type ListMatch ¶
func NewListMatch ¶
type RecordKeyBoolMatch ¶
type RecordKeyBoolMatch string
func NewRecordKeyBoolMatch ¶
func NewRecordKeyBoolMatch(s string) *RecordKeyBoolMatch
Click to show internal directories.
Click to hide internal directories.