(meh MacroExprFactory, target ast.Expr, args []ast.Expr)
| 878 | } |
| 879 | |
| 880 | func optFlatMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 881 | varIdent := args[0] |
| 882 | varName := "" |
| 883 | switch varIdent.Kind() { |
| 884 | case ast.IdentKind: |
| 885 | varName = varIdent.AsIdent() |
| 886 | default: |
| 887 | return nil, meh.NewError(varIdent.ID(), "optFlatMap() variable name must be a simple identifier") |
| 888 | } |
| 889 | mapExpr := args[1] |
| 890 | return meh.NewCall( |
| 891 | operators.Conditional, |
| 892 | meh.NewMemberCall(hasValueFunc, target), |
| 893 | meh.NewComprehension( |
| 894 | meh.NewList(), |
| 895 | unusedIterVar, |
| 896 | varName, |
| 897 | meh.NewMemberCall(valueFunc, meh.Copy(target)), |
| 898 | meh.NewLiteral(types.False), |
| 899 | meh.NewIdent(varName), |
| 900 | mapExpr, |
| 901 | ), |
| 902 | meh.NewCall(optionalNoneFunc), |
| 903 | ), nil |
| 904 | } |
| 905 | |
| 906 | func optFlatMapV2(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 907 | varIdent := args[0] |
nothing calls this directly
no test coverage detected