| 134 | } |
| 135 | |
| 136 | func (obj *ExprIfFunc) replaceSubGraph(b bool) error { |
| 137 | // delete the old subgraph |
| 138 | if err := obj.init.Txn.Reverse(); err != nil { |
| 139 | return errwrap.Wrapf(err, "could not Reverse") |
| 140 | } |
| 141 | |
| 142 | var f interfaces.Func |
| 143 | if b { |
| 144 | obj.init.Txn.AddGraph(obj.ThenGraph) |
| 145 | f = obj.ThenFunc |
| 146 | } else { |
| 147 | obj.init.Txn.AddGraph(obj.ElseGraph) |
| 148 | f = obj.ElseFunc |
| 149 | } |
| 150 | |
| 151 | // create the new subgraph |
| 152 | edgeName := OutputFuncArgName |
| 153 | edge := &interfaces.FuncEdge{Args: []string{edgeName}} |
| 154 | obj.init.Txn.AddVertex(f) |
| 155 | obj.init.Txn.AddEdge(f, obj.OutputVertex, edge) |
| 156 | |
| 157 | return obj.init.Txn.Commit() |
| 158 | } |
| 159 | |
| 160 | // Call this func and return the value if it is possible to do so at this time. |
| 161 | func (obj *ExprIfFunc) Call(ctx context.Context, args []types.Value) (types.Value, error) { |