MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / toVariableId

Method toVariableId

ecgo/builder/builder.go:154–168  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

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
154func (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
170func (builder *builder) toVariable(input interface{}) frontend.Variable {
171 return newVariable(builder.toVariableId(input))

Callers 14

NegMethod · 0.95
SelectMethod · 0.95
IsZeroMethod · 0.95
CmpMethod · 0.95
OutputMethod · 0.95
ConstantValueMethod · 0.95
toVariableMethod · 0.95
toVariableIdsMethod · 0.95
AssertIsEqualMethod · 0.95
AssertIsDifferentMethod · 0.95
AssertIsBooleanMethod · 0.95
mustBeLessOrEqVarMethod · 0.95

Calls 3

ceToIdMethod · 0.95
WireIDMethod · 0.80
FromInterfaceMethod · 0.65

Tested by

no test coverage detected