(meh MacroExprFactory, target ast.Expr, args []ast.Expr)
| 806 | } |
| 807 | |
| 808 | func optMap(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 809 | varIdent := args[0] |
| 810 | varName := "" |
| 811 | switch varIdent.Kind() { |
| 812 | case ast.IdentKind: |
| 813 | varName = varIdent.AsIdent() |
| 814 | default: |
| 815 | return nil, meh.NewError(varIdent.ID(), "optMap() variable name must be a simple identifier") |
| 816 | } |
| 817 | mapExpr := args[1] |
| 818 | return meh.NewCall( |
| 819 | operators.Conditional, |
| 820 | meh.NewMemberCall(hasValueFunc, target), |
| 821 | meh.NewCall(optionalOfFunc, |
| 822 | meh.NewComprehension( |
| 823 | meh.NewList(), |
| 824 | unusedIterVar, |
| 825 | varName, |
| 826 | meh.NewMemberCall(valueFunc, meh.Copy(target)), |
| 827 | meh.NewLiteral(types.False), |
| 828 | meh.NewIdent(varName), |
| 829 | mapExpr, |
| 830 | ), |
| 831 | ), |
| 832 | meh.NewCall(optionalNoneFunc), |
| 833 | ), nil |
| 834 | } |
| 835 | |
| 836 | func optMapV2(meh MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *Error) { |
| 837 | varIdent := args[0] |
nothing calls this directly
no test coverage detected