toVariable will return (and allocate if neccesary) an Expression from given value if input is already an Expression, does nothing else, attempts to convert input to a big.Int (see utils.FromInterface) and returns a toVariable Expression
(input interface{})
| 152 | // if input is already an Expression, does nothing |
| 153 | // else, attempts to convert input to a big.Int (see utils.FromInterface) and returns a toVariable Expression |
| 154 | func (builder *builder) toVariableId(input interface{}) int { |
| 155 | |
| 156 | switch t := input.(type) { |
| 157 | case gnarkexpr.Expr: |
| 158 | return t.WireID() |
| 159 | case constraint.Element: |
| 160 | return builder.ceToId(t) |
| 161 | case *constraint.Element: |
| 162 | return builder.ceToId(*t) |
| 163 | default: |
| 164 | // try to make it into a constant |
| 165 | c := builder.field.FromInterface(t) |
| 166 | return builder.ceToId(c) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func (builder *builder) toVariable(input interface{}) frontend.Variable { |
| 171 | return newVariable(builder.toVariableId(input)) |
no test coverage detected