(meh MacroExprFactory, target ast.Expr, args []ast.Expr)
| 600 | } |
| 601 | |
| 602 | func optMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 603 | varIdent := args[0] |
| 604 | varName := "" |
| 605 | switch varIdent.Kind() { |
| 606 | case ast.IdentKind: |
| 607 | varName = varIdent.AsIdent() |
| 608 | default: |
| 609 | return nil, meh.NewError(varIdent.ID(), "optMap() variable name must be a simple identifier") |
| 610 | } |
| 611 | mapExpr := args[1] |
| 612 | return meh.NewCall( |
| 613 | operators.Conditional, |
| 614 | meh.NewMemberCall(hasValueFunc, target), |
| 615 | meh.NewCall(optionalOfFunc, |
| 616 | meh.NewComprehension( |
| 617 | meh.NewList(), |
| 618 | unusedIterVar, |
| 619 | varName, |
| 620 | meh.NewMemberCall(valueFunc, meh.Copy(target)), |
| 621 | meh.NewLiteral(types.False), |
| 622 | meh.NewIdent(varName), |
| 623 | mapExpr, |
| 624 | ), |
| 625 | ), |
| 626 | meh.NewCall(optionalNoneFunc), |
| 627 | ), nil |
| 628 | } |
| 629 | |
| 630 | func optFlatMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 631 | varIdent := args[0] |
nothing calls this directly
no test coverage detected