| 206 | } |
| 207 | |
| 208 | func (s *state) evalCall(dot, fun reflect.Value, node expr.Node, name string, args []expr.Node, final reflect.Value) reflect.Value { |
| 209 | typ := fun.Type() |
| 210 | if !goodFunc(typ) { |
| 211 | // TODO: This could still be a confusing error; maybe goodFunc should provide info. |
| 212 | return s.errorf("can't call method/function %q with %d results", name, typ.NumOut()) |
| 213 | } |
| 214 | // Build the arg list. |
| 215 | argv := make([]reflect.Value, 0) |
| 216 | result := fun.Call(argv) |
| 217 | // If we have an error that is not nil, stop execution and return that error to the caller. |
| 218 | if len(result) == 2 && !result[1].IsNil() { |
| 219 | return s.errorf("error calling %s: %s", name, result[1].Interface().(error)) |
| 220 | } |
| 221 | return result[0] |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | // evalCall executes a function or method call. If it's a method, fun already has the receiver bound, so |