And computes the logical AND between two frontend.Variables.
(_a, _b frontend.Variable)
| 262 | |
| 263 | // And computes the logical AND between two frontend.Variables. |
| 264 | func (builder *builder) And(_a, _b frontend.Variable) frontend.Variable { |
| 265 | vars := builder.toVariableIds(_a, _b) |
| 266 | a := vars[0] |
| 267 | b := vars[1] |
| 268 | c1, ok1 := builder.constantValue(a) |
| 269 | c2, ok2 := builder.constantValue(b) |
| 270 | if ok1 && ok2 { |
| 271 | builder.AssertIsBoolean(_a) |
| 272 | builder.AssertIsBoolean(_b) |
| 273 | if c1.IsZero() || c2.IsZero() { |
| 274 | return builder.toVariable(constraint.Element{}) |
| 275 | } |
| 276 | return builder.toVariable(builder.tOne) |
| 277 | } |
| 278 | builder.instructions = append(builder.instructions, irsource.Instruction{ |
| 279 | Type: irsource.BoolBinOp, |
| 280 | X: a, |
| 281 | Y: b, |
| 282 | ExtraId: 3, |
| 283 | }) |
| 284 | return builder.addVar() |
| 285 | } |
| 286 | |
| 287 | // --------------------------------------------------------------------------------------------- |
| 288 | // Conditionals |
no test coverage detected