| 150 | } |
| 151 | |
| 152 | func (t *thread) PopFloat() (float64, error) { |
| 153 | val := t.Pop() |
| 154 | switch n := val.(type) { |
| 155 | case float64: |
| 156 | return n, nil |
| 157 | case int: |
| 158 | return float64(n), nil |
| 159 | case string: |
| 160 | r, err := strconv.ParseFloat(n, 64) |
| 161 | if err != nil { |
| 162 | return 0, errors.Wrapf(err, "conversion of %q to float failed", val) |
| 163 | } |
| 164 | return r, nil |
| 165 | case datum.Datum: |
| 166 | return datum.GetFloat(n), nil |
| 167 | } |
| 168 | return 0, errors.Errorf("unexpected float type %T %q", val, val) |
| 169 | } |
| 170 | |
| 171 | func (t *thread) PopString() (string, error) { |
| 172 | val := t.Pop() |