(args ...vector.Any)
| 87 | } |
| 88 | |
| 89 | func (i *Is) Call(args ...vector.Any) vector.Any { |
| 90 | vec := args[0] |
| 91 | typeVal := args[1] |
| 92 | if len(args) == 3 { |
| 93 | vec = args[1] |
| 94 | typeVal = args[2] |
| 95 | } |
| 96 | if typeVal.Type().ID() != super.IDType { |
| 97 | return vector.NewWrappedError(i.sctx, "is: type value argument expected", typeVal) |
| 98 | } |
| 99 | if _, ok := typeVal.(*vector.Const); ok { |
| 100 | b := vector.TypeValueValue(typeVal, 0) |
| 101 | typ, err := i.sctx.LookupByValue(b) |
| 102 | v := err == nil && typ == vec.Type() |
| 103 | return vector.NewConstBool(v, vec.Len()) |
| 104 | } |
| 105 | inTyp := vec.Type() |
| 106 | out := vector.NewFalse(vec.Len()) |
| 107 | for k := range vec.Len() { |
| 108 | b := vector.TypeValueValue(typeVal, k) |
| 109 | typ, err := i.sctx.LookupByValue(b) |
| 110 | if err == nil && typ == inTyp { |
| 111 | out.Set(k) |
| 112 | } |
| 113 | } |
| 114 | return out |
| 115 | } |
| 116 | |
| 117 | type IsErr struct{} |
| 118 |
nothing calls this directly
no test coverage detected